18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Definitions for Marvell PPv2 network controller for Armada 375 SoC. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2014 Marvell 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Marcin Wojtas <mw@semihalf.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef _MVPP2_H_ 108c2ecf20Sopenharmony_ci#define _MVPP2_H_ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 138c2ecf20Sopenharmony_ci#include <linux/kernel.h> 148c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 158c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h> 168c2ecf20Sopenharmony_ci#include <linux/phy.h> 178c2ecf20Sopenharmony_ci#include <linux/phylink.h> 188c2ecf20Sopenharmony_ci#include <net/flow_offload.h> 198c2ecf20Sopenharmony_ci#include <net/page_pool.h> 208c2ecf20Sopenharmony_ci#include <linux/bpf.h> 218c2ecf20Sopenharmony_ci#include <net/xdp.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* The PacketOffset field is measured in units of 32 bytes and is 3 bits wide, 248c2ecf20Sopenharmony_ci * so the maximum offset is 7 * 32 = 224 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci#define MVPP2_SKB_HEADROOM min(max(XDP_PACKET_HEADROOM, NET_SKB_PAD), 224) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define MVPP2_XDP_PASS 0 298c2ecf20Sopenharmony_ci#define MVPP2_XDP_DROPPED BIT(0) 308c2ecf20Sopenharmony_ci#define MVPP2_XDP_TX BIT(1) 318c2ecf20Sopenharmony_ci#define MVPP2_XDP_REDIR BIT(2) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* Fifo Registers */ 348c2ecf20Sopenharmony_ci#define MVPP2_RX_DATA_FIFO_SIZE_REG(port) (0x00 + 4 * (port)) 358c2ecf20Sopenharmony_ci#define MVPP2_RX_ATTR_FIFO_SIZE_REG(port) (0x20 + 4 * (port)) 368c2ecf20Sopenharmony_ci#define MVPP2_RX_MIN_PKT_SIZE_REG 0x60 378c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_INIT_REG 0x64 388c2ecf20Sopenharmony_ci#define MVPP22_TX_FIFO_THRESH_REG(port) (0x8840 + 4 * (port)) 398c2ecf20Sopenharmony_ci#define MVPP22_TX_FIFO_SIZE_REG(port) (0x8860 + 4 * (port)) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* RX DMA Top Registers */ 428c2ecf20Sopenharmony_ci#define MVPP2_RX_CTRL_REG(port) (0x140 + 4 * (port)) 438c2ecf20Sopenharmony_ci#define MVPP2_RX_LOW_LATENCY_PKT_SIZE(s) (((s) & 0xfff) << 16) 448c2ecf20Sopenharmony_ci#define MVPP2_RX_USE_PSEUDO_FOR_CSUM_MASK BIT(31) 458c2ecf20Sopenharmony_ci#define MVPP2_POOL_BUF_SIZE_REG(pool) (0x180 + 4 * (pool)) 468c2ecf20Sopenharmony_ci#define MVPP2_POOL_BUF_SIZE_OFFSET 5 478c2ecf20Sopenharmony_ci#define MVPP2_RXQ_CONFIG_REG(rxq) (0x800 + 4 * (rxq)) 488c2ecf20Sopenharmony_ci#define MVPP2_SNOOP_PKT_SIZE_MASK 0x1ff 498c2ecf20Sopenharmony_ci#define MVPP2_SNOOP_BUF_HDR_MASK BIT(9) 508c2ecf20Sopenharmony_ci#define MVPP2_RXQ_POOL_SHORT_OFFS 20 518c2ecf20Sopenharmony_ci#define MVPP21_RXQ_POOL_SHORT_MASK 0x700000 528c2ecf20Sopenharmony_ci#define MVPP22_RXQ_POOL_SHORT_MASK 0xf00000 538c2ecf20Sopenharmony_ci#define MVPP2_RXQ_POOL_LONG_OFFS 24 548c2ecf20Sopenharmony_ci#define MVPP21_RXQ_POOL_LONG_MASK 0x7000000 558c2ecf20Sopenharmony_ci#define MVPP22_RXQ_POOL_LONG_MASK 0xf000000 568c2ecf20Sopenharmony_ci#define MVPP2_RXQ_PACKET_OFFSET_OFFS 28 578c2ecf20Sopenharmony_ci#define MVPP2_RXQ_PACKET_OFFSET_MASK 0x70000000 588c2ecf20Sopenharmony_ci#define MVPP2_RXQ_DISABLE_MASK BIT(31) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* Top Registers */ 618c2ecf20Sopenharmony_ci#define MVPP2_MH_REG(port) (0x5040 + 4 * (port)) 628c2ecf20Sopenharmony_ci#define MVPP2_DSA_EXTENDED BIT(5) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Parser Registers */ 658c2ecf20Sopenharmony_ci#define MVPP2_PRS_INIT_LOOKUP_REG 0x1000 668c2ecf20Sopenharmony_ci#define MVPP2_PRS_PORT_LU_MAX 0xf 678c2ecf20Sopenharmony_ci#define MVPP2_PRS_PORT_LU_MASK(port) (0xff << ((port) * 4)) 688c2ecf20Sopenharmony_ci#define MVPP2_PRS_PORT_LU_VAL(port, val) ((val) << ((port) * 4)) 698c2ecf20Sopenharmony_ci#define MVPP2_PRS_INIT_OFFS_REG(port) (0x1004 + ((port) & 4)) 708c2ecf20Sopenharmony_ci#define MVPP2_PRS_INIT_OFF_MASK(port) (0x3f << (((port) % 4) * 8)) 718c2ecf20Sopenharmony_ci#define MVPP2_PRS_INIT_OFF_VAL(port, val) ((val) << (((port) % 4) * 8)) 728c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAX_LOOP_REG(port) (0x100c + ((port) & 4)) 738c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAX_LOOP_MASK(port) (0xff << (((port) % 4) * 8)) 748c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAX_LOOP_VAL(port, val) ((val) << (((port) % 4) * 8)) 758c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_IDX_REG 0x1100 768c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_DATA_REG(idx) (0x1104 + (idx) * 4) 778c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_INV_MASK BIT(31) 788c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_IDX_REG 0x1200 798c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_DATA_REG(idx) (0x1204 + (idx) * 4) 808c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_CTRL_REG 0x1230 818c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_EN_MASK BIT(0) 828c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_HIT_IDX_REG 0x1240 838c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_HIT_CNT_REG 0x1244 848c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_HIT_CNT_MASK GENMASK(15, 0) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* RSS Registers */ 878c2ecf20Sopenharmony_ci#define MVPP22_RSS_INDEX 0x1500 888c2ecf20Sopenharmony_ci#define MVPP22_RSS_INDEX_TABLE_ENTRY(idx) (idx) 898c2ecf20Sopenharmony_ci#define MVPP22_RSS_INDEX_TABLE(idx) ((idx) << 8) 908c2ecf20Sopenharmony_ci#define MVPP22_RSS_INDEX_QUEUE(idx) ((idx) << 16) 918c2ecf20Sopenharmony_ci#define MVPP22_RXQ2RSS_TABLE 0x1504 928c2ecf20Sopenharmony_ci#define MVPP22_RSS_TABLE_POINTER(p) (p) 938c2ecf20Sopenharmony_ci#define MVPP22_RSS_TABLE_ENTRY 0x1508 948c2ecf20Sopenharmony_ci#define MVPP22_RSS_WIDTH 0x150c 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* Classifier Registers */ 978c2ecf20Sopenharmony_ci#define MVPP2_CLS_MODE_REG 0x1800 988c2ecf20Sopenharmony_ci#define MVPP2_CLS_MODE_ACTIVE_MASK BIT(0) 998c2ecf20Sopenharmony_ci#define MVPP2_CLS_PORT_WAY_REG 0x1810 1008c2ecf20Sopenharmony_ci#define MVPP2_CLS_PORT_WAY_MASK(port) (1 << (port)) 1018c2ecf20Sopenharmony_ci#define MVPP2_CLS_LKP_INDEX_REG 0x1814 1028c2ecf20Sopenharmony_ci#define MVPP2_CLS_LKP_INDEX_WAY_OFFS 6 1038c2ecf20Sopenharmony_ci#define MVPP2_CLS_LKP_TBL_REG 0x1818 1048c2ecf20Sopenharmony_ci#define MVPP2_CLS_LKP_TBL_RXQ_MASK 0xff 1058c2ecf20Sopenharmony_ci#define MVPP2_CLS_LKP_FLOW_PTR(flow) ((flow) << 16) 1068c2ecf20Sopenharmony_ci#define MVPP2_CLS_LKP_TBL_LOOKUP_EN_MASK BIT(25) 1078c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_INDEX_REG 0x1820 1088c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_REG 0x1824 1098c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_LAST BIT(0) 1108c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_ENG_MASK 0x7 1118c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_OFFS 1 1128c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_ENG(x) ((x) << 1) 1138c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_PORT_ID_MASK 0xff 1148c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_PORT_ID(port) ((port) << 4) 1158c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_PORT_ID_SEL BIT(23) 1168c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_REG 0x1828 1178c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_N_FIELDS_MASK 0x7 1188c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_N_FIELDS(x) (x) 1198c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_LU_TYPE(lu) (((lu) & 0x3f) << 3) 1208c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_PRIO_MASK 0x3f 1218c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_PRIO(x) ((x) << 9) 1228c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_SEQ_MASK 0x7 1238c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_SEQ(x) ((x) << 15) 1248c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_REG 0x182c 1258c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_FLD_MASK 0x3f 1268c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_FLD_OFFS(n) ((n) * 6) 1278c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_FLD(n, x) ((x) << ((n) * 6)) 1288c2ecf20Sopenharmony_ci#define MVPP2_CLS_OVERSIZE_RXQ_LOW_REG(port) (0x1980 + ((port) * 4)) 1298c2ecf20Sopenharmony_ci#define MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS 3 1308c2ecf20Sopenharmony_ci#define MVPP2_CLS_OVERSIZE_RXQ_LOW_MASK 0x7 1318c2ecf20Sopenharmony_ci#define MVPP2_CLS_SWFWD_P2HQ_REG(port) (0x19b0 + ((port) * 4)) 1328c2ecf20Sopenharmony_ci#define MVPP2_CLS_SWFWD_PCTRL_REG 0x19d0 1338c2ecf20Sopenharmony_ci#define MVPP2_CLS_SWFWD_PCTRL_MASK(port) (1 << (port)) 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* Classifier C2 engine Registers */ 1368c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_IDX 0x1b00 1378c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA0 0x1b10 1388c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA1 0x1b14 1398c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA2 0x1b18 1408c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA3 0x1b1c 1418c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA4 0x1b20 1428c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f) 1438c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8) 1448c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_PORT_MASK (0xff << 8) 1458c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_INV 0x1b24 1468c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_INV_BIT BIT(31) 1478c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_HIT_CTR 0x1b50 1488c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ACT 0x1b60 1498c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19) 1508c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13) 1518c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11) 1528c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9) 1538c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ACT_COLOR(act) ((act) & 0x7) 1548c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0 0x1b64 1558c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24) 1568c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f 1578c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QHIGH_OFFS 24 1588c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QLOW(ql) (((ql) & 0x7) << 21) 1598c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QLOW_MASK 0x7 1608c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QLOW_OFFS 21 1618c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR1 0x1b68 1628c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR2 0x1b6c 1638c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR2_RSS_EN BIT(30) 1648c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_ATTR3 0x1b70 1658c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_CTRL 0x1b90 1668c2ecf20Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_BYPASS_FIFO BIT(0) 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci/* Descriptor Manager Top Registers */ 1698c2ecf20Sopenharmony_ci#define MVPP2_RXQ_NUM_REG 0x2040 1708c2ecf20Sopenharmony_ci#define MVPP2_RXQ_DESC_ADDR_REG 0x2044 1718c2ecf20Sopenharmony_ci#define MVPP22_DESC_ADDR_OFFS 8 1728c2ecf20Sopenharmony_ci#define MVPP2_RXQ_DESC_SIZE_REG 0x2048 1738c2ecf20Sopenharmony_ci#define MVPP2_RXQ_DESC_SIZE_MASK 0x3ff0 1748c2ecf20Sopenharmony_ci#define MVPP2_RXQ_STATUS_UPDATE_REG(rxq) (0x3000 + 4 * (rxq)) 1758c2ecf20Sopenharmony_ci#define MVPP2_RXQ_NUM_PROCESSED_OFFSET 0 1768c2ecf20Sopenharmony_ci#define MVPP2_RXQ_NUM_NEW_OFFSET 16 1778c2ecf20Sopenharmony_ci#define MVPP2_RXQ_STATUS_REG(rxq) (0x3400 + 4 * (rxq)) 1788c2ecf20Sopenharmony_ci#define MVPP2_RXQ_OCCUPIED_MASK 0x3fff 1798c2ecf20Sopenharmony_ci#define MVPP2_RXQ_NON_OCCUPIED_OFFSET 16 1808c2ecf20Sopenharmony_ci#define MVPP2_RXQ_NON_OCCUPIED_MASK 0x3fff0000 1818c2ecf20Sopenharmony_ci#define MVPP2_RXQ_THRESH_REG 0x204c 1828c2ecf20Sopenharmony_ci#define MVPP2_OCCUPIED_THRESH_OFFSET 0 1838c2ecf20Sopenharmony_ci#define MVPP2_OCCUPIED_THRESH_MASK 0x3fff 1848c2ecf20Sopenharmony_ci#define MVPP2_RXQ_INDEX_REG 0x2050 1858c2ecf20Sopenharmony_ci#define MVPP2_TXQ_NUM_REG 0x2080 1868c2ecf20Sopenharmony_ci#define MVPP2_TXQ_DESC_ADDR_REG 0x2084 1878c2ecf20Sopenharmony_ci#define MVPP2_TXQ_DESC_SIZE_REG 0x2088 1888c2ecf20Sopenharmony_ci#define MVPP2_TXQ_DESC_SIZE_MASK 0x3ff0 1898c2ecf20Sopenharmony_ci#define MVPP2_TXQ_THRESH_REG 0x2094 1908c2ecf20Sopenharmony_ci#define MVPP2_TXQ_THRESH_OFFSET 16 1918c2ecf20Sopenharmony_ci#define MVPP2_TXQ_THRESH_MASK 0x3fff 1928c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_UPDATE_REG 0x2090 1938c2ecf20Sopenharmony_ci#define MVPP2_TXQ_INDEX_REG 0x2098 1948c2ecf20Sopenharmony_ci#define MVPP2_TXQ_PREF_BUF_REG 0x209c 1958c2ecf20Sopenharmony_ci#define MVPP2_PREF_BUF_PTR(desc) ((desc) & 0xfff) 1968c2ecf20Sopenharmony_ci#define MVPP2_PREF_BUF_SIZE_4 (BIT(12) | BIT(13)) 1978c2ecf20Sopenharmony_ci#define MVPP2_PREF_BUF_SIZE_16 (BIT(12) | BIT(14)) 1988c2ecf20Sopenharmony_ci#define MVPP2_PREF_BUF_THRESH(val) ((val) << 17) 1998c2ecf20Sopenharmony_ci#define MVPP2_TXQ_DRAIN_EN_MASK BIT(31) 2008c2ecf20Sopenharmony_ci#define MVPP2_TXQ_PENDING_REG 0x20a0 2018c2ecf20Sopenharmony_ci#define MVPP2_TXQ_PENDING_MASK 0x3fff 2028c2ecf20Sopenharmony_ci#define MVPP2_TXQ_INT_STATUS_REG 0x20a4 2038c2ecf20Sopenharmony_ci#define MVPP2_TXQ_SENT_REG(txq) (0x3c00 + 4 * (txq)) 2048c2ecf20Sopenharmony_ci#define MVPP2_TRANSMITTED_COUNT_OFFSET 16 2058c2ecf20Sopenharmony_ci#define MVPP2_TRANSMITTED_COUNT_MASK 0x3fff0000 2068c2ecf20Sopenharmony_ci#define MVPP2_TXQ_RSVD_REQ_REG 0x20b0 2078c2ecf20Sopenharmony_ci#define MVPP2_TXQ_RSVD_REQ_Q_OFFSET 16 2088c2ecf20Sopenharmony_ci#define MVPP2_TXQ_RSVD_RSLT_REG 0x20b4 2098c2ecf20Sopenharmony_ci#define MVPP2_TXQ_RSVD_RSLT_MASK 0x3fff 2108c2ecf20Sopenharmony_ci#define MVPP2_TXQ_RSVD_CLR_REG 0x20b8 2118c2ecf20Sopenharmony_ci#define MVPP2_TXQ_RSVD_CLR_OFFSET 16 2128c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_DESC_ADDR_REG(cpu) (0x2100 + 4 * (cpu)) 2138c2ecf20Sopenharmony_ci#define MVPP22_AGGR_TXQ_DESC_ADDR_OFFS 8 2148c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_DESC_SIZE_REG(cpu) (0x2140 + 4 * (cpu)) 2158c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_DESC_SIZE_MASK 0x3ff0 2168c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_STATUS_REG(cpu) (0x2180 + 4 * (cpu)) 2178c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_PENDING_MASK 0x3fff 2188c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_INDEX_REG(cpu) (0x21c0 + 4 * (cpu)) 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci/* MBUS bridge registers */ 2218c2ecf20Sopenharmony_ci#define MVPP2_WIN_BASE(w) (0x4000 + ((w) << 2)) 2228c2ecf20Sopenharmony_ci#define MVPP2_WIN_SIZE(w) (0x4020 + ((w) << 2)) 2238c2ecf20Sopenharmony_ci#define MVPP2_WIN_REMAP(w) (0x4040 + ((w) << 2)) 2248c2ecf20Sopenharmony_ci#define MVPP2_BASE_ADDR_ENABLE 0x4060 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* AXI Bridge Registers */ 2278c2ecf20Sopenharmony_ci#define MVPP22_AXI_BM_WR_ATTR_REG 0x4100 2288c2ecf20Sopenharmony_ci#define MVPP22_AXI_BM_RD_ATTR_REG 0x4104 2298c2ecf20Sopenharmony_ci#define MVPP22_AXI_AGGRQ_DESCR_RD_ATTR_REG 0x4110 2308c2ecf20Sopenharmony_ci#define MVPP22_AXI_TXQ_DESCR_WR_ATTR_REG 0x4114 2318c2ecf20Sopenharmony_ci#define MVPP22_AXI_TXQ_DESCR_RD_ATTR_REG 0x4118 2328c2ecf20Sopenharmony_ci#define MVPP22_AXI_RXQ_DESCR_WR_ATTR_REG 0x411c 2338c2ecf20Sopenharmony_ci#define MVPP22_AXI_RX_DATA_WR_ATTR_REG 0x4120 2348c2ecf20Sopenharmony_ci#define MVPP22_AXI_TX_DATA_RD_ATTR_REG 0x4130 2358c2ecf20Sopenharmony_ci#define MVPP22_AXI_RD_NORMAL_CODE_REG 0x4150 2368c2ecf20Sopenharmony_ci#define MVPP22_AXI_RD_SNOOP_CODE_REG 0x4154 2378c2ecf20Sopenharmony_ci#define MVPP22_AXI_WR_NORMAL_CODE_REG 0x4160 2388c2ecf20Sopenharmony_ci#define MVPP22_AXI_WR_SNOOP_CODE_REG 0x4164 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci/* Values for AXI Bridge registers */ 2418c2ecf20Sopenharmony_ci#define MVPP22_AXI_ATTR_CACHE_OFFS 0 2428c2ecf20Sopenharmony_ci#define MVPP22_AXI_ATTR_DOMAIN_OFFS 12 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_OFFS 0 2458c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_DOMAIN_OFFS 4 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_NON_CACHE 0x3 2488c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_WR_CACHE 0x7 2498c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_RD_CACHE 0xb 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_DOMAIN_OUTER_DOM 2 2528c2ecf20Sopenharmony_ci#define MVPP22_AXI_CODE_DOMAIN_SYSTEM 3 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* Interrupt Cause and Mask registers */ 2558c2ecf20Sopenharmony_ci#define MVPP2_ISR_TX_THRESHOLD_REG(port) (0x5140 + 4 * (port)) 2568c2ecf20Sopenharmony_ci#define MVPP2_MAX_ISR_TX_THRESHOLD 0xfffff0 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci#define MVPP2_ISR_RX_THRESHOLD_REG(rxq) (0x5200 + 4 * (rxq)) 2598c2ecf20Sopenharmony_ci#define MVPP2_MAX_ISR_RX_THRESHOLD 0xfffff0 2608c2ecf20Sopenharmony_ci#define MVPP21_ISR_RXQ_GROUP_REG(port) (0x5400 + 4 * (port)) 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_REG 0x5400 2638c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf 2648c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380 2658c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_OFFSET 7 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf 2688c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_CONFIG_REG 0x5404 2718c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_STARTQ_MASK 0x1f 2728c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_MASK 0xf00 2738c2ecf20Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_OFFSET 8 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci#define MVPP2_ISR_ENABLE_REG(port) (0x5420 + 4 * (port)) 2768c2ecf20Sopenharmony_ci#define MVPP2_ISR_ENABLE_INTERRUPT(mask) ((mask) & 0xffff) 2778c2ecf20Sopenharmony_ci#define MVPP2_ISR_DISABLE_INTERRUPT(mask) (((mask) << 16) & 0xffff0000) 2788c2ecf20Sopenharmony_ci#define MVPP2_ISR_RX_TX_CAUSE_REG(port) (0x5480 + 4 * (port)) 2798c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK(version) \ 2808c2ecf20Sopenharmony_ci ((version) == MVPP21 ? 0xffff : 0xff) 2818c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK 0xff0000 2828c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_OFFSET 16 2838c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_RX_FIFO_OVERRUN_MASK BIT(24) 2848c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_FCS_ERR_MASK BIT(25) 2858c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_TX_FIFO_UNDERRUN_MASK BIT(26) 2868c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_TX_EXCEPTION_SUM_MASK BIT(29) 2878c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_RX_EXCEPTION_SUM_MASK BIT(30) 2888c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_MISC_SUM_MASK BIT(31) 2898c2ecf20Sopenharmony_ci#define MVPP2_ISR_RX_TX_MASK_REG(port) (0x54a0 + 4 * (port)) 2908c2ecf20Sopenharmony_ci#define MVPP2_ISR_PON_RX_TX_MASK_REG 0x54bc 2918c2ecf20Sopenharmony_ci#define MVPP2_PON_CAUSE_RXQ_OCCUP_DESC_ALL_MASK 0xffff 2928c2ecf20Sopenharmony_ci#define MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK 0x3fc00000 2938c2ecf20Sopenharmony_ci#define MVPP2_PON_CAUSE_MISC_SUM_MASK BIT(31) 2948c2ecf20Sopenharmony_ci#define MVPP2_ISR_MISC_CAUSE_REG 0x55b0 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci/* Buffer Manager registers */ 2978c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_BASE_REG(pool) (0x6000 + ((pool) * 4)) 2988c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_BASE_ADDR_MASK 0xfffff80 2998c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_SIZE_REG(pool) (0x6040 + ((pool) * 4)) 3008c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_SIZE_MASK 0xfff0 3018c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_READ_PTR_REG(pool) (0x6080 + ((pool) * 4)) 3028c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_GET_READ_PTR_MASK 0xfff0 3038c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_PTRS_NUM_REG(pool) (0x60c0 + ((pool) * 4)) 3048c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_PTRS_NUM_MASK 0xfff0 3058c2ecf20Sopenharmony_ci#define MVPP2_BM_BPPI_READ_PTR_REG(pool) (0x6100 + ((pool) * 4)) 3068c2ecf20Sopenharmony_ci#define MVPP2_BM_BPPI_PTRS_NUM_REG(pool) (0x6140 + ((pool) * 4)) 3078c2ecf20Sopenharmony_ci#define MVPP2_BM_BPPI_PTR_NUM_MASK 0x7ff 3088c2ecf20Sopenharmony_ci#define MVPP22_BM_POOL_PTRS_NUM_MASK 0xfff8 3098c2ecf20Sopenharmony_ci#define MVPP2_BM_BPPI_PREFETCH_FULL_MASK BIT(16) 3108c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_CTRL_REG(pool) (0x6200 + ((pool) * 4)) 3118c2ecf20Sopenharmony_ci#define MVPP2_BM_START_MASK BIT(0) 3128c2ecf20Sopenharmony_ci#define MVPP2_BM_STOP_MASK BIT(1) 3138c2ecf20Sopenharmony_ci#define MVPP2_BM_STATE_MASK BIT(4) 3148c2ecf20Sopenharmony_ci#define MVPP2_BM_LOW_THRESH_OFFS 8 3158c2ecf20Sopenharmony_ci#define MVPP2_BM_LOW_THRESH_MASK 0x7f00 3168c2ecf20Sopenharmony_ci#define MVPP2_BM_LOW_THRESH_VALUE(val) ((val) << \ 3178c2ecf20Sopenharmony_ci MVPP2_BM_LOW_THRESH_OFFS) 3188c2ecf20Sopenharmony_ci#define MVPP2_BM_HIGH_THRESH_OFFS 16 3198c2ecf20Sopenharmony_ci#define MVPP2_BM_HIGH_THRESH_MASK 0x7f0000 3208c2ecf20Sopenharmony_ci#define MVPP2_BM_HIGH_THRESH_VALUE(val) ((val) << \ 3218c2ecf20Sopenharmony_ci MVPP2_BM_HIGH_THRESH_OFFS) 3228c2ecf20Sopenharmony_ci#define MVPP2_BM_INTR_CAUSE_REG(pool) (0x6240 + ((pool) * 4)) 3238c2ecf20Sopenharmony_ci#define MVPP2_BM_RELEASED_DELAY_MASK BIT(0) 3248c2ecf20Sopenharmony_ci#define MVPP2_BM_ALLOC_FAILED_MASK BIT(1) 3258c2ecf20Sopenharmony_ci#define MVPP2_BM_BPPE_EMPTY_MASK BIT(2) 3268c2ecf20Sopenharmony_ci#define MVPP2_BM_BPPE_FULL_MASK BIT(3) 3278c2ecf20Sopenharmony_ci#define MVPP2_BM_AVAILABLE_BP_LOW_MASK BIT(4) 3288c2ecf20Sopenharmony_ci#define MVPP2_BM_INTR_MASK_REG(pool) (0x6280 + ((pool) * 4)) 3298c2ecf20Sopenharmony_ci#define MVPP2_BM_PHY_ALLOC_REG(pool) (0x6400 + ((pool) * 4)) 3308c2ecf20Sopenharmony_ci#define MVPP2_BM_PHY_ALLOC_GRNTD_MASK BIT(0) 3318c2ecf20Sopenharmony_ci#define MVPP2_BM_VIRT_ALLOC_REG 0x6440 3328c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_ALLOC 0x6444 3338c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_PHYS_MASK 0xff 3348c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_MASK 0xff00 3358c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_SHIFT 8 3368c2ecf20Sopenharmony_ci#define MVPP2_BM_PHY_RLS_REG(pool) (0x6480 + ((pool) * 4)) 3378c2ecf20Sopenharmony_ci#define MVPP2_BM_PHY_RLS_MC_BUFF_MASK BIT(0) 3388c2ecf20Sopenharmony_ci#define MVPP2_BM_PHY_RLS_PRIO_EN_MASK BIT(1) 3398c2ecf20Sopenharmony_ci#define MVPP2_BM_PHY_RLS_GRNTD_MASK BIT(2) 3408c2ecf20Sopenharmony_ci#define MVPP2_BM_VIRT_RLS_REG 0x64c0 3418c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_RLS_REG 0x64c4 3428c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_PHYS_RLS_MASK 0xff 3438c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK 0xff00 3448c2ecf20Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT 8 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci/* Packet Processor per-port counters */ 3478c2ecf20Sopenharmony_ci#define MVPP2_OVERRUN_ETH_DROP 0x7000 3488c2ecf20Sopenharmony_ci#define MVPP2_CLS_ETH_DROP 0x7020 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci/* Hit counters registers */ 3518c2ecf20Sopenharmony_ci#define MVPP2_CTRS_IDX 0x7040 3528c2ecf20Sopenharmony_ci#define MVPP22_CTRS_TX_CTR(port, txq) ((txq) | ((port) << 3) | BIT(7)) 3538c2ecf20Sopenharmony_ci#define MVPP2_TX_DESC_ENQ_CTR 0x7100 3548c2ecf20Sopenharmony_ci#define MVPP2_TX_DESC_ENQ_TO_DDR_CTR 0x7104 3558c2ecf20Sopenharmony_ci#define MVPP2_TX_BUFF_ENQ_TO_DDR_CTR 0x7108 3568c2ecf20Sopenharmony_ci#define MVPP2_TX_DESC_ENQ_HW_FWD_CTR 0x710c 3578c2ecf20Sopenharmony_ci#define MVPP2_RX_DESC_ENQ_CTR 0x7120 3588c2ecf20Sopenharmony_ci#define MVPP2_TX_PKTS_DEQ_CTR 0x7130 3598c2ecf20Sopenharmony_ci#define MVPP2_TX_PKTS_FULL_QUEUE_DROP_CTR 0x7200 3608c2ecf20Sopenharmony_ci#define MVPP2_TX_PKTS_EARLY_DROP_CTR 0x7204 3618c2ecf20Sopenharmony_ci#define MVPP2_TX_PKTS_BM_DROP_CTR 0x7208 3628c2ecf20Sopenharmony_ci#define MVPP2_TX_PKTS_BM_MC_DROP_CTR 0x720c 3638c2ecf20Sopenharmony_ci#define MVPP2_RX_PKTS_FULL_QUEUE_DROP_CTR 0x7220 3648c2ecf20Sopenharmony_ci#define MVPP2_RX_PKTS_EARLY_DROP_CTR 0x7224 3658c2ecf20Sopenharmony_ci#define MVPP2_RX_PKTS_BM_DROP_CTR 0x7228 3668c2ecf20Sopenharmony_ci#define MVPP2_CLS_DEC_TBL_HIT_CTR 0x7700 3678c2ecf20Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL_HIT_CTR 0x7704 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci/* TX Scheduler registers */ 3708c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_PORT_INDEX_REG 0x8000 3718c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_Q_CMD_REG 0x8004 3728c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_ENQ_MASK 0xff 3738c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_DISQ_OFFSET 8 3748c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_CMD_1_REG 0x8010 3758c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_FIXED_PRIO_REG 0x8014 3768c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_PERIOD_REG 0x8018 3778c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_MTU_REG 0x801c 3788c2ecf20Sopenharmony_ci#define MVPP2_TXP_MTU_MAX 0x7FFFF 3798c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_REFILL_REG 0x8020 3808c2ecf20Sopenharmony_ci#define MVPP2_TXP_REFILL_TOKENS_ALL_MASK 0x7ffff 3818c2ecf20Sopenharmony_ci#define MVPP2_TXP_REFILL_PERIOD_ALL_MASK 0x3ff00000 3828c2ecf20Sopenharmony_ci#define MVPP2_TXP_REFILL_PERIOD_MASK(v) ((v) << 20) 3838c2ecf20Sopenharmony_ci#define MVPP2_TXP_SCHED_TOKEN_SIZE_REG 0x8024 3848c2ecf20Sopenharmony_ci#define MVPP2_TXP_TOKEN_SIZE_MAX 0xffffffff 3858c2ecf20Sopenharmony_ci#define MVPP2_TXQ_SCHED_REFILL_REG(q) (0x8040 + ((q) << 2)) 3868c2ecf20Sopenharmony_ci#define MVPP2_TXQ_REFILL_TOKENS_ALL_MASK 0x7ffff 3878c2ecf20Sopenharmony_ci#define MVPP2_TXQ_REFILL_PERIOD_ALL_MASK 0x3ff00000 3888c2ecf20Sopenharmony_ci#define MVPP2_TXQ_REFILL_PERIOD_MASK(v) ((v) << 20) 3898c2ecf20Sopenharmony_ci#define MVPP2_TXQ_SCHED_TOKEN_SIZE_REG(q) (0x8060 + ((q) << 2)) 3908c2ecf20Sopenharmony_ci#define MVPP2_TXQ_TOKEN_SIZE_MAX 0x7fffffff 3918c2ecf20Sopenharmony_ci#define MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(q) (0x8080 + ((q) << 2)) 3928c2ecf20Sopenharmony_ci#define MVPP2_TXQ_TOKEN_CNTR_MAX 0xffffffff 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci/* TX general registers */ 3958c2ecf20Sopenharmony_ci#define MVPP2_TX_SNOOP_REG 0x8800 3968c2ecf20Sopenharmony_ci#define MVPP2_TX_PORT_FLUSH_REG 0x8810 3978c2ecf20Sopenharmony_ci#define MVPP2_TX_PORT_FLUSH_MASK(port) (1 << (port)) 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci/* LMS registers */ 4008c2ecf20Sopenharmony_ci#define MVPP2_SRC_ADDR_MIDDLE 0x24 4018c2ecf20Sopenharmony_ci#define MVPP2_SRC_ADDR_HIGH 0x28 4028c2ecf20Sopenharmony_ci#define MVPP2_PHY_AN_CFG0_REG 0x34 4038c2ecf20Sopenharmony_ci#define MVPP2_PHY_AN_STOP_SMI0_MASK BIT(7) 4048c2ecf20Sopenharmony_ci#define MVPP2_MNG_EXTENDED_GLOBAL_CTRL_REG 0x305c 4058c2ecf20Sopenharmony_ci#define MVPP2_EXT_GLOBAL_CTRL_DEFAULT 0x27 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci/* Per-port registers */ 4088c2ecf20Sopenharmony_ci#define MVPP2_GMAC_CTRL_0_REG 0x0 4098c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PORT_EN_MASK BIT(0) 4108c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PORT_TYPE_MASK BIT(1) 4118c2ecf20Sopenharmony_ci#define MVPP2_GMAC_MAX_RX_SIZE_OFFS 2 4128c2ecf20Sopenharmony_ci#define MVPP2_GMAC_MAX_RX_SIZE_MASK 0x7ffc 4138c2ecf20Sopenharmony_ci#define MVPP2_GMAC_MIB_CNTR_EN_MASK BIT(15) 4148c2ecf20Sopenharmony_ci#define MVPP2_GMAC_CTRL_1_REG 0x4 4158c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PERIODIC_XON_EN_MASK BIT(1) 4168c2ecf20Sopenharmony_ci#define MVPP2_GMAC_GMII_LB_EN_MASK BIT(5) 4178c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PCS_LB_EN_BIT 6 4188c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PCS_LB_EN_MASK BIT(6) 4198c2ecf20Sopenharmony_ci#define MVPP2_GMAC_SA_LOW_OFFS 7 4208c2ecf20Sopenharmony_ci#define MVPP2_GMAC_CTRL_2_REG 0x8 4218c2ecf20Sopenharmony_ci#define MVPP2_GMAC_INBAND_AN_MASK BIT(0) 4228c2ecf20Sopenharmony_ci#define MVPP2_GMAC_FLOW_CTRL_MASK GENMASK(2, 1) 4238c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PCS_ENABLE_MASK BIT(3) 4248c2ecf20Sopenharmony_ci#define MVPP2_GMAC_INTERNAL_CLK_MASK BIT(4) 4258c2ecf20Sopenharmony_ci#define MVPP2_GMAC_DISABLE_PADDING BIT(5) 4268c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PORT_RESET_MASK BIT(6) 4278c2ecf20Sopenharmony_ci#define MVPP2_GMAC_AUTONEG_CONFIG 0xc 4288c2ecf20Sopenharmony_ci#define MVPP2_GMAC_FORCE_LINK_DOWN BIT(0) 4298c2ecf20Sopenharmony_ci#define MVPP2_GMAC_FORCE_LINK_PASS BIT(1) 4308c2ecf20Sopenharmony_ci#define MVPP2_GMAC_IN_BAND_AUTONEG BIT(2) 4318c2ecf20Sopenharmony_ci#define MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS BIT(3) 4328c2ecf20Sopenharmony_ci#define MVPP2_GMAC_IN_BAND_RESTART_AN BIT(4) 4338c2ecf20Sopenharmony_ci#define MVPP2_GMAC_CONFIG_MII_SPEED BIT(5) 4348c2ecf20Sopenharmony_ci#define MVPP2_GMAC_CONFIG_GMII_SPEED BIT(6) 4358c2ecf20Sopenharmony_ci#define MVPP2_GMAC_AN_SPEED_EN BIT(7) 4368c2ecf20Sopenharmony_ci#define MVPP2_GMAC_FC_ADV_EN BIT(9) 4378c2ecf20Sopenharmony_ci#define MVPP2_GMAC_FC_ADV_ASM_EN BIT(10) 4388c2ecf20Sopenharmony_ci#define MVPP2_GMAC_FLOW_CTRL_AUTONEG BIT(11) 4398c2ecf20Sopenharmony_ci#define MVPP2_GMAC_CONFIG_FULL_DUPLEX BIT(12) 4408c2ecf20Sopenharmony_ci#define MVPP2_GMAC_AN_DUPLEX_EN BIT(13) 4418c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0 0x10 4428c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_LINK_UP BIT(0) 4438c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_GMII_SPEED BIT(1) 4448c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_MII_SPEED BIT(2) 4458c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_FULL_DUPLEX BIT(3) 4468c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_RX_PAUSE BIT(4) 4478c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_TX_PAUSE BIT(5) 4488c2ecf20Sopenharmony_ci#define MVPP2_GMAC_STATUS0_AN_COMPLETE BIT(11) 4498c2ecf20Sopenharmony_ci#define MVPP2_GMAC_PORT_FIFO_CFG_1_REG 0x1c 4508c2ecf20Sopenharmony_ci#define MVPP2_GMAC_TX_FIFO_MIN_TH_OFFS 6 4518c2ecf20Sopenharmony_ci#define MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK 0x1fc0 4528c2ecf20Sopenharmony_ci#define MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(v) (((v) << 6) & \ 4538c2ecf20Sopenharmony_ci MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK) 4548c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_STAT 0x20 4558c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_STAT_LINK BIT(1) 4568c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_MASK 0x24 4578c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_MASK_LINK_STAT BIT(1) 4588c2ecf20Sopenharmony_ci#define MVPP22_GMAC_CTRL_4_REG 0x90 4598c2ecf20Sopenharmony_ci#define MVPP22_CTRL4_EXT_PIN_GMII_SEL BIT(0) 4608c2ecf20Sopenharmony_ci#define MVPP22_CTRL4_RX_FC_EN BIT(3) 4618c2ecf20Sopenharmony_ci#define MVPP22_CTRL4_TX_FC_EN BIT(4) 4628c2ecf20Sopenharmony_ci#define MVPP22_CTRL4_DP_CLK_SEL BIT(5) 4638c2ecf20Sopenharmony_ci#define MVPP22_CTRL4_SYNC_BYPASS_DIS BIT(6) 4648c2ecf20Sopenharmony_ci#define MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE BIT(7) 4658c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_STAT 0xa0 4668c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_STAT_INTERNAL BIT(1) 4678c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_STAT_PTP BIT(2) 4688c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_MASK 0xa4 4698c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_MASK_LINK_STAT BIT(1) 4708c2ecf20Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_MASK_PTP BIT(2) 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci/* Per-port XGMAC registers. PPv2.2 only, only for GOP port 0, 4738c2ecf20Sopenharmony_ci * relative to port->base. 4748c2ecf20Sopenharmony_ci */ 4758c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_REG 0x100 4768c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_PORT_EN BIT(0) 4778c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_MAC_RESET_DIS BIT(1) 4788c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_FORCE_LINK_DOWN BIT(2) 4798c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_FORCE_LINK_PASS BIT(3) 4808c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_RX_FLOW_CTRL_EN BIT(7) 4818c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN BIT(8) 4828c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL0_MIB_CNT_DIS BIT(14) 4838c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL1_REG 0x104 4848c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_OFFS 0 4858c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_MASK 0x1fff 4868c2ecf20Sopenharmony_ci#define MVPP22_XLG_STATUS 0x10c 4878c2ecf20Sopenharmony_ci#define MVPP22_XLG_STATUS_LINK_UP BIT(0) 4888c2ecf20Sopenharmony_ci#define MVPP22_XLG_INT_STAT 0x114 4898c2ecf20Sopenharmony_ci#define MVPP22_XLG_INT_STAT_LINK BIT(1) 4908c2ecf20Sopenharmony_ci#define MVPP22_XLG_INT_MASK 0x118 4918c2ecf20Sopenharmony_ci#define MVPP22_XLG_INT_MASK_LINK BIT(1) 4928c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL3_REG 0x11c 4938c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL3_MACMODESELECT_MASK (7 << 13) 4948c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL3_MACMODESELECT_GMAC (0 << 13) 4958c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL3_MACMODESELECT_10G (1 << 13) 4968c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_STAT 0x158 4978c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_STAT_XLG BIT(1) 4988c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_STAT_PTP BIT(7) 4998c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK 0x15c 5008c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK_XLG BIT(1) 5018c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK_GIG BIT(2) 5028c2ecf20Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK_PTP BIT(7) 5038c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL4_REG 0x184 5048c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL4_FWD_FC BIT(5) 5058c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL4_FWD_PFC BIT(6) 5068c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL4_MACMODSELECT_GMAC BIT(12) 5078c2ecf20Sopenharmony_ci#define MVPP22_XLG_CTRL4_EN_IDLE_CHECK BIT(14) 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci/* SMI registers. PPv2.2 only, relative to priv->iface_base. */ 5108c2ecf20Sopenharmony_ci#define MVPP22_SMI_MISC_CFG_REG 0x1204 5118c2ecf20Sopenharmony_ci#define MVPP22_SMI_POLLING_EN BIT(10) 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci/* TAI registers, PPv2.2 only, relative to priv->iface_base */ 5148c2ecf20Sopenharmony_ci#define MVPP22_TAI_INT_CAUSE 0x1400 5158c2ecf20Sopenharmony_ci#define MVPP22_TAI_INT_MASK 0x1404 5168c2ecf20Sopenharmony_ci#define MVPP22_TAI_CR0 0x1408 5178c2ecf20Sopenharmony_ci#define MVPP22_TAI_CR1 0x140c 5188c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCFCR0 0x1410 5198c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCFCR1 0x1414 5208c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCFCR2 0x1418 5218c2ecf20Sopenharmony_ci#define MVPP22_TAI_FATWR 0x141c 5228c2ecf20Sopenharmony_ci#define MVPP22_TAI_TOD_STEP_NANO_CR 0x1420 5238c2ecf20Sopenharmony_ci#define MVPP22_TAI_TOD_STEP_FRAC_HIGH 0x1424 5248c2ecf20Sopenharmony_ci#define MVPP22_TAI_TOD_STEP_FRAC_LOW 0x1428 5258c2ecf20Sopenharmony_ci#define MVPP22_TAI_TAPDC_HIGH 0x142c 5268c2ecf20Sopenharmony_ci#define MVPP22_TAI_TAPDC_LOW 0x1430 5278c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_SEC_HIGH 0x1434 5288c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_SEC_MED 0x1438 5298c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_SEC_LOW 0x143c 5308c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_NANO_HIGH 0x1440 5318c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_NANO_LOW 0x1444 5328c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_FRAC_HIGH 0x1448 5338c2ecf20Sopenharmony_ci#define MVPP22_TAI_TGTOD_FRAC_LOW 0x144c 5348c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_SEC_HIGH 0x1450 5358c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_SEC_MED 0x1454 5368c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_SEC_LOW 0x1458 5378c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_NANO_HIGH 0x145c 5388c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_NANO_LOW 0x1460 5398c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_FRAC_HIGH 0x1464 5408c2ecf20Sopenharmony_ci#define MVPP22_TAI_TLV_FRAC_LOW 0x1468 5418c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_SEC_HIGH 0x146c 5428c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_SEC_MED 0x1470 5438c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_SEC_LOW 0x1474 5448c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_NANO_HIGH 0x1478 5458c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_NANO_LOW 0x147c 5468c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_FRAC_HIGH 0x1480 5478c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV0_FRAC_LOW 0x1484 5488c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_SEC_HIGH 0x1488 5498c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_SEC_MED 0x148c 5508c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_SEC_LOW 0x1490 5518c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_NANO_HIGH 0x1494 5528c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_NANO_LOW 0x1498 5538c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_FRAC_HIGH 0x149c 5548c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCV1_FRAC_LOW 0x14a0 5558c2ecf20Sopenharmony_ci#define MVPP22_TAI_TCSR 0x14a4 5568c2ecf20Sopenharmony_ci#define MVPP22_TAI_TUC_LSB 0x14a8 5578c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_SEC_HIGH 0x14ac 5588c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_SEC_MED 0x14b0 5598c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_SEC_LOW 0x14b4 5608c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_NANO_HIGH 0x14b8 5618c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_NANO_LOW 0x14bc 5628c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_FRAC_HIGH 0x14c0 5638c2ecf20Sopenharmony_ci#define MVPP22_TAI_GFM_FRAC_LOW 0x14c4 5648c2ecf20Sopenharmony_ci#define MVPP22_TAI_PCLK_DA_HIGH 0x14c8 5658c2ecf20Sopenharmony_ci#define MVPP22_TAI_PCLK_DA_LOW 0x14cc 5668c2ecf20Sopenharmony_ci#define MVPP22_TAI_CTCR 0x14d0 5678c2ecf20Sopenharmony_ci#define MVPP22_TAI_PCLK_CCC_HIGH 0x14d4 5688c2ecf20Sopenharmony_ci#define MVPP22_TAI_PCLK_CCC_LOW 0x14d8 5698c2ecf20Sopenharmony_ci#define MVPP22_TAI_DTC_HIGH 0x14dc 5708c2ecf20Sopenharmony_ci#define MVPP22_TAI_DTC_LOW 0x14e0 5718c2ecf20Sopenharmony_ci#define MVPP22_TAI_CCC_HIGH 0x14e4 5728c2ecf20Sopenharmony_ci#define MVPP22_TAI_CCC_LOW 0x14e8 5738c2ecf20Sopenharmony_ci#define MVPP22_TAI_ICICE 0x14f4 5748c2ecf20Sopenharmony_ci#define MVPP22_TAI_ICICC_LOW 0x14f8 5758c2ecf20Sopenharmony_ci#define MVPP22_TAI_TUC_MSB 0x14fc 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci#define MVPP22_GMAC_BASE(port) (0x7000 + (port) * 0x1000 + 0xe00) 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci#define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK 0xff 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci/* Descriptor ring Macros */ 5828c2ecf20Sopenharmony_ci#define MVPP2_QUEUE_NEXT_DESC(q, index) \ 5838c2ecf20Sopenharmony_ci (((index) < (q)->last_desc) ? ((index) + 1) : 0) 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci/* XPCS registers. PPv2.2 only */ 5868c2ecf20Sopenharmony_ci#define MVPP22_MPCS_BASE(port) (0x7000 + (port) * 0x1000) 5878c2ecf20Sopenharmony_ci#define MVPP22_MPCS_CTRL 0x14 5888c2ecf20Sopenharmony_ci#define MVPP22_MPCS_CTRL_FWD_ERR_CONN BIT(10) 5898c2ecf20Sopenharmony_ci#define MVPP22_MPCS_CLK_RESET 0x14c 5908c2ecf20Sopenharmony_ci#define MAC_CLK_RESET_SD_TX BIT(0) 5918c2ecf20Sopenharmony_ci#define MAC_CLK_RESET_SD_RX BIT(1) 5928c2ecf20Sopenharmony_ci#define MAC_CLK_RESET_MAC BIT(2) 5938c2ecf20Sopenharmony_ci#define MVPP22_MPCS_CLK_RESET_DIV_RATIO(n) ((n) << 4) 5948c2ecf20Sopenharmony_ci#define MVPP22_MPCS_CLK_RESET_DIV_SET BIT(11) 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci/* XPCS registers. PPv2.2 only */ 5978c2ecf20Sopenharmony_ci#define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000) 5988c2ecf20Sopenharmony_ci#define MVPP22_XPCS_CFG0 0x0 5998c2ecf20Sopenharmony_ci#define MVPP22_XPCS_CFG0_RESET_DIS BIT(0) 6008c2ecf20Sopenharmony_ci#define MVPP22_XPCS_CFG0_PCS_MODE(n) ((n) << 3) 6018c2ecf20Sopenharmony_ci#define MVPP22_XPCS_CFG0_ACTIVE_LANE(n) ((n) << 5) 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci/* PTP registers. PPv2.2 only */ 6048c2ecf20Sopenharmony_ci#define MVPP22_PTP_BASE(port) (0x7800 + (port * 0x1000)) 6058c2ecf20Sopenharmony_ci#define MVPP22_PTP_INT_CAUSE 0x00 6068c2ecf20Sopenharmony_ci#define MVPP22_PTP_INT_CAUSE_QUEUE1 BIT(6) 6078c2ecf20Sopenharmony_ci#define MVPP22_PTP_INT_CAUSE_QUEUE0 BIT(5) 6088c2ecf20Sopenharmony_ci#define MVPP22_PTP_INT_MASK 0x04 6098c2ecf20Sopenharmony_ci#define MVPP22_PTP_INT_MASK_QUEUE1 BIT(6) 6108c2ecf20Sopenharmony_ci#define MVPP22_PTP_INT_MASK_QUEUE0 BIT(5) 6118c2ecf20Sopenharmony_ci#define MVPP22_PTP_GCR 0x08 6128c2ecf20Sopenharmony_ci#define MVPP22_PTP_GCR_RX_RESET BIT(13) 6138c2ecf20Sopenharmony_ci#define MVPP22_PTP_GCR_TX_RESET BIT(1) 6148c2ecf20Sopenharmony_ci#define MVPP22_PTP_GCR_TSU_ENABLE BIT(0) 6158c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_Q0_R0 0x0c 6168c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_Q0_R1 0x10 6178c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_Q0_R2 0x14 6188c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_Q1_R0 0x18 6198c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_Q1_R1 0x1c 6208c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_Q1_R2 0x20 6218c2ecf20Sopenharmony_ci#define MVPP22_PTP_TPCR 0x24 6228c2ecf20Sopenharmony_ci#define MVPP22_PTP_V1PCR 0x28 6238c2ecf20Sopenharmony_ci#define MVPP22_PTP_V2PCR 0x2c 6248c2ecf20Sopenharmony_ci#define MVPP22_PTP_Y1731PCR 0x30 6258c2ecf20Sopenharmony_ci#define MVPP22_PTP_NTPTSPCR 0x34 6268c2ecf20Sopenharmony_ci#define MVPP22_PTP_NTPRXPCR 0x38 6278c2ecf20Sopenharmony_ci#define MVPP22_PTP_NTPTXPCR 0x3c 6288c2ecf20Sopenharmony_ci#define MVPP22_PTP_WAMPPCR 0x40 6298c2ecf20Sopenharmony_ci#define MVPP22_PTP_NAPCR 0x44 6308c2ecf20Sopenharmony_ci#define MVPP22_PTP_FAPCR 0x48 6318c2ecf20Sopenharmony_ci#define MVPP22_PTP_CAPCR 0x50 6328c2ecf20Sopenharmony_ci#define MVPP22_PTP_ATAPCR 0x54 6338c2ecf20Sopenharmony_ci#define MVPP22_PTP_ACTAPCR 0x58 6348c2ecf20Sopenharmony_ci#define MVPP22_PTP_CATAPCR 0x5c 6358c2ecf20Sopenharmony_ci#define MVPP22_PTP_CACTAPCR 0x60 6368c2ecf20Sopenharmony_ci#define MVPP22_PTP_AITAPCR 0x64 6378c2ecf20Sopenharmony_ci#define MVPP22_PTP_CAITAPCR 0x68 6388c2ecf20Sopenharmony_ci#define MVPP22_PTP_CITAPCR 0x6c 6398c2ecf20Sopenharmony_ci#define MVPP22_PTP_NTP_OFF_HIGH 0x70 6408c2ecf20Sopenharmony_ci#define MVPP22_PTP_NTP_OFF_LOW 0x74 6418c2ecf20Sopenharmony_ci#define MVPP22_PTP_TX_PIPE_STATUS_DELAY 0x78 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci/* System controller registers. Accessed through a regmap. */ 6448c2ecf20Sopenharmony_ci#define GENCONF_SOFT_RESET1 0x1108 6458c2ecf20Sopenharmony_ci#define GENCONF_SOFT_RESET1_GOP BIT(6) 6468c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL0 0x1110 6478c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL0_BUS_WIDTH_SELECT BIT(1) 6488c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL0_RX_DATA_SAMPLE BIT(29) 6498c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL0_CLK_DIV_PHASE_CLR BIT(31) 6508c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL1 0x1114 6518c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL1_EN(p) BIT(p) 6528c2ecf20Sopenharmony_ci#define GENCONF_PORT_CTRL1_RESET(p) (BIT(p) << 28) 6538c2ecf20Sopenharmony_ci#define GENCONF_CTRL0 0x1120 6548c2ecf20Sopenharmony_ci#define GENCONF_CTRL0_PORT0_RGMII BIT(0) 6558c2ecf20Sopenharmony_ci#define GENCONF_CTRL0_PORT1_RGMII_MII BIT(1) 6568c2ecf20Sopenharmony_ci#define GENCONF_CTRL0_PORT1_RGMII BIT(2) 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci/* Various constants */ 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci/* Coalescing */ 6618c2ecf20Sopenharmony_ci#define MVPP2_TXDONE_COAL_PKTS_THRESH 64 6628c2ecf20Sopenharmony_ci#define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL 6638c2ecf20Sopenharmony_ci#define MVPP2_TXDONE_COAL_USEC 1000 6648c2ecf20Sopenharmony_ci#define MVPP2_RX_COAL_PKTS 32 6658c2ecf20Sopenharmony_ci#define MVPP2_RX_COAL_USEC 64 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci/* The two bytes Marvell header. Either contains a special value used 6688c2ecf20Sopenharmony_ci * by Marvell switches when a specific hardware mode is enabled (not 6698c2ecf20Sopenharmony_ci * supported by this driver) or is filled automatically by zeroes on 6708c2ecf20Sopenharmony_ci * the RX side. Those two bytes being at the front of the Ethernet 6718c2ecf20Sopenharmony_ci * header, they allow to have the IP header aligned on a 4 bytes 6728c2ecf20Sopenharmony_ci * boundary automatically: the hardware skips those two bytes on its 6738c2ecf20Sopenharmony_ci * own. 6748c2ecf20Sopenharmony_ci */ 6758c2ecf20Sopenharmony_ci#define MVPP2_MH_SIZE 2 6768c2ecf20Sopenharmony_ci#define MVPP2_ETH_TYPE_LEN 2 6778c2ecf20Sopenharmony_ci#define MVPP2_PPPOE_HDR_SIZE 8 6788c2ecf20Sopenharmony_ci#define MVPP2_VLAN_TAG_LEN 4 6798c2ecf20Sopenharmony_ci#define MVPP2_VLAN_TAG_EDSA_LEN 8 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci/* Lbtd 802.3 type */ 6828c2ecf20Sopenharmony_ci#define MVPP2_IP_LBDT_TYPE 0xfffa 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci#define MVPP2_TX_CSUM_MAX_SIZE 9800 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci/* Timeout constants */ 6878c2ecf20Sopenharmony_ci#define MVPP2_TX_DISABLE_TIMEOUT_MSEC 1000 6888c2ecf20Sopenharmony_ci#define MVPP2_TX_PENDING_TIMEOUT_MSEC 1000 6898c2ecf20Sopenharmony_ci 6908c2ecf20Sopenharmony_ci#define MVPP2_TX_MTU_MAX 0x7ffff 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ci/* Maximum number of T-CONTs of PON port */ 6938c2ecf20Sopenharmony_ci#define MVPP2_MAX_TCONT 16 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci/* Maximum number of supported ports */ 6968c2ecf20Sopenharmony_ci#define MVPP2_MAX_PORTS 4 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci/* Maximum number of TXQs used by single port */ 6998c2ecf20Sopenharmony_ci#define MVPP2_MAX_TXQ 8 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci/* MVPP2_MAX_TSO_SEGS is the maximum number of fragments to allow in the GSO 7028c2ecf20Sopenharmony_ci * skb. As we need a maxium of two descriptors per fragments (1 header, 1 data), 7038c2ecf20Sopenharmony_ci * multiply this value by two to count the maximum number of skb descs needed. 7048c2ecf20Sopenharmony_ci */ 7058c2ecf20Sopenharmony_ci#define MVPP2_MAX_TSO_SEGS 300 7068c2ecf20Sopenharmony_ci#define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS) 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ci/* Max number of RXQs per port */ 7098c2ecf20Sopenharmony_ci#define MVPP2_PORT_MAX_RXQ 32 7108c2ecf20Sopenharmony_ci 7118c2ecf20Sopenharmony_ci/* Max number of Rx descriptors */ 7128c2ecf20Sopenharmony_ci#define MVPP2_MAX_RXD_MAX 1024 7138c2ecf20Sopenharmony_ci#define MVPP2_MAX_RXD_DFLT 128 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_ci/* Max number of Tx descriptors */ 7168c2ecf20Sopenharmony_ci#define MVPP2_MAX_TXD_MAX 2048 7178c2ecf20Sopenharmony_ci#define MVPP2_MAX_TXD_DFLT 1024 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci/* Amount of Tx descriptors that can be reserved at once by CPU */ 7208c2ecf20Sopenharmony_ci#define MVPP2_CPU_DESC_CHUNK 64 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci/* Max number of Tx descriptors in each aggregated queue */ 7238c2ecf20Sopenharmony_ci#define MVPP2_AGGR_TXQ_SIZE 256 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci/* Descriptor aligned size */ 7268c2ecf20Sopenharmony_ci#define MVPP2_DESC_ALIGNED_SIZE 32 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_ci/* Descriptor alignment mask */ 7298c2ecf20Sopenharmony_ci#define MVPP2_TX_DESC_ALIGN (MVPP2_DESC_ALIGNED_SIZE - 1) 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci/* RX FIFO constants */ 7328c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_32KB 0x8000 7338c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_8KB 0x2000 7348c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_4KB 0x1000 7358c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_ATTR_SIZE_32KB 0x200 7368c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_ATTR_SIZE_8KB 0x80 7378c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_ATTR_SIZE_4KB 0x40 7388c2ecf20Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_MIN_PKT 0x80 7398c2ecf20Sopenharmony_ci 7408c2ecf20Sopenharmony_ci/* TX FIFO constants */ 7418c2ecf20Sopenharmony_ci#define MVPP22_TX_FIFO_DATA_SIZE_10KB 0xa 7428c2ecf20Sopenharmony_ci#define MVPP22_TX_FIFO_DATA_SIZE_3KB 0x3 7438c2ecf20Sopenharmony_ci#define MVPP2_TX_FIFO_THRESHOLD_MIN 256 7448c2ecf20Sopenharmony_ci#define MVPP2_TX_FIFO_THRESHOLD_10KB \ 7458c2ecf20Sopenharmony_ci (MVPP22_TX_FIFO_DATA_SIZE_10KB * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN) 7468c2ecf20Sopenharmony_ci#define MVPP2_TX_FIFO_THRESHOLD_3KB \ 7478c2ecf20Sopenharmony_ci (MVPP22_TX_FIFO_DATA_SIZE_3KB * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN) 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_ci/* RX buffer constants */ 7508c2ecf20Sopenharmony_ci#define MVPP2_SKB_SHINFO_SIZE \ 7518c2ecf20Sopenharmony_ci SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci#define MVPP2_RX_PKT_SIZE(mtu) \ 7548c2ecf20Sopenharmony_ci ALIGN((mtu) + MVPP2_MH_SIZE + MVPP2_VLAN_TAG_LEN + \ 7558c2ecf20Sopenharmony_ci ETH_HLEN + ETH_FCS_LEN, cache_line_size()) 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci#define MVPP2_RX_BUF_SIZE(pkt_size) ((pkt_size) + MVPP2_SKB_HEADROOM) 7588c2ecf20Sopenharmony_ci#define MVPP2_RX_TOTAL_SIZE(buf_size) ((buf_size) + MVPP2_SKB_SHINFO_SIZE) 7598c2ecf20Sopenharmony_ci#define MVPP2_RX_MAX_PKT_SIZE(total_size) \ 7608c2ecf20Sopenharmony_ci ((total_size) - MVPP2_SKB_HEADROOM - MVPP2_SKB_SHINFO_SIZE) 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci#define MVPP2_MAX_RX_BUF_SIZE (PAGE_SIZE - MVPP2_SKB_SHINFO_SIZE - MVPP2_SKB_HEADROOM) 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_ci#define MVPP2_BIT_TO_BYTE(bit) ((bit) / 8) 7658c2ecf20Sopenharmony_ci#define MVPP2_BIT_TO_WORD(bit) ((bit) / 32) 7668c2ecf20Sopenharmony_ci#define MVPP2_BIT_IN_WORD(bit) ((bit) % 32) 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci#define MVPP2_N_PRS_FLOWS 52 7698c2ecf20Sopenharmony_ci#define MVPP2_N_RFS_ENTRIES_PER_FLOW 4 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ci/* There are 7 supported high-level flows */ 7728c2ecf20Sopenharmony_ci#define MVPP2_N_RFS_RULES (MVPP2_N_RFS_ENTRIES_PER_FLOW * 7) 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci/* RSS constants */ 7758c2ecf20Sopenharmony_ci#define MVPP22_N_RSS_TABLES 8 7768c2ecf20Sopenharmony_ci#define MVPP22_RSS_TABLE_ENTRIES 32 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci/* IPv6 max L3 address size */ 7798c2ecf20Sopenharmony_ci#define MVPP2_MAX_L3_ADDR_SIZE 16 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_ci/* Port flags */ 7828c2ecf20Sopenharmony_ci#define MVPP2_F_LOOPBACK BIT(0) 7838c2ecf20Sopenharmony_ci#define MVPP2_F_DT_COMPAT BIT(1) 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci/* Marvell tag types */ 7868c2ecf20Sopenharmony_cienum mvpp2_tag_type { 7878c2ecf20Sopenharmony_ci MVPP2_TAG_TYPE_NONE = 0, 7888c2ecf20Sopenharmony_ci MVPP2_TAG_TYPE_MH = 1, 7898c2ecf20Sopenharmony_ci MVPP2_TAG_TYPE_DSA = 2, 7908c2ecf20Sopenharmony_ci MVPP2_TAG_TYPE_EDSA = 3, 7918c2ecf20Sopenharmony_ci MVPP2_TAG_TYPE_VLAN = 4, 7928c2ecf20Sopenharmony_ci MVPP2_TAG_TYPE_LAST = 5 7938c2ecf20Sopenharmony_ci}; 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci/* L2 cast enum */ 7968c2ecf20Sopenharmony_cienum mvpp2_prs_l2_cast { 7978c2ecf20Sopenharmony_ci MVPP2_PRS_L2_UNI_CAST, 7988c2ecf20Sopenharmony_ci MVPP2_PRS_L2_MULTI_CAST, 7998c2ecf20Sopenharmony_ci}; 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci/* L3 cast enum */ 8028c2ecf20Sopenharmony_cienum mvpp2_prs_l3_cast { 8038c2ecf20Sopenharmony_ci MVPP2_PRS_L3_UNI_CAST, 8048c2ecf20Sopenharmony_ci MVPP2_PRS_L3_MULTI_CAST, 8058c2ecf20Sopenharmony_ci MVPP2_PRS_L3_BROAD_CAST 8068c2ecf20Sopenharmony_ci}; 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci/* PTP descriptor constants. The low bits of the descriptor are stored 8098c2ecf20Sopenharmony_ci * separately from the high bits. 8108c2ecf20Sopenharmony_ci */ 8118c2ecf20Sopenharmony_ci#define MVPP22_PTP_DESC_MASK_LOW 0xfff 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci/* PTPAction */ 8148c2ecf20Sopenharmony_cienum mvpp22_ptp_action { 8158c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_NONE = 0, 8168c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_FORWARD = 1, 8178c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_CAPTURE = 3, 8188c2ecf20Sopenharmony_ci /* The following have not been verified */ 8198c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_ADDTIME = 4, 8208c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_ADDCORRECTEDTIME = 5, 8218c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREADDTIME = 6, 8228c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREADDCORRECTEDTIME = 7, 8238c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_ADDINGRESSTIME = 8, 8248c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREADDINGRESSTIME = 9, 8258c2ecf20Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREINGRESSTIME = 10, 8268c2ecf20Sopenharmony_ci}; 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ci/* PTPPacketFormat */ 8298c2ecf20Sopenharmony_cienum mvpp22_ptp_packet_format { 8308c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_PTPV2 = 0, 8318c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_PTPV1 = 1, 8328c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_Y1731 = 2, 8338c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_NTPTS = 3, 8348c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_NTPRX = 4, 8358c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_NTPTX = 5, 8368c2ecf20Sopenharmony_ci MVPP22_PTP_PKT_FMT_TWAMP = 6, 8378c2ecf20Sopenharmony_ci}; 8388c2ecf20Sopenharmony_ci 8398c2ecf20Sopenharmony_ci#define MVPP22_PTP_ACTION(x) (((x) & 15) << 0) 8408c2ecf20Sopenharmony_ci#define MVPP22_PTP_PACKETFORMAT(x) (((x) & 7) << 4) 8418c2ecf20Sopenharmony_ci#define MVPP22_PTP_MACTIMESTAMPINGEN BIT(11) 8428c2ecf20Sopenharmony_ci#define MVPP22_PTP_TIMESTAMPENTRYID(x) (((x) & 31) << 12) 8438c2ecf20Sopenharmony_ci#define MVPP22_PTP_TIMESTAMPQUEUESELECT BIT(18) 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci/* BM constants */ 8468c2ecf20Sopenharmony_ci#define MVPP2_BM_JUMBO_BUF_NUM 512 8478c2ecf20Sopenharmony_ci#define MVPP2_BM_LONG_BUF_NUM 1024 8488c2ecf20Sopenharmony_ci#define MVPP2_BM_SHORT_BUF_NUM 2048 8498c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_SIZE_MAX (16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4) 8508c2ecf20Sopenharmony_ci#define MVPP2_BM_POOL_PTR_ALIGN 128 8518c2ecf20Sopenharmony_ci#define MVPP2_BM_MAX_POOLS 8 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_ci/* BM cookie (32 bits) definition */ 8548c2ecf20Sopenharmony_ci#define MVPP2_BM_COOKIE_POOL_OFFS 8 8558c2ecf20Sopenharmony_ci#define MVPP2_BM_COOKIE_CPU_OFFS 24 8568c2ecf20Sopenharmony_ci 8578c2ecf20Sopenharmony_ci#define MVPP2_BM_SHORT_FRAME_SIZE 736 /* frame size 128 */ 8588c2ecf20Sopenharmony_ci#define MVPP2_BM_LONG_FRAME_SIZE 2240 /* frame size 1664 */ 8598c2ecf20Sopenharmony_ci#define MVPP2_BM_JUMBO_FRAME_SIZE 10432 /* frame size 9856 */ 8608c2ecf20Sopenharmony_ci/* BM short pool packet size 8618c2ecf20Sopenharmony_ci * These value assure that for SWF the total number 8628c2ecf20Sopenharmony_ci * of bytes allocated for each buffer will be 512 8638c2ecf20Sopenharmony_ci */ 8648c2ecf20Sopenharmony_ci#define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE) 8658c2ecf20Sopenharmony_ci#define MVPP2_BM_LONG_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_LONG_FRAME_SIZE) 8668c2ecf20Sopenharmony_ci#define MVPP2_BM_JUMBO_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_JUMBO_FRAME_SIZE) 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_ci#define MVPP21_ADDR_SPACE_SZ 0 8698c2ecf20Sopenharmony_ci#define MVPP22_ADDR_SPACE_SZ SZ_64K 8708c2ecf20Sopenharmony_ci 8718c2ecf20Sopenharmony_ci#define MVPP2_MAX_THREADS 9 8728c2ecf20Sopenharmony_ci#define MVPP2_MAX_QVECS MVPP2_MAX_THREADS 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci/* GMAC MIB Counters register definitions */ 8758c2ecf20Sopenharmony_ci#define MVPP21_MIB_COUNTERS_OFFSET 0x1000 8768c2ecf20Sopenharmony_ci#define MVPP21_MIB_COUNTERS_PORT_SZ 0x400 8778c2ecf20Sopenharmony_ci#define MVPP22_MIB_COUNTERS_OFFSET 0x0 8788c2ecf20Sopenharmony_ci#define MVPP22_MIB_COUNTERS_PORT_SZ 0x100 8798c2ecf20Sopenharmony_ci 8808c2ecf20Sopenharmony_ci#define MVPP2_MIB_GOOD_OCTETS_RCVD 0x0 8818c2ecf20Sopenharmony_ci#define MVPP2_MIB_BAD_OCTETS_RCVD 0x8 8828c2ecf20Sopenharmony_ci#define MVPP2_MIB_CRC_ERRORS_SENT 0xc 8838c2ecf20Sopenharmony_ci#define MVPP2_MIB_UNICAST_FRAMES_RCVD 0x10 8848c2ecf20Sopenharmony_ci#define MVPP2_MIB_BROADCAST_FRAMES_RCVD 0x18 8858c2ecf20Sopenharmony_ci#define MVPP2_MIB_MULTICAST_FRAMES_RCVD 0x1c 8868c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAMES_64_OCTETS 0x20 8878c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAMES_65_TO_127_OCTETS 0x24 8888c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAMES_128_TO_255_OCTETS 0x28 8898c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAMES_256_TO_511_OCTETS 0x2c 8908c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAMES_512_TO_1023_OCTETS 0x30 8918c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34 8928c2ecf20Sopenharmony_ci#define MVPP2_MIB_GOOD_OCTETS_SENT 0x38 8938c2ecf20Sopenharmony_ci#define MVPP2_MIB_UNICAST_FRAMES_SENT 0x40 8948c2ecf20Sopenharmony_ci#define MVPP2_MIB_MULTICAST_FRAMES_SENT 0x48 8958c2ecf20Sopenharmony_ci#define MVPP2_MIB_BROADCAST_FRAMES_SENT 0x4c 8968c2ecf20Sopenharmony_ci#define MVPP2_MIB_FC_SENT 0x54 8978c2ecf20Sopenharmony_ci#define MVPP2_MIB_FC_RCVD 0x58 8988c2ecf20Sopenharmony_ci#define MVPP2_MIB_RX_FIFO_OVERRUN 0x5c 8998c2ecf20Sopenharmony_ci#define MVPP2_MIB_UNDERSIZE_RCVD 0x60 9008c2ecf20Sopenharmony_ci#define MVPP2_MIB_FRAGMENTS_RCVD 0x64 9018c2ecf20Sopenharmony_ci#define MVPP2_MIB_OVERSIZE_RCVD 0x68 9028c2ecf20Sopenharmony_ci#define MVPP2_MIB_JABBER_RCVD 0x6c 9038c2ecf20Sopenharmony_ci#define MVPP2_MIB_MAC_RCV_ERROR 0x70 9048c2ecf20Sopenharmony_ci#define MVPP2_MIB_BAD_CRC_EVENT 0x74 9058c2ecf20Sopenharmony_ci#define MVPP2_MIB_COLLISION 0x78 9068c2ecf20Sopenharmony_ci#define MVPP2_MIB_LATE_COLLISION 0x7c 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci#define MVPP2_MIB_COUNTERS_STATS_DELAY (1 * HZ) 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci#define MVPP2_DESC_DMA_MASK DMA_BIT_MASK(40) 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci/* Buffer header info bits */ 9138c2ecf20Sopenharmony_ci#define MVPP2_B_HDR_INFO_MC_ID_MASK 0xfff 9148c2ecf20Sopenharmony_ci#define MVPP2_B_HDR_INFO_MC_ID(info) ((info) & MVPP2_B_HDR_INFO_MC_ID_MASK) 9158c2ecf20Sopenharmony_ci#define MVPP2_B_HDR_INFO_LAST_OFFS 12 9168c2ecf20Sopenharmony_ci#define MVPP2_B_HDR_INFO_LAST_MASK BIT(12) 9178c2ecf20Sopenharmony_ci#define MVPP2_B_HDR_INFO_IS_LAST(info) \ 9188c2ecf20Sopenharmony_ci (((info) & MVPP2_B_HDR_INFO_LAST_MASK) >> MVPP2_B_HDR_INFO_LAST_OFFS) 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_cistruct mvpp2_tai; 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci/* Definitions */ 9238c2ecf20Sopenharmony_cistruct mvpp2_dbgfs_entries; 9248c2ecf20Sopenharmony_ci 9258c2ecf20Sopenharmony_cistruct mvpp2_rss_table { 9268c2ecf20Sopenharmony_ci u32 indir[MVPP22_RSS_TABLE_ENTRIES]; 9278c2ecf20Sopenharmony_ci}; 9288c2ecf20Sopenharmony_ci 9298c2ecf20Sopenharmony_cistruct mvpp2_buff_hdr { 9308c2ecf20Sopenharmony_ci __le32 next_phys_addr; 9318c2ecf20Sopenharmony_ci __le32 next_dma_addr; 9328c2ecf20Sopenharmony_ci __le16 byte_count; 9338c2ecf20Sopenharmony_ci __le16 info; 9348c2ecf20Sopenharmony_ci __le16 reserved1; /* bm_qset (for future use, BM) */ 9358c2ecf20Sopenharmony_ci u8 next_phys_addr_high; 9368c2ecf20Sopenharmony_ci u8 next_dma_addr_high; 9378c2ecf20Sopenharmony_ci __le16 reserved2; 9388c2ecf20Sopenharmony_ci __le16 reserved3; 9398c2ecf20Sopenharmony_ci __le16 reserved4; 9408c2ecf20Sopenharmony_ci __le16 reserved5; 9418c2ecf20Sopenharmony_ci}; 9428c2ecf20Sopenharmony_ci 9438c2ecf20Sopenharmony_ci/* Shared Packet Processor resources */ 9448c2ecf20Sopenharmony_cistruct mvpp2 { 9458c2ecf20Sopenharmony_ci /* Shared registers' base addresses */ 9468c2ecf20Sopenharmony_ci void __iomem *lms_base; 9478c2ecf20Sopenharmony_ci void __iomem *iface_base; 9488c2ecf20Sopenharmony_ci 9498c2ecf20Sopenharmony_ci /* On PPv2.2, each "software thread" can access the base 9508c2ecf20Sopenharmony_ci * register through a separate address space, each 64 KB apart 9518c2ecf20Sopenharmony_ci * from each other. Typically, such address spaces will be 9528c2ecf20Sopenharmony_ci * used per CPU. 9538c2ecf20Sopenharmony_ci */ 9548c2ecf20Sopenharmony_ci void __iomem *swth_base[MVPP2_MAX_THREADS]; 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci /* On PPv2.2, some port control registers are located into the system 9578c2ecf20Sopenharmony_ci * controller space. These registers are accessible through a regmap. 9588c2ecf20Sopenharmony_ci */ 9598c2ecf20Sopenharmony_ci struct regmap *sysctrl_base; 9608c2ecf20Sopenharmony_ci 9618c2ecf20Sopenharmony_ci /* Common clocks */ 9628c2ecf20Sopenharmony_ci struct clk *pp_clk; 9638c2ecf20Sopenharmony_ci struct clk *gop_clk; 9648c2ecf20Sopenharmony_ci struct clk *mg_clk; 9658c2ecf20Sopenharmony_ci struct clk *mg_core_clk; 9668c2ecf20Sopenharmony_ci struct clk *axi_clk; 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_ci /* List of pointers to port structures */ 9698c2ecf20Sopenharmony_ci int port_count; 9708c2ecf20Sopenharmony_ci struct mvpp2_port *port_list[MVPP2_MAX_PORTS]; 9718c2ecf20Sopenharmony_ci struct mvpp2_tai *tai; 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ci /* Number of Tx threads used */ 9748c2ecf20Sopenharmony_ci unsigned int nthreads; 9758c2ecf20Sopenharmony_ci /* Map of threads needing locking */ 9768c2ecf20Sopenharmony_ci unsigned long lock_map; 9778c2ecf20Sopenharmony_ci 9788c2ecf20Sopenharmony_ci /* Aggregated TXQs */ 9798c2ecf20Sopenharmony_ci struct mvpp2_tx_queue *aggr_txqs; 9808c2ecf20Sopenharmony_ci 9818c2ecf20Sopenharmony_ci /* Are we using page_pool with per-cpu pools? */ 9828c2ecf20Sopenharmony_ci int percpu_pools; 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci /* BM pools */ 9858c2ecf20Sopenharmony_ci struct mvpp2_bm_pool *bm_pools; 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci /* PRS shadow table */ 9888c2ecf20Sopenharmony_ci struct mvpp2_prs_shadow *prs_shadow; 9898c2ecf20Sopenharmony_ci /* PRS auxiliary table for double vlan entries control */ 9908c2ecf20Sopenharmony_ci bool *prs_double_vlans; 9918c2ecf20Sopenharmony_ci 9928c2ecf20Sopenharmony_ci /* Tclk value */ 9938c2ecf20Sopenharmony_ci u32 tclk; 9948c2ecf20Sopenharmony_ci 9958c2ecf20Sopenharmony_ci /* HW version */ 9968c2ecf20Sopenharmony_ci enum { MVPP21, MVPP22 } hw_version; 9978c2ecf20Sopenharmony_ci 9988c2ecf20Sopenharmony_ci /* Maximum number of RXQs per port */ 9998c2ecf20Sopenharmony_ci unsigned int max_port_rxqs; 10008c2ecf20Sopenharmony_ci 10018c2ecf20Sopenharmony_ci /* Workqueue to gather hardware statistics */ 10028c2ecf20Sopenharmony_ci char queue_name[30]; 10038c2ecf20Sopenharmony_ci struct workqueue_struct *stats_queue; 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci /* Debugfs root entry */ 10068c2ecf20Sopenharmony_ci struct dentry *dbgfs_dir; 10078c2ecf20Sopenharmony_ci 10088c2ecf20Sopenharmony_ci /* Debugfs entries private data */ 10098c2ecf20Sopenharmony_ci struct mvpp2_dbgfs_entries *dbgfs_entries; 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_ci /* RSS Indirection tables */ 10128c2ecf20Sopenharmony_ci struct mvpp2_rss_table *rss_tables[MVPP22_N_RSS_TABLES]; 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_ci /* page_pool allocator */ 10158c2ecf20Sopenharmony_ci struct page_pool *page_pool[MVPP2_PORT_MAX_RXQ]; 10168c2ecf20Sopenharmony_ci}; 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_cistruct mvpp2_pcpu_stats { 10198c2ecf20Sopenharmony_ci struct u64_stats_sync syncp; 10208c2ecf20Sopenharmony_ci u64 rx_packets; 10218c2ecf20Sopenharmony_ci u64 rx_bytes; 10228c2ecf20Sopenharmony_ci u64 tx_packets; 10238c2ecf20Sopenharmony_ci u64 tx_bytes; 10248c2ecf20Sopenharmony_ci /* XDP */ 10258c2ecf20Sopenharmony_ci u64 xdp_redirect; 10268c2ecf20Sopenharmony_ci u64 xdp_pass; 10278c2ecf20Sopenharmony_ci u64 xdp_drop; 10288c2ecf20Sopenharmony_ci u64 xdp_xmit; 10298c2ecf20Sopenharmony_ci u64 xdp_xmit_err; 10308c2ecf20Sopenharmony_ci u64 xdp_tx; 10318c2ecf20Sopenharmony_ci u64 xdp_tx_err; 10328c2ecf20Sopenharmony_ci}; 10338c2ecf20Sopenharmony_ci 10348c2ecf20Sopenharmony_ci/* Per-CPU port control */ 10358c2ecf20Sopenharmony_cistruct mvpp2_port_pcpu { 10368c2ecf20Sopenharmony_ci struct hrtimer tx_done_timer; 10378c2ecf20Sopenharmony_ci struct net_device *dev; 10388c2ecf20Sopenharmony_ci bool timer_scheduled; 10398c2ecf20Sopenharmony_ci}; 10408c2ecf20Sopenharmony_ci 10418c2ecf20Sopenharmony_cistruct mvpp2_queue_vector { 10428c2ecf20Sopenharmony_ci int irq; 10438c2ecf20Sopenharmony_ci struct napi_struct napi; 10448c2ecf20Sopenharmony_ci enum { MVPP2_QUEUE_VECTOR_SHARED, MVPP2_QUEUE_VECTOR_PRIVATE } type; 10458c2ecf20Sopenharmony_ci int sw_thread_id; 10468c2ecf20Sopenharmony_ci u16 sw_thread_mask; 10478c2ecf20Sopenharmony_ci int first_rxq; 10488c2ecf20Sopenharmony_ci int nrxqs; 10498c2ecf20Sopenharmony_ci u32 pending_cause_rx; 10508c2ecf20Sopenharmony_ci struct mvpp2_port *port; 10518c2ecf20Sopenharmony_ci struct cpumask *mask; 10528c2ecf20Sopenharmony_ci}; 10538c2ecf20Sopenharmony_ci 10548c2ecf20Sopenharmony_ci/* Internal represention of a Flow Steering rule */ 10558c2ecf20Sopenharmony_cistruct mvpp2_rfs_rule { 10568c2ecf20Sopenharmony_ci /* Rule location inside the flow*/ 10578c2ecf20Sopenharmony_ci int loc; 10588c2ecf20Sopenharmony_ci 10598c2ecf20Sopenharmony_ci /* Flow type, such as TCP_V4_FLOW, IP6_FLOW, etc. */ 10608c2ecf20Sopenharmony_ci int flow_type; 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci /* Index of the C2 TCAM entry handling this rule */ 10638c2ecf20Sopenharmony_ci int c2_index; 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci /* Header fields that needs to be extracted to match this flow */ 10668c2ecf20Sopenharmony_ci u16 hek_fields; 10678c2ecf20Sopenharmony_ci 10688c2ecf20Sopenharmony_ci /* CLS engine : only c2 is supported for now. */ 10698c2ecf20Sopenharmony_ci u8 engine; 10708c2ecf20Sopenharmony_ci 10718c2ecf20Sopenharmony_ci /* TCAM key and mask for C2-based steering. These fields should be 10728c2ecf20Sopenharmony_ci * encapsulated in a union should we add more engines. 10738c2ecf20Sopenharmony_ci */ 10748c2ecf20Sopenharmony_ci u64 c2_tcam; 10758c2ecf20Sopenharmony_ci u64 c2_tcam_mask; 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_ci struct flow_rule *flow; 10788c2ecf20Sopenharmony_ci}; 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_cistruct mvpp2_ethtool_fs { 10818c2ecf20Sopenharmony_ci struct mvpp2_rfs_rule rule; 10828c2ecf20Sopenharmony_ci struct ethtool_rxnfc rxnfc; 10838c2ecf20Sopenharmony_ci}; 10848c2ecf20Sopenharmony_ci 10858c2ecf20Sopenharmony_cistruct mvpp2_hwtstamp_queue { 10868c2ecf20Sopenharmony_ci struct sk_buff *skb[32]; 10878c2ecf20Sopenharmony_ci u8 next; 10888c2ecf20Sopenharmony_ci}; 10898c2ecf20Sopenharmony_ci 10908c2ecf20Sopenharmony_cistruct mvpp2_port { 10918c2ecf20Sopenharmony_ci u8 id; 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_ci /* Index of the port from the "group of ports" complex point 10948c2ecf20Sopenharmony_ci * of view. This is specific to PPv2.2. 10958c2ecf20Sopenharmony_ci */ 10968c2ecf20Sopenharmony_ci int gop_id; 10978c2ecf20Sopenharmony_ci 10988c2ecf20Sopenharmony_ci int port_irq; 10998c2ecf20Sopenharmony_ci 11008c2ecf20Sopenharmony_ci struct mvpp2 *priv; 11018c2ecf20Sopenharmony_ci 11028c2ecf20Sopenharmony_ci /* Firmware node associated to the port */ 11038c2ecf20Sopenharmony_ci struct fwnode_handle *fwnode; 11048c2ecf20Sopenharmony_ci 11058c2ecf20Sopenharmony_ci /* Is a PHY always connected to the port */ 11068c2ecf20Sopenharmony_ci bool has_phy; 11078c2ecf20Sopenharmony_ci 11088c2ecf20Sopenharmony_ci /* Per-port registers' base address */ 11098c2ecf20Sopenharmony_ci void __iomem *base; 11108c2ecf20Sopenharmony_ci void __iomem *stats_base; 11118c2ecf20Sopenharmony_ci 11128c2ecf20Sopenharmony_ci struct mvpp2_rx_queue **rxqs; 11138c2ecf20Sopenharmony_ci unsigned int nrxqs; 11148c2ecf20Sopenharmony_ci struct mvpp2_tx_queue **txqs; 11158c2ecf20Sopenharmony_ci unsigned int ntxqs; 11168c2ecf20Sopenharmony_ci struct net_device *dev; 11178c2ecf20Sopenharmony_ci 11188c2ecf20Sopenharmony_ci struct bpf_prog *xdp_prog; 11198c2ecf20Sopenharmony_ci 11208c2ecf20Sopenharmony_ci int pkt_size; 11218c2ecf20Sopenharmony_ci 11228c2ecf20Sopenharmony_ci /* Per-CPU port control */ 11238c2ecf20Sopenharmony_ci struct mvpp2_port_pcpu __percpu *pcpu; 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_ci /* Protect the BM refills and the Tx paths when a thread is used on more 11268c2ecf20Sopenharmony_ci * than a single CPU. 11278c2ecf20Sopenharmony_ci */ 11288c2ecf20Sopenharmony_ci spinlock_t bm_lock[MVPP2_MAX_THREADS]; 11298c2ecf20Sopenharmony_ci spinlock_t tx_lock[MVPP2_MAX_THREADS]; 11308c2ecf20Sopenharmony_ci 11318c2ecf20Sopenharmony_ci /* Flags */ 11328c2ecf20Sopenharmony_ci unsigned long flags; 11338c2ecf20Sopenharmony_ci 11348c2ecf20Sopenharmony_ci u16 tx_ring_size; 11358c2ecf20Sopenharmony_ci u16 rx_ring_size; 11368c2ecf20Sopenharmony_ci struct mvpp2_pcpu_stats __percpu *stats; 11378c2ecf20Sopenharmony_ci u64 *ethtool_stats; 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_ci unsigned long state; 11408c2ecf20Sopenharmony_ci 11418c2ecf20Sopenharmony_ci /* Per-port work and its lock to gather hardware statistics */ 11428c2ecf20Sopenharmony_ci struct mutex gather_stats_lock; 11438c2ecf20Sopenharmony_ci struct delayed_work stats_work; 11448c2ecf20Sopenharmony_ci 11458c2ecf20Sopenharmony_ci struct device_node *of_node; 11468c2ecf20Sopenharmony_ci 11478c2ecf20Sopenharmony_ci phy_interface_t phy_interface; 11488c2ecf20Sopenharmony_ci struct phylink *phylink; 11498c2ecf20Sopenharmony_ci struct phylink_config phylink_config; 11508c2ecf20Sopenharmony_ci struct phylink_pcs phylink_pcs; 11518c2ecf20Sopenharmony_ci struct phy *comphy; 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci struct mvpp2_bm_pool *pool_long; 11548c2ecf20Sopenharmony_ci struct mvpp2_bm_pool *pool_short; 11558c2ecf20Sopenharmony_ci 11568c2ecf20Sopenharmony_ci /* Index of first port's physical RXQ */ 11578c2ecf20Sopenharmony_ci u8 first_rxq; 11588c2ecf20Sopenharmony_ci 11598c2ecf20Sopenharmony_ci struct mvpp2_queue_vector qvecs[MVPP2_MAX_QVECS]; 11608c2ecf20Sopenharmony_ci unsigned int nqvecs; 11618c2ecf20Sopenharmony_ci bool has_tx_irqs; 11628c2ecf20Sopenharmony_ci 11638c2ecf20Sopenharmony_ci u32 tx_time_coal; 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_ci /* List of steering rules active on that port */ 11668c2ecf20Sopenharmony_ci struct mvpp2_ethtool_fs *rfs_rules[MVPP2_N_RFS_ENTRIES_PER_FLOW]; 11678c2ecf20Sopenharmony_ci int n_rfs_rules; 11688c2ecf20Sopenharmony_ci 11698c2ecf20Sopenharmony_ci /* Each port has its own view of the rss contexts, so that it can number 11708c2ecf20Sopenharmony_ci * them from 0 11718c2ecf20Sopenharmony_ci */ 11728c2ecf20Sopenharmony_ci int rss_ctx[MVPP22_N_RSS_TABLES]; 11738c2ecf20Sopenharmony_ci 11748c2ecf20Sopenharmony_ci bool hwtstamp; 11758c2ecf20Sopenharmony_ci bool rx_hwtstamp; 11768c2ecf20Sopenharmony_ci enum hwtstamp_tx_types tx_hwtstamp_type; 11778c2ecf20Sopenharmony_ci struct mvpp2_hwtstamp_queue tx_hwtstamp_queue[2]; 11788c2ecf20Sopenharmony_ci}; 11798c2ecf20Sopenharmony_ci 11808c2ecf20Sopenharmony_ci/* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the 11818c2ecf20Sopenharmony_ci * layout of the transmit and reception DMA descriptors, and their 11828c2ecf20Sopenharmony_ci * layout is therefore defined by the hardware design 11838c2ecf20Sopenharmony_ci */ 11848c2ecf20Sopenharmony_ci 11858c2ecf20Sopenharmony_ci#define MVPP2_TXD_L3_OFF_SHIFT 0 11868c2ecf20Sopenharmony_ci#define MVPP2_TXD_IP_HLEN_SHIFT 8 11878c2ecf20Sopenharmony_ci#define MVPP2_TXD_L4_CSUM_FRAG BIT(13) 11888c2ecf20Sopenharmony_ci#define MVPP2_TXD_L4_CSUM_NOT BIT(14) 11898c2ecf20Sopenharmony_ci#define MVPP2_TXD_IP_CSUM_DISABLE BIT(15) 11908c2ecf20Sopenharmony_ci#define MVPP2_TXD_PADDING_DISABLE BIT(23) 11918c2ecf20Sopenharmony_ci#define MVPP2_TXD_L4_UDP BIT(24) 11928c2ecf20Sopenharmony_ci#define MVPP2_TXD_L3_IP6 BIT(26) 11938c2ecf20Sopenharmony_ci#define MVPP2_TXD_L_DESC BIT(28) 11948c2ecf20Sopenharmony_ci#define MVPP2_TXD_F_DESC BIT(29) 11958c2ecf20Sopenharmony_ci 11968c2ecf20Sopenharmony_ci#define MVPP2_RXD_ERR_SUMMARY BIT(15) 11978c2ecf20Sopenharmony_ci#define MVPP2_RXD_ERR_CODE_MASK (BIT(13) | BIT(14)) 11988c2ecf20Sopenharmony_ci#define MVPP2_RXD_ERR_CRC 0x0 11998c2ecf20Sopenharmony_ci#define MVPP2_RXD_ERR_OVERRUN BIT(13) 12008c2ecf20Sopenharmony_ci#define MVPP2_RXD_ERR_RESOURCE (BIT(13) | BIT(14)) 12018c2ecf20Sopenharmony_ci#define MVPP2_RXD_BM_POOL_ID_OFFS 16 12028c2ecf20Sopenharmony_ci#define MVPP2_RXD_BM_POOL_ID_MASK (BIT(16) | BIT(17) | BIT(18)) 12038c2ecf20Sopenharmony_ci#define MVPP2_RXD_HWF_SYNC BIT(21) 12048c2ecf20Sopenharmony_ci#define MVPP2_RXD_L4_CSUM_OK BIT(22) 12058c2ecf20Sopenharmony_ci#define MVPP2_RXD_IP4_HEADER_ERR BIT(24) 12068c2ecf20Sopenharmony_ci#define MVPP2_RXD_L4_TCP BIT(25) 12078c2ecf20Sopenharmony_ci#define MVPP2_RXD_L4_UDP BIT(26) 12088c2ecf20Sopenharmony_ci#define MVPP2_RXD_L3_IP4 BIT(28) 12098c2ecf20Sopenharmony_ci#define MVPP2_RXD_L3_IP6 BIT(30) 12108c2ecf20Sopenharmony_ci#define MVPP2_RXD_BUF_HDR BIT(31) 12118c2ecf20Sopenharmony_ci 12128c2ecf20Sopenharmony_ci/* HW TX descriptor for PPv2.1 */ 12138c2ecf20Sopenharmony_cistruct mvpp21_tx_desc { 12148c2ecf20Sopenharmony_ci __le32 command; /* Options used by HW for packet transmitting.*/ 12158c2ecf20Sopenharmony_ci u8 packet_offset; /* the offset from the buffer beginning */ 12168c2ecf20Sopenharmony_ci u8 phys_txq; /* destination queue ID */ 12178c2ecf20Sopenharmony_ci __le16 data_size; /* data size of transmitted packet in bytes */ 12188c2ecf20Sopenharmony_ci __le32 buf_dma_addr; /* physical addr of transmitted buffer */ 12198c2ecf20Sopenharmony_ci __le32 buf_cookie; /* cookie for access to TX buffer in tx path */ 12208c2ecf20Sopenharmony_ci __le32 reserved1[3]; /* hw_cmd (for future use, BM, PON, PNC) */ 12218c2ecf20Sopenharmony_ci __le32 reserved2; /* reserved (for future use) */ 12228c2ecf20Sopenharmony_ci}; 12238c2ecf20Sopenharmony_ci 12248c2ecf20Sopenharmony_ci/* HW RX descriptor for PPv2.1 */ 12258c2ecf20Sopenharmony_cistruct mvpp21_rx_desc { 12268c2ecf20Sopenharmony_ci __le32 status; /* info about received packet */ 12278c2ecf20Sopenharmony_ci __le16 reserved1; /* parser_info (for future use, PnC) */ 12288c2ecf20Sopenharmony_ci __le16 data_size; /* size of received packet in bytes */ 12298c2ecf20Sopenharmony_ci __le32 buf_dma_addr; /* physical address of the buffer */ 12308c2ecf20Sopenharmony_ci __le32 buf_cookie; /* cookie for access to RX buffer in rx path */ 12318c2ecf20Sopenharmony_ci __le16 reserved2; /* gem_port_id (for future use, PON) */ 12328c2ecf20Sopenharmony_ci __le16 reserved3; /* csum_l4 (for future use, PnC) */ 12338c2ecf20Sopenharmony_ci u8 reserved4; /* bm_qset (for future use, BM) */ 12348c2ecf20Sopenharmony_ci u8 reserved5; 12358c2ecf20Sopenharmony_ci __le16 reserved6; /* classify_info (for future use, PnC) */ 12368c2ecf20Sopenharmony_ci __le32 reserved7; /* flow_id (for future use, PnC) */ 12378c2ecf20Sopenharmony_ci __le32 reserved8; 12388c2ecf20Sopenharmony_ci}; 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci/* HW TX descriptor for PPv2.2 */ 12418c2ecf20Sopenharmony_cistruct mvpp22_tx_desc { 12428c2ecf20Sopenharmony_ci __le32 command; 12438c2ecf20Sopenharmony_ci u8 packet_offset; 12448c2ecf20Sopenharmony_ci u8 phys_txq; 12458c2ecf20Sopenharmony_ci __le16 data_size; 12468c2ecf20Sopenharmony_ci __le32 ptp_descriptor; 12478c2ecf20Sopenharmony_ci __le32 reserved2; 12488c2ecf20Sopenharmony_ci __le64 buf_dma_addr_ptp; 12498c2ecf20Sopenharmony_ci __le64 buf_cookie_misc; 12508c2ecf20Sopenharmony_ci}; 12518c2ecf20Sopenharmony_ci 12528c2ecf20Sopenharmony_ci/* HW RX descriptor for PPv2.2 */ 12538c2ecf20Sopenharmony_cistruct mvpp22_rx_desc { 12548c2ecf20Sopenharmony_ci __le32 status; 12558c2ecf20Sopenharmony_ci __le16 reserved1; 12568c2ecf20Sopenharmony_ci __le16 data_size; 12578c2ecf20Sopenharmony_ci __le32 reserved2; 12588c2ecf20Sopenharmony_ci __le32 timestamp; 12598c2ecf20Sopenharmony_ci __le64 buf_dma_addr_key_hash; 12608c2ecf20Sopenharmony_ci __le64 buf_cookie_misc; 12618c2ecf20Sopenharmony_ci}; 12628c2ecf20Sopenharmony_ci 12638c2ecf20Sopenharmony_ci/* Opaque type used by the driver to manipulate the HW TX and RX 12648c2ecf20Sopenharmony_ci * descriptors 12658c2ecf20Sopenharmony_ci */ 12668c2ecf20Sopenharmony_cistruct mvpp2_tx_desc { 12678c2ecf20Sopenharmony_ci union { 12688c2ecf20Sopenharmony_ci struct mvpp21_tx_desc pp21; 12698c2ecf20Sopenharmony_ci struct mvpp22_tx_desc pp22; 12708c2ecf20Sopenharmony_ci }; 12718c2ecf20Sopenharmony_ci}; 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_cistruct mvpp2_rx_desc { 12748c2ecf20Sopenharmony_ci union { 12758c2ecf20Sopenharmony_ci struct mvpp21_rx_desc pp21; 12768c2ecf20Sopenharmony_ci struct mvpp22_rx_desc pp22; 12778c2ecf20Sopenharmony_ci }; 12788c2ecf20Sopenharmony_ci}; 12798c2ecf20Sopenharmony_ci 12808c2ecf20Sopenharmony_cienum mvpp2_tx_buf_type { 12818c2ecf20Sopenharmony_ci MVPP2_TYPE_SKB, 12828c2ecf20Sopenharmony_ci MVPP2_TYPE_XDP_TX, 12838c2ecf20Sopenharmony_ci MVPP2_TYPE_XDP_NDO, 12848c2ecf20Sopenharmony_ci}; 12858c2ecf20Sopenharmony_ci 12868c2ecf20Sopenharmony_cistruct mvpp2_txq_pcpu_buf { 12878c2ecf20Sopenharmony_ci enum mvpp2_tx_buf_type type; 12888c2ecf20Sopenharmony_ci 12898c2ecf20Sopenharmony_ci /* Transmitted SKB */ 12908c2ecf20Sopenharmony_ci union { 12918c2ecf20Sopenharmony_ci struct xdp_frame *xdpf; 12928c2ecf20Sopenharmony_ci struct sk_buff *skb; 12938c2ecf20Sopenharmony_ci }; 12948c2ecf20Sopenharmony_ci 12958c2ecf20Sopenharmony_ci /* Physical address of transmitted buffer */ 12968c2ecf20Sopenharmony_ci dma_addr_t dma; 12978c2ecf20Sopenharmony_ci 12988c2ecf20Sopenharmony_ci /* Size transmitted */ 12998c2ecf20Sopenharmony_ci size_t size; 13008c2ecf20Sopenharmony_ci}; 13018c2ecf20Sopenharmony_ci 13028c2ecf20Sopenharmony_ci/* Per-CPU Tx queue control */ 13038c2ecf20Sopenharmony_cistruct mvpp2_txq_pcpu { 13048c2ecf20Sopenharmony_ci unsigned int thread; 13058c2ecf20Sopenharmony_ci 13068c2ecf20Sopenharmony_ci /* Number of Tx DMA descriptors in the descriptor ring */ 13078c2ecf20Sopenharmony_ci int size; 13088c2ecf20Sopenharmony_ci 13098c2ecf20Sopenharmony_ci /* Number of currently used Tx DMA descriptor in the 13108c2ecf20Sopenharmony_ci * descriptor ring 13118c2ecf20Sopenharmony_ci */ 13128c2ecf20Sopenharmony_ci int count; 13138c2ecf20Sopenharmony_ci 13148c2ecf20Sopenharmony_ci int wake_threshold; 13158c2ecf20Sopenharmony_ci int stop_threshold; 13168c2ecf20Sopenharmony_ci 13178c2ecf20Sopenharmony_ci /* Number of Tx DMA descriptors reserved for each CPU */ 13188c2ecf20Sopenharmony_ci int reserved_num; 13198c2ecf20Sopenharmony_ci 13208c2ecf20Sopenharmony_ci /* Infos about transmitted buffers */ 13218c2ecf20Sopenharmony_ci struct mvpp2_txq_pcpu_buf *buffs; 13228c2ecf20Sopenharmony_ci 13238c2ecf20Sopenharmony_ci /* Index of last TX DMA descriptor that was inserted */ 13248c2ecf20Sopenharmony_ci int txq_put_index; 13258c2ecf20Sopenharmony_ci 13268c2ecf20Sopenharmony_ci /* Index of the TX DMA descriptor to be cleaned up */ 13278c2ecf20Sopenharmony_ci int txq_get_index; 13288c2ecf20Sopenharmony_ci 13298c2ecf20Sopenharmony_ci /* DMA buffer for TSO headers */ 13308c2ecf20Sopenharmony_ci char *tso_headers; 13318c2ecf20Sopenharmony_ci dma_addr_t tso_headers_dma; 13328c2ecf20Sopenharmony_ci}; 13338c2ecf20Sopenharmony_ci 13348c2ecf20Sopenharmony_cistruct mvpp2_tx_queue { 13358c2ecf20Sopenharmony_ci /* Physical number of this Tx queue */ 13368c2ecf20Sopenharmony_ci u8 id; 13378c2ecf20Sopenharmony_ci 13388c2ecf20Sopenharmony_ci /* Logical number of this Tx queue */ 13398c2ecf20Sopenharmony_ci u8 log_id; 13408c2ecf20Sopenharmony_ci 13418c2ecf20Sopenharmony_ci /* Number of Tx DMA descriptors in the descriptor ring */ 13428c2ecf20Sopenharmony_ci int size; 13438c2ecf20Sopenharmony_ci 13448c2ecf20Sopenharmony_ci /* Number of currently used Tx DMA descriptor in the descriptor ring */ 13458c2ecf20Sopenharmony_ci int count; 13468c2ecf20Sopenharmony_ci 13478c2ecf20Sopenharmony_ci /* Per-CPU control of physical Tx queues */ 13488c2ecf20Sopenharmony_ci struct mvpp2_txq_pcpu __percpu *pcpu; 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_ci u32 done_pkts_coal; 13518c2ecf20Sopenharmony_ci 13528c2ecf20Sopenharmony_ci /* Virtual address of thex Tx DMA descriptors array */ 13538c2ecf20Sopenharmony_ci struct mvpp2_tx_desc *descs; 13548c2ecf20Sopenharmony_ci 13558c2ecf20Sopenharmony_ci /* DMA address of the Tx DMA descriptors array */ 13568c2ecf20Sopenharmony_ci dma_addr_t descs_dma; 13578c2ecf20Sopenharmony_ci 13588c2ecf20Sopenharmony_ci /* Index of the last Tx DMA descriptor */ 13598c2ecf20Sopenharmony_ci int last_desc; 13608c2ecf20Sopenharmony_ci 13618c2ecf20Sopenharmony_ci /* Index of the next Tx DMA descriptor to process */ 13628c2ecf20Sopenharmony_ci int next_desc_to_proc; 13638c2ecf20Sopenharmony_ci}; 13648c2ecf20Sopenharmony_ci 13658c2ecf20Sopenharmony_cistruct mvpp2_rx_queue { 13668c2ecf20Sopenharmony_ci /* RX queue number, in the range 0-31 for physical RXQs */ 13678c2ecf20Sopenharmony_ci u8 id; 13688c2ecf20Sopenharmony_ci 13698c2ecf20Sopenharmony_ci /* Num of rx descriptors in the rx descriptor ring */ 13708c2ecf20Sopenharmony_ci int size; 13718c2ecf20Sopenharmony_ci 13728c2ecf20Sopenharmony_ci u32 pkts_coal; 13738c2ecf20Sopenharmony_ci u32 time_coal; 13748c2ecf20Sopenharmony_ci 13758c2ecf20Sopenharmony_ci /* Virtual address of the RX DMA descriptors array */ 13768c2ecf20Sopenharmony_ci struct mvpp2_rx_desc *descs; 13778c2ecf20Sopenharmony_ci 13788c2ecf20Sopenharmony_ci /* DMA address of the RX DMA descriptors array */ 13798c2ecf20Sopenharmony_ci dma_addr_t descs_dma; 13808c2ecf20Sopenharmony_ci 13818c2ecf20Sopenharmony_ci /* Index of the last RX DMA descriptor */ 13828c2ecf20Sopenharmony_ci int last_desc; 13838c2ecf20Sopenharmony_ci 13848c2ecf20Sopenharmony_ci /* Index of the next RX DMA descriptor to process */ 13858c2ecf20Sopenharmony_ci int next_desc_to_proc; 13868c2ecf20Sopenharmony_ci 13878c2ecf20Sopenharmony_ci /* ID of port to which physical RXQ is mapped */ 13888c2ecf20Sopenharmony_ci int port; 13898c2ecf20Sopenharmony_ci 13908c2ecf20Sopenharmony_ci /* Port's logic RXQ number to which physical RXQ is mapped */ 13918c2ecf20Sopenharmony_ci int logic_rxq; 13928c2ecf20Sopenharmony_ci 13938c2ecf20Sopenharmony_ci /* XDP memory accounting */ 13948c2ecf20Sopenharmony_ci struct xdp_rxq_info xdp_rxq_short; 13958c2ecf20Sopenharmony_ci struct xdp_rxq_info xdp_rxq_long; 13968c2ecf20Sopenharmony_ci}; 13978c2ecf20Sopenharmony_ci 13988c2ecf20Sopenharmony_cistruct mvpp2_bm_pool { 13998c2ecf20Sopenharmony_ci /* Pool number in the range 0-7 */ 14008c2ecf20Sopenharmony_ci int id; 14018c2ecf20Sopenharmony_ci 14028c2ecf20Sopenharmony_ci /* Buffer Pointers Pool External (BPPE) size */ 14038c2ecf20Sopenharmony_ci int size; 14048c2ecf20Sopenharmony_ci /* BPPE size in bytes */ 14058c2ecf20Sopenharmony_ci int size_bytes; 14068c2ecf20Sopenharmony_ci /* Number of buffers for this pool */ 14078c2ecf20Sopenharmony_ci int buf_num; 14088c2ecf20Sopenharmony_ci /* Pool buffer size */ 14098c2ecf20Sopenharmony_ci int buf_size; 14108c2ecf20Sopenharmony_ci /* Packet size */ 14118c2ecf20Sopenharmony_ci int pkt_size; 14128c2ecf20Sopenharmony_ci int frag_size; 14138c2ecf20Sopenharmony_ci 14148c2ecf20Sopenharmony_ci /* BPPE virtual base address */ 14158c2ecf20Sopenharmony_ci u32 *virt_addr; 14168c2ecf20Sopenharmony_ci /* BPPE DMA base address */ 14178c2ecf20Sopenharmony_ci dma_addr_t dma_addr; 14188c2ecf20Sopenharmony_ci 14198c2ecf20Sopenharmony_ci /* Ports using BM pool */ 14208c2ecf20Sopenharmony_ci u32 port_map; 14218c2ecf20Sopenharmony_ci}; 14228c2ecf20Sopenharmony_ci 14238c2ecf20Sopenharmony_ci#define IS_TSO_HEADER(txq_pcpu, addr) \ 14248c2ecf20Sopenharmony_ci ((addr) >= (txq_pcpu)->tso_headers_dma && \ 14258c2ecf20Sopenharmony_ci (addr) < (txq_pcpu)->tso_headers_dma + \ 14268c2ecf20Sopenharmony_ci (txq_pcpu)->size * TSO_HEADER_SIZE) 14278c2ecf20Sopenharmony_ci 14288c2ecf20Sopenharmony_ci#define MVPP2_DRIVER_NAME "mvpp2" 14298c2ecf20Sopenharmony_ci#define MVPP2_DRIVER_VERSION "1.0" 14308c2ecf20Sopenharmony_ci 14318c2ecf20Sopenharmony_civoid mvpp2_write(struct mvpp2 *priv, u32 offset, u32 data); 14328c2ecf20Sopenharmony_ciu32 mvpp2_read(struct mvpp2 *priv, u32 offset); 14338c2ecf20Sopenharmony_ci 14348c2ecf20Sopenharmony_civoid mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name); 14358c2ecf20Sopenharmony_ci 14368c2ecf20Sopenharmony_civoid mvpp2_dbgfs_cleanup(struct mvpp2 *priv); 14378c2ecf20Sopenharmony_civoid mvpp2_dbgfs_exit(void); 14388c2ecf20Sopenharmony_ci 14398c2ecf20Sopenharmony_ci#ifdef CONFIG_MVPP2_PTP 14408c2ecf20Sopenharmony_ciint mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv); 14418c2ecf20Sopenharmony_civoid mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp, 14428c2ecf20Sopenharmony_ci struct skb_shared_hwtstamps *hwtstamp); 14438c2ecf20Sopenharmony_civoid mvpp22_tai_start(struct mvpp2_tai *tai); 14448c2ecf20Sopenharmony_civoid mvpp22_tai_stop(struct mvpp2_tai *tai); 14458c2ecf20Sopenharmony_ciint mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai); 14468c2ecf20Sopenharmony_ci#else 14478c2ecf20Sopenharmony_cistatic inline int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv) 14488c2ecf20Sopenharmony_ci{ 14498c2ecf20Sopenharmony_ci return 0; 14508c2ecf20Sopenharmony_ci} 14518c2ecf20Sopenharmony_cistatic inline void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp, 14528c2ecf20Sopenharmony_ci struct skb_shared_hwtstamps *hwtstamp) 14538c2ecf20Sopenharmony_ci{ 14548c2ecf20Sopenharmony_ci} 14558c2ecf20Sopenharmony_cistatic inline void mvpp22_tai_start(struct mvpp2_tai *tai) 14568c2ecf20Sopenharmony_ci{ 14578c2ecf20Sopenharmony_ci} 14588c2ecf20Sopenharmony_cistatic inline void mvpp22_tai_stop(struct mvpp2_tai *tai) 14598c2ecf20Sopenharmony_ci{ 14608c2ecf20Sopenharmony_ci} 14618c2ecf20Sopenharmony_cistatic inline int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai) 14628c2ecf20Sopenharmony_ci{ 14638c2ecf20Sopenharmony_ci return -1; 14648c2ecf20Sopenharmony_ci} 14658c2ecf20Sopenharmony_ci#endif 14668c2ecf20Sopenharmony_ci 14678c2ecf20Sopenharmony_cistatic inline bool mvpp22_rx_hwtstamping(struct mvpp2_port *port) 14688c2ecf20Sopenharmony_ci{ 14698c2ecf20Sopenharmony_ci return IS_ENABLED(CONFIG_MVPP2_PTP) && port->rx_hwtstamp; 14708c2ecf20Sopenharmony_ci} 14718c2ecf20Sopenharmony_ci#endif 1472