Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2/* Copyright 2025 NXP */
3#ifndef __NETC_NTMP_H
4#define __NETC_NTMP_H
5
6#include <linux/bitops.h>
7#include <linux/if_ether.h>
8
9struct maft_keye_data {
10 u8 mac_addr[ETH_ALEN];
11 __le16 resv;
12};
13
14struct maft_cfge_data {
15 __le16 si_bitmap;
16 __le16 resv;
17};
18
19struct netc_cbdr_regs {
20 void __iomem *pir;
21 void __iomem *cir;
22 void __iomem *mr;
23
24 void __iomem *bar0;
25 void __iomem *bar1;
26 void __iomem *lenr;
27};
28
29struct netc_tbl_vers {
30 u8 maft_ver;
31 u8 rsst_ver;
32};
33
34struct netc_cbdr {
35 struct device *dev;
36 struct netc_cbdr_regs regs;
37
38 int bd_num;
39 int next_to_use;
40 int next_to_clean;
41
42 int dma_size;
43 void *addr_base;
44 void *addr_base_align;
45 dma_addr_t dma_base;
46 dma_addr_t dma_base_align;
47
48 /* Serialize the order of command BD ring */
49 spinlock_t ring_lock;
50};
51
52struct ntmp_user {
53 int cbdr_num; /* number of control BD ring */
54 struct device *dev;
55 struct netc_cbdr *ring;
56 struct netc_tbl_vers tbl;
57};
58
59struct maft_entry_data {
60 struct maft_keye_data keye;
61 struct maft_cfge_data cfge;
62};
63
64#if IS_ENABLED(CONFIG_NXP_NETC_LIB)
65int ntmp_init_cbdr(struct netc_cbdr *cbdr, struct device *dev,
66 const struct netc_cbdr_regs *regs);
67void ntmp_free_cbdr(struct netc_cbdr *cbdr);
68
69/* NTMP APIs */
70int ntmp_maft_add_entry(struct ntmp_user *user, u32 entry_id,
71 struct maft_entry_data *maft);
72int ntmp_maft_query_entry(struct ntmp_user *user, u32 entry_id,
73 struct maft_entry_data *maft);
74int ntmp_maft_delete_entry(struct ntmp_user *user, u32 entry_id);
75int ntmp_rsst_update_entry(struct ntmp_user *user, const u32 *table,
76 int count);
77int ntmp_rsst_query_entry(struct ntmp_user *user,
78 u32 *table, int count);
79#else
80static inline int ntmp_init_cbdr(struct netc_cbdr *cbdr, struct device *dev,
81 const struct netc_cbdr_regs *regs)
82{
83 return 0;
84}
85
86static inline void ntmp_free_cbdr(struct netc_cbdr *cbdr)
87{
88}
89
90static inline int ntmp_maft_add_entry(struct ntmp_user *user, u32 entry_id,
91 struct maft_entry_data *maft)
92{
93 return 0;
94}
95
96static inline int ntmp_maft_query_entry(struct ntmp_user *user, u32 entry_id,
97 struct maft_entry_data *maft)
98{
99 return 0;
100}
101
102static inline int ntmp_maft_delete_entry(struct ntmp_user *user, u32 entry_id)
103{
104 return 0;
105}
106
107static inline int ntmp_rsst_update_entry(struct ntmp_user *user,
108 const u32 *table, int count)
109{
110 return 0;
111}
112
113static inline int ntmp_rsst_query_entry(struct ntmp_user *user,
114 u32 *table, int count)
115{
116 return 0;
117}
118
119#endif
120
121#endif