Amit Gupta | 316729b | 2016-08-12 12:21:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
| 3 | * Copyright (c) 2016, The Linux Foundation. All rights reserved. |
| 4 | * 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) |
| 45 | #define PPE_PKT_CODE_DROP_GET(d0, d1) (PPE_PKT_CODE_DROP0_GET(d0) + PPE_PKT_CODE_DROP1_GET(d1)) |
| 46 | |
| 47 | #define PPE_PKT_CODE_CPU_GET(x) (((x) >> 3) & 0xff) |
| 48 | |
| 49 | |
| 50 | /* |
| 51 | * Data structures to store ppe nss debug stats |
| 52 | */ |
| 53 | static DEFINE_SPINLOCK(nss_ppe_stats_lock); |
| 54 | static struct nss_stats_ppe_debug nss_ppe_debug_stats; |
| 55 | |
| 56 | /* |
| 57 | * Private data structure |
| 58 | */ |
| 59 | static struct nss_ppe_pvt { |
| 60 | void * __iomem ppe_base; |
| 61 | } ppe_pvt; |
| 62 | |
| 63 | /* |
| 64 | * nss_ppe_reg_read() |
| 65 | */ |
| 66 | static inline void nss_ppe_reg_read(u32 reg, u32 *val) |
| 67 | { |
| 68 | *val = readl((ppe_pvt.ppe_base + reg)); |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | * nss_ppe_reg_write() |
| 73 | */ |
| 74 | static inline void nss_ppe_reg_write(u32 reg, u32 val) |
| 75 | { |
| 76 | writel(val, (ppe_pvt.ppe_base + reg)); |
| 77 | } |