xref: /linux/include/linux/fsl/ntmp.h (revision ab93e0dd72c37d378dd936f031ffb83ff2bd87ce)
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 
9 struct maft_keye_data {
10 	u8 mac_addr[ETH_ALEN];
11 	__le16 resv;
12 };
13 
14 struct maft_cfge_data {
15 	__le16 si_bitmap;
16 	__le16 resv;
17 };
18 
19 struct 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 
29 struct netc_tbl_vers {
30 	u8 maft_ver;
31 	u8 rsst_ver;
32 };
33 
34 struct 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 
52 struct 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 
59 struct 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)
65 int ntmp_init_cbdr(struct netc_cbdr *cbdr, struct device *dev,
66 		   const struct netc_cbdr_regs *regs);
67 void ntmp_free_cbdr(struct netc_cbdr *cbdr);
68 
69 /* NTMP APIs */
70 int ntmp_maft_add_entry(struct ntmp_user *user, u32 entry_id,
71 			struct maft_entry_data *maft);
72 int ntmp_maft_query_entry(struct ntmp_user *user, u32 entry_id,
73 			  struct maft_entry_data *maft);
74 int ntmp_maft_delete_entry(struct ntmp_user *user, u32 entry_id);
75 int ntmp_rsst_update_entry(struct ntmp_user *user, const u32 *table,
76 			   int count);
77 int ntmp_rsst_query_entry(struct ntmp_user *user,
78 			  u32 *table, int count);
79 #else
ntmp_init_cbdr(struct netc_cbdr * cbdr,struct device * dev,const struct netc_cbdr_regs * regs)80 static 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 
ntmp_free_cbdr(struct netc_cbdr * cbdr)86 static inline void ntmp_free_cbdr(struct netc_cbdr *cbdr)
87 {
88 }
89 
ntmp_maft_add_entry(struct ntmp_user * user,u32 entry_id,struct maft_entry_data * maft)90 static 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 
ntmp_maft_query_entry(struct ntmp_user * user,u32 entry_id,struct maft_entry_data * maft)96 static 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 
ntmp_maft_delete_entry(struct ntmp_user * user,u32 entry_id)102 static inline int ntmp_maft_delete_entry(struct ntmp_user *user, u32 entry_id)
103 {
104 	return 0;
105 }
106 
ntmp_rsst_update_entry(struct ntmp_user * user,const u32 * table,int count)107 static inline int ntmp_rsst_update_entry(struct ntmp_user *user,
108 					 const u32 *table, int count)
109 {
110 	return 0;
111 }
112 
ntmp_rsst_query_entry(struct ntmp_user * user,u32 * table,int count)113 static 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
122