xref: /dpdk/drivers/bus/dpaa/include/fsl_fman.h (revision 68a03efeed657e6e05f281479b33b51102797e15)
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2017 NXP
4  *
5  */
6 
7 #ifndef __FSL_FMAN_H
8 #define __FSL_FMAN_H
9 
10 #include <rte_compat.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /* Status field in FD is updated on Rx side by FMAN with following information.
17  * Refer to field description in FM BG.
18  */
19 struct fm_status_t {
20 	unsigned int reserved0:3;
21 	unsigned int dcl4c:1; /* Don't Check L4 Checksum */
22 	unsigned int reserved1:1;
23 	unsigned int ufd:1; /* Unsupported Format */
24 	unsigned int lge:1; /* Length Error */
25 	unsigned int dme:1; /* DMA Error */
26 
27 	unsigned int reserved2:4;
28 	unsigned int fpe:1; /* Frame physical Error */
29 	unsigned int fse:1; /* Frame Size Error */
30 	unsigned int dis:1; /* Discard by Classification */
31 	unsigned int reserved3:1;
32 
33 	unsigned int eof:1; /* Key Extraction goes out of frame */
34 	unsigned int nss:1; /* No Scheme selected */
35 	unsigned int kso:1; /* Key Size Overflow */
36 	unsigned int reserved4:1;
37 	unsigned int fcl:2; /* Frame Color */
38 	unsigned int ipp:1; /* Illegal Policer Profile Selected */
39 	unsigned int flm:1; /* Frame Length Mismatch */
40 	unsigned int pte:1; /* Parser Timeout */
41 	unsigned int isp:1; /* Invalid Soft Parser Instruction */
42 	unsigned int phe:1; /* Header Error during parsing */
43 	unsigned int frdr:1; /* Frame Dropped by disabled port */
44 	unsigned int reserved5:4;
45 } __rte_packed;
46 
47 /* Set MAC address for a particular interface */
48 __rte_internal
49 int fman_if_add_mac_addr(struct fman_if *p, uint8_t *eth, uint8_t addr_num);
50 
51 /* Remove a MAC address for a particular interface */
52 __rte_internal
53 void fman_if_clear_mac_addr(struct fman_if *p, uint8_t addr_num);
54 
55 /* Get the FMAN statistics */
56 __rte_internal
57 void fman_if_stats_get(struct fman_if *p, struct rte_eth_stats *stats);
58 
59 /* Reset the FMAN statistics */
60 __rte_internal
61 void fman_if_stats_reset(struct fman_if *p);
62 
63 /* Get all of the FMAN statistics */
64 __rte_internal
65 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n);
66 
67 /* Set ignore pause option for a specific interface */
68 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable);
69 
70 /* Set max frame length */
71 void fman_if_conf_max_frame_len(struct fman_if *p, unsigned int max_frame_len);
72 
73 /* Enable/disable Rx promiscuous mode on specified interface */
74 __rte_internal
75 void fman_if_promiscuous_enable(struct fman_if *p);
76 __rte_internal
77 void fman_if_promiscuous_disable(struct fman_if *p);
78 
79 /* Enable/disable Rx on specific interfaces */
80 __rte_internal
81 void fman_if_enable_rx(struct fman_if *p);
82 __rte_internal
83 void fman_if_disable_rx(struct fman_if *p);
84 
85 /* Enable/disable loopback on specific interfaces */
86 __rte_internal
87 void fman_if_loopback_enable(struct fman_if *p);
88 __rte_internal
89 void fman_if_loopback_disable(struct fman_if *p);
90 
91 /* Set buffer pool on specific interface */
92 __rte_internal
93 void fman_if_set_bp(struct fman_if *fm_if, unsigned int num, int bpid,
94 		    size_t bufsize);
95 
96 /* Get Flow Control threshold parameters on specific interface */
97 __rte_internal
98 int fman_if_get_fc_threshold(struct fman_if *fm_if);
99 
100 /* Enable and Set Flow Control threshold parameters on specific interface */
101 __rte_internal
102 int fman_if_set_fc_threshold(struct fman_if *fm_if,
103 			u32 high_water, u32 low_water, u32 bpid);
104 
105 /* Get Flow Control pause quanta on specific interface */
106 __rte_internal
107 int fman_if_get_fc_quanta(struct fman_if *fm_if);
108 
109 /* Set Flow Control pause quanta on specific interface */
110 __rte_internal
111 int fman_if_set_fc_quanta(struct fman_if *fm_if, u16 pause_quanta);
112 
113 /* Set default error fqid on specific interface */
114 __rte_internal
115 void fman_if_set_err_fqid(struct fman_if *fm_if, uint32_t err_fqid);
116 
117 /* Get IC transfer params */
118 int fman_if_get_ic_params(struct fman_if *fm_if, struct fman_if_ic_params *icp);
119 
120 /* Set IC transfer params */
121 __rte_internal
122 int fman_if_set_ic_params(struct fman_if *fm_if,
123 			  const struct fman_if_ic_params *icp);
124 
125 /* Get interface fd->offset value */
126 __rte_internal
127 int fman_if_get_fdoff(struct fman_if *fm_if);
128 
129 /* Set interface fd->offset value */
130 __rte_internal
131 void fman_if_set_fdoff(struct fman_if *fm_if, uint32_t fd_offset);
132 
133 /* Get interface SG enable status value */
134 __rte_internal
135 int fman_if_get_sg_enable(struct fman_if *fm_if);
136 
137 /* Set interface SG support mode */
138 __rte_internal
139 void fman_if_set_sg(struct fman_if *fm_if, int enable);
140 
141 /* Get interface Max Frame length (MTU) */
142 __rte_internal
143 uint16_t fman_if_get_maxfrm(struct fman_if *fm_if);
144 
145 /* Set interface  Max Frame length (MTU) */
146 __rte_internal
147 void fman_if_set_maxfrm(struct fman_if *fm_if, uint16_t max_frm);
148 
149 /* Set interface next invoked action for dequeue operation */
150 void fman_if_set_dnia(struct fman_if *fm_if, uint32_t nia);
151 
152 /* discard error packets on rx */
153 __rte_internal
154 void fman_if_discard_rx_errors(struct fman_if *fm_if);
155 
156 __rte_internal
157 void fman_if_receive_rx_errors(struct fman_if *fm_if,
158 	unsigned int err_eq);
159 
160 __rte_internal
161 void fman_if_set_mcast_filter_table(struct fman_if *p);
162 
163 __rte_internal
164 void fman_if_reset_mcast_filter_table(struct fman_if *p);
165 
166 int fman_if_add_hash_mac_addr(struct fman_if *p, uint8_t *eth);
167 
168 int fman_if_get_primary_mac_addr(struct fman_if *p, uint8_t *eth);
169 
170 
171 /* Enable/disable Rx on all interfaces */
172 static inline void fman_if_enable_all_rx(void)
173 {
174 	struct fman_if *__if;
175 
176 	list_for_each_entry(__if, fman_if_list, node)
177 		fman_if_enable_rx(__if);
178 }
179 
180 static inline void fman_if_disable_all_rx(void)
181 {
182 	struct fman_if *__if;
183 
184 	list_for_each_entry(__if, fman_if_list, node)
185 		fman_if_disable_rx(__if);
186 }
187 #endif /* __FSL_FMAN_H */
188