Home | History | Annotate | Download | only in Pp2Dxe
      1 /********************************************************************************
      2 Copyright (C) 2016 Marvell International Ltd.
      3 
      4 Marvell BSD License Option
      5 
      6 If you received this File from Marvell, you may opt to use, redistribute and/or
      7 modify this File under the following licensing terms.
      8 Redistribution and use in source and binary forms, with or without modification,
      9 are permitted provided that the following conditions are met:
     10 
     11   * Redistributions of source code must retain the above copyright notice,
     12     this list of conditions and the following disclaimer.
     13 
     14   * Redistributions in binary form must reproduce the above copyright
     15     notice, this list of conditions and the following disclaimer in the
     16     documentation and/or other materials provided with the distribution.
     17 
     18   * Neither the name of Marvell nor the names of its contributors may be
     19     used to endorse or promote products derived from this software without
     20     specific prior written permission.
     21 
     22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
     26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 
     33 *******************************************************************************/
     34 
     35 #ifndef __MVPP2_LIB_HW__
     36 #define __MVPP2_LIB_HW__
     37 
     38 #ifndef BIT
     39 #define BIT(nr)         (1 << (nr))
     40 #endif
     41 
     42 /* RX Fifo Registers */
     43 #define MVPP2_RX_DATA_FIFO_SIZE_REG(port)                 (0x00 + 4 * (port))
     44 #define MVPP2_RX_ATTR_FIFO_SIZE_REG(port)                 (0x20 + 4 * (port))
     45 #define MVPP2_RX_MIN_PKT_SIZE_REG                         0x60
     46 #define MVPP2_RX_FIFO_INIT_REG                            0x64
     47 
     48 /* RX DMA Top Registers */
     49 #define MVPP2_RX_CTRL_REG(port)                           (0x140 + 4 * (port))
     50 #define MVPP2_RX_LOW_LATENCY_PKT_SIZE(s)                  (((s) & 0xfff) << 16)
     51 #define MVPP2_RX_USE_PSEUDO_FOR_CSUM_MASK                 BIT(31)
     52 #define MVPP2_POOL_BUF_SIZE_REG(pool)                     (0x180 + 4 * (pool))
     53 #define MVPP2_POOL_BUF_SIZE_OFFSET                        5
     54 #define MVPP2_RXQ_CONFIG_REG(rxq)                         (0x800 + 4 * (rxq))
     55 #define MVPP2_SNOOP_PKT_SIZE_MASK                         0x1ff
     56 #define MVPP2_SNOOP_BUF_HDR_MASK                          BIT(9)
     57 #define MVPP2_RXQ_POOL_SHORT_OFFS                         20
     58 #define MVPP2_RXQ_POOL_SHORT_MASK                         0x700000
     59 #define MVPP2_RXQ_POOL_LONG_OFFS                          24
     60 #define MVPP2_RXQ_POOL_LONG_MASK                          0x7000000
     61 #define MVPP2_RXQ_PACKET_OFFSET_OFFS                      28
     62 #define MVPP2_RXQ_PACKET_OFFSET_MASK                      0x70000000
     63 #define MVPP2_RXQ_DISABLE_MASK                            BIT(31)
     64 
     65 /* Parser Registers */
     66 #define MVPP2_PRS_INIT_LOOKUP_REG                         0x1000
     67 #define MVPP2_PRS_PORT_LU_MAX                             0xf
     68 #define MVPP2_PRS_PORT_LU_MASK(port)                      (0xff << ((port) * 4))
     69 #define MVPP2_PRS_PORT_LU_VAL(port, val)                  ((val) << ((port) * 4))
     70 #define MVPP2_PRS_INIT_OFFS_REG(port)                     (0x1004 + ((port) & 4))
     71 #define MVPP2_PRS_INIT_OFF_MASK(port)                     (0x3f << (((port) % 4) * 8))
     72 #define MVPP2_PRS_INIT_OFF_VAL(port, val)                 ((val) << (((port) % 4) * 8))
     73 #define MVPP2_PRS_MAX_LOOP_REG(port)                      (0x100c + ((port) & 4))
     74 #define MVPP2_PRS_MAX_LOOP_MASK(port)                     (0xff << (((port) % 4) * 8))
     75 #define MVPP2_PRS_MAX_LOOP_VAL(port, val)                 ((val) << (((port) % 4) * 8))
     76 #define MVPP2_PRS_TCAM_IDX_REG                            0x1100
     77 #define MVPP2_PRS_TCAM_DATA_REG(idx)                      (0x1104 + (idx) * 4)
     78 #define MVPP2_PRS_TCAM_INV_MASK                           BIT(31)
     79 #define MVPP2_PRS_SRAM_IDX_REG                            0x1200
     80 #define MVPP2_PRS_SRAM_DATA_REG(idx)                      (0x1204 + (idx) * 4)
     81 #define MVPP2_PRS_TCAM_CTRL_REG                           0x1230
     82 #define MVPP2_PRS_TCAM_EN_MASK                            BIT(0)
     83 
     84 /* Classifier Registers */
     85 #define MVPP2_CLS_MODE_REG                                0x1800
     86 #define MVPP2_CLS_MODE_ACTIVE_MASK                        BIT(0)
     87 #define MVPP2_CLS_PORT_WAY_REG                            0x1810
     88 #define MVPP2_CLS_PORT_WAY_MASK(port)                     (1 << (port))
     89 #define MVPP2_CLS_LKP_INDEX_REG                           0x1814
     90 #define MVPP2_CLS_LKP_INDEX_WAY_OFFS                      6
     91 #define MVPP2_CLS_LKP_TBL_REG                             0x1818
     92 #define MVPP2_CLS_LKP_TBL_RXQ_MASK                        0xff
     93 #define MVPP2_CLS_LKP_TBL_LOOKUP_EN_MASK                  BIT(25)
     94 #define MVPP2_CLS_FLOW_INDEX_REG                          0x1820
     95 #define MVPP2_CLS_FLOW_TBL0_REG                           0x1824
     96 #define MVPP2_CLS_FLOW_TBL1_REG                           0x1828
     97 #define MVPP2_CLS_FLOW_TBL2_REG                           0x182c
     98 #define MVPP2_CLS_OVERSIZE_RXQ_LOW_REG(port)              (0x1980 + ((port) * 4))
     99 #define MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS                   3
    100 #define MVPP2_CLS_OVERSIZE_RXQ_LOW_MASK                   0x7
    101 #define MVPP2_CLS_SWFWD_P2HQ_REG(port)                    (0x19b0 + ((port) * 4))
    102 #define MVPP2_CLS_SWFWD_PCTRL_REG                         0x19d0
    103 #define MVPP2_CLS_SWFWD_PCTRL_MASK(port)                  (1 << (port))
    104 
    105 /* Descriptor Manager Top Registers */
    106 #define MVPP2_RXQ_NUM_REG                                 0x2040
    107 #define MVPP2_RXQ_DESC_ADDR_REG                           0x2044
    108 #define MVPP2_RXQ_DESC_SIZE_REG                           0x2048
    109 #define MVPP2_RXQ_DESC_SIZE_MASK                          0x3ff0
    110 #define MVPP2_RXQ_STATUS_UPDATE_REG(rxq)                  (0x3000 + 4 * (rxq))
    111 #define MVPP2_RXQ_NUM_PROCESSED_OFFSET                    0
    112 #define MVPP2_RXQ_NUM_NEW_OFFSET                          16
    113 #define MVPP2_RXQ_STATUS_REG(rxq)                         (0x3400 + 4 * (rxq))
    114 #define MVPP2_RXQ_OCCUPIED_MASK                           0x3fff
    115 #define MVPP2_RXQ_NON_OCCUPIED_OFFSET                     16
    116 #define MVPP2_RXQ_NON_OCCUPIED_MASK                       0x3fff0000
    117 #define MVPP2_RXQ_THRESH_REG                              0x204c
    118 #define MVPP2_OCCUPIED_THRESH_OFFSET                      0
    119 #define MVPP2_OCCUPIED_THRESH_MASK                        0x3fff
    120 #define MVPP2_RXQ_INDEX_REG                               0x2050
    121 #define MVPP2_TXQ_NUM_REG                                 0x2080
    122 #define MVPP2_TXQ_DESC_ADDR_REG                           0x2084
    123 #define MVPP22_TXQ_DESC_ADDR_HIGH_REG                     0x20a8
    124 #define MVPP22_TXQ_DESC_ADDR_HIGH_MASK                    0xff
    125 #define MVPP2_TXQ_DESC_SIZE_REG                           0x2088
    126 #define MVPP2_TXQ_DESC_SIZE_MASK                          0x3ff0
    127 #define MVPP2_AGGR_TXQ_UPDATE_REG                         0x2090
    128 #define MVPP2_TXQ_THRESH_REG                              0x2094
    129 #define MVPP2_TRANSMITTED_THRESH_OFFSET                   16
    130 #define MVPP2_TRANSMITTED_THRESH_MASK                     0x3fff0000
    131 #define MVPP2_TXQ_INDEX_REG                               0x2098
    132 #define MVPP2_TXQ_PREF_BUF_REG                            0x209c
    133 #define MVPP2_PREF_BUF_PTR(desc)                          ((desc) & 0xfff)
    134 #define MVPP2_PREF_BUF_SIZE_4                             (BIT(12) | BIT(13))
    135 #define MVPP2_PREF_BUF_SIZE_16                            (BIT(12) | BIT(14))
    136 #define MVPP2_PREF_BUF_THRESH(val)                        ((val) << 17)
    137 #define MVPP2_TXQ_DRAIN_EN_MASK                           BIT(31)
    138 #define MVPP2_TXQ_PENDING_REG                             0x20a0
    139 #define MVPP2_TXQ_PENDING_MASK                            0x3fff
    140 #define MVPP2_TXQ_INT_STATUS_REG                          0x20a4
    141 #define MVPP2_TXQ_SENT_REG(txq)                           (0x3c00 + 4 * (txq))
    142 #define MVPP22_TXQ_SENT_REG(txq)                          (0x3e00 + 4 * (txq-128))
    143 #define MVPP2_TRANSMITTED_COUNT_OFFSET                    16
    144 #define MVPP2_TRANSMITTED_COUNT_MASK                      0x3fff0000
    145 #define MVPP2_TXQ_RSVD_REQ_REG                            0x20b0
    146 #define MVPP2_TXQ_RSVD_REQ_Q_OFFSET                       16
    147 #define MVPP2_TXQ_RSVD_RSLT_REG                           0x20b4
    148 #define MVPP2_TXQ_RSVD_RSLT_MASK                          0x3fff
    149 #define MVPP2_TXQ_RSVD_CLR_REG                            0x20b8
    150 #define MVPP2_TXQ_RSVD_CLR_OFFSET                         16
    151 #define MVPP2_AGGR_TXQ_DESC_ADDR_REG(cpu)                 (0x2100 + 4 * (cpu))
    152 #define MVPP2_AGGR_TXQ_DESC_SIZE_REG(cpu)                 (0x2140 + 4 * (cpu))
    153 #define MVPP2_AGGR_TXQ_DESC_SIZE_MASK                     0x3ff0
    154 #define MVPP2_AGGR_TXQ_STATUS_REG(cpu)                    (0x2180 + 4 * (cpu))
    155 #define MVPP2_AGGR_TXQ_PENDING_MASK                       0x3fff
    156 #define MVPP2_AGGR_TXQ_INDEX_REG(cpu)                     (0x21c0 + 4 * (cpu))
    157 
    158 /* MBUS bridge registers */
    159 #define MVPP2_WIN_BASE(w)                                 (0x4000 + ((w) << 2))
    160 #define MVPP2_WIN_SIZE(w)                                 (0x4020 + ((w) << 2))
    161 #define MVPP2_WIN_REMAP(w)                                (0x4040 + ((w) << 2))
    162 #define MVPP2_BASE_ADDR_ENABLE                            0x4060
    163 
    164 /* Interrupt Cause and Mask registers */
    165 #define MVPP2_ISR_RX_THRESHOLD_REG(rxq)                   (0x5200 + 4 * (rxq))
    166 #define MVPP2_ISR_RXQ_GROUP_REG(rxq)                      (0x5400 + 4 * (rxq))
    167 #define MVPP2_ISR_ENABLE_REG(port)                        (0x5420 + 4 * (port))
    168 #define MVPP2_ISR_ENABLE_INTERRUPT(mask)                  ((mask) & 0xffff)
    169 #define MVPP2_ISR_DISABLE_INTERRUPT(mask)                 (((mask) << 16) & 0xffff0000)
    170 #define MVPP2_ISR_RX_TX_CAUSE_REG(port)                   (0x5480 + 4 * (port))
    171 #define MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK               0xffff
    172 #define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK               0xff0000
    173 #define MVPP2_CAUSE_RX_FIFO_OVERRUN_MASK                  BIT(24)
    174 #define MVPP2_CAUSE_FCS_ERR_MASK                          BIT(25)
    175 #define MVPP2_CAUSE_TX_FIFO_UNDERRUN_MASK                 BIT(26)
    176 #define MVPP2_CAUSE_TX_EXCEPTION_SUM_MASK                 BIT(29)
    177 #define MVPP2_CAUSE_RX_EXCEPTION_SUM_MASK                 BIT(30)
    178 #define MVPP2_CAUSE_MISC_SUM_MASK                         BIT(31)
    179 #define MVPP2_ISR_RX_TX_MASK_REG(port)                    (0x54a0 + 4 * (port))
    180 #define MVPP2_ISR_PON_RX_TX_MASK_REG                      0x54bc
    181 #define MVPP2_PON_CAUSE_RXQ_OCCUP_DESC_ALL_MASK           0xffff
    182 #define MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK           0x3fc00000
    183 #define MVPP2_PON_CAUSE_MISC_SUM_MASK                     BIT(31)
    184 #define MVPP2_ISR_MISC_CAUSE_REG                          0x55b0
    185 
    186 /* Buffer Manager registers */
    187 #define MVPP2_BM_POOL_BASE_REG(pool)                      (0x6000 + ((pool) * 4))
    188 #define MVPP2_BM_POOL_BASE_ADDR_MASK                      0xfffff80
    189 #define MVPP2_BM_POOL_SIZE_REG(pool)                      (0x6040 + ((pool) * 4))
    190 #define MVPP2_BM_POOL_SIZE_MASK                           0xfff0
    191 #define MVPP2_BM_POOL_READ_PTR_REG(pool)                  (0x6080 + ((pool) * 4))
    192 #define MVPP2_BM_POOL_GET_READ_PTR_MASK                   0xfff0
    193 #define MVPP2_BM_POOL_PTRS_NUM_REG(pool)                  (0x60c0 + ((pool) * 4))
    194 #define MVPP2_BM_POOL_PTRS_NUM_MASK                       0xfff0
    195 #define MVPP2_BM_BPPI_READ_PTR_REG(pool)                  (0x6100 + ((pool) * 4))
    196 #define MVPP2_BM_BPPI_PTRS_NUM_REG(pool)                  (0x6140 + ((pool) * 4))
    197 #define MVPP2_BM_BPPI_PTR_NUM_MASK                        0x7ff
    198 #define MVPP2_BM_BPPI_PREFETCH_FULL_MASK                  BIT(16)
    199 #define MVPP2_BM_POOL_CTRL_REG(pool)                      (0x6200 + ((pool) * 4))
    200 #define MVPP2_BM_START_MASK                               BIT(0)
    201 #define MVPP2_BM_STOP_MASK                                BIT(1)
    202 #define MVPP2_BM_STATE_MASK                               BIT(4)
    203 #define MVPP2_BM_LOW_THRESH_OFFS                          8
    204 #define MVPP2_BM_LOW_THRESH_MASK                          0x7f00
    205 #define MVPP2_BM_LOW_THRESH_VALUE(val)                    ((val) << MVPP2_BM_LOW_THRESH_OFFS)
    206 #define MVPP2_BM_HIGH_THRESH_OFFS                         16
    207 #define MVPP2_BM_HIGH_THRESH_MASK                         0x7f0000
    208 #define MVPP2_BM_HIGH_THRESH_VALUE(val)                   ((val) << MVPP2_BM_HIGH_THRESH_OFFS)
    209 #define MVPP2_BM_INTR_CAUSE_REG(pool)                     (0x6240 + ((pool) * 4))
    210 #define MVPP2_BM_RELEASED_DELAY_MASK                      BIT(0)
    211 #define MVPP2_BM_ALLOC_FAILED_MASK                        BIT(1)
    212 #define MVPP2_BM_BPPE_EMPTY_MASK                          BIT(2)
    213 #define MVPP2_BM_BPPE_FULL_MASK                           BIT(3)
    214 #define MVPP2_BM_AVAILABLE_BP_LOW_MASK                    BIT(4)
    215 #define MVPP2_BM_INTR_MASK_REG(pool)                      (0x6280 + ((pool) * 4))
    216 #define MVPP2_BM_PHY_ALLOC_REG(pool)                      (0x6400 + ((pool) * 4))
    217 #define MVPP2_BM_PHY_ALLOC_GRNTD_MASK                     BIT(0)
    218 #define MVPP2_BM_VIRT_ALLOC_REG                           0x6440
    219 #define MVPP2_BM_PHY_RLS_REG(pool)                        (0x6480 + ((pool) * 4))
    220 #define MVPP2_BM_PHY_RLS_MC_BUFF_MASK                     BIT(0)
    221 #define MVPP2_BM_PHY_RLS_PRIO_EN_MASK                     BIT(1)
    222 #define MVPP2_BM_PHY_RLS_GRNTD_MASK                       BIT(2)
    223 #define MVPP2_BM_VIRT_RLS_REG                             0x64c0
    224 #define MVPP2_BM_MC_RLS_REG                               0x64c4
    225 #define MVPP2_BM_MC_ID_MASK                               0xfff
    226 #define MVPP2_BM_FORCE_RELEASE_MASK                       BIT(12)
    227 
    228 #define MVPP22_BM_PHY_VIRT_HIGH_ALLOC_REG                 0x6444
    229 #define MVPP22_BM_PHY_HIGH_ALLOC_OFFSET                   0
    230 #define MVPP22_BM_VIRT_HIGH_ALLOC_OFFSET                  8
    231 #define MVPP22_BM_VIRT_HIGH_ALLOC_MASK                    0xff00
    232 
    233 #define MVPP22_BM_PHY_VIRT_HIGH_RLS_REG                   0x64c4
    234 
    235 #define MVPP22_BM_PHY_HIGH_RLS_OFFSET                     0
    236 #define MVPP22_BM_VIRT_HIGH_RLS_OFFST                     8
    237 
    238 #define MVPP22_BM_POOL_BASE_HIGH_REG                      0x6310
    239 #define MVPP22_BM_POOL_BASE_HIGH_MASK                     0xff
    240 #define MVPP2_BM_PRIO_CTRL_REG                            0x6800
    241 
    242 /* TX Scheduler registers */
    243 #define MVPP2_TXP_SCHED_PORT_INDEX_REG                    0x8000
    244 #define MVPP2_TXP_SCHED_Q_CMD_REG                         0x8004
    245 #define MVPP2_TXP_SCHED_ENQ_MASK                          0xff
    246 #define MVPP2_TXP_SCHED_DISQ_OFFSET                       8
    247 #define MVPP2_TXP_SCHED_CMD_1_REG                         0x8010
    248 #define MVPP2_TXP_SCHED_PERIOD_REG                        0x8018
    249 #define MVPP2_TXP_SCHED_MTU_REG                           0x801c
    250 #define MVPP2_TXP_MTU_MAX                                 0x7FFFF
    251 #define MVPP2_TXP_SCHED_REFILL_REG                        0x8020
    252 #define MVPP2_TXP_REFILL_TOKENS_ALL_MASK                  0x7ffff
    253 #define MVPP2_TXP_REFILL_PERIOD_ALL_MASK                  0x3ff00000
    254 #define MVPP2_TXP_REFILL_PERIOD_MASK(v)                   ((v) << 20)
    255 #define MVPP2_TXP_SCHED_TOKEN_SIZE_REG                    0x8024
    256 #define MVPP2_TXP_TOKEN_SIZE_MAX                          0xffffffff
    257 #define MVPP2_TXQ_SCHED_REFILL_REG(q)                     (0x8040 + ((q) << 2))
    258 #define MVPP2_TXQ_REFILL_TOKENS_ALL_MASK                  0x7ffff
    259 #define MVPP2_TXQ_REFILL_PERIOD_ALL_MASK                  0x3ff00000
    260 #define MVPP2_TXQ_REFILL_PERIOD_MASK(v)                   ((v) << 20)
    261 #define MVPP2_TXQ_SCHED_TOKEN_SIZE_REG(q)                 (0x8060 + ((q) << 2))
    262 #define MVPP2_TXQ_TOKEN_SIZE_MAX                          0x7fffffff
    263 #define MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(q)                 (0x8080 + ((q) << 2))
    264 #define MVPP2_TXQ_TOKEN_CNTR_MAX                          0xffffffff
    265 
    266 /* TX general registers */
    267 #define MVPP2_TX_SNOOP_REG                                0x8800
    268 #define MVPP2_TX_PORT_FLUSH_REG                           0x8810
    269 #define MVPP2_TX_PORT_FLUSH_MASK(port)                    (1 << (port))
    270 
    271 /* LMS registers */
    272 #define MVPP2_SRC_ADDR_MIDDLE                             0x24
    273 #define MVPP2_SRC_ADDR_HIGH                               0x28
    274 #define MVPP2_PHY_AN_CFG0_REG                             0x34
    275 #define MVPP2_PHY_AN_STOP_SMI0_MASK                       BIT(7)
    276 #define MVPP2_MIB_COUNTERS_BASE(port)                     (0x1000 + ((port) >> 1) * 0x400 + (port) * 0x400)
    277 #define MVPP2_MIB_LATE_COLLISION                          0x7c
    278 #define MVPP2_ISR_SUM_MASK_REG                            0x220c
    279 #define MVPP2_MNG_EXTENDED_GLOBAL_CTRL_REG                0x305c
    280 #define MVPP2_EXT_GLOBAL_CTRL_DEFAULT                     0x27
    281 
    282 /* Per-port registers */
    283 #define MVPP2_GMAC_CTRL_0_REG                             0x0
    284 #define MVPP2_GMAC_PORT_EN_MASK                           BIT(0)
    285 #define MVPP2_GMAC_MAX_RX_SIZE_OFFS                       2
    286 #define MVPP2_GMAC_MAX_RX_SIZE_MASK                       0x7ffc
    287 #define MVPP2_GMAC_MIB_CNTR_EN_MASK                       BIT(15)
    288 #define MVPP2_GMAC_CTRL_1_REG                             0x4
    289 #define MVPP2_GMAC_PERIODIC_XON_EN_MASK                   BIT(1)
    290 #define MVPP2_GMAC_GMII_LB_EN_MASK                        BIT(5)
    291 #define MVPP2_GMAC_PCS_LB_EN_BIT                          6
    292 #define MVPP2_GMAC_PCS_LB_EN_MASK                         BIT(6)
    293 #define MVPP2_GMAC_SA_LOW_OFFS                            7
    294 #define MVPP2_GMAC_CTRL_2_REG                             0x8
    295 #define MVPP2_GMAC_INBAND_AN_MASK                         BIT(0)
    296 #define MVPP2_GMAC_PCS_ENABLE_MASK                        BIT(3)
    297 #define MVPP2_GMAC_PORT_RGMII_MASK                        BIT(4)
    298 #define MVPP2_GMAC_PORT_RESET_MASK                        BIT(6)
    299 #define MVPP2_GMAC_AUTONEG_CONFIG                         0xc
    300 #define MVPP2_GMAC_FORCE_LINK_DOWN                        BIT(0)
    301 #define MVPP2_GMAC_FORCE_LINK_PASS                        BIT(1)
    302 #define MVPP2_GMAC_CONFIG_MII_SPEED                       BIT(5)
    303 #define MVPP2_GMAC_CONFIG_GMII_SPEED                      BIT(6)
    304 #define MVPP2_GMAC_AN_SPEED_EN                            BIT(7)
    305 #define MVPP2_GMAC_FC_ADV_EN                              BIT(9)
    306 #define MVPP2_GMAC_CONFIG_FULL_DUPLEX                     BIT(12)
    307 #define MVPP2_GMAC_AN_DUPLEX_EN                           BIT(13)
    308 #define MVPP2_GMAC_PORT_FIFO_CFG_1_REG                    0x1c
    309 #define MVPP2_GMAC_TX_FIFO_MIN_TH_OFFS                    6
    310 #define MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK                0x1fc0
    311 #define MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(v)                 (((v) << 6) & MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK)
    312 
    313 /* Port Interrupts */
    314 #define MV_GMAC_INTERRUPT_CAUSE_REG                       (0x0020)
    315 #define MV_GMAC_INTERRUPT_MASK_REG                        (0x0024)
    316 #define MV_GMAC_INTERRUPT_CAUSE_LINK_CHANGE_OFFS          1
    317 #define MV_GMAC_INTERRUPT_CAUSE_LINK_CHANGE_MASK          (0x1 << MV_GMAC_INTERRUPT_CAUSE_LINK_CHANGE_OFFS)
    318 
    319 /* Port Interrupt Summary */
    320 #define MV_GMAC_INTERRUPT_SUM_CAUSE_REG                   (0x00A0)
    321 #define MV_GMAC_INTERRUPT_SUM_MASK_REG                    (0x00A4)
    322 #define MV_GMAC_INTERRUPT_SUM_CAUSE_LINK_CHANGE_OFFS      1
    323 #define MV_GMAC_INTERRUPT_SUM_CAUSE_LINK_CHANGE_MASK      (0x1 << MV_GMAC_INTERRUPT_SUM_CAUSE_LINK_CHANGE_OFFS)
    324 
    325 /* Port Mac Control0 */
    326 #define MVPP2_PORT_CTRL0_REG                              (0x0000)
    327 #define MVPP2_PORT_CTRL0_PORTEN_OFFS    0
    328 #define MVPP2_PORT_CTRL0_PORTEN_MASK    \
    329     (0x00000001 << MVPP2_PORT_CTRL0_PORTEN_OFFS)
    330 
    331 #define MVPP2_PORT_CTRL0_PORTTYPE_OFFS    1
    332 #define MVPP2_PORT_CTRL0_PORTTYPE_MASK    \
    333     (0x00000001 << MVPP2_PORT_CTRL0_PORTTYPE_OFFS)
    334 
    335 #define MVPP2_PORT_CTRL0_FRAMESIZELIMIT_OFFS    2
    336 #define MVPP2_PORT_CTRL0_FRAMESIZELIMIT_MASK    \
    337     (0x00001fff << MVPP2_PORT_CTRL0_FRAMESIZELIMIT_OFFS)
    338 
    339 #define MVPP2_PORT_CTRL0_COUNT_EN_OFFS    15
    340 #define MVPP2_PORT_CTRL0_COUNT_EN_MASK    \
    341     (0x00000001 << MVPP2_PORT_CTRL0_COUNT_EN_OFFS)
    342 
    343 /* Port Mac Control1 */
    344 #define MVPP2_PORT_CTRL1_REG                              (0x0004)
    345 #define MVPP2_PORT_CTRL1_EN_RX_CRC_CHECK_OFFS    0
    346 #define MVPP2_PORT_CTRL1_EN_RX_CRC_CHECK_MASK    \
    347     (0x00000001 << MVPP2_PORT_CTRL1_EN_RX_CRC_CHECK_OFFS)
    348 
    349 #define MVPP2_PORT_CTRL1_EN_PERIODIC_FC_XON_OFFS    1
    350 #define MVPP2_PORT_CTRL1_EN_PERIODIC_FC_XON_MASK    \
    351     (0x00000001 << MVPP2_PORT_CTRL1_EN_PERIODIC_FC_XON_OFFS)
    352 
    353 #define MVPP2_PORT_CTRL1_MGMII_MODE_OFFS    2
    354 #define MVPP2_PORT_CTRL1_MGMII_MODE_MASK    \
    355     (0x00000001 << MVPP2_PORT_CTRL1_MGMII_MODE_OFFS)
    356 
    357 #define MVPP2_PORT_CTRL1_PFC_CASCADE_PORT_ENABLE_OFFS   3
    358 #define MVPP2_PORT_CTRL1_PFC_CASCADE_PORT_ENABLE_MASK    \
    359     (0x00000001 << MVPP2_PORT_CTRL1_PFC_CASCADE_PORT_ENABLE_OFFS)
    360 
    361 #define MVPP2_PORT_CTRL1_DIS_EXCESSIVE_COL_OFFS   4
    362 #define MVPP2_PORT_CTRL1_DIS_EXCESSIVE_COL_MASK    \
    363     (0x00000001 << MVPP2_PORT_CTRL1_DIS_EXCESSIVE_COL_OFFS)
    364 
    365 #define MVPP2_PORT_CTRL1_GMII_LOOPBACK_OFFS   5
    366 #define MVPP2_PORT_CTRL1_GMII_LOOPBACK_MASK    \
    367     (0x00000001 << MVPP2_PORT_CTRL1_GMII_LOOPBACK_OFFS)
    368 
    369 #define MVPP2_PORT_CTRL1_PCS_LOOPBACK_OFFS    6
    370 #define MVPP2_PORT_CTRL1_PCS_LOOPBACK_MASK    \
    371     (0x00000001 << MVPP2_PORT_CTRL1_PCS_LOOPBACK_OFFS)
    372 
    373 #define MVPP2_PORT_CTRL1_FC_SA_ADDR_LO_OFFS   7
    374 #define MVPP2_PORT_CTRL1_FC_SA_ADDR_LO_MASK    \
    375     (0x000000ff << MVPP2_PORT_CTRL1_FC_SA_ADDR_LO_OFFS)
    376 
    377 #define MVPP2_PORT_CTRL1_EN_SHORT_PREAMBLE_OFFS   15
    378 #define MVPP2_PORT_CTRL1_EN_SHORT_PREAMBLE_MASK    \
    379     (0x00000001 << MVPP2_PORT_CTRL1_EN_SHORT_PREAMBLE_OFFS)
    380 
    381 /* Port Mac Control2 */
    382 #define MVPP2_PORT_CTRL2_REG                              (0x0008)
    383 #define MVPP2_PORT_CTRL2_SGMII_MODE_OFFS    0
    384 #define MVPP2_PORT_CTRL2_SGMII_MODE_MASK    \
    385     (0x00000001 << MVPP2_PORT_CTRL2_SGMII_MODE_OFFS)
    386 
    387 #define MVPP2_PORT_CTRL2_FC_MODE_OFFS   1
    388 #define MVPP2_PORT_CTRL2_FC_MODE_MASK    \
    389     (0x00000003 << MVPP2_PORT_CTRL2_FC_MODE_OFFS)
    390 
    391 #define MVPP2_PORT_CTRL2_PCS_EN_OFFS    3
    392 #define MVPP2_PORT_CTRL2_PCS_EN_MASK    \
    393     (0x00000001 << MVPP2_PORT_CTRL2_PCS_EN_OFFS)
    394 
    395 #define MVPP2_PORT_CTRL2_RGMII_MODE_OFFS    4
    396 #define MVPP2_PORT_CTRL2_RGMII_MODE_MASK    \
    397     (0x00000001 << MVPP2_PORT_CTRL2_RGMII_MODE_OFFS)
    398 
    399 #define MVPP2_PORT_CTRL2_DIS_PADING_OFFS    5
    400 #define MVPP2_PORT_CTRL2_DIS_PADING_MASK    \
    401     (0x00000001 << MVPP2_PORT_CTRL2_DIS_PADING_OFFS)
    402 
    403 #define MVPP2_PORT_CTRL2_PORTMACRESET_OFFS    6
    404 #define MVPP2_PORT_CTRL2_PORTMACRESET_MASK    \
    405     (0x00000001 << MVPP2_PORT_CTRL2_PORTMACRESET_OFFS)
    406 
    407 #define MVPP2_PORT_CTRL2_TX_DRAIN_OFFS    7
    408 #define MVPP2_PORT_CTRL2_TX_DRAIN_MASK    \
    409     (0x00000001 << MVPP2_PORT_CTRL2_TX_DRAIN_OFFS)
    410 
    411 #define MVPP2_PORT_CTRL2_EN_MII_ODD_PRE_OFFS    8
    412 #define MVPP2_PORT_CTRL2_EN_MII_ODD_PRE_MASK    \
    413     (0x00000001 << MVPP2_PORT_CTRL2_EN_MII_ODD_PRE_OFFS)
    414 
    415 #define MVPP2_PORT_CTRL2_CLK_125_BYPS_EN_OFFS   9
    416 #define MVPP2_PORT_CTRL2_CLK_125_BYPS_EN_MASK    \
    417     (0x00000001 << MVPP2_PORT_CTRL2_CLK_125_BYPS_EN_OFFS)
    418 
    419 #define MVPP2_PORT_CTRL2_PRBS_CHECK_EN_OFFS   10
    420 #define MVPP2_PORT_CTRL2_PRBS_CHECK_EN_MASK    \
    421     (0x00000001 << MVPP2_PORT_CTRL2_PRBS_CHECK_EN_OFFS)
    422 
    423 #define MVPP2_PORT_CTRL2_PRBS_GEN_EN_OFFS   11
    424 #define MVPP2_PORT_CTRL2_PRBS_GEN_EN_MASK    \
    425     (0x00000001 << MVPP2_PORT_CTRL2_PRBS_GEN_EN_OFFS)
    426 
    427 #define MVPP2_PORT_CTRL2_SELECT_DATA_TO_TX_OFFS   12
    428 #define MVPP2_PORT_CTRL2_SELECT_DATA_TO_TX_MASK    \
    429     (0x00000003 << MVPP2_PORT_CTRL2_SELECT_DATA_TO_TX_OFFS)
    430 
    431 #define MVPP2_PORT_CTRL2_EN_COL_ON_BP_OFFS    14
    432 #define MVPP2_PORT_CTRL2_EN_COL_ON_BP_MASK    \
    433     (0x00000001 << MVPP2_PORT_CTRL2_EN_COL_ON_BP_OFFS)
    434 
    435 #define MVPP2_PORT_CTRL2_EARLY_REJECT_MODE_OFFS   15
    436 #define MVPP2_PORT_CTRL2_EARLY_REJECT_MODE_MASK    \
    437     (0x00000001 << MVPP2_PORT_CTRL2_EARLY_REJECT_MODE_OFFS)
    438 
    439 /* Port Auto-negotiation Configuration */
    440 #define MVPP2_PORT_AUTO_NEG_CFG_REG                       (0x000c)
    441 #define MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_DOWN_OFFS    0
    442 #define MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_DOWN_MASK    \
    443     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_DOWN_OFFS)
    444 
    445 #define MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_UP_OFFS    1
    446 #define MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_UP_MASK    \
    447     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_UP_OFFS)
    448 
    449 #define MVPP2_PORT_AUTO_NEG_CFG_EN_PCS_AN_OFFS    2
    450 #define MVPP2_PORT_AUTO_NEG_CFG_EN_PCS_AN_MASK    \
    451     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_EN_PCS_AN_OFFS)
    452 
    453 #define MVPP2_PORT_AUTO_NEG_CFG_AN_BYPASS_EN_OFFS    3
    454 #define MVPP2_PORT_AUTO_NEG_CFG_AN_BYPASS_EN_MASK    \
    455     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_AN_BYPASS_EN_OFFS)
    456 
    457 #define MVPP2_PORT_AUTO_NEG_CFG_INBAND_RESTARTAN_OFFS    4
    458 #define MVPP2_PORT_AUTO_NEG_CFG_INBAND_RESTARTAN_MASK    \
    459     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_INBAND_RESTARTAN_OFFS)
    460 
    461 #define MVPP2_PORT_AUTO_NEG_CFG_SET_MII_SPEED_OFFS    5
    462 #define MVPP2_PORT_AUTO_NEG_CFG_SET_MII_SPEED_MASK    \
    463     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_SET_MII_SPEED_OFFS)
    464 
    465 #define MVPP2_PORT_AUTO_NEG_CFG_SET_GMII_SPEED_OFFS   6
    466 #define MVPP2_PORT_AUTO_NEG_CFG_SET_GMII_SPEED_MASK    \
    467     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_SET_GMII_SPEED_OFFS)
    468 
    469 #define MVPP2_PORT_AUTO_NEG_CFG_EN_AN_SPEED_OFFS    7
    470 #define MVPP2_PORT_AUTO_NEG_CFG_EN_AN_SPEED_MASK    \
    471     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_EN_AN_SPEED_OFFS)
    472 
    473 #define MVPP2_PORT_AUTO_NEG_CFG_ADV_PAUSE_OFFS    9
    474 #define MVPP2_PORT_AUTO_NEG_CFG_ADV_PAUSE_MASK    \
    475     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_ADV_PAUSE_OFFS)
    476 
    477 #define MVPP2_PORT_AUTO_NEG_CFG_ADV_ASM_PAUSE_OFFS    10
    478 #define MVPP2_PORT_AUTO_NEG_CFG_ADV_ASM_PAUSE_MASK    \
    479     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_ADV_ASM_PAUSE_OFFS)
    480 
    481 #define MVPP2_PORT_AUTO_NEG_CFG_EN_FC_AN_OFFS    11
    482 #define MVPP2_PORT_AUTO_NEG_CFG_EN_FC_AN_MASK    \
    483     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_EN_FC_AN_OFFS)
    484 
    485 #define MVPP2_PORT_AUTO_NEG_CFG_SET_FULL_DX_OFFS    12
    486 #define MVPP2_PORT_AUTO_NEG_CFG_SET_FULL_DX_MASK    \
    487     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_SET_FULL_DX_OFFS)
    488 
    489 #define MVPP2_PORT_AUTO_NEG_CFG_EN_FDX_AN_OFFS    13
    490 #define MVPP2_PORT_AUTO_NEG_CFG_EN_FDX_AN_MASK    \
    491     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_EN_FDX_AN_OFFS)
    492 
    493 #define MVPP2_PORT_AUTO_NEG_CFG_PHY_MODE_OFFS    14
    494 #define MVPP2_PORT_AUTO_NEG_CFG_PHY_MODE_MASK    \
    495     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_PHY_MODE_OFFS)
    496 
    497 #define MVPP2_PORT_AUTO_NEG_CFG_CHOOSE_SAMPLE_TX_CONFIG_OFFS    15
    498 #define MVPP2_PORT_AUTO_NEG_CFG_CHOOSE_SAMPLE_TX_CONFIG_MASK    \
    499     (0x00000001 << MVPP2_PORT_AUTO_NEG_CFG_CHOOSE_SAMPLE_TX_CONFIG_OFFS)
    500 
    501 /* Port Status0 */
    502 #define MVPP2_PORT_STATUS0_REG                            (0x0010)
    503 #define MVPP2_PORT_STATUS0_LINKUP_OFFS    0
    504 #define MVPP2_PORT_STATUS0_LINKUP_MASK    \
    505     (0x00000001 << MVPP2_PORT_STATUS0_LINKUP_OFFS)
    506 
    507 #define MVPP2_PORT_STATUS0_GMIISPEED_OFFS    1
    508 #define MVPP2_PORT_STATUS0_GMIISPEED_MASK    \
    509     (0x00000001 << MVPP2_PORT_STATUS0_GMIISPEED_OFFS)
    510 
    511 #define MVPP2_PORT_STATUS0_MIISPEED_OFFS    2
    512 #define MVPP2_PORT_STATUS0_MIISPEED_MASK    \
    513     (0x00000001 << MVPP2_PORT_STATUS0_MIISPEED_OFFS)
    514 
    515 #define MVPP2_PORT_STATUS0_FULLDX_OFFS    3
    516 #define MVPP2_PORT_STATUS0_FULLDX_MASK    \
    517     (0x00000001 << MVPP2_PORT_STATUS0_FULLDX_OFFS)
    518 
    519 #define MVPP2_PORT_STATUS0_RXFCEN_OFFS    4
    520 #define MVPP2_PORT_STATUS0_RXFCEN_MASK    \
    521     (0x00000001 << MVPP2_PORT_STATUS0_RXFCEN_OFFS)
    522 
    523 #define MVPP2_PORT_STATUS0_TXFCEN_OFFS    5
    524 #define MVPP2_PORT_STATUS0_TXFCEN_MASK    \
    525     (0x00000001 << MVPP2_PORT_STATUS0_TXFCEN_OFFS)
    526 
    527 #define MVPP2_PORT_STATUS0_PORTRXPAUSE_OFFS    6
    528 #define MVPP2_PORT_STATUS0_PORTRXPAUSE_MASK    \
    529     (0x00000001 << MVPP2_PORT_STATUS0_PORTRXPAUSE_OFFS)
    530 
    531 #define MVPP2_PORT_STATUS0_PORTTXPAUSE_OFFS    7
    532 #define MVPP2_PORT_STATUS0_PORTTXPAUSE_MASK    \
    533     (0x00000001 << MVPP2_PORT_STATUS0_PORTTXPAUSE_OFFS)
    534 
    535 #define MVPP2_PORT_STATUS0_PORTIS_DOINGPRESSURE_OFFS    8
    536 #define MVPP2_PORT_STATUS0_PORTIS_DOINGPRESSURE_MASK    \
    537     (0x00000001 << MVPP2_PORT_STATUS0_PORTIS_DOINGPRESSURE_OFFS)
    538 
    539 #define MVPP2_PORT_STATUS0_PORTBUFFULL_OFFS    9
    540 #define MVPP2_PORT_STATUS0_PORTBUFFULL_MASK    \
    541     (0x00000001 << MVPP2_PORT_STATUS0_PORTBUFFULL_OFFS)
    542 
    543 #define MVPP2_PORT_STATUS0_SYNCFAIL10MS_OFFS    10
    544 #define MVPP2_PORT_STATUS0_SYNCFAIL10MS_MASK    \
    545     (0x00000001 << MVPP2_PORT_STATUS0_SYNCFAIL10MS_OFFS)
    546 
    547 #define MVPP2_PORT_STATUS0_ANDONE_OFFS    11
    548 #define MVPP2_PORT_STATUS0_ANDONE_MASK    \
    549     (0x00000001 << MVPP2_PORT_STATUS0_ANDONE_OFFS)
    550 
    551 #define MVPP2_PORT_STATUS0_INBAND_AUTONEG_BYPASSACT_OFFS    12
    552 #define MVPP2_PORT_STATUS0_INBAND_AUTONEG_BYPASSACT_MASK    \
    553     (0x00000001 << MVPP2_PORT_STATUS0_INBAND_AUTONEG_BYPASSACT_OFFS)
    554 
    555 #define MVPP2_PORT_STATUS0_SERDESPLL_LOCKED_OFFS    13
    556 #define MVPP2_PORT_STATUS0_SERDESPLL_LOCKED_MASK    \
    557     (0x00000001 << MVPP2_PORT_STATUS0_SERDESPLL_LOCKED_OFFS)
    558 
    559 #define MVPP2_PORT_STATUS0_SYNCOK_OFFS    14
    560 #define MVPP2_PORT_STATUS0_SYNCOK_MASK    \
    561     (0x00000001 << MVPP2_PORT_STATUS0_SYNCOK_OFFS)
    562 
    563 #define MVPP2_PORT_STATUS0_SQUELCHNOT_DETECTED_OFFS    15
    564 #define MVPP2_PORT_STATUS0_SQUELCHNOT_DETECTED_MASK    \
    565     (0x00000001 << MVPP2_PORT_STATUS0_SQUELCHNOT_DETECTED_OFFS)
    566 
    567 /* Port Serial Parameters Configuration */
    568 #define MVPP2_PORT_SERIAL_PARAM_CFG_REG                   (0x0014)
    569 #define MVPP2_PORT_SERIAL_PARAM_CFG_UNIDIRECTIONAL_ENABLE_OFFS    0
    570 #define MVPP2_PORT_SERIAL_PARAM_CFG_UNIDIRECTIONAL_ENABLE_MASK    \
    571     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_UNIDIRECTIONAL_ENABLE_OFFS)
    572 
    573 #define MVPP2_PORT_SERIAL_PARAM_CFG_RETRANSMIT_COLLISION_DOMAIN_OFFS    1
    574 #define MVPP2_PORT_SERIAL_PARAM_CFG_RETRANSMIT_COLLISION_DOMAIN_MASK    \
    575     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_RETRANSMIT_COLLISION_DOMAIN_OFFS)
    576 
    577 #define MVPP2_PORT_SERIAL_PARAM_CFG_PUMA2_BTS1444_EN_OFFS    2
    578 #define MVPP2_PORT_SERIAL_PARAM_CFG_PUMA2_BTS1444_EN_MASK    \
    579     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_PUMA2_BTS1444_EN_OFFS)
    580 
    581 #define MVPP2_PORT_SERIAL_PARAM_CFG_FORWARD_802_3X_FC_EN_OFFS    3
    582 #define MVPP2_PORT_SERIAL_PARAM_CFG_FORWARD_802_3X_FC_EN_MASK    \
    583     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_FORWARD_802_3X_FC_EN_OFFS)
    584 
    585 #define MVPP2_PORT_SERIAL_PARAM_CFG_BP_EN_OFFS    4
    586 #define MVPP2_PORT_SERIAL_PARAM_CFG_BP_EN_MASK    \
    587     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_BP_EN_OFFS)
    588 
    589 #define MVPP2_PORT_SERIAL_PARAM_CFG_RX_NEGEDGE_SAMPLE_EN_OFFS   5
    590 #define MVPP2_PORT_SERIAL_PARAM_CFG_RX_NEGEDGE_SAMPLE_EN_MASK   \
    591     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_RX_NEGEDGE_SAMPLE_EN_OFFS)
    592 
    593 #define MVPP2_PORT_SERIAL_PARAM_CFG_COL_DOMAIN_LIMIT_OFFS    6
    594 #define MVPP2_PORT_SERIAL_PARAM_CFG_COL_DOMAIN_LIMIT_MASK    \
    595     (0x0000003f << MVPP2_PORT_SERIAL_PARAM_CFG_COL_DOMAIN_LIMIT_OFFS)
    596 
    597 #define MVPP2_PORT_SERIAL_PARAM_CFG_PERIODIC_TYPE_SELECT_OFFS   12
    598 #define MVPP2_PORT_SERIAL_PARAM_CFG_PERIODIC_TYPE_SELECT_MASK   \
    599     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_PERIODIC_TYPE_SELECT_OFFS)
    600 
    601 #define MVPP2_PORT_SERIAL_PARAM_CFG_PER_PRIORITY_FC_EN_OFFS   13
    602 #define MVPP2_PORT_SERIAL_PARAM_CFG_PER_PRIORITY_FC_EN_MASK   \
    603     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_PER_PRIORITY_FC_EN_OFFS)
    604 
    605 #define MVPP2_PORT_SERIAL_PARAM_CFG_TX_STANDARD_PRBS7_OFFS    14
    606 #define MVPP2_PORT_SERIAL_PARAM_CFG_TX_STANDARD_PRBS7_MASK    \
    607     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_TX_STANDARD_PRBS7_OFFS)
    608 
    609 #define MVPP2_PORT_SERIAL_PARAM_CFG_REVERSE_PRBS_RX_OFFS    15
    610 #define MVPP2_PORT_SERIAL_PARAM_CFG_REVERSE_PRBS_RX_MASK    \
    611     (0x00000001 << MVPP2_PORT_SERIAL_PARAM_CFG_REVERSE_PRBS_RX_OFFS)
    612 
    613 /* Port Fifo Configuration 0 */
    614 #define MVPP2_PORT_FIFO_CFG_0_REG                         (0x0018)
    615 #define MVPP2_PORT_FIFO_CFG_0_TX_FIFO_HIGH_WM_OFFS    0
    616 #define MVPP2_PORT_FIFO_CFG_0_TX_FIFO_HIGH_WM_MASK    \
    617     (0x000000ff << MVPP2_PORT_FIFO_CFG_0_TX_FIFO_HIGH_WM_OFFS)
    618 
    619 #define MVPP2_PORT_FIFO_CFG_0_TX_FIFO_LOW_WM_OFFS    8
    620 #define MVPP2_PORT_FIFO_CFG_0_TX_FIFO_LOW_WM_MASK    \
    621     (0x000000ff << MVPP2_PORT_FIFO_CFG_0_TX_FIFO_LOW_WM_OFFS)
    622 
    623 /* Port Fifo Configuration 1 */
    624 #define MVPP2_PORT_FIFO_CFG_1_REG                         (0x001c)
    625 #define MVPP2_PORT_FIFO_CFG_1_RX_FIFO_MAX_TH_OFFS    0
    626 #define MVPP2_PORT_FIFO_CFG_1_RX_FIFO_MAX_TH_MASK    \
    627     (0x0000003f << MVPP2_PORT_FIFO_CFG_1_RX_FIFO_MAX_TH_OFFS)
    628 
    629 #define MVPP2_PORT_FIFO_CFG_1_TX_FIFO_MIN_TH_OFFS    6
    630 #define MVPP2_PORT_FIFO_CFG_1_TX_FIFO_MIN_TH_MASK    \
    631     (0x000000ff << MVPP2_PORT_FIFO_CFG_1_TX_FIFO_MIN_TH_OFFS)
    632 
    633 #define MVPP2_PORT_FIFO_CFG_1_PORT_EN_FIX_EN_OFFS    15
    634 #define MVPP2_PORT_FIFO_CFG_1_PORT_EN_FIX_EN_MASK    \
    635     (0x00000001 << MVPP2_PORT_FIFO_CFG_1_PORT_EN_FIX_EN_OFFS)
    636 
    637 /* Port Serdes Configuration0 */
    638 #define MVPP2_PORT_SERDES_CFG0_REG                        (0x0028)
    639 #define MVPP2_PORT_SERDES_CFG0_SERDESRESET_OFFS    0
    640 #define MVPP2_PORT_SERDES_CFG0_SERDESRESET_MASK    \
    641     (0x00000001 << MVPP2_PORT_SERDES_CFG0_SERDESRESET_OFFS)
    642 
    643 #define MVPP2_PORT_SERDES_CFG0_PU_TX_OFFS    1
    644 #define MVPP2_PORT_SERDES_CFG0_PU_TX_MASK    \
    645     (0x00000001 << MVPP2_PORT_SERDES_CFG0_PU_TX_OFFS)
    646 
    647 #define MVPP2_PORT_SERDES_CFG0_PU_RX_OFFS    2
    648 #define MVPP2_PORT_SERDES_CFG0_PU_RX_MASK    \
    649     (0x00000001 << MVPP2_PORT_SERDES_CFG0_PU_RX_OFFS)
    650 
    651 #define MVPP2_PORT_SERDES_CFG0_PU_PLL_OFFS    3
    652 #define MVPP2_PORT_SERDES_CFG0_PU_PLL_MASK    \
    653     (0x00000001 << MVPP2_PORT_SERDES_CFG0_PU_PLL_OFFS)
    654 
    655 #define MVPP2_PORT_SERDES_CFG0_PU_IVREF_OFFS    4
    656 #define MVPP2_PORT_SERDES_CFG0_PU_IVREF_MASK    \
    657     (0x00000001 << MVPP2_PORT_SERDES_CFG0_PU_IVREF_OFFS)
    658 
    659 #define MVPP2_PORT_SERDES_CFG0_TESTEN_OFFS    5
    660 #define MVPP2_PORT_SERDES_CFG0_TESTEN_MASK    \
    661     (0x00000001 << MVPP2_PORT_SERDES_CFG0_TESTEN_OFFS)
    662 
    663 #define MVPP2_PORT_SERDES_CFG0_DPHER_EN_OFFS    6
    664 #define MVPP2_PORT_SERDES_CFG0_DPHER_EN_MASK    \
    665     (0x00000001 << MVPP2_PORT_SERDES_CFG0_DPHER_EN_OFFS)
    666 
    667 #define MVPP2_PORT_SERDES_CFG0_RUDI_INVALID_ENABLE_OFFS    7
    668 #define MVPP2_PORT_SERDES_CFG0_RUDI_INVALID_ENABLE_MASK    \
    669     (0x00000001 << MVPP2_PORT_SERDES_CFG0_RUDI_INVALID_ENABLE_OFFS)
    670 
    671 #define MVPP2_PORT_SERDES_CFG0_ACK_OVERRIDE_ENABLE_OFFS    8
    672 #define MVPP2_PORT_SERDES_CFG0_ACK_OVERRIDE_ENABLE_MASK    \
    673     (0x00000001 << MVPP2_PORT_SERDES_CFG0_ACK_OVERRIDE_ENABLE_OFFS)
    674 
    675 #define MVPP2_PORT_SERDES_CFG0_CONFIG_WORD_ENABLE_OFFS    9
    676 #define MVPP2_PORT_SERDES_CFG0_CONFIG_WORD_ENABLE_MASK    \
    677     (0x00000001 << MVPP2_PORT_SERDES_CFG0_CONFIG_WORD_ENABLE_OFFS)
    678 
    679 #define MVPP2_PORT_SERDES_CFG0_SYNC_FAIL_INT_ENABLE_OFFS    10
    680 #define MVPP2_PORT_SERDES_CFG0_SYNC_FAIL_INT_ENABLE_MASK    \
    681     (0x00000001 << MVPP2_PORT_SERDES_CFG0_SYNC_FAIL_INT_ENABLE_OFFS)
    682 
    683 #define MVPP2_PORT_SERDES_CFG0_MASTER_MODE_ENABLE_OFFS    11
    684 #define MVPP2_PORT_SERDES_CFG0_MASTER_MODE_ENABLE_MASK    \
    685     (0x00000001 << MVPP2_PORT_SERDES_CFG0_MASTER_MODE_ENABLE_OFFS)
    686 
    687 #define MVPP2_PORT_SERDES_CFG0_TERM75_TX_OFFS    12
    688 #define MVPP2_PORT_SERDES_CFG0_TERM75_TX_MASK    \
    689     (0x00000001 << MVPP2_PORT_SERDES_CFG0_TERM75_TX_OFFS)
    690 
    691 #define MVPP2_PORT_SERDES_CFG0_OUTAMP_OFFS    13
    692 #define MVPP2_PORT_SERDES_CFG0_OUTAMP_MASK    \
    693     (0x00000001 << MVPP2_PORT_SERDES_CFG0_OUTAMP_OFFS)
    694 
    695 #define MVPP2_PORT_SERDES_CFG0_BTS712_FIX_EN_OFFS    14
    696 #define MVPP2_PORT_SERDES_CFG0_BTS712_FIX_EN_MASK    \
    697     (0x00000001 << MVPP2_PORT_SERDES_CFG0_BTS712_FIX_EN_OFFS)
    698 
    699 #define MVPP2_PORT_SERDES_CFG0_BTS156_FIX_EN_OFFS    15
    700 #define MVPP2_PORT_SERDES_CFG0_BTS156_FIX_EN_MASK    \
    701     (0x00000001 << MVPP2_PORT_SERDES_CFG0_BTS156_FIX_EN_OFFS)
    702 
    703 /* Port Serdes Configuration1 */
    704 #define MVPP2_PORT_SERDES_CFG1_REG                        (0x002c)
    705 #define MVPP2_PORT_SERDES_CFG1_SMII_RX_10MB_CLK_EDGE_SEL_OFFS    0
    706 #define MVPP2_PORT_SERDES_CFG1_SMII_RX_10MB_CLK_EDGE_SEL_MASK    \
    707     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_SMII_RX_10MB_CLK_EDGE_SEL_OFFS)
    708 
    709 #define MVPP2_GMAC_PORT_SERDES_CFG1_SMII_TX_10MB_CLK_EDGE_SEL_OFFS    1
    710 #define MVPP2_GMAC_PORT_SERDES_CFG1_SMII_TX_10MB_CLK_EDGE_SEL_MASK    \
    711     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_SMII_TX_10MB_CLK_EDGE_SEL_OFFS)
    712 
    713 #define MVPP2_GMAC_PORT_SERDES_CFG1_MEN_OFFS    2
    714 #define MVPP2_GMAC_PORT_SERDES_CFG1_MEN_MASK    \
    715     (0x00000003 << MVPP2_GMAC_PORT_SERDES_CFG1_MEN_OFFS)
    716 
    717 #define MVPP2_GMAC_PORT_SERDES_CFG1_VCMS_OFFS    4
    718 #define MVPP2_GMAC_PORT_SERDES_CFG1_VCMS_MASK    \
    719     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_VCMS_OFFS)
    720 
    721 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_USE_SIGDET_OFFS    5
    722 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_USE_SIGDET_MASK    \
    723     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_USE_SIGDET_OFFS)
    724 
    725 #define MVPP2_GMAC_PORT_SERDES_CFG1_EN_CRS_MASK_TX_OFFS    6
    726 #define MVPP2_GMAC_PORT_SERDES_CFG1_EN_CRS_MASK_TX_MASK    \
    727     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_EN_CRS_MASK_TX_OFFS)
    728 
    729 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_ENABLE_OFFS    7
    730 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_ENABLE_MASK    \
    731     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_100FX_ENABLE_OFFS)
    732 
    733 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_PHY_ADDRESS_OFFS    8
    734 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_PHY_ADDRESS_MASK    \
    735     (0x0000001f << MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_PHY_ADDRESS_OFFS)
    736 
    737 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_SIGDET_POLARITY_OFFS    13
    738 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_SIGDET_POLARITY_MASK    \
    739     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_SIGDET_POLARITY_OFFS)
    740 
    741 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_INTERRUPT_POLARITY_OFFS    14
    742 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_INTERRUPT_POLARITY_MASK    \
    743     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_INTERRUPT_POLARITY_OFFS)
    744 
    745 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_SERDES_POLARITY_OFFS    15
    746 #define MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_SERDES_POLARITY_MASK    \
    747     (0x00000001 << MVPP2_GMAC_PORT_SERDES_CFG1_100FX_PCS_SERDES_POLARITY_OFFS)
    748 
    749 /* Port Serdes Configuration2 */
    750 #define MVPP2_PORT_SERDES_CFG2_REG                        (0x0030)
    751 #define MVPP2_PORT_SERDES_CFG2_AN_ADV_CONFIGURATION_OFFS    0
    752 #define MVPP2_PORT_SERDES_CFG2_AN_ADV_CONFIGURATION_MASK    \
    753     (0x0000ffff << MVPP2_PORT_SERDES_CFG2_AN_ADV_CONFIGURATION_OFFS)
    754 
    755 /* Port Serdes Configuration3 */
    756 #define MVPP2_PORT_SERDES_CFG3_REG                        (0x0034)
    757 #define MVPP2_PORT_SERDES_CFG3_ABILITY_MATCH_STATUS_OFFS    0
    758 #define MVPP2_PORT_SERDES_CFG3_ABILITY_MATCH_STATUS_MASK    \
    759     (0x0000ffff << MVPP2_PORT_SERDES_CFG3_ABILITY_MATCH_STATUS_OFFS)
    760 
    761 /* Port Prbs Status */
    762 #define MVPP2_PORT_PRBS_STATUS_REG                        (0x0038)
    763 #define MVPP2_PORT_PRBS_STATUS_PRBSCHECK_LOCKED_OFFS    0
    764 #define MVPP2_PORT_PRBS_STATUS_PRBSCHECK_LOCKED_MASK    \
    765     (0x00000001 << MVPP2_PORT_PRBS_STATUS_PRBSCHECK_LOCKED_OFFS)
    766 
    767 #define MVPP2_PORT_PRBS_STATUS_PRBSCHECKRDY_OFFS    1
    768 #define MVPP2_PORT_PRBS_STATUS_PRBSCHECKRDY_MASK    \
    769     (0x00000001 << MVPP2_PORT_PRBS_STATUS_PRBSCHECKRDY_OFFS)
    770 
    771 /* Port Prbs Error Counter */
    772 #define MVPP2_PORT_PRBS_ERR_CNTR_REG                      (0x003c)
    773 #define MVPP2_PORT_PRBS_ERR_CNTR_PRBSBITERRCNT_OFFS    0
    774 #define MVPP2_PORT_PRBS_ERR_CNTR_PRBSBITERRCNT_MASK    \
    775     (0x0000ffff << MVPP2_PORT_PRBS_ERR_CNTR_PRBSBITERRCNT_OFFS)
    776 
    777 /* Port Status1 */
    778 #define MVPP2_PORT_STATUS1_REG                            (0x0040)
    779 #define MVPP2_PORT_STATUS1_MEDIAACTIVE_OFFS    0
    780 #define MVPP2_PORT_STATUS1_MEDIAACTIVE_MASK    \
    781     (0x00000001 << MVPP2_PORT_STATUS1_MEDIAACTIVE_OFFS)
    782 
    783 /* Port Mib Counters Control */
    784 #define MVPP2_PORT_MIB_CNTRS_CTRL_REG                     (0x0044)
    785 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_COPY_TRIGGER_OFFS    0
    786 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_COPY_TRIGGER_MASK    \
    787     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_MIB_COPY_TRIGGER_OFFS)
    788 
    789 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_CLEAR_ON_READ__OFFS     1
    790 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_CLEAR_ON_READ__MASK     \
    791     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_MIB_CLEAR_ON_READ__OFFS)
    792 
    793 #define MVPP2_PORT_MIB_CNTRS_CTRL_RX_HISTOGRAM_EN_OFFS    2
    794 #define MVPP2_PORT_MIB_CNTRS_CTRL_RX_HISTOGRAM_EN_MASK    \
    795     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_RX_HISTOGRAM_EN_OFFS)
    796 
    797 #define MVPP2_PORT_MIB_CNTRS_CTRL_TX_HISTOGRAM_EN_OFFS    3
    798 #define MVPP2_PORT_MIB_CNTRS_CTRL_TX_HISTOGRAM_EN_MASK    \
    799     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_TX_HISTOGRAM_EN_OFFS)
    800 
    801 #define MVPP2_PORT_MIB_CNTRS_CTRL_MFA1_BTT940_FIX_ENABLE__OFFS    4
    802 #define MVPP2_PORT_MIB_CNTRS_CTRL_MFA1_BTT940_FIX_ENABLE__MASK    \
    803     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_MFA1_BTT940_FIX_ENABLE__OFFS)
    804 
    805 #define MVPP2_PORT_MIB_CNTRS_CTRL_XCAT_BTS_340_EN__OFFS    5
    806 #define MVPP2_PORT_MIB_CNTRS_CTRL_XCAT_BTS_340_EN__MASK    \
    807     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_XCAT_BTS_340_EN__OFFS)
    808 
    809 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_4_COUNT_HIST_OFFS    6
    810 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_4_COUNT_HIST_MASK    \
    811     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_MIB_4_COUNT_HIST_OFFS)
    812 
    813 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_4_LIMIT_1518_1522_OFFS    7
    814 #define MVPP2_PORT_MIB_CNTRS_CTRL_MIB_4_LIMIT_1518_1522_MASK    \
    815     (0x00000001 << MVPP2_PORT_MIB_CNTRS_CTRL_MIB_4_LIMIT_1518_1522_OFFS)
    816 
    817 /* Port Mac Control3 */
    818 #define MVPP2_PORT_CTRL3_REG                              (0x0048)
    819 #define MVPP2_PORT_CTRL3_BUF_SIZE_OFFS    0
    820 #define MVPP2_PORT_CTRL3_BUF_SIZE_MASK    \
    821     (0x0000003f << MVPP2_PORT_CTRL3_BUF_SIZE_OFFS)
    822 
    823 #define MVPP2_PORT_CTRL3_IPG_DATA_OFFS    6
    824 #define MVPP2_PORT_CTRL3_IPG_DATA_MASK    \
    825     (0x000001ff << MVPP2_PORT_CTRL3_IPG_DATA_OFFS)
    826 
    827 #define MVPP2_PORT_CTRL3_LLFC_GLOBAL_FC_ENABLE_OFFS    15
    828 #define MVPP2_PORT_CTRL3_LLFC_GLOBAL_FC_ENABLE_MASK    \
    829     (0x00000001 << MVPP2_PORT_CTRL3_LLFC_GLOBAL_FC_ENABLE_OFFS)
    830 #define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK    0xff
    831 
    832 /* Port Mac Control4 */
    833 #define MVPP2_PORT_CTRL4_REG                              (0x0090)
    834 #define MVPP2_PORT_CTRL4_EXT_PIN_GMII_SEL_OFFS    0
    835 #define MVPP2_PORT_CTRL4_EXT_PIN_GMII_SEL_MASK    \
    836     (0x00000001 << MVPP2_PORT_CTRL4_EXT_PIN_GMII_SEL_OFFS)
    837 
    838 #define MVPP2_PORT_CTRL4_PREAMBLE_FIX_OFFS    1
    839 #define MVPP2_PORT_CTRL4_PREAMBLE_FIX_MASK    \
    840     (0x00000001 << MVPP2_PORT_CTRL4_PREAMBLE_FIX_OFFS)
    841 
    842 #define MVPP2_PORT_CTRL4_SQ_DETECT_FIX_EN_OFFS    2
    843 #define MVPP2_PORT_CTRL4_SQ_DETECT_FIX_EN_MASK    \
    844     (0x00000001 << MVPP2_PORT_CTRL4_SQ_DETECT_FIX_EN_OFFS)
    845 
    846 #define MVPP2_PORT_CTRL4_FC_EN_RX_OFFS    3
    847 #define MVPP2_PORT_CTRL4_FC_EN_RX_MASK    \
    848     (0x00000001 << MVPP2_PORT_CTRL4_FC_EN_RX_OFFS)
    849 
    850 #define MVPP2_PORT_CTRL4_FC_EN_TX_OFFS    4
    851 #define MVPP2_PORT_CTRL4_FC_EN_TX_MASK    \
    852     (0x00000001 << MVPP2_PORT_CTRL4_FC_EN_TX_OFFS)
    853 
    854 #define MVPP2_PORT_CTRL4_DP_CLK_SEL_OFFS    5
    855 #define MVPP2_PORT_CTRL4_DP_CLK_SEL_MASK    \
    856     (0x00000001 << MVPP2_PORT_CTRL4_DP_CLK_SEL_OFFS)
    857 
    858 #define MVPP2_PORT_CTRL4_SYNC_BYPASS_OFFS   6
    859 #define MVPP2_PORT_CTRL4_SYNC_BYPASS_MASK    \
    860     (0x00000001 << MVPP2_PORT_CTRL4_SYNC_BYPASS_OFFS)
    861 
    862 #define MVPP2_PORT_CTRL4_QSGMII_BYPASS_ACTIVE_OFFS    7
    863 #define MVPP2_PORT_CTRL4_QSGMII_BYPASS_ACTIVE_MASK    \
    864     (0x00000001 << MVPP2_PORT_CTRL4_QSGMII_BYPASS_ACTIVE_OFFS)
    865 
    866 #define MVPP2_PORT_CTRL4_COUNT_EXTERNAL_FC_EN_OFFS    8
    867 #define MVPP2_PORT_CTRL4_COUNT_EXTERNAL_FC_EN_MASK    \
    868     (0x00000001 << MVPP2_PORT_CTRL4_COUNT_EXTERNAL_FC_EN_OFFS)
    869 
    870 #define MVPP2_PORT_CTRL4_MARVELL_HEADER_EN_OFFS    9
    871 #define MVPP2_PORT_CTRL4_MARVELL_HEADER_EN_MASK    \
    872     (0x00000001 << MVPP2_PORT_CTRL4_MARVELL_HEADER_EN_OFFS)
    873 
    874 #define MVPP2_PORT_CTRL4_LEDS_NUMBER_OFFS    10
    875 #define MVPP2_PORT_CTRL4_LEDS_NUMBER_MASK    \
    876     (0x0000003f << MVPP2_PORT_CTRL4_LEDS_NUMBER_OFFS)
    877 
    878 /* Descriptor ring Macros */
    879 #define MVPP2_QUEUE_NEXT_DESC(q, index)                   (((index) < (q)->LastDesc) ? ((index) + 1) : 0)
    880 
    881 /* Various constants */
    882 
    883 /* Coalescing */
    884 #define MVPP2_TXDONE_COAL_PKTS_THRESH                     15
    885 #define MVPP2_TXDONE_HRTIMER_PERIOD_NS                    1000000UL
    886 #define MVPP2_RX_COAL_PKTS                                32
    887 #define MVPP2_RX_COAL_USEC                                100
    888 
    889 /*
    890  * The two bytes Marvell header. Either contains a special value used
    891  * by Marvell switches when a specific hardware mode is enabled (not
    892  * supported by this driver) or is filled automatically by zeroes on
    893  * the RX side. Those two bytes being at the front of the Ethernet
    894  * header, they allow to have the IP header aligned on a 4 bytes
    895  * boundary automatically: the hardware skips those two bytes on its
    896  * own.
    897  */
    898 #define MVPP2_MH_SIZE                                     2
    899 #define MVPP2_ETH_TYPE_LEN                                2
    900 #define MVPP2_PPPOE_HDR_SIZE                              8
    901 #define MVPP2_VLAN_TAG_LEN                                4
    902 
    903 /* Lbtd 802.3 type */
    904 #define MVPP2_IP_LBDT_TYPE                                0xfffa
    905 
    906 #define MVPP2_CPU_D_CACHE_LINE_SIZE                       32
    907 #define MVPP2_TX_CSUM_MAX_SIZE                            9800
    908 
    909 /* Timeout constants */
    910 #define MVPP2_TX_DISABLE_TIMEOUT_MSEC                     1000
    911 #define MVPP2_TX_PENDING_TIMEOUT_MSEC                     1000
    912 
    913 #define MVPP2_TX_MTU_MAX                                  0x7ffff
    914 
    915 /* Maximum number of T-CONTs of PON port */
    916 #define MVPP2_MAX_TCONT                                   16
    917 
    918 /* Maximum number of supported ports */
    919 #define MVPP2_MAX_PORTS                                   4
    920 
    921 /* Maximum number of TXQs used by single port */
    922 #define MVPP2_MAX_TXQ                                     8
    923 
    924 /* Maximum number of RXQs used by single port */
    925 #define MVPP2_MAX_RXQ                                     8
    926 
    927 /* Dfault number of RXQs in use */
    928 #define MVPP2_DEFAULT_RXQ                                 4
    929 
    930 /* Total number of RXQs available to all ports */
    931 #define MVPP2_RXQ_TOTAL_NUM                               (MVPP2_MAX_PORTS * MVPP2_MAX_RXQ)
    932 
    933 /* Max number of Rx descriptors */
    934 #define MVPP2_MAX_RXD                                     32
    935 
    936 /* Max number of Tx descriptors */
    937 #define MVPP2_MAX_TXD                                     32
    938 
    939 /* Amount of Tx descriptors that can be reserved at once by CPU */
    940 #define MVPP2_CPU_DESC_CHUNK                              64
    941 
    942 /* Max number of Tx descriptors in each aggregated queue */
    943 #define MVPP2_AGGR_TXQ_SIZE                               256
    944 
    945 /* Descriptor aligned size */
    946 #define MVPP2_DESC_ALIGNED_SIZE                           32
    947 
    948 /* Descriptor alignment mask */
    949 #define MVPP2_TX_DESC_ALIGN                               (MVPP2_DESC_ALIGNED_SIZE - 1)
    950 
    951 /* RX FIFO constants */
    952 #define MVPP2_RX_FIFO_PORT_DATA_SIZE                      0x2000
    953 #define MVPP2_RX_FIFO_PORT_ATTR_SIZE                      0x80
    954 #define MVPP2_RX_FIFO_PORT_MIN_PKT                        0x80
    955 
    956 #define MVPP2_BIT_TO_BYTE(bit)                            ((bit) / 8)
    957 
    958 /* IPv6 max L3 address size */
    959 #define MVPP2_MAX_L3_ADDR_SIZE                            16
    960 
    961 /* Port flags */
    962 #define MVPP2_F_LOOPBACK                                  BIT(0)
    963 
    964 /* SD1 Control1 */
    965 #define SD1_CONTROL_1_REG                                 (0x148)
    966 
    967 #define SD1_CONTROL_XAUI_EN_OFFSET    28
    968 #define SD1_CONTROL_XAUI_EN_MASK    (0x1 << SD1_CONTROL_XAUI_EN_OFFSET)
    969 
    970 #define SD1_CONTROL_RXAUI0_L23_EN_OFFSET    27
    971 #define SD1_CONTROL_RXAUI0_L23_EN_MASK    (0x1 << SD1_CONTROL_RXAUI0_L23_EN_OFFSET)
    972 
    973 #define SD1_CONTROL_RXAUI1_L45_EN_OFFSET    26
    974 #define SD1_CONTROL_RXAUI1_L45_EN_MASK    (0x1 << SD1_CONTROL_RXAUI1_L45_EN_OFFSET)
    975 
    976 /* System Soft Reset 1 */
    977 #define MV_GOP_SOFT_RESET_1_REG                           (0x108)
    978 
    979 #define NETC_GOP_SOFT_RESET_OFFSET    6
    980 #define NETC_GOP_SOFT_RESET_MASK    (0x1 << NETC_GOP_SOFT_RESET_OFFSET)
    981 
    982 /* Ports Control 0 */
    983 #define MV_NETCOMP_PORTS_CONTROL_0                        (0x110)
    984 
    985 #define NETC_CLK_DIV_PHASE_OFFSET    31
    986 #define NETC_CLK_DIV_PHASE_MASK    (0x1 << NETC_CLK_DIV_PHASE_OFFSET)
    987 
    988 #define NETC_GIG_RX_DATA_SAMPLE_OFFSET    29
    989 #define NETC_GIG_RX_DATA_SAMPLE_MASK    (0x1 << NETC_GIG_RX_DATA_SAMPLE_OFFSET)
    990 
    991 #define NETC_BUS_WIDTH_SELECT_OFFSET    1
    992 #define NETC_BUS_WIDTH_SELECT_MASK    (0x1 << NETC_BUS_WIDTH_SELECT_OFFSET)
    993 
    994 #define NETC_GOP_ENABLE_OFFSET    0
    995 #define NETC_GOP_ENABLE_MASK    (0x1 << NETC_GOP_ENABLE_OFFSET)
    996 
    997 /* Ports Control 1 */
    998 #define MV_NETCOMP_PORTS_CONTROL_1                        (0x114)
    999 
   1000 #define NETC_PORT_GIG_RF_RESET_OFFSET(port)    (28 + port)
   1001 #define NETC_PORT_GIG_RF_RESET_MASK(port)    (0x1 << NETC_PORT_GIG_RF_RESET_OFFSET(port))
   1002 
   1003 #define NETC_PORTS_ACTIVE_OFFSET(port)    (0 + port)
   1004 #define NETC_PORTS_ACTIVE_MASK(port)    (0x1 << NETC_PORTS_ACTIVE_OFFSET(port))
   1005 
   1006 /* Ports Status */
   1007 #define MV_NETCOMP_PORTS_STATUS                           (0x11C)
   1008 #define NETC_PORTS_STATUS_OFFSET(port)    (0 + port)
   1009 #define NETC_PORTS_STATUS_MASK(port)    (0x1 << NETC_PORTS_STATUS_OFFSET(port))
   1010 
   1011 /* Networking Complex Control 0 */
   1012 #define MV_NETCOMP_CONTROL_0                              (0x120)
   1013 
   1014 #define NETC_GBE_PORT1_MII_MODE_OFFSET    2
   1015 #define NETC_GBE_PORT1_MII_MODE_MASK    (0x1 << NETC_GBE_PORT1_MII_MODE_OFFSET)
   1016 
   1017 #define NETC_GBE_PORT1_SGMII_MODE_OFFSET    1
   1018 #define NETC_GBE_PORT1_SGMII_MODE_MASK    (0x1 << NETC_GBE_PORT1_SGMII_MODE_OFFSET)
   1019 
   1020 #define NETC_GBE_PORT0_SGMII_MODE_OFFSET    0
   1021 #define NETC_GBE_PORT0_SGMII_MODE_MASK    (0x1 << NETC_GBE_PORT0_SGMII_MODE_OFFSET)
   1022 
   1023 /* Port Mac Control0 */
   1024 #define MV_XLG_PORT_MAC_CTRL0_REG     (                   0x0000)
   1025 #define MV_XLG_MAC_CTRL0_PORTEN_OFFS    0
   1026 #define MV_XLG_MAC_CTRL0_PORTEN_MASK    \
   1027     (0x00000001 << MV_XLG_MAC_CTRL0_PORTEN_OFFS)
   1028 
   1029 #define MV_XLG_MAC_CTRL0_MACRESETN_OFFS    1
   1030 #define MV_XLG_MAC_CTRL0_MACRESETN_MASK    \
   1031     (0x00000001 << MV_XLG_MAC_CTRL0_MACRESETN_OFFS)
   1032 
   1033 #define MV_XLG_MAC_CTRL0_FORCELINKDOWN_OFFS    2
   1034 #define MV_XLG_MAC_CTRL0_FORCELINKDOWN_MASK    \
   1035     (0x00000001 << MV_XLG_MAC_CTRL0_FORCELINKDOWN_OFFS)
   1036 
   1037 #define MV_XLG_MAC_CTRL0_FORCELINKPASS_OFFS    3
   1038 #define MV_XLG_MAC_CTRL0_FORCELINKPASS_MASK    \
   1039     (0x00000001 << MV_XLG_MAC_CTRL0_FORCELINKPASS_OFFS)
   1040 
   1041 #define MV_XLG_MAC_CTRL0_TXIPGMODE_OFFS    5
   1042 #define MV_XLG_MAC_CTRL0_TXIPGMODE_MASK    \
   1043     (0x00000003 << MV_XLG_MAC_CTRL0_TXIPGMODE_OFFS)
   1044 
   1045 #define MV_XLG_MAC_CTRL0_RXFCEN_OFFS    7
   1046 #define MV_XLG_MAC_CTRL0_RXFCEN_MASK    \
   1047     (0x00000001 << MV_XLG_MAC_CTRL0_RXFCEN_OFFS)
   1048 
   1049 #define MV_XLG_MAC_CTRL0_TXFCEN_OFFS    8
   1050 #define MV_XLG_MAC_CTRL0_TXFCEN_MASK    \
   1051     (0x00000001 << MV_XLG_MAC_CTRL0_TXFCEN_OFFS)
   1052 
   1053 #define MV_XLG_MAC_CTRL0_RXCRCCHECKEN_OFFS    9
   1054 #define MV_XLG_MAC_CTRL0_RXCRCCHECKEN_MASK    \
   1055     (0x00000001 << MV_XLG_MAC_CTRL0_RXCRCCHECKEN_OFFS)
   1056 
   1057 #define MV_XLG_MAC_CTRL0_PERIODICXONEN_OFFS    10
   1058 #define MV_XLG_MAC_CTRL0_PERIODICXONEN_MASK    \
   1059     (0x00000001 << MV_XLG_MAC_CTRL0_PERIODICXONEN_OFFS)
   1060 
   1061 #define MV_XLG_MAC_CTRL0_RXCRCSTRIPEN_OFFS    11
   1062 #define MV_XLG_MAC_CTRL0_RXCRCSTRIPEN_MASK    \
   1063     (0x00000001 << MV_XLG_MAC_CTRL0_RXCRCSTRIPEN_OFFS)
   1064 
   1065 #define MV_XLG_MAC_CTRL0_PADDINGDIS_OFFS    13
   1066 #define MV_XLG_MAC_CTRL0_PADDINGDIS_MASK    \
   1067     (0x00000001 << MV_XLG_MAC_CTRL0_PADDINGDIS_OFFS)
   1068 
   1069 #define MV_XLG_MAC_CTRL0_MIBCNTDIS_OFFS    14
   1070 #define MV_XLG_MAC_CTRL0_MIBCNTDIS_MASK    \
   1071     (0x00000001 << MV_XLG_MAC_CTRL0_MIBCNTDIS_OFFS)
   1072 
   1073 #define MV_XLG_MAC_CTRL0_PFC_CASCADE_PORT_ENABLE_OFFS    15
   1074 #define MV_XLG_MAC_CTRL0_PFC_CASCADE_PORT_ENABLE_MASK    \
   1075     (0x00000001 << MV_XLG_MAC_CTRL0_PFC_CASCADE_PORT_ENABLE_OFFS)
   1076 
   1077 /* Port Mac Control1 */
   1078 #define MV_XLG_PORT_MAC_CTRL1_REG                         (0x0004)
   1079 #define MV_XLG_MAC_CTRL1_FRAMESIZELIMIT_OFFS    0
   1080 #define MV_XLG_MAC_CTRL1_FRAMESIZELIMIT_MASK    \
   1081     (0x00001fff << MV_XLG_MAC_CTRL1_FRAMESIZELIMIT_OFFS)
   1082 
   1083 #define MV_XLG_MAC_CTRL1_MACLOOPBACKEN_OFFS    13
   1084 #define MV_XLG_MAC_CTRL1_MACLOOPBACKEN_MASK    \
   1085     (0x00000001 << MV_XLG_MAC_CTRL1_MACLOOPBACKEN_OFFS)
   1086 
   1087 #define MV_XLG_MAC_CTRL1_XGMIILOOPBACKEN_OFFS    14
   1088 #define MV_XLG_MAC_CTRL1_XGMIILOOPBACKEN_MASK    \
   1089     (0x00000001 << MV_XLG_MAC_CTRL1_XGMIILOOPBACKEN_OFFS)
   1090 
   1091 #define MV_XLG_MAC_CTRL1_LOOPBACKCLOCKSELECT_OFFS    15
   1092 #define MV_XLG_MAC_CTRL1_LOOPBACKCLOCKSELECT_MASK    \
   1093     (0x00000001 << MV_XLG_MAC_CTRL1_LOOPBACKCLOCKSELECT_OFFS)
   1094 
   1095 /* Port Mac Control2 */
   1096 #define MV_XLG_PORT_MAC_CTRL2_REG                         (0x0008)
   1097 #define MV_XLG_MAC_CTRL2_SALOW_7_0_OFFS    0
   1098 #define MV_XLG_MAC_CTRL2_SALOW_7_0_MASK    \
   1099     (0x000000ff << MV_XLG_MAC_CTRL2_SALOW_7_0_OFFS)
   1100 
   1101 #define MV_XLG_MAC_CTRL2_UNIDIRECTIONALEN_OFFS    8
   1102 #define MV_XLG_MAC_CTRL2_UNIDIRECTIONALEN_MASK    \
   1103     (0x00000001 << MV_XLG_MAC_CTRL2_UNIDIRECTIONALEN_OFFS)
   1104 
   1105 #define MV_XLG_MAC_CTRL2_FIXEDIPGBASE_OFFS    9
   1106 #define MV_XLG_MAC_CTRL2_FIXEDIPGBASE_MASK    \
   1107     (0x00000001 << MV_XLG_MAC_CTRL2_FIXEDIPGBASE_OFFS)
   1108 
   1109 #define MV_XLG_MAC_CTRL2_PERIODICXOFFEN_OFFS    10
   1110 #define MV_XLG_MAC_CTRL2_PERIODICXOFFEN_MASK    \
   1111     (0x00000001 << MV_XLG_MAC_CTRL2_PERIODICXOFFEN_OFFS)
   1112 
   1113 #define MV_XLG_MAC_CTRL2_SIMPLEXMODEEN_OFFS    13
   1114 #define MV_XLG_MAC_CTRL2_SIMPLEXMODEEN_MASK    \
   1115     (0x00000001 << MV_XLG_MAC_CTRL2_SIMPLEXMODEEN_OFFS)
   1116 
   1117 #define MV_XLG_MAC_CTRL2_FC_MODE_OFFS    14
   1118 #define MV_XLG_MAC_CTRL2_FC_MODE_MASK    \
   1119     (0x00000003 << MV_XLG_MAC_CTRL2_FC_MODE_OFFS)
   1120 
   1121 /* Port Status */
   1122 #define MV_XLG_MAC_PORT_STATUS_REG                        (0x000c)
   1123 #define MV_XLG_MAC_PORT_STATUS_LINKSTATUS_OFFS    0
   1124 #define MV_XLG_MAC_PORT_STATUS_LINKSTATUS_MASK    \
   1125     (0x00000001 << MV_XLG_MAC_PORT_STATUS_LINKSTATUS_OFFS)
   1126 
   1127 #define MV_XLG_MAC_PORT_STATUS_REMOTEFAULT_OFFS    1
   1128 #define MV_XLG_MAC_PORT_STATUS_REMOTEFAULT_MASK    \
   1129     (0x00000001 << MV_XLG_MAC_PORT_STATUS_REMOTEFAULT_OFFS)
   1130 
   1131 #define MV_XLG_MAC_PORT_STATUS_LOCALFAULT_OFFS    2
   1132 #define MV_XLG_MAC_PORT_STATUS_LOCALFAULT_MASK    \
   1133     (0x00000001 << MV_XLG_MAC_PORT_STATUS_LOCALFAULT_OFFS)
   1134 
   1135 #define MV_XLG_MAC_PORT_STATUS_LINKSTATUSCLEAN_OFFS    3
   1136 #define MV_XLG_MAC_PORT_STATUS_LINKSTATUSCLEAN_MASK    \
   1137     (0x00000001 << MV_XLG_MAC_PORT_STATUS_LINKSTATUSCLEAN_OFFS)
   1138 
   1139 #define MV_XLG_MAC_PORT_STATUS_LOCALFAULTCLEAN_OFFS    4
   1140 #define MV_XLG_MAC_PORT_STATUS_LOCALFAULTCLEAN_MASK    \
   1141     (0x00000001 << MV_XLG_MAC_PORT_STATUS_LOCALFAULTCLEAN_OFFS)
   1142 
   1143 #define MV_XLG_MAC_PORT_STATUS_REMOTEFAULTCLEAN_OFFS    5
   1144 #define MV_XLG_MAC_PORT_STATUS_REMOTEFAULTCLEAN_MASK    \
   1145     (0x00000001 << MV_XLG_MAC_PORT_STATUS_REMOTEFAULTCLEAN_OFFS)
   1146 
   1147 #define MV_XLG_MAC_PORT_STATUS_PORTRXPAUSE_OFFS    6
   1148 #define MV_XLG_MAC_PORT_STATUS_PORTRXPAUSE_MASK    \
   1149     (0x00000001 << MV_XLG_MAC_PORT_STATUS_PORTRXPAUSE_OFFS)
   1150 
   1151 #define MV_XLG_MAC_PORT_STATUS_PORTTXPAUSE_OFFS    7
   1152 #define MV_XLG_MAC_PORT_STATUS_PORTTXPAUSE_MASK    \
   1153     (0x00000001 << MV_XLG_MAC_PORT_STATUS_PORTTXPAUSE_OFFS)
   1154 
   1155 #define MV_XLG_MAC_PORT_STATUS_PFC_SYNC_FIFO_FULL_OFFS    8
   1156 #define MV_XLG_MAC_PORT_STATUS_PFC_SYNC_FIFO_FULL_MASK    \
   1157     (0x00000001 << MV_XLG_MAC_PORT_STATUS_PFC_SYNC_FIFO_FULL_OFFS)
   1158 
   1159 /* Port Fifos Thresholds Configuration */
   1160 #define MV_XLG_PORT_FIFOS_THRS_CFG_REG                    (0x001)
   1161 #define MV_XLG_MAC_PORT_FIFOS_THRS_CFG_RXFULLTHR_OFFS    0
   1162 #define MV_XLG_MAC_PORT_FIFOS_THRS_CFG_RXFULLTHR_MASK    \
   1163     (0x0000001f << MV_XLG_MAC_PORT_FIFOS_THRS_CFG_RXFULLTHR_OFFS)
   1164 
   1165 #define MV_XLG_MAC_PORT_FIFOS_THRS_CFG_TXFIFOSIZE_OFFS    5
   1166 #define MV_XLG_MAC_PORT_FIFOS_THRS_CFG_TXFIFOSIZE_MASK    \
   1167     (0x0000003f << MV_XLG_MAC_PORT_FIFOS_THRS_CFG_TXFIFOSIZE_OFFS)
   1168 
   1169 #define MV_XLG_MAC_PORT_FIFOS_THRS_CFG_TXRDTHR_OFFS    11
   1170 #define MV_XLG_MAC_PORT_FIFOS_THRS_CFG_TXRDTHR_MASK    \
   1171     (0x0000001f << MV_XLG_MAC_PORT_FIFOS_THRS_CFG_TXRDTHR_OFFS)
   1172 
   1173 /* Port Mac Control3 */
   1174 #define MV_XLG_PORT_MAC_CTRL3_REG                         (0x001c)
   1175 #define MV_XLG_MAC_CTRL3_BUFSIZE_OFFS    0
   1176 #define MV_XLG_MAC_CTRL3_BUFSIZE_MASK    \
   1177     (0x0000003f << MV_XLG_MAC_CTRL3_BUFSIZE_OFFS)
   1178 
   1179 #define MV_XLG_MAC_CTRL3_XTRAIPG_OFFS    6
   1180 #define MV_XLG_MAC_CTRL3_XTRAIPG_MASK    \
   1181     (0x0000007f << MV_XLG_MAC_CTRL3_XTRAIPG_OFFS)
   1182 
   1183 #define MV_XLG_MAC_CTRL3_MACMODESELECT_OFFS    13
   1184 #define MV_XLG_MAC_CTRL3_MACMODESELECT_MASK    \
   1185     (0x00000007 << MV_XLG_MAC_CTRL3_MACMODESELECT_OFFS)
   1186 
   1187 /* Port Per Prio Flow Control Status */
   1188 #define MV_XLG_PORT_PER_PRIO_FLOW_CTRL_STATUS_REG         (0x0020)
   1189 #define MV_XLG_MAC_PORT_PER_PRIO_FLOW_CTRL_STATUS_PRIONSTATUS_OFFS    0
   1190 #define MV_XLG_MAC_PORT_PER_PRIO_FLOW_CTRL_STATUS_PRIONSTATUS_MASK    \
   1191     (0x00000001 << MV_XLG_MAC_PORT_PER_PRIO_FLOW_CTRL_STATUS_PRIONSTATUS_OFFS)
   1192 
   1193 /* Debug Bus Status */
   1194 #define MV_XLG_DEBUG_BUS_STATUS_REG                       (0x0024)
   1195 #define MV_XLG_MAC_DEBUG_BUS_STATUS_DEBUG_BUS_OFFS    0
   1196 #define MV_XLG_MAC_DEBUG_BUS_STATUS_DEBUG_BUS_MASK    \
   1197     (0x0000ffff << MV_XLG_MAC_DEBUG_BUS_STATUS_DEBUG_BUS_OFFS)
   1198 
   1199 /* Port Metal Fix */
   1200 #define MV_XLG_PORT_METAL_FIX_REG                         (0x002c)
   1201 #define MV_XLG_MAC_PORT_METAL_FIX_EN_EOP_IN_FIFO__OFFS    0
   1202 #define MV_XLG_MAC_PORT_METAL_FIX_EN_EOP_IN_FIFO__MASK    \
   1203     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_EOP_IN_FIFO__OFFS)
   1204 
   1205 #define MV_XLG_MAC_PORT_METAL_FIX_EN_LTF_FIX__OFFS    1
   1206 #define MV_XLG_MAC_PORT_METAL_FIX_EN_LTF_FIX__MASK    \
   1207     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_LTF_FIX__OFFS)
   1208 
   1209 #define MV_XLG_MAC_PORT_METAL_FIX_EN_HOLD_FIX__OFFS    2
   1210 #define MV_XLG_MAC_PORT_METAL_FIX_EN_HOLD_FIX__MASK    \
   1211     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_HOLD_FIX__OFFS)
   1212 
   1213 #define MV_XLG_MAC_PORT_METAL_FIX_EN_LED_FIX__OFFS    3
   1214 #define MV_XLG_MAC_PORT_METAL_FIX_EN_LED_FIX__MASK    \
   1215     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_LED_FIX__OFFS)
   1216 
   1217 #define MV_XLG_MAC_PORT_METAL_FIX_EN_PAD_PROTECT__OFFS    4
   1218 #define MV_XLG_MAC_PORT_METAL_FIX_EN_PAD_PROTECT__MASK    \
   1219     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_PAD_PROTECT__OFFS)
   1220 
   1221 #define MV_XLG_MAC_PORT_METAL_FIX_EN_NX_BTS44__OFFS    5
   1222 #define MV_XLG_MAC_PORT_METAL_FIX_EN_NX_BTS44__MASK    \
   1223     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_NX_BTS44__OFFS)
   1224 
   1225 #define MV_XLG_MAC_PORT_METAL_FIX_EN_NX_BTS42__OFFS    6
   1226 #define MV_XLG_MAC_PORT_METAL_FIX_EN_NX_BTS42__MASK    \
   1227     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_NX_BTS42__OFFS)
   1228 
   1229 #define MV_XLG_MAC_PORT_METAL_FIX_EN_FLUSH_FIX_OFFS    7
   1230 #define MV_XLG_MAC_PORT_METAL_FIX_EN_FLUSH_FIX_MASK    \
   1231     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_FLUSH_FIX_OFFS)
   1232 
   1233 #define MV_XLG_MAC_PORT_METAL_FIX_EN_PORT_EN_FIX_OFFS    8
   1234 #define MV_XLG_MAC_PORT_METAL_FIX_EN_PORT_EN_FIX_MASK    \
   1235     (0x00000001 << MV_XLG_MAC_PORT_METAL_FIX_EN_PORT_EN_FIX_OFFS)
   1236 
   1237 #define MV_XLG_MAC_PORT_METAL_FIX_SPARE_DEF0_BITS_OFFS    9
   1238 #define MV_XLG_MAC_PORT_METAL_FIX_SPARE_DEF0_BITS_MASK    \
   1239     (0x0000000f << MV_XLG_MAC_PORT_METAL_FIX_SPARE_DEF0_BITS_OFFS)
   1240 
   1241 #define MV_XLG_MAC_PORT_METAL_FIX_SPARE_DEF1_BITS_OFFS    13
   1242 #define MV_XLG_MAC_PORT_METAL_FIX_SPARE_DEF1_BITS_MASK    \
   1243     (0x00000007 << MV_XLG_MAC_PORT_METAL_FIX_SPARE_DEF1_BITS_OFFS)
   1244 
   1245 /* Xg Mib Counters Control */
   1246 #define MV_XLG_MIB_CNTRS_CTRL_REG                         (0x0030)
   1247 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGCAPTURETRIGGER_OFFS    0
   1248 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGCAPTURETRIGGER_MASK    \
   1249     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGCAPTURETRIGGER_OFFS)
   1250 
   1251 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGDONTCLEARAFTERREAD_OFFS    1
   1252 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGDONTCLEARAFTERREAD_MASK    \
   1253     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGDONTCLEARAFTERREAD_OFFS)
   1254 
   1255 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGRXHISTOGRAMEN_OFFS    2
   1256 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGRXHISTOGRAMEN_MASK    \
   1257     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGRXHISTOGRAMEN_OFFS)
   1258 
   1259 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGTXHISTOGRAMEN_OFFS    3
   1260 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGTXHISTOGRAMEN_MASK    \
   1261     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_XGTXHISTOGRAMEN_OFFS)
   1262 
   1263 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MFA1_BTT940_FIX_ENABLE__OFFS    4
   1264 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MFA1_BTT940_FIX_ENABLE__MASK    \
   1265     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MFA1_BTT940_FIX_ENABLE__OFFS)
   1266 
   1267 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_LEDS_NUMBER_OFFS    5
   1268 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_LEDS_NUMBER_MASK    \
   1269     (0x0000003f << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_LEDS_NUMBER_OFFS)
   1270 
   1271 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MIB_4_COUNT_HIST_OFFS    11
   1272 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MIB_4_COUNT_HIST_MASK    \
   1273     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MIB_4_COUNT_HIST_OFFS)
   1274 
   1275 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MIB_4_LIMIT_1518_1522_OFFS    12
   1276 #define MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MIB_4_LIMIT_1518_1522_MASK    \
   1277     (0x00000001 << MV_XLG_MAC_XG_MIB_CNTRS_CTRL_MIB_4_LIMIT_1518_1522_OFFS)
   1278 
   1279 /* Cn/ccfc Timer%i */
   1280 #define MV_XLG_CNCCFC_TIMERI_REG(t)                       ((0x0038 + (t) * 4))
   1281 #define MV_XLG_MAC_CNCCFC_TIMERI_PORTSPEEDTIMER_OFFS    0
   1282 #define MV_XLG_MAC_CNCCFC_TIMERI_PORTSPEEDTIMER_MASK    \
   1283     (0x0000ffff << MV_XLG_MAC_CNCCFC_TIMERI_PORTSPEEDTIMER_OFFS)
   1284 
   1285 /* Ppfc Control */
   1286 #define MV_XLG_MAC_PPFC_CTRL_REG                          (0x0060)
   1287 #define MV_XLG_MAC_PPFC_CTRL_GLOBAL_PAUSE_ENI_OFFS    0
   1288 #define MV_XLG_MAC_PPFC_CTRL_GLOBAL_PAUSE_ENI_MASK    \
   1289     (0x00000001 << MV_XLG_MAC_PPFC_CTRL_GLOBAL_PAUSE_ENI_OFFS)
   1290 
   1291 #define MV_XLG_MAC_PPFC_CTRL_DIP_BTS_677_EN_OFFS    9
   1292 #define MV_XLG_MAC_PPFC_CTRL_DIP_BTS_677_EN_MASK    \
   1293     (0x00000001 << MV_XLG_MAC_PPFC_CTRL_DIP_BTS_677_EN_OFFS)
   1294 
   1295 /* Fc Dsa Tag 0 */
   1296 #define MV_XLG_MAC_FC_DSA_TAG_0_REG                       (0x0068)
   1297 #define MV_XLG_MAC_FC_DSA_TAG_0_DSATAGREG0_OFFS    0
   1298 #define MV_XLG_MAC_FC_DSA_TAG_0_DSATAGREG0_MASK    \
   1299     (0x0000ffff << MV_XLG_MAC_FC_DSA_TAG_0_DSATAGREG0_OFFS)
   1300 
   1301 /* Fc Dsa Tag 1 */
   1302 #define MV_XLG_MAC_FC_DSA_TAG_1_REG                       (0x006c)
   1303 #define MV_XLG_MAC_FC_DSA_TAG_1_DSATAGREG1_OFFS    0
   1304 #define MV_XLG_MAC_FC_DSA_TAG_1_DSATAGREG1_MASK    \
   1305     (0x0000ffff << MV_XLG_MAC_FC_DSA_TAG_1_DSATAGREG1_OFFS)
   1306 
   1307 /* Fc Dsa Tag 2 */
   1308 #define MV_XLG_MAC_FC_DSA_TAG_2_REG                       (0x0070)
   1309 #define MV_XLG_MAC_FC_DSA_TAG_2_DSATAGREG2_OFFS    0
   1310 #define MV_XLG_MAC_FC_DSA_TAG_2_DSATAGREG2_MASK    \
   1311     (0x0000ffff << MV_XLG_MAC_FC_DSA_TAG_2_DSATAGREG2_OFFS)
   1312 
   1313 /* Fc Dsa Tag 3 */
   1314 #define MV_XLG_MAC_FC_DSA_TAG_3_REG                       (0x0074)
   1315 #define MV_XLG_MAC_FC_DSA_TAG_3_DSATAGREG3_OFFS    0
   1316 #define MV_XLG_MAC_FC_DSA_TAG_3_DSATAGREG3_MASK    \
   1317     (0x0000ffff << MV_XLG_MAC_FC_DSA_TAG_3_DSATAGREG3_OFFS)
   1318 
   1319 /* Dic Budget Compensation */
   1320 #define MV_XLG_MAC_DIC_BUDGET_COMPENSATION_REG            (0x0080)
   1321 #define MV_XLG_MAC_DIC_BUDGET_COMPENSATION_DIC_COUNTER_TO_ADD_8BYTES_OFFS    0
   1322 #define MV_XLG_MAC_DIC_BUDGET_COMPENSATION_DIC_COUNTER_TO_ADD_8BYTES_MASK    \
   1323     (0x0000ffff << MV_XLG_MAC_DIC_BUDGET_COMPENSATION_DIC_COUNTER_TO_ADD_8BYTES_OFFS)
   1324 
   1325 /* Port Mac Control4 */
   1326 #define MV_XLG_PORT_MAC_CTRL4_REG                         (0x0084)
   1327 #define MV_XLG_MAC_CTRL4_LLFC_GLOBAL_FC_ENABLE_OFFS    0
   1328 #define MV_XLG_MAC_CTRL4_LLFC_GLOBAL_FC_ENABLE_MASK    \
   1329     (0x00000001 << MV_XLG_MAC_CTRL4_LLFC_GLOBAL_FC_ENABLE_OFFS)
   1330 
   1331 #define MV_XLG_MAC_CTRL4_LED_STREAM_SELECT_OFFS    1
   1332 #define MV_XLG_MAC_CTRL4_LED_STREAM_SELECT_MASK    \
   1333     (0x00000001 << MV_XLG_MAC_CTRL4_LED_STREAM_SELECT_OFFS)
   1334 
   1335 #define MV_XLG_MAC_CTRL4_DEBUG_BUS_SELECT_OFFS    2
   1336 #define MV_XLG_MAC_CTRL4_DEBUG_BUS_SELECT_MASK    \
   1337     (0x00000001 << MV_XLG_MAC_CTRL4_DEBUG_BUS_SELECT_OFFS)
   1338 
   1339 #define MV_XLG_MAC_CTRL4_MASK_PCS_RESET_OFFS    3
   1340 #define MV_XLG_MAC_CTRL4_MASK_PCS_RESET_MASK    \
   1341     (0x00000001 << MV_XLG_MAC_CTRL4_MASK_PCS_RESET_OFFS)
   1342 
   1343 #define MV_XLG_MAC_CTRL4_ENABLE_SHORT_PREAMBLE_FOR_XLG_OFFS    4
   1344 #define MV_XLG_MAC_CTRL4_ENABLE_SHORT_PREAMBLE_FOR_XLG_MASK    \
   1345     (0x00000001 << MV_XLG_MAC_CTRL4_ENABLE_SHORT_PREAMBLE_FOR_XLG_OFFS)
   1346 
   1347 #define MV_XLG_MAC_CTRL4_FORWARD_802_3X_FC_EN_OFFS    5
   1348 #define MV_XLG_MAC_CTRL4_FORWARD_802_3X_FC_EN_MASK    \
   1349     (0x00000001 << MV_XLG_MAC_CTRL4_FORWARD_802_3X_FC_EN_OFFS)
   1350 
   1351 #define MV_XLG_MAC_CTRL4_FORWARD_PFC_EN_OFFS    6
   1352 #define MV_XLG_MAC_CTRL4_FORWARD_PFC_EN_MASK    \
   1353     (0x00000001 << MV_XLG_MAC_CTRL4_FORWARD_PFC_EN_OFFS)
   1354 
   1355 #define MV_XLG_MAC_CTRL4_FORWARD_UNKNOWN_FC_EN_OFFS    7
   1356 #define MV_XLG_MAC_CTRL4_FORWARD_UNKNOWN_FC_EN_MASK    \
   1357     (0x00000001 << MV_XLG_MAC_CTRL4_FORWARD_UNKNOWN_FC_EN_OFFS)
   1358 
   1359 #define MV_XLG_MAC_CTRL4_USE_XPCS_OFFS    8
   1360 #define MV_XLG_MAC_CTRL4_USE_XPCS_MASK    \
   1361     (0x00000001 << MV_XLG_MAC_CTRL4_USE_XPCS_OFFS)
   1362 
   1363 #define MV_XLG_MAC_CTRL4_DMA_INTERFACE_IS_64_BIT_OFFS    9
   1364 #define MV_XLG_MAC_CTRL4_DMA_INTERFACE_IS_64_BIT_MASK    \
   1365     (0x00000001 << MV_XLG_MAC_CTRL4_DMA_INTERFACE_IS_64_BIT_OFFS)
   1366 
   1367 #define MV_XLG_MAC_CTRL4_TX_DMA_INTERFACE_BITS_OFFS    10
   1368 #define MV_XLG_MAC_CTRL4_TX_DMA_INTERFACE_BITS_MASK    \
   1369     (0x00000003 << MV_XLG_MAC_CTRL4_TX_DMA_INTERFACE_BITS_OFFS)
   1370 
   1371 #define MV_XLG_MAC_CTRL4_MAC_MODE_DMA_1G_OFFS    12
   1372 #define MV_XLG_MAC_CTRL4_MAC_MODE_DMA_1G_MASK    \
   1373     (0x00000001 << MV_XLG_MAC_CTRL4_MAC_MODE_DMA_1G_OFFS)
   1374 
   1375 /* Port Mac Control5 */
   1376 #define MV_XLG_PORT_MAC_CTRL5_REG                         (0x0088)
   1377 #define MV_XLG_MAC_CTRL5_TXIPGLENGTH_OFFS    0
   1378 #define MV_XLG_MAC_CTRL5_TXIPGLENGTH_MASK    \
   1379     (0x0000000f << MV_XLG_MAC_CTRL5_TXIPGLENGTH_OFFS)
   1380 
   1381 #define MV_XLG_MAC_CTRL5_PREAMBLELENGTHTX_OFFS    4
   1382 #define MV_XLG_MAC_CTRL5_PREAMBLELENGTHTX_MASK    \
   1383     (0x00000007 << MV_XLG_MAC_CTRL5_PREAMBLELENGTHTX_OFFS)
   1384 
   1385 #define MV_XLG_MAC_CTRL5_PREAMBLELENGTHRX_OFFS    7
   1386 #define MV_XLG_MAC_CTRL5_PREAMBLELENGTHRX_MASK    \
   1387     (0x00000007 << MV_XLG_MAC_CTRL5_PREAMBLELENGTHRX_OFFS)
   1388 
   1389 #define MV_XLG_MAC_CTRL5_TXNUMCRCBYTES_OFFS    10
   1390 #define MV_XLG_MAC_CTRL5_TXNUMCRCBYTES_MASK    \
   1391     (0x00000007 << MV_XLG_MAC_CTRL5_TXNUMCRCBYTES_OFFS)
   1392 
   1393 #define MV_XLG_MAC_CTRL5_RXNUMCRCBYTES_OFFS    13
   1394 #define MV_XLG_MAC_CTRL5_RXNUMCRCBYTES_MASK    \
   1395     (0x00000007 << MV_XLG_MAC_CTRL5_RXNUMCRCBYTES_OFFS)
   1396 
   1397 /* External Control */
   1398 #define MV_XLG_MAC_EXT_CTRL_REG                           (0x0090)
   1399 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL0_OFFS    0
   1400 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL0_MASK    \
   1401     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL0_OFFS)
   1402 
   1403 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL1_OFFS    1
   1404 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL1_MASK    \
   1405     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL1_OFFS)
   1406 
   1407 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL2_OFFS    2
   1408 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL2_MASK    \
   1409     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL2_OFFS)
   1410 
   1411 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL3_OFFS    3
   1412 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL3_MASK    \
   1413     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL3_OFFS)
   1414 
   1415 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL4_OFFS    4
   1416 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL4_MASK    \
   1417     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL4_OFFS)
   1418 
   1419 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL5_OFFS    5
   1420 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL5_MASK    \
   1421     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL5_OFFS)
   1422 
   1423 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL6_OFFS    6
   1424 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL6_MASK    \
   1425     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL6_OFFS)
   1426 
   1427 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL7_OFFS    7
   1428 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL7_MASK    \
   1429     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL7_OFFS)
   1430 
   1431 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL8_OFFS    8
   1432 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL8_MASK    \
   1433     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL8_OFFS)
   1434 
   1435 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL9_OFFS    9
   1436 #define MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL9_MASK    \
   1437     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXTERNAL_CTRL9_OFFS)
   1438 
   1439 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_10_OFFS    10
   1440 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_10_MASK    \
   1441     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXT_CTRL_10_OFFS)
   1442 
   1443 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_11_OFFS    11
   1444 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_11_MASK    \
   1445     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXT_CTRL_11_OFFS)
   1446 
   1447 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_12_OFFS    12
   1448 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_12_MASK    \
   1449     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXT_CTRL_12_OFFS)
   1450 
   1451 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_13_OFFS    13
   1452 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_13_MASK    \
   1453     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXT_CTRL_13_OFFS)
   1454 
   1455 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_14_OFFS    14
   1456 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_14_MASK    \
   1457     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXT_CTRL_14_OFFS)
   1458 
   1459 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_15_OFFS    15
   1460 #define MV_XLG_MAC_EXT_CTRL_EXT_CTRL_15_MASK    \
   1461     (0x00000001 << MV_XLG_MAC_EXT_CTRL_EXT_CTRL_15_OFFS)
   1462 
   1463 /* Macro Control */
   1464 #define MV_XLG_MAC_MACRO_CTRL_REG                         (0x0094)
   1465 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_0_OFFS    0
   1466 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_0_MASK    \
   1467     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_0_OFFS)
   1468 
   1469 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_1_OFFS    1
   1470 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_1_MASK    \
   1471     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_1_OFFS)
   1472 
   1473 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_2_OFFS    2
   1474 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_2_MASK    \
   1475     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_2_OFFS)
   1476 
   1477 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_3_OFFS    3
   1478 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_3_MASK    \
   1479     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_3_OFFS)
   1480 
   1481 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_4_OFFS    4
   1482 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_4_MASK    \
   1483     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_4_OFFS)
   1484 
   1485 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_5_OFFS    5
   1486 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_5_MASK    \
   1487     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_5_OFFS)
   1488 
   1489 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_6_OFFS    6
   1490 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_6_MASK    \
   1491     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_6_OFFS)
   1492 
   1493 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_7_OFFS    7
   1494 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_7_MASK    \
   1495     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_7_OFFS)
   1496 
   1497 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_8_OFFS    8
   1498 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_8_MASK    \
   1499     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_8_OFFS)
   1500 
   1501 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_9_OFFS    9
   1502 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_9_MASK    \
   1503     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_9_OFFS)
   1504 
   1505 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_10_OFFS    10
   1506 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_10_MASK    \
   1507     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_10_OFFS)
   1508 
   1509 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_11_OFFS    11
   1510 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_11_MASK    \
   1511     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_11_OFFS)
   1512 
   1513 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_12_OFFS    12
   1514 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_12_MASK    \
   1515     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_12_OFFS)
   1516 
   1517 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_13_OFFS    13
   1518 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_13_MASK    \
   1519     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_13_OFFS)
   1520 
   1521 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_14_OFFS    14
   1522 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_14_MASK    \
   1523     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_14_OFFS)
   1524 
   1525 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_15_OFFS    15
   1526 #define MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_15_MASK    \
   1527     (0x00000001 << MV_XLG_MAC_MACRO_CTRL_MACRO_CTRL_15_OFFS)
   1528 
   1529 #define MV_XLG_MAC_DIC_PPM_IPG_REDUCE_REG                 (0x0094)
   1530 
   1531 /* Port Interrupt Cause */
   1532 #define MV_XLG_INTERRUPT_CAUSE_REG                        (0x0014)
   1533 /* Port Interrupt Mask */
   1534 #define MV_XLG_INTERRUPT_MASK_REG                         (0x0018)
   1535 #define MV_XLG_INTERRUPT_LINK_CHANGE_OFFS    1
   1536 #define MV_XLG_INTERRUPT_LINK_CHANGE_MASK    \
   1537     (0x1 << MV_XLG_INTERRUPT_LINK_CHANGE_OFFS)
   1538 
   1539 /* Port Interrupt Summary Cause */
   1540 #define MV_XLG_EXTERNAL_INTERRUPT_CAUSE_REG               (0x0058)
   1541 /* Port Interrupt Summary Mask */
   1542 #define MV_XLG_EXTERNAL_INTERRUPT_MASK_REG                (0x005C)
   1543 #define MV_XLG_EXTERNAL_INTERRUPT_LINK_CHANGE_OFFS    1
   1544 #define MV_XLG_EXTERNAL_INTERRUPT_LINK_CHANGE_MASK    \
   1545     (0x1 << MV_XLG_EXTERNAL_INTERRUPT_LINK_CHANGE_OFFS)
   1546 
   1547 /*All PPV22 Addresses are 40-bit */
   1548 #define MVPP22_ADDR_HIGH_SIZE    8
   1549 #define MVPP22_ADDR_HIGH_MASK    ((1<<MVPP22_ADDR_HIGH_SIZE) - 1)
   1550 #define MVPP22_ADDR_MASK    (0xFFFFFFFFFF)
   1551 
   1552 /* Desc addr shift */
   1553 #define MVPP21_DESC_ADDR_SHIFT    0 /*Applies to RXQ, AGGR_TXQ*/
   1554 #define MVPP22_DESC_ADDR_SHIFT    8 /*Applies to RXQ, AGGR_TXQ*/
   1555 
   1556 /* AXI Bridge Registers */
   1557 #define MVPP22_AXI_BM_WR_ATTR_REG                         0x4100
   1558 #define MVPP22_AXI_BM_RD_ATTR_REG                         0x4104
   1559 #define MVPP22_AXI_AGGRQ_DESCR_RD_ATTR_REG                0x4110
   1560 #define MVPP22_AXI_TXQ_DESCR_WR_ATTR_REG                  0x4114
   1561 #define MVPP22_AXI_TXQ_DESCR_RD_ATTR_REG                  0x4118
   1562 #define MVPP22_AXI_RXQ_DESCR_WR_ATTR_REG                  0x411c
   1563 #define MVPP22_AXI_RX_DATA_WR_ATTR_REG                    0x4120
   1564 #define MVPP22_AXI_TX_DATA_RD_ATTR_REG                    0x4130
   1565 #define MVPP22_AXI_RD_NORMAL_CODE_REG                     0x4150
   1566 #define MVPP22_AXI_RD_SNP_CODE_REG                        0x4154
   1567 #define MVPP22_AXI_WR_NORMAL_CODE_REG                     0x4160
   1568 #define MVPP22_AXI_WR_SNP_CODE_REG                        0x4164
   1569 
   1570 #define MVPP22_AXI_RD_CODE_MASK    0x33
   1571 #define MVPP22_AXI_WR_CODE_MASK    0x33
   1572 
   1573 #define MVPP22_AXI_ATTR_CACHE_OFFS    0
   1574 #define MVPP22_AXI_ATTR_CACHE_SIZE    4
   1575 #define MVPP22_AXI_ATTR_CACHE_MASK    0x0000000F
   1576 
   1577 #define MVPP22_AXI_ATTR_QOS_OFFS    4
   1578 #define MVPP22_AXI_ATTR_QOS_SIZE    4
   1579 #define MVPP22_AXI_ATTR_QOS_MASK    0x000000F0
   1580 
   1581 #define MVPP22_AXI_ATTR_TC_OFFS    8
   1582 #define MVPP22_AXI_ATTR_TC_SIZE    4
   1583 #define MVPP22_AXI_ATTR_TC_MASK    0x00000F00
   1584 
   1585 #define MVPP22_AXI_ATTR_DOMAIN_OFFS    12
   1586 #define MVPP22_AXI_ATTR_DOMAIN_SIZE    2
   1587 #define MVPP22_AXI_ATTR_DOMAIN_MASK    0x00003000
   1588 
   1589 #define MVPP22_AXI_ATTR_SNOOP_CNTRL_BIT    BIT(16)
   1590 
   1591 /* PHY address register */
   1592 #define MV_SMI_PHY_ADDRESS_REG(n)                         (0xC + 0x4 * (n))
   1593 #define MV_SMI_PHY_ADDRESS_PHYAD_OFFS    0
   1594 #define MV_SMI_PHY_ADDRESS_PHYAD_MASK    \
   1595   (0x1F << MV_SMI_PHY_ADDRESS_PHYAD_OFFS)
   1596 
   1597 /* Marvell tag types */
   1598 enum Mvpp2TagType {
   1599   MVPP2_TAG_TYPE_NONE = 0,
   1600   MVPP2_TAG_TYPE_MH   = 1,
   1601   MVPP2_TAG_TYPE_DSA  = 2,
   1602   MVPP2_TAG_TYPE_EDSA = 3,
   1603   MVPP2_TAG_TYPE_VLAN = 4,
   1604   MVPP2_TAG_TYPE_LAST = 5
   1605 };
   1606 
   1607 /* Parser constants */
   1608 #define MVPP2_PRS_TCAM_SRAM_SIZE    256
   1609 #define MVPP2_PRS_TCAM_WORDS    6
   1610 #define MVPP2_PRS_SRAM_WORDS    4
   1611 #define MVPP2_PRS_FLOW_ID_SIZE    64
   1612 #define MVPP2_PRS_FLOW_ID_MASK    0x3f
   1613 #define MVPP2_PRS_TCAM_ENTRY_INVALID    1
   1614 #define MVPP2_PRS_TCAM_DSA_TAGGED_BIT    BIT(5)
   1615 #define MVPP2_PRS_IPV4_HEAD    0x40
   1616 #define MVPP2_PRS_IPV4_HEAD_MASK    0xf0
   1617 #define MVPP2_PRS_IPV4_MC    0xe0
   1618 #define MVPP2_PRS_IPV4_MC_MASK    0xf0
   1619 #define MVPP2_PRS_IPV4_BC_MASK    0xff
   1620 #define MVPP2_PRS_IPV4_IHL    0x5
   1621 #define MVPP2_PRS_IPV4_IHL_MASK    0xf
   1622 #define MVPP2_PRS_IPV6_MC    0xff
   1623 #define MVPP2_PRS_IPV6_MC_MASK    0xff
   1624 #define MVPP2_PRS_IPV6_HOP_MASK    0xff
   1625 #define MVPP2_PRS_TCAM_PROTO_MASK    0xff
   1626 #define MVPP2_PRS_TCAM_PROTO_MASK_L    0x3f
   1627 #define MVPP2_PRS_DBL_VLANS_MAX    100
   1628 
   1629 /*
   1630  * Tcam structure:
   1631  * - lookup ID - 4 bits
   1632  * - port ID - 1 byte
   1633  * - additional information - 1 byte
   1634  * - header data - 8 bytes
   1635  * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(5)->(0).
   1636  */
   1637 #define MVPP2_PRS_AI_BITS    8
   1638 #define MVPP2_PRS_PORT_MASK    0xff
   1639 #define MVPP2_PRS_LU_MASK    0xf
   1640 #define MVPP2_PRS_TCAM_DATA_BYTE(offs)    (((offs) - ((offs) % 2)) * 2 + ((offs) % 2))
   1641 #define MVPP2_PRS_TCAM_DATA_BYTE_EN(offs)    (((offs) * 2) - ((offs) % 2)  + 2)
   1642 #define MVPP2_PRS_TCAM_AI_BYTE    16
   1643 #define MVPP2_PRS_TCAM_PORT_BYTE    17
   1644 #define MVPP2_PRS_TCAM_LU_BYTE    20
   1645 #define MVPP2_PRS_TCAM_EN_OFFS(offs)    ((offs) + 2)
   1646 #define MVPP2_PRS_TCAM_INV_WORD    5
   1647 /* Tcam entries ID */
   1648 #define MVPP2_PE_DROP_ALL    0
   1649 #define MVPP2_PE_FIRST_FREE_TID    1
   1650 #define MVPP2_PE_LAST_FREE_TID    (MVPP2_PRS_TCAM_SRAM_SIZE - 31)
   1651 #define MVPP2_PE_IP6_EXT_PROTO_UN    (MVPP2_PRS_TCAM_SRAM_SIZE - 30)
   1652 #define MVPP2_PE_MAC_MC_IP6    (MVPP2_PRS_TCAM_SRAM_SIZE - 29)
   1653 #define MVPP2_PE_IP6_ADDR_UN    (MVPP2_PRS_TCAM_SRAM_SIZE - 28)
   1654 #define MVPP2_PE_IP4_ADDR_UN    (MVPP2_PRS_TCAM_SRAM_SIZE - 27)
   1655 #define MVPP2_PE_LAST_DEFAULT_FLOW    (MVPP2_PRS_TCAM_SRAM_SIZE - 26)
   1656 #define MVPP2_PE_FIRST_DEFAULT_FLOW    (MVPP2_PRS_TCAM_SRAM_SIZE - 19)
   1657 #define MVPP2_PE_EDSA_TAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 18)
   1658 #define MVPP2_PE_EDSA_UNTAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 17)
   1659 #define MVPP2_PE_DSA_TAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 16)
   1660 #define MVPP2_PE_DSA_UNTAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 15)
   1661 #define MVPP2_PE_ETYPE_EDSA_TAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 14)
   1662 #define MVPP2_PE_ETYPE_EDSA_UNTAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 13)
   1663 #define MVPP2_PE_ETYPE_DSA_TAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 12)
   1664 #define MVPP2_PE_ETYPE_DSA_UNTAGGED    (MVPP2_PRS_TCAM_SRAM_SIZE - 11)
   1665 #define MVPP2_PE_MH_DEFAULT    (MVPP2_PRS_TCAM_SRAM_SIZE - 10)
   1666 #define MVPP2_PE_DSA_DEFAULT    (MVPP2_PRS_TCAM_SRAM_SIZE - 9)
   1667 #define MVPP2_PE_IP6_PROTO_UN    (MVPP2_PRS_TCAM_SRAM_SIZE - 8)
   1668 #define MVPP2_PE_IP4_PROTO_UN    (MVPP2_PRS_TCAM_SRAM_SIZE - 7)
   1669 #define MVPP2_PE_ETH_TYPE_UN    (MVPP2_PRS_TCAM_SRAM_SIZE - 6)
   1670 #define MVPP2_PE_VLAN_DBL    (MVPP2_PRS_TCAM_SRAM_SIZE - 5)
   1671 #define MVPP2_PE_VLAN_NONE    (MVPP2_PRS_TCAM_SRAM_SIZE - 4)
   1672 #define MVPP2_PE_MAC_MC_ALL    (MVPP2_PRS_TCAM_SRAM_SIZE - 3)
   1673 #define MVPP2_PE_MAC_PROMISCUOUS    (MVPP2_PRS_TCAM_SRAM_SIZE - 2)
   1674 #define MVPP2_PE_MAC_NON_PROMISCUOUS    (MVPP2_PRS_TCAM_SRAM_SIZE - 1)
   1675 
   1676 /*
   1677  * Sram structure
   1678  * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(3)->(0).
   1679  */
   1680 #define MVPP2_PRS_SRAM_RI_OFFS    0
   1681 #define MVPP2_PRS_SRAM_RI_WORD    0
   1682 #define MVPP2_PRS_SRAM_RI_CTRL_OFFS    32
   1683 #define MVPP2_PRS_SRAM_RI_CTRL_WORD    1
   1684 #define MVPP2_PRS_SRAM_RI_CTRL_BITS    32
   1685 #define MVPP2_PRS_SRAM_SHIFT_OFFS    64
   1686 #define MVPP2_PRS_SRAM_SHIFT_SIGN_BIT    72
   1687 #define MVPP2_PRS_SRAM_UDF_OFFS    73
   1688 #define MVPP2_PRS_SRAM_UDF_BITS    8
   1689 #define MVPP2_PRS_SRAM_UDF_MASK    0xff
   1690 #define MVPP2_PRS_SRAM_UDF_SIGN_BIT    81
   1691 #define MVPP2_PRS_SRAM_UDF_TYPE_OFFS    82
   1692 #define MVPP2_PRS_SRAM_UDF_TYPE_MASK    0x7
   1693 #define MVPP2_PRS_SRAM_UDF_TYPE_L3    1
   1694 #define MVPP2_PRS_SRAM_UDF_TYPE_L4    4
   1695 #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_OFFS    85
   1696 #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_MASK    0x3
   1697 #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_ADD    1
   1698 #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP4_ADD    2
   1699 #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP6_ADD    3
   1700 #define MVPP2_PRS_SRAM_OP_SEL_UDF_OFFS    87
   1701 #define MVPP2_PRS_SRAM_OP_SEL_UDF_BITS    2
   1702 #define MVPP2_PRS_SRAM_OP_SEL_UDF_MASK    0x3
   1703 #define MVPP2_PRS_SRAM_OP_SEL_UDF_ADD    0
   1704 #define MVPP2_PRS_SRAM_OP_SEL_UDF_IP4_ADD    2
   1705 #define MVPP2_PRS_SRAM_OP_SEL_UDF_IP6_ADD    3
   1706 #define MVPP2_PRS_SRAM_OP_SEL_BASE_OFFS    89
   1707 #define MVPP2_PRS_SRAM_AI_OFFS    90
   1708 #define MVPP2_PRS_SRAM_AI_CTRL_OFFS    98
   1709 #define MVPP2_PRS_SRAM_AI_CTRL_BITS    8
   1710 #define MVPP2_PRS_SRAM_AI_MASK    0xff
   1711 #define MVPP2_PRS_SRAM_NEXT_LU_OFFS    106
   1712 #define MVPP2_PRS_SRAM_NEXT_LU_MASK    0xf
   1713 #define MVPP2_PRS_SRAM_LU_DONE_BIT    110
   1714 #define MVPP2_PRS_SRAM_LU_GEN_BIT    111
   1715 
   1716 /* Sram result info bits assignment */
   1717 #define MVPP2_PRS_RI_MAC_ME_MASK    0x1
   1718 #define MVPP2_PRS_RI_DSA_MASK    0x2
   1719 #define MVPP2_PRS_RI_VLAN_MASK    0xc
   1720 #define MVPP2_PRS_RI_VLAN_NONE    ~(BIT(2) | BIT(3))
   1721 #define MVPP2_PRS_RI_VLAN_SINGLE    BIT(2)
   1722 #define MVPP2_PRS_RI_VLAN_DOUBLE    BIT(3)
   1723 #define MVPP2_PRS_RI_VLAN_TRIPLE    (BIT(2) | BIT(3))
   1724 #define MVPP2_PRS_RI_CPU_CODE_MASK    0x70
   1725 #define MVPP2_PRS_RI_CPU_CODE_RX_SPEC    BIT(4)
   1726 #define MVPP2_PRS_RI_L2_CAST_MASK    0x600
   1727 #define MVPP2_PRS_RI_L2_UCAST    ~(BIT(9) | BIT(10))
   1728 #define MVPP2_PRS_RI_L2_MCAST    BIT(9)
   1729 #define MVPP2_PRS_RI_L2_BCAST    BIT(10)
   1730 #define MVPP2_PRS_RI_PPPOE_MASK    0x800
   1731 #define MVPP2_PRS_RI_L3_PROTO_MASK    0x7000
   1732 #define MVPP2_PRS_RI_L3_UN    ~(BIT(12) | BIT(13) | BIT(14))
   1733 #define MVPP2_PRS_RI_L3_IP4    BIT(12)
   1734 #define MVPP2_PRS_RI_L3_IP4_OPT    BIT(13)
   1735 #define MVPP2_PRS_RI_L3_IP4_OTHER    (BIT(12) | BIT(13))
   1736 #define MVPP2_PRS_RI_L3_IP6    BIT(14)
   1737 #define MVPP2_PRS_RI_L3_IP6_EXT    (BIT(12) | BIT(14))
   1738 #define MVPP2_PRS_RI_L3_ARP    (BIT(13) | BIT(14))
   1739 #define MVPP2_PRS_RI_L3_ADDR_MASK    0x18000
   1740 #define MVPP2_PRS_RI_L3_UCAST    ~(BIT(15) | BIT(16))
   1741 #define MVPP2_PRS_RI_L3_MCAST    BIT(15)
   1742 #define MVPP2_PRS_RI_L3_BCAST    (BIT(15) | BIT(16))
   1743 #define MVPP2_PRS_RI_IP_FRAG_MASK    0x20000
   1744 #define MVPP2_PRS_RI_UDF3_MASK    0x300000
   1745 #define MVPP2_PRS_RI_UDF3_RX_SPECIAL    BIT(21)
   1746 #define MVPP2_PRS_RI_L4_PROTO_MASK    0x1c00000
   1747 #define MVPP2_PRS_RI_L4_TCP    BIT(22)
   1748 #define MVPP2_PRS_RI_L4_UDP    BIT(23)
   1749 #define MVPP2_PRS_RI_L4_OTHER    (BIT(22) | BIT(23))
   1750 #define MVPP2_PRS_RI_UDF7_MASK    0x60000000
   1751 #define MVPP2_PRS_RI_UDF7_IP6_LITE    BIT(29)
   1752 #define MVPP2_PRS_RI_DROP_MASK    0x80000000
   1753 
   1754 /* Sram additional info bits assignment */
   1755 #define MVPP2_PRS_IPV4_DIP_AI_BIT    BIT(0)
   1756 #define MVPP2_PRS_IPV6_NO_EXT_AI_BIT    BIT(0)
   1757 #define MVPP2_PRS_IPV6_EXT_AI_BIT    BIT(1)
   1758 #define MVPP2_PRS_IPV6_EXT_AH_AI_BIT    BIT(2)
   1759 #define MVPP2_PRS_IPV6_EXT_AH_LEN_AI_BIT    BIT(3)
   1760 #define MVPP2_PRS_IPV6_EXT_AH_L4_AI_BIT    BIT(4)
   1761 #define MVPP2_PRS_SINGLE_VLAN_AI    0
   1762 #define MVPP2_PRS_DBL_VLAN_AI_BIT    BIT(7)
   1763 
   1764 /* DSA/EDSA type */
   1765 #define MVPP2_PRS_TAGGED    TRUE
   1766 #define MVPP2_PRS_UNTAGGED    FALSE
   1767 #define MVPP2_PRS_EDSA    TRUE
   1768 #define MVPP2_PRS_DSA    FALSE
   1769 
   1770 /* MAC entries, shadow udf */
   1771 enum Mvpp2PrsUdf {
   1772   MVPP2_PRS_UDF_MAC_DEF,
   1773   MVPP2_PRS_UDF_MAC_RANGE,
   1774   MVPP2_PRS_UDF_L2_DEF,
   1775   MVPP2_PRS_UDF_L2_DEF_COPY,
   1776   MVPP2_PRS_UDF_L2_USER,
   1777 };
   1778 
   1779 /* Lookup ID */
   1780 enum Mvpp2PrsLookup {
   1781   MVPP2_PRS_LU_MH,
   1782   MVPP2_PRS_LU_MAC,
   1783   MVPP2_PRS_LU_DSA,
   1784   MVPP2_PRS_LU_VLAN,
   1785   MVPP2_PRS_LU_L2,
   1786   MVPP2_PRS_LU_PPPOE,
   1787   MVPP2_PRS_LU_IP4,
   1788   MVPP2_PRS_LU_IP6,
   1789   MVPP2_PRS_LU_FLOWS,
   1790   MVPP2_PRS_LU_LAST,
   1791 };
   1792 
   1793 /* L3 cast enum */
   1794 enum Mvpp2PrsL3Cast {
   1795   MVPP2_PRS_L3_UNI_CAST,
   1796   MVPP2_PRS_L3_MULTI_CAST,
   1797   MVPP2_PRS_L3_BROAD_CAST
   1798 };
   1799 
   1800 /* Classifier constants */
   1801 #define MVPP2_CLS_FLOWS_TBL_SIZE    512
   1802 #define MVPP2_CLS_FLOWS_TBL_DATA_WORDS    3
   1803 #define MVPP2_CLS_LKP_TBL_SIZE    64
   1804 
   1805 /* BM cookie (32 bits) definition */
   1806 #define MVPP2_BM_COOKIE_POOL_OFFS    8
   1807 #define MVPP2_BM_COOKIE_CPU_OFFS    24
   1808 
   1809 /*
   1810  * The MVPP2_TX_DESC and MVPP2_RX_DESC structures describe the
   1811  * layout of the transmit and reception DMA descriptors, and their
   1812  * layout is therefore defined by the hardware design
   1813  */
   1814 #define MVPP2_TXD_L3_OFF_SHIFT    0
   1815 #define MVPP2_TXD_IP_HLEN_SHIFT    8
   1816 #define MVPP2_TXD_L4_CSUM_FRAG    BIT(13)
   1817 #define MVPP2_TXD_L4_CSUM_NOT    BIT(14)
   1818 #define MVPP2_TXD_IP_CSUM_DISABLE    BIT(15)
   1819 #define MVPP2_TXD_PADDING_DISABLE    BIT(23)
   1820 #define MVPP2_TXD_L4_UDP    BIT(24)
   1821 #define MVPP2_TXD_L3_IP6    BIT(26)
   1822 #define MVPP2_TXD_L_DESC    BIT(28)
   1823 #define MVPP2_TXD_F_DESC    BIT(29)
   1824 
   1825 #define MVPP2_RXD_ERR_SUMMARY    BIT(15)
   1826 #define MVPP2_RXD_ERR_CODE_MASK    (BIT(13) | BIT(14))
   1827 #define MVPP2_RXD_ERR_CRC    0x0
   1828 #define MVPP2_RXD_ERR_OVERRUN    BIT(13)
   1829 #define MVPP2_RXD_ERR_RESOURCE    (BIT(13) | BIT(14))
   1830 #define MVPP2_RXD_BM_POOL_ID_OFFS    16
   1831 #define MVPP2_RXD_BM_POOL_ID_MASK    (BIT(16) | BIT(17) | BIT(18))
   1832 #define MVPP2_RXD_HWF_SYNC    BIT(21)
   1833 #define MVPP2_RXD_L4_CSUM_OK    BIT(22)
   1834 #define MVPP2_RXD_IP4_HEADER_ERR    BIT(24)
   1835 #define MVPP2_RXD_L4_TCP    BIT(25)
   1836 #define MVPP2_RXD_L4_UDP    BIT(26)
   1837 #define MVPP2_RXD_L3_IP4    BIT(28)
   1838 #define MVPP2_RXD_L3_IP6    BIT(30)
   1839 #define MVPP2_RXD_BUF_HDR    BIT(31)
   1840 
   1841 typedef struct {
   1842   UINT32 command;   /* Options used by HW for packet transmitting.*/
   1843   UINT8  PacketOffset; /* the offset from the buffer beginning */
   1844   UINT8  PhysTxq;    /* destination queue ID     */
   1845   UINT16 DataSize;   /* data size of transmitted packet in bytes */
   1846   UINT64 RsrvdHwCmd1; /* HwCmd (BM, PON, PNC) */
   1847   UINT64 BufPhysAddrHwCmd2;
   1848   UINT64 BufCookieBmQsetHwCmd3;
   1849 } MVPP2_TX_DESC;
   1850 
   1851 typedef struct {
   1852   UINT32 status;    /* info about received packet   */
   1853   UINT16 reserved1;   /* ParserInfo (for future use, PnC)  */
   1854   UINT16 DataSize;   /* size of received packet in bytes */
   1855   UINT16 RsrvdGem;   /* GemPortId (for future use, PON)  */
   1856   UINT16 RsrvdL4csum;  /* CsumL4 (for future use, PnC)  */
   1857   UINT32 RsrvdTimestamp;
   1858   UINT64 BufPhysAddrKeyHash;
   1859   UINT64 BufCookieBmQsetClsInfo;
   1860 } MVPP2_RX_DESC;
   1861 
   1862 union Mvpp2PrsTcamEntry {
   1863   UINT32 Word[MVPP2_PRS_TCAM_WORDS];
   1864   UINT8 Byte[MVPP2_PRS_TCAM_WORDS * 4];
   1865 };
   1866 
   1867 union Mvpp2PrsSramEntry {
   1868   UINT32 Word[MVPP2_PRS_SRAM_WORDS];
   1869   UINT8 Byte[MVPP2_PRS_SRAM_WORDS * 4];
   1870 };
   1871 
   1872 typedef struct {
   1873   UINT32 Index;
   1874   union Mvpp2PrsTcamEntry Tcam;
   1875   union Mvpp2PrsSramEntry Sram;
   1876 } MVPP2_PRS_ENTRY;
   1877 
   1878 typedef struct {
   1879   BOOLEAN Valid;
   1880   BOOLEAN Finish;
   1881 
   1882   /* Lookup ID */
   1883   INT32 Lu;
   1884 
   1885   /* User defined offset */
   1886   INT32 Udf;
   1887 
   1888   /* Result info */
   1889   UINT32 Ri;
   1890   UINT32 RiMask;
   1891 } MVPP2_PRS_SHADOW;
   1892 
   1893 typedef struct {
   1894   UINT32 Index;
   1895   UINT32 Data[MVPP2_CLS_FLOWS_TBL_DATA_WORDS];
   1896 } MVPP2_CLS_FLOW_ENTRY;
   1897 
   1898 typedef struct {
   1899   UINT32 Lkpid;
   1900   UINT32 Way;
   1901   UINT32 Data;
   1902 } MVPP2_CLS_LOOKUP_ENTRY;
   1903 
   1904 typedef struct {
   1905   UINT32 NextBuffPhysAddr;
   1906   UINT32 NextBuffVirtAddr;
   1907   UINT16 ByteCount;
   1908   UINT16 info;
   1909   UINT8  reserved1;   /* BmQset (for future use, BM)   */
   1910 } MVPP2_BUFF_HDR;
   1911 
   1912 /* Buffer header info bits */
   1913 #define MVPP2_B_HDR_INFO_MC_ID_MASK    0xfff
   1914 #define MVPP2_B_HDR_INFO_MC_ID(info)    ((info) & MVPP2_B_HDR_INFO_MC_ID_MASK)
   1915 #define MVPP2_B_HDR_INFO_LAST_OFFS    12
   1916 #define MVPP2_B_HDR_INFO_LAST_MASK    BIT(12)
   1917 #define MVPP2_B_HDR_INFO_IS_LAST(info)    ((info & MVPP2_B_HDR_INFO_LAST_MASK) >> MVPP2_B_HDR_INFO_LAST_OFFS)
   1918 
   1919 /* Net Complex */
   1920 enum MvNetcTopology {
   1921   MV_NETC_GE_MAC0_RXAUI_L23 = BIT(0),
   1922   MV_NETC_GE_MAC0_RXAUI_L45 = BIT(1),
   1923   MV_NETC_GE_MAC0_XAUI = BIT(2),
   1924   MV_NETC_GE_MAC2_SGMII = BIT(3),
   1925   MV_NETC_GE_MAC3_SGMII = BIT(4),
   1926   MV_NETC_GE_MAC3_RGMII = BIT(5),
   1927 };
   1928 
   1929 enum MvNetcPhase {
   1930   MV_NETC_FIRST_PHASE,
   1931   MV_NETC_SECOND_PHASE,
   1932 };
   1933 
   1934 enum MvNetcSgmiiXmiMode {
   1935   MV_NETC_GBE_SGMII,
   1936   MV_NETC_GBE_XMII,
   1937 };
   1938 
   1939 enum MvNetcMiiMode {
   1940   MV_NETC_GBE_RGMII,
   1941   MV_NETC_GBE_MII,
   1942 };
   1943 
   1944 enum MvNetcLanes {
   1945   MV_NETC_LANE_23,
   1946   MV_NETC_LANE_45,
   1947 };
   1948 
   1949 /* Port related */
   1950 enum MvReset {
   1951   RESET,
   1952   UNRESET
   1953 };
   1954 
   1955 enum Mvpp2Command {
   1956   MVPP2_START,    /* Start     */
   1957   MVPP2_STOP,    /* Stop     */
   1958   MVPP2_PAUSE,    /* Pause    */
   1959   MVPP2_RESTART    /* Restart  */
   1960 };
   1961 
   1962 enum MvPortDuplex {
   1963   MV_PORT_DUPLEX_AN,
   1964   MV_PORT_DUPLEX_HALF,
   1965   MV_PORT_DUPLEX_FULL
   1966 };
   1967 
   1968 #endif /* __MVPP2_LIB_HW__ */
   1969