blob: 713981927b2c6c3dee160ffb21aac77d2be159fb [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/*
74 * Data structures to store ppe nss debug stats
75 */
76static DEFINE_SPINLOCK(nss_ppe_stats_lock);
77static struct nss_stats_ppe_debug nss_ppe_debug_stats;
78
79/*
80 * Private data structure
81 */
82static struct nss_ppe_pvt {
83 void * __iomem ppe_base;
Amit Gupta1263b082017-07-06 14:22:57 +053084 struct semaphore sem;
85 struct completion complete;
86 int response;
87 void *cb;
88 void *app_data;
Amit Gupta316729b2016-08-12 12:21:15 +053089} ppe_pvt;
90
91/*
92 * nss_ppe_reg_read()
93 */
94static inline void nss_ppe_reg_read(u32 reg, u32 *val)
95{
96 *val = readl((ppe_pvt.ppe_base + reg));
97}
98
99/*
100 * nss_ppe_reg_write()
101 */
102static inline void nss_ppe_reg_write(u32 reg, u32 val)
103{
104 writel(val, (ppe_pvt.ppe_base + reg));
105}