18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * drivers/net/ethernet/rocker/rocker_hw.h - Rocker switch device driver 48c2ecf20Sopenharmony_ci * Copyright (c) 2014-2016 Jiri Pirko <jiri@mellanox.com> 58c2ecf20Sopenharmony_ci * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _ROCKER_HW_H 98c2ecf20Sopenharmony_ci#define _ROCKER_HW_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* Return codes */ 148c2ecf20Sopenharmony_cienum { 158c2ecf20Sopenharmony_ci ROCKER_OK = 0, 168c2ecf20Sopenharmony_ci ROCKER_ENOENT = 2, 178c2ecf20Sopenharmony_ci ROCKER_ENXIO = 6, 188c2ecf20Sopenharmony_ci ROCKER_ENOMEM = 12, 198c2ecf20Sopenharmony_ci ROCKER_EEXIST = 17, 208c2ecf20Sopenharmony_ci ROCKER_EINVAL = 22, 218c2ecf20Sopenharmony_ci ROCKER_EMSGSIZE = 90, 228c2ecf20Sopenharmony_ci ROCKER_ENOTSUP = 95, 238c2ecf20Sopenharmony_ci ROCKER_ENOBUFS = 105, 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define ROCKER_FP_PORTS_MAX 62 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_REDHAT_ROCKER 0x0006 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define ROCKER_PCI_BAR0_SIZE 0x2000 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* MSI-X vectors */ 338c2ecf20Sopenharmony_cienum { 348c2ecf20Sopenharmony_ci ROCKER_MSIX_VEC_CMD, 358c2ecf20Sopenharmony_ci ROCKER_MSIX_VEC_EVENT, 368c2ecf20Sopenharmony_ci ROCKER_MSIX_VEC_TEST, 378c2ecf20Sopenharmony_ci ROCKER_MSIX_VEC_RESERVED0, 388c2ecf20Sopenharmony_ci __ROCKER_MSIX_VEC_TX, 398c2ecf20Sopenharmony_ci __ROCKER_MSIX_VEC_RX, 408c2ecf20Sopenharmony_ci#define ROCKER_MSIX_VEC_TX(port) \ 418c2ecf20Sopenharmony_ci (__ROCKER_MSIX_VEC_TX + ((port) * 2)) 428c2ecf20Sopenharmony_ci#define ROCKER_MSIX_VEC_RX(port) \ 438c2ecf20Sopenharmony_ci (__ROCKER_MSIX_VEC_RX + ((port) * 2)) 448c2ecf20Sopenharmony_ci#define ROCKER_MSIX_VEC_COUNT(portcnt) \ 458c2ecf20Sopenharmony_ci (ROCKER_MSIX_VEC_RX((portcnt - 1)) + 1) 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Rocker bogus registers */ 498c2ecf20Sopenharmony_ci#define ROCKER_BOGUS_REG0 0x0000 508c2ecf20Sopenharmony_ci#define ROCKER_BOGUS_REG1 0x0004 518c2ecf20Sopenharmony_ci#define ROCKER_BOGUS_REG2 0x0008 528c2ecf20Sopenharmony_ci#define ROCKER_BOGUS_REG3 0x000c 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* Rocker test registers */ 558c2ecf20Sopenharmony_ci#define ROCKER_TEST_REG 0x0010 568c2ecf20Sopenharmony_ci#define ROCKER_TEST_REG64 0x0018 /* 8-byte */ 578c2ecf20Sopenharmony_ci#define ROCKER_TEST_IRQ 0x0020 588c2ecf20Sopenharmony_ci#define ROCKER_TEST_DMA_ADDR 0x0028 /* 8-byte */ 598c2ecf20Sopenharmony_ci#define ROCKER_TEST_DMA_SIZE 0x0030 608c2ecf20Sopenharmony_ci#define ROCKER_TEST_DMA_CTRL 0x0034 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* Rocker test register ctrl */ 638c2ecf20Sopenharmony_ci#define ROCKER_TEST_DMA_CTRL_CLEAR BIT(0) 648c2ecf20Sopenharmony_ci#define ROCKER_TEST_DMA_CTRL_FILL BIT(1) 658c2ecf20Sopenharmony_ci#define ROCKER_TEST_DMA_CTRL_INVERT BIT(2) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* Rocker DMA ring register offsets */ 688c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_ADDR(x) (0x1000 + (x) * 32) /* 8-byte */ 698c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_SIZE(x) (0x1008 + (x) * 32) 708c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_HEAD(x) (0x100c + (x) * 32) 718c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_TAIL(x) (0x1010 + (x) * 32) 728c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_CTRL(x) (0x1014 + (x) * 32) 738c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_CREDITS(x) (0x1018 + (x) * 32) 748c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_RES1(x) (0x101c + (x) * 32) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Rocker dma ctrl register bits */ 778c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_CTRL_RESET BIT(0) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Rocker DMA ring types */ 808c2ecf20Sopenharmony_cienum rocker_dma_type { 818c2ecf20Sopenharmony_ci ROCKER_DMA_CMD, 828c2ecf20Sopenharmony_ci ROCKER_DMA_EVENT, 838c2ecf20Sopenharmony_ci __ROCKER_DMA_TX, 848c2ecf20Sopenharmony_ci __ROCKER_DMA_RX, 858c2ecf20Sopenharmony_ci#define ROCKER_DMA_TX(port) (__ROCKER_DMA_TX + (port) * 2) 868c2ecf20Sopenharmony_ci#define ROCKER_DMA_RX(port) (__ROCKER_DMA_RX + (port) * 2) 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* Rocker DMA ring size limits and default sizes */ 908c2ecf20Sopenharmony_ci#define ROCKER_DMA_SIZE_MIN 2ul 918c2ecf20Sopenharmony_ci#define ROCKER_DMA_SIZE_MAX 65536ul 928c2ecf20Sopenharmony_ci#define ROCKER_DMA_CMD_DEFAULT_SIZE 32ul 938c2ecf20Sopenharmony_ci#define ROCKER_DMA_EVENT_DEFAULT_SIZE 32ul 948c2ecf20Sopenharmony_ci#define ROCKER_DMA_TX_DEFAULT_SIZE 64ul 958c2ecf20Sopenharmony_ci#define ROCKER_DMA_TX_DESC_SIZE 256 968c2ecf20Sopenharmony_ci#define ROCKER_DMA_RX_DEFAULT_SIZE 64ul 978c2ecf20Sopenharmony_ci#define ROCKER_DMA_RX_DESC_SIZE 256 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* Rocker DMA descriptor struct */ 1008c2ecf20Sopenharmony_cistruct rocker_desc { 1018c2ecf20Sopenharmony_ci u64 buf_addr; 1028c2ecf20Sopenharmony_ci u64 cookie; 1038c2ecf20Sopenharmony_ci u16 buf_size; 1048c2ecf20Sopenharmony_ci u16 tlv_size; 1058c2ecf20Sopenharmony_ci u16 resv[5]; 1068c2ecf20Sopenharmony_ci u16 comp_err; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define ROCKER_DMA_DESC_COMP_ERR_GEN BIT(15) 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* Rocker DMA TLV struct */ 1128c2ecf20Sopenharmony_cistruct rocker_tlv { 1138c2ecf20Sopenharmony_ci u32 type; 1148c2ecf20Sopenharmony_ci u16 len; 1158c2ecf20Sopenharmony_ci}; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* TLVs */ 1188c2ecf20Sopenharmony_cienum { 1198c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_UNSPEC, 1208c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE, /* u16 */ 1218c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_INFO, /* nest */ 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci __ROCKER_TLV_CMD_MAX, 1248c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_MAX = __ROCKER_TLV_CMD_MAX - 1, 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cienum { 1288c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_UNSPEC, 1298c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_GET_PORT_SETTINGS, 1308c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_SET_PORT_SETTINGS, 1318c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_ADD, 1328c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_MOD, 1338c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_DEL, 1348c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_FLOW_GET_STATS, 1358c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_ADD, 1368c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_MOD, 1378c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_DEL, 1388c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_GET_STATS, 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_CLEAR_PORT_STATS, 1418c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_GET_PORT_STATS, 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci __ROCKER_TLV_CMD_TYPE_MAX, 1448c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_TYPE_MAX = __ROCKER_TLV_CMD_TYPE_MAX - 1, 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cienum { 1488c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_UNSPEC, 1498c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_PPORT, /* u32 */ 1508c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_SPEED, /* u32 */ 1518c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_DUPLEX, /* u8 */ 1528c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_AUTONEG, /* u8 */ 1538c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_MACADDR, /* binary */ 1548c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_MODE, /* u8 */ 1558c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_LEARNING, /* u8 */ 1568c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_PHYS_NAME, /* binary */ 1578c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_MTU, /* u16 */ 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci __ROCKER_TLV_CMD_PORT_SETTINGS_MAX, 1608c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_SETTINGS_MAX = 1618c2ecf20Sopenharmony_ci __ROCKER_TLV_CMD_PORT_SETTINGS_MAX - 1, 1628c2ecf20Sopenharmony_ci}; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_cienum { 1658c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_UNSPEC, 1668c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_PPORT, /* u32 */ 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_RX_PKTS, /* u64 */ 1698c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_RX_BYTES, /* u64 */ 1708c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_RX_DROPPED, /* u64 */ 1718c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_RX_ERRORS, /* u64 */ 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_TX_PKTS, /* u64 */ 1748c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_TX_BYTES, /* u64 */ 1758c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_TX_DROPPED, /* u64 */ 1768c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_TX_ERRORS, /* u64 */ 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci __ROCKER_TLV_CMD_PORT_STATS_MAX, 1798c2ecf20Sopenharmony_ci ROCKER_TLV_CMD_PORT_STATS_MAX = __ROCKER_TLV_CMD_PORT_STATS_MAX - 1, 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_cienum rocker_port_mode { 1838c2ecf20Sopenharmony_ci ROCKER_PORT_MODE_OF_DPA, 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_cienum { 1878c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_UNSPEC, 1888c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_TYPE, /* u16 */ 1898c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_INFO, /* nest */ 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci __ROCKER_TLV_EVENT_MAX, 1928c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_MAX = __ROCKER_TLV_EVENT_MAX - 1, 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cienum { 1968c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_TYPE_UNSPEC, 1978c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_TYPE_LINK_CHANGED, 1988c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_TYPE_MAC_VLAN_SEEN, 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci __ROCKER_TLV_EVENT_TYPE_MAX, 2018c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_TYPE_MAX = __ROCKER_TLV_EVENT_TYPE_MAX - 1, 2028c2ecf20Sopenharmony_ci}; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cienum { 2058c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_LINK_CHANGED_UNSPEC, 2068c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_LINK_CHANGED_PPORT, /* u32 */ 2078c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_LINK_CHANGED_LINKUP, /* u8 */ 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci __ROCKER_TLV_EVENT_LINK_CHANGED_MAX, 2108c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_LINK_CHANGED_MAX = 2118c2ecf20Sopenharmony_ci __ROCKER_TLV_EVENT_LINK_CHANGED_MAX - 1, 2128c2ecf20Sopenharmony_ci}; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_cienum { 2158c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_MAC_VLAN_UNSPEC, 2168c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_MAC_VLAN_PPORT, /* u32 */ 2178c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_MAC_VLAN_MAC, /* binary */ 2188c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_MAC_VLAN_VLAN_ID, /* __be16 */ 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci __ROCKER_TLV_EVENT_MAC_VLAN_MAX, 2218c2ecf20Sopenharmony_ci ROCKER_TLV_EVENT_MAC_VLAN_MAX = __ROCKER_TLV_EVENT_MAC_VLAN_MAX - 1, 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_cienum { 2258c2ecf20Sopenharmony_ci ROCKER_TLV_RX_UNSPEC, 2268c2ecf20Sopenharmony_ci ROCKER_TLV_RX_FLAGS, /* u16, see ROCKER_RX_FLAGS_ */ 2278c2ecf20Sopenharmony_ci ROCKER_TLV_RX_CSUM, /* u16 */ 2288c2ecf20Sopenharmony_ci ROCKER_TLV_RX_FRAG_ADDR, /* u64 */ 2298c2ecf20Sopenharmony_ci ROCKER_TLV_RX_FRAG_MAX_LEN, /* u16 */ 2308c2ecf20Sopenharmony_ci ROCKER_TLV_RX_FRAG_LEN, /* u16 */ 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci __ROCKER_TLV_RX_MAX, 2338c2ecf20Sopenharmony_ci ROCKER_TLV_RX_MAX = __ROCKER_TLV_RX_MAX - 1, 2348c2ecf20Sopenharmony_ci}; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_IPV4 BIT(0) 2378c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_IPV6 BIT(1) 2388c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_CSUM_CALC BIT(2) 2398c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_IPV4_CSUM_GOOD BIT(3) 2408c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_IP_FRAG BIT(4) 2418c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_TCP BIT(5) 2428c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_UDP BIT(6) 2438c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_TCP_UDP_CSUM_GOOD BIT(7) 2448c2ecf20Sopenharmony_ci#define ROCKER_RX_FLAGS_FWD_OFFLOAD BIT(8) 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_cienum { 2478c2ecf20Sopenharmony_ci ROCKER_TLV_TX_UNSPEC, 2488c2ecf20Sopenharmony_ci ROCKER_TLV_TX_OFFLOAD, /* u8, see ROCKER_TX_OFFLOAD_ */ 2498c2ecf20Sopenharmony_ci ROCKER_TLV_TX_L3_CSUM_OFF, /* u16 */ 2508c2ecf20Sopenharmony_ci ROCKER_TLV_TX_TSO_MSS, /* u16 */ 2518c2ecf20Sopenharmony_ci ROCKER_TLV_TX_TSO_HDR_LEN, /* u16 */ 2528c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAGS, /* array */ 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci __ROCKER_TLV_TX_MAX, 2558c2ecf20Sopenharmony_ci ROCKER_TLV_TX_MAX = __ROCKER_TLV_TX_MAX - 1, 2568c2ecf20Sopenharmony_ci}; 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci#define ROCKER_TX_OFFLOAD_NONE 0 2598c2ecf20Sopenharmony_ci#define ROCKER_TX_OFFLOAD_IP_CSUM 1 2608c2ecf20Sopenharmony_ci#define ROCKER_TX_OFFLOAD_TCP_UDP_CSUM 2 2618c2ecf20Sopenharmony_ci#define ROCKER_TX_OFFLOAD_L3_CSUM 3 2628c2ecf20Sopenharmony_ci#define ROCKER_TX_OFFLOAD_TSO 4 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci#define ROCKER_TX_FRAGS_MAX 16 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_cienum { 2678c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG_UNSPEC, 2688c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG, /* nest */ 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci __ROCKER_TLV_TX_FRAG_MAX, 2718c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG_MAX = __ROCKER_TLV_TX_FRAG_MAX - 1, 2728c2ecf20Sopenharmony_ci}; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_cienum { 2758c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG_ATTR_UNSPEC, 2768c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG_ATTR_ADDR, /* u64 */ 2778c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG_ATTR_LEN, /* u16 */ 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci __ROCKER_TLV_TX_FRAG_ATTR_MAX, 2808c2ecf20Sopenharmony_ci ROCKER_TLV_TX_FRAG_ATTR_MAX = __ROCKER_TLV_TX_FRAG_ATTR_MAX - 1, 2818c2ecf20Sopenharmony_ci}; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci/* cmd info nested for OF-DPA msgs */ 2848c2ecf20Sopenharmony_cienum { 2858c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_UNSPEC, 2868c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_TABLE_ID, /* u16 */ 2878c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_PRIORITY, /* u32 */ 2888c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_HARDTIME, /* u32 */ 2898c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IDLETIME, /* u32 */ 2908c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_COOKIE, /* u64 */ 2918c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IN_PPORT, /* u32 */ 2928c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IN_PPORT_MASK, /* u32 */ 2938c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_OUT_PPORT, /* u32 */ 2948c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_GOTO_TABLE_ID, /* u16 */ 2958c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_GROUP_ID, /* u32 */ 2968c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_GROUP_ID_LOWER, /* u32 */ 2978c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_GROUP_COUNT, /* u16 */ 2988c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_GROUP_IDS, /* u32 array */ 2998c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_VLAN_ID, /* __be16 */ 3008c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_VLAN_ID_MASK, /* __be16 */ 3018c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_VLAN_PCP, /* __be16 */ 3028c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_VLAN_PCP_MASK, /* __be16 */ 3038c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_VLAN_PCP_ACTION, /* u8 */ 3048c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_NEW_VLAN_ID, /* __be16 */ 3058c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_NEW_VLAN_PCP, /* u8 */ 3068c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_TUNNEL_ID, /* u32 */ 3078c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_TUNNEL_LPORT, /* u32 */ 3088c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_ETHERTYPE, /* __be16 */ 3098c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_DST_MAC, /* binary */ 3108c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_DST_MAC_MASK, /* binary */ 3118c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_MAC, /* binary */ 3128c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_MAC_MASK, /* binary */ 3138c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_PROTO, /* u8 */ 3148c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_PROTO_MASK, /* u8 */ 3158c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_DSCP, /* u8 */ 3168c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_DSCP_MASK, /* u8 */ 3178c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_DSCP_ACTION, /* u8 */ 3188c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_NEW_IP_DSCP, /* u8 */ 3198c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_ECN, /* u8 */ 3208c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IP_ECN_MASK, /* u8 */ 3218c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_DST_IP, /* __be32 */ 3228c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_DST_IP_MASK, /* __be32 */ 3238c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_IP, /* __be32 */ 3248c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_IP_MASK, /* __be32 */ 3258c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_DST_IPV6, /* binary */ 3268c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_DST_IPV6_MASK, /* binary */ 3278c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_IPV6, /* binary */ 3288c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_IPV6_MASK, /* binary */ 3298c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_ARP_IP, /* __be32 */ 3308c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_SRC_ARP_IP_MASK, /* __be32 */ 3318c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_L4_DST_PORT, /* __be16 */ 3328c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_L4_DST_PORT_MASK, /* __be16 */ 3338c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_L4_SRC_PORT, /* __be16 */ 3348c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_L4_SRC_PORT_MASK, /* __be16 */ 3358c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_ICMP_TYPE, /* u8 */ 3368c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_ICMP_TYPE_MASK, /* u8 */ 3378c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_ICMP_CODE, /* u8 */ 3388c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_ICMP_CODE_MASK, /* u8 */ 3398c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IPV6_LABEL, /* __be32 */ 3408c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_IPV6_LABEL_MASK, /* __be32 */ 3418c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_QUEUE_ID_ACTION, /* u8 */ 3428c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_NEW_QUEUE_ID, /* u8 */ 3438c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_CLEAR_ACTIONS, /* u32 */ 3448c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_POP_VLAN, /* u8 */ 3458c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_TTL_CHECK, /* u8 */ 3468c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_COPY_CPU_ACTION, /* u8 */ 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci __ROCKER_TLV_OF_DPA_MAX, 3498c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_MAX = __ROCKER_TLV_OF_DPA_MAX - 1, 3508c2ecf20Sopenharmony_ci}; 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_ci/* OF-DPA table IDs */ 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cienum rocker_of_dpa_table_id { 3558c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_INGRESS_PORT = 0, 3568c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_VLAN = 10, 3578c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_TERMINATION_MAC = 20, 3588c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_UNICAST_ROUTING = 30, 3598c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_MULTICAST_ROUTING = 40, 3608c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_BRIDGING = 50, 3618c2ecf20Sopenharmony_ci ROCKER_OF_DPA_TABLE_ID_ACL_POLICY = 60, 3628c2ecf20Sopenharmony_ci}; 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci/* OF-DPA flow stats */ 3658c2ecf20Sopenharmony_cienum { 3668c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_FLOW_STAT_UNSPEC, 3678c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_FLOW_STAT_DURATION, /* u32 */ 3688c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_FLOW_STAT_RX_PKTS, /* u64 */ 3698c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_FLOW_STAT_TX_PKTS, /* u64 */ 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci __ROCKER_TLV_OF_DPA_FLOW_STAT_MAX, 3728c2ecf20Sopenharmony_ci ROCKER_TLV_OF_DPA_FLOW_STAT_MAX = __ROCKER_TLV_OF_DPA_FLOW_STAT_MAX - 1, 3738c2ecf20Sopenharmony_ci}; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci/* OF-DPA group types */ 3768c2ecf20Sopenharmony_cienum rocker_of_dpa_group_type { 3778c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L2_INTERFACE = 0, 3788c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L2_REWRITE, 3798c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L3_UCAST, 3808c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L2_MCAST, 3818c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L2_FLOOD, 3828c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L3_INTERFACE, 3838c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L3_MCAST, 3848c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L3_ECMP, 3858c2ecf20Sopenharmony_ci ROCKER_OF_DPA_GROUP_TYPE_L2_OVERLAY, 3868c2ecf20Sopenharmony_ci}; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci/* OF-DPA group L2 overlay types */ 3898c2ecf20Sopenharmony_cienum rocker_of_dpa_overlay_type { 3908c2ecf20Sopenharmony_ci ROCKER_OF_DPA_OVERLAY_TYPE_FLOOD_UCAST = 0, 3918c2ecf20Sopenharmony_ci ROCKER_OF_DPA_OVERLAY_TYPE_FLOOD_MCAST, 3928c2ecf20Sopenharmony_ci ROCKER_OF_DPA_OVERLAY_TYPE_MCAST_UCAST, 3938c2ecf20Sopenharmony_ci ROCKER_OF_DPA_OVERLAY_TYPE_MCAST_MCAST, 3948c2ecf20Sopenharmony_ci}; 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci/* OF-DPA group ID encoding */ 3978c2ecf20Sopenharmony_ci#define ROCKER_GROUP_TYPE_SHIFT 28 3988c2ecf20Sopenharmony_ci#define ROCKER_GROUP_TYPE_MASK 0xf0000000 3998c2ecf20Sopenharmony_ci#define ROCKER_GROUP_VLAN_SHIFT 16 4008c2ecf20Sopenharmony_ci#define ROCKER_GROUP_VLAN_MASK 0x0fff0000 4018c2ecf20Sopenharmony_ci#define ROCKER_GROUP_PORT_SHIFT 0 4028c2ecf20Sopenharmony_ci#define ROCKER_GROUP_PORT_MASK 0x0000ffff 4038c2ecf20Sopenharmony_ci#define ROCKER_GROUP_TUNNEL_ID_SHIFT 12 4048c2ecf20Sopenharmony_ci#define ROCKER_GROUP_TUNNEL_ID_MASK 0x0ffff000 4058c2ecf20Sopenharmony_ci#define ROCKER_GROUP_SUBTYPE_SHIFT 10 4068c2ecf20Sopenharmony_ci#define ROCKER_GROUP_SUBTYPE_MASK 0x00000c00 4078c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_SHIFT 0 4088c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_MASK 0x0000ffff 4098c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_LONG_SHIFT 0 4108c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_LONG_MASK 0x0fffffff 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci#define ROCKER_GROUP_TYPE_GET(group_id) \ 4138c2ecf20Sopenharmony_ci (((group_id) & ROCKER_GROUP_TYPE_MASK) >> ROCKER_GROUP_TYPE_SHIFT) 4148c2ecf20Sopenharmony_ci#define ROCKER_GROUP_TYPE_SET(type) \ 4158c2ecf20Sopenharmony_ci (((type) << ROCKER_GROUP_TYPE_SHIFT) & ROCKER_GROUP_TYPE_MASK) 4168c2ecf20Sopenharmony_ci#define ROCKER_GROUP_VLAN_GET(group_id) \ 4178c2ecf20Sopenharmony_ci (((group_id) & ROCKER_GROUP_VLAN_ID_MASK) >> ROCKER_GROUP_VLAN_ID_SHIFT) 4188c2ecf20Sopenharmony_ci#define ROCKER_GROUP_VLAN_SET(vlan_id) \ 4198c2ecf20Sopenharmony_ci (((vlan_id) << ROCKER_GROUP_VLAN_SHIFT) & ROCKER_GROUP_VLAN_MASK) 4208c2ecf20Sopenharmony_ci#define ROCKER_GROUP_PORT_GET(group_id) \ 4218c2ecf20Sopenharmony_ci (((group_id) & ROCKER_GROUP_PORT_MASK) >> ROCKER_GROUP_PORT_SHIFT) 4228c2ecf20Sopenharmony_ci#define ROCKER_GROUP_PORT_SET(port) \ 4238c2ecf20Sopenharmony_ci (((port) << ROCKER_GROUP_PORT_SHIFT) & ROCKER_GROUP_PORT_MASK) 4248c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_GET(group_id) \ 4258c2ecf20Sopenharmony_ci (((group_id) & ROCKER_GROUP_INDEX_MASK) >> ROCKER_GROUP_INDEX_SHIFT) 4268c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_SET(index) \ 4278c2ecf20Sopenharmony_ci (((index) << ROCKER_GROUP_INDEX_SHIFT) & ROCKER_GROUP_INDEX_MASK) 4288c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_LONG_GET(group_id) \ 4298c2ecf20Sopenharmony_ci (((group_id) & ROCKER_GROUP_INDEX_LONG_MASK) >> \ 4308c2ecf20Sopenharmony_ci ROCKER_GROUP_INDEX_LONG_SHIFT) 4318c2ecf20Sopenharmony_ci#define ROCKER_GROUP_INDEX_LONG_SET(index) \ 4328c2ecf20Sopenharmony_ci (((index) << ROCKER_GROUP_INDEX_LONG_SHIFT) & \ 4338c2ecf20Sopenharmony_ci ROCKER_GROUP_INDEX_LONG_MASK) 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci#define ROCKER_GROUP_NONE 0 4368c2ecf20Sopenharmony_ci#define ROCKER_GROUP_L2_INTERFACE(vlan_id, port) \ 4378c2ecf20Sopenharmony_ci (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_INTERFACE) |\ 4388c2ecf20Sopenharmony_ci ROCKER_GROUP_VLAN_SET(ntohs(vlan_id)) | ROCKER_GROUP_PORT_SET(port)) 4398c2ecf20Sopenharmony_ci#define ROCKER_GROUP_L2_REWRITE(index) \ 4408c2ecf20Sopenharmony_ci (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_REWRITE) |\ 4418c2ecf20Sopenharmony_ci ROCKER_GROUP_INDEX_LONG_SET(index)) 4428c2ecf20Sopenharmony_ci#define ROCKER_GROUP_L2_MCAST(vlan_id, index) \ 4438c2ecf20Sopenharmony_ci (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_MCAST) |\ 4448c2ecf20Sopenharmony_ci ROCKER_GROUP_VLAN_SET(ntohs(vlan_id)) | ROCKER_GROUP_INDEX_SET(index)) 4458c2ecf20Sopenharmony_ci#define ROCKER_GROUP_L2_FLOOD(vlan_id, index) \ 4468c2ecf20Sopenharmony_ci (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L2_FLOOD) |\ 4478c2ecf20Sopenharmony_ci ROCKER_GROUP_VLAN_SET(ntohs(vlan_id)) | ROCKER_GROUP_INDEX_SET(index)) 4488c2ecf20Sopenharmony_ci#define ROCKER_GROUP_L3_UNICAST(index) \ 4498c2ecf20Sopenharmony_ci (ROCKER_GROUP_TYPE_SET(ROCKER_OF_DPA_GROUP_TYPE_L3_UCAST) |\ 4508c2ecf20Sopenharmony_ci ROCKER_GROUP_INDEX_LONG_SET(index)) 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci/* Rocker general purpose registers */ 4538c2ecf20Sopenharmony_ci#define ROCKER_CONTROL 0x0300 4548c2ecf20Sopenharmony_ci#define ROCKER_PORT_PHYS_COUNT 0x0304 4558c2ecf20Sopenharmony_ci#define ROCKER_PORT_PHYS_LINK_STATUS 0x0310 /* 8-byte */ 4568c2ecf20Sopenharmony_ci#define ROCKER_PORT_PHYS_ENABLE 0x0318 /* 8-byte */ 4578c2ecf20Sopenharmony_ci#define ROCKER_SWITCH_ID 0x0320 /* 8-byte */ 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci/* Rocker control bits */ 4608c2ecf20Sopenharmony_ci#define ROCKER_CONTROL_RESET BIT(0) 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci#endif 463