blob: bc5e53f2c0150debd283e102c832df3480dc5095 [file] [log] [blame]
Amit Gupta316729b2016-08-12 12:21:15 +05301/*
2 **************************************************************************
Amit Gupta79c1c202017-06-30 15:28:13 +05303 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Amit Gupta316729b2016-08-12 12:21:15 +05304 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/*
18 * nss_ppe.h
19 * NSS PPE header file
20 */
21
22#include <net/sock.h>
23#include "nss_tx_rx_common.h"
24
25#define PPE_BASE_ADDR 0x3a000000
26#define PPE_REG_SIZE 0x1000000
27
28#define PPE_L3_DBG_WR_OFFSET 0x200c04
29#define PPE_L3_DBG_RD_OFFSET 0x200c0c
30#define PPE_L3_DBG0_OFFSET 0x10001
31#define PPE_L3_DBG1_OFFSET 0x10002
32#define PPE_L3_DBG2_OFFSET 0x10003
33#define PPE_L3_DBG3_OFFSET 0x10004
34#define PPE_L3_DBG4_OFFSET 0x10005
35#define PPE_L3_DBG_PORT_OFFSET 0x11e80
36
37#define PPE_PKT_CODE_WR_OFFSET 0x100080
38#define PPE_PKT_CODE_RD_OFFSET 0x100084
39#define PPE_PKT_CODE_DROP0_OFFSET 0xf000000
40#define PPE_PKT_CODE_DROP1_OFFSET 0x10000000
41#define PPE_PKT_CODE_CPU_OFFSET 0x40000000
42
43#define PPE_PKT_CODE_DROP0_GET(x) (((x) & 0xe0000000) >> 29)
44#define PPE_PKT_CODE_DROP1_GET(x) (((x) & 0x7) << 3)
Amit Gupta79c1c202017-06-30 15:28:13 +053045#define PPE_PKT_CODE_DROP_GET(d0, d1) (PPE_PKT_CODE_DROP0_GET(d0) | PPE_PKT_CODE_DROP1_GET(d1))
Amit Gupta316729b2016-08-12 12:21:15 +053046
47#define PPE_PKT_CODE_CPU_GET(x) (((x) >> 3) & 0xff)
48
Amit Gupta79c1c202017-06-30 15:28:13 +053049#define PPE_IPE_PC_REG 0x100000
50
51/*
52 * NSS_SYS_REG_DROP_CPU_CNT_TBL
53 * Address map and access APIs for DROP_CPU_CNT table.
54 */
55#define PPE_DROP_CPU_CNT_TBL_OFFSET 0x60000
56#define PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE 0x10
57#define PPE_DROP_CPU_CNT_TBL_BASE_OFFSET (PPE_IPE_PC_REG + PPE_DROP_CPU_CNT_TBL_OFFSET)
58#define PPE_CPU_CODE_MAX_NUM 256
59
60/*
61 * CPU code offset
62 */
63#define PPE_CPU_CODE_OFFSET(n) (PPE_DROP_CPU_CNT_TBL_BASE_OFFSET + ((n) * PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE))
64
65/*
66 * DROP code offset
67 */
68#define PPE_DROP_CODE_IDX(code, src_port) (PPE_CPU_CODE_MAX_NUM + (8 * (code)) + (src_port))
69#define PPE_DROP_CODE_OFFSET(code, src_port) (PPE_DROP_CPU_CNT_TBL_BASE_OFFSET + ((PPE_DROP_CODE_IDX(code, src_port)) * PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE))
Amit Gupta316729b2016-08-12 12:21:15 +053070
Amit Gupta1263b082017-07-06 14:22:57 +053071#define NSS_PPE_TX_TIMEOUT 1000 /* 1 Second */
72
Amit Gupta316729b2016-08-12 12:21:15 +053073/*
Amit Gupta6c0f6412017-11-20 15:42:43 +053074 * ppe nss debug stats lock
Amit Gupta316729b2016-08-12 12:21:15 +053075 */
Amit Gupta6c0f6412017-11-20 15:42:43 +053076extern spinlock_t nss_ppe_stats_lock;
Amit Gupta316729b2016-08-12 12:21:15 +053077
78/*
79 * Private data structure
80 */
Amit Gupta6c0f6412017-11-20 15:42:43 +053081struct nss_ppe_pvt {
Amit Gupta316729b2016-08-12 12:21:15 +053082 void * __iomem ppe_base;
Amit Gupta1263b082017-07-06 14:22:57 +053083 struct semaphore sem;
84 struct completion complete;
85 int response;
86 void *cb;
87 void *app_data;
Amit Gupta6c0f6412017-11-20 15:42:43 +053088};
89
90/*
91 * Data structure to store to PPE private context
92 */
93extern struct nss_ppe_pvt ppe_pvt;
Amit Gupta316729b2016-08-12 12:21:15 +053094
95/*
96 * nss_ppe_reg_read()
97 */
98static inline void nss_ppe_reg_read(u32 reg, u32 *val)
99{
100 *val = readl((ppe_pvt.ppe_base + reg));
101}
102
103/*
104 * nss_ppe_reg_write()
105 */
106static inline void nss_ppe_reg_write(u32 reg, u32 val)
107{
108 writel(val, (ppe_pvt.ppe_base + reg));
109}