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