xref: /dpdk/drivers/net/ark/ark_ext.h (revision 664cb3b2607d0c18281dbfa3e059ec00e2ed3df8)
1540914bcSEd Czeck /* SPDX-License-Identifier: BSD-3-Clause
2540914bcSEd Czeck  * Copyright (c) 2015-2018 Atomic Rules LLC
3727b3fe2SEd Czeck  */
4727b3fe2SEd Czeck 
5727b3fe2SEd Czeck #ifndef _ARK_EXT_H_
6727b3fe2SEd Czeck #define _ARK_EXT_H_
7727b3fe2SEd Czeck 
8*664cb3b2SEd Czeck #include <rte_mbuf.h>
9df96fd0dSBruce Richardson #include <ethdev_driver.h>
10727b3fe2SEd Czeck 
11f2764c36SEd Czeck /* The following section lists function prototypes for Arkville's
12f2764c36SEd Czeck  * dynamic PMD extension. User's who create an extension
13f2764c36SEd Czeck  * must include this file and define the necessary and desired
14f2764c36SEd Czeck  * functions. Only 1 function is required for an extension,
15f2764c36SEd Czeck  * rte_pmd_ark_dev_init(); all other functions prototypes in this
16f2764c36SEd Czeck  * section are optional.
17f2764c36SEd Czeck  * See documentation for compiling and use of extensions.
18727b3fe2SEd Czeck  */
19727b3fe2SEd Czeck 
20*664cb3b2SEd Czeck /* private data optionally attached to mempool for rx */
21*664cb3b2SEd Czeck struct rte_pmd_ark_lmbuf_mempool_priv {
22*664cb3b2SEd Czeck 	struct rte_pktmbuf_pool_private pool_private;
23*664cb3b2SEd Czeck 	char cookie[4];
24*664cb3b2SEd Czeck 	uint32_t dataroom;
25*664cb3b2SEd Czeck };
26*664cb3b2SEd Czeck #define ARK_MEMPOOL_COOKIE "ARK1"
27*664cb3b2SEd Czeck 
28f2764c36SEd Czeck /**
29f2764c36SEd Czeck  * Extension prototype, required implementation if extensions are used.
30f2764c36SEd Czeck  * Called during device probe to initialize the user structure
31f2764c36SEd Czeck  * passed to other extension functions.  This is called once for each
32f2764c36SEd Czeck  * port of the device.
33f2764c36SEd Czeck  *
34f2764c36SEd Czeck  * @param dev
35f2764c36SEd Czeck  *   current device.
36f2764c36SEd Czeck  * @param a_bar
37f2764c36SEd Czeck  *   access to PCIe device bar (application bar) and hence access to
38f2764c36SEd Czeck  *   user's portion of FPGA.
39f2764c36SEd Czeck  * @param port_id
40f2764c36SEd Czeck  *   port identifier.
41f2764c36SEd Czeck  * @return user_data
42f2764c36SEd Czeck  *   which will be passed to other extension functions.
43727b3fe2SEd Czeck  */
44f2764c36SEd Czeck void *rte_pmd_ark_dev_init(struct rte_eth_dev *dev, void *a_bar, int port_id);
45727b3fe2SEd Czeck 
46f2764c36SEd Czeck /**
47f2764c36SEd Czeck  * Extension prototype, optional implementation.
48f2764c36SEd Czeck  * Called during device uninit.
49f2764c36SEd Czeck  *
50f2764c36SEd Czeck  * @param dev
51f2764c36SEd Czeck  *   current device.
52f2764c36SEd Czeck  * @param user_data
53f2764c36SEd Czeck  *   user argument from dev_init() call.
54727b3fe2SEd Czeck  */
55f2764c36SEd Czeck void rte_pmd_ark_dev_uninit(struct rte_eth_dev *dev, void *user_data);
56727b3fe2SEd Czeck 
57f2764c36SEd Czeck /**
58f2764c36SEd Czeck  * Extension prototype, optional implementation.
59f2764c36SEd Czeck  * Called during device probe to change the port count from 1.
60f2764c36SEd Czeck  *
61f2764c36SEd Czeck  * @param dev
62f2764c36SEd Czeck  *   current device.
63f2764c36SEd Czeck  * @param user_data
64f2764c36SEd Czeck  *   user argument from dev_init() call.
65f2764c36SEd Czeck  * @return (0) if successful.
66727b3fe2SEd Czeck  */
67f2764c36SEd Czeck uint8_t dev_get_port_count(struct rte_eth_dev *dev, void *user_data);
68727b3fe2SEd Czeck 
69f2764c36SEd Czeck /**
70f2764c36SEd Czeck  * Extension prototype, optional implementation.
71f2764c36SEd Czeck  * Called during rte_eth_dev_configure().
72f2764c36SEd Czeck  *
73f2764c36SEd Czeck  * @param dev
74f2764c36SEd Czeck  *   current device.
75f2764c36SEd Czeck  * @param user_data
76f2764c36SEd Czeck  *   user argument from dev_init() call.
77f2764c36SEd Czeck  * @return (0) if successful.
78f2764c36SEd Czeck  */
79f2764c36SEd Czeck int rte_pmd_ark_dev_configure(struct rte_eth_dev *dev, void *user_data);
80727b3fe2SEd Czeck 
81f2764c36SEd Czeck /**
82f2764c36SEd Czeck  * Extension prototype, optional implementation.
83f2764c36SEd Czeck  * Called during rte_eth_dev_start().
84f2764c36SEd Czeck  *
85f2764c36SEd Czeck  * @param dev
86f2764c36SEd Czeck  *   current device.
87f2764c36SEd Czeck  * @param user_data
88f2764c36SEd Czeck  *   user argument from dev_init() call.
89f2764c36SEd Czeck  * @return (0) if successful.
90f2764c36SEd Czeck  */
91f2764c36SEd Czeck int rte_pmd_ark_dev_start(struct rte_eth_dev *dev, void *user_data);
92727b3fe2SEd Czeck 
93f2764c36SEd Czeck /**
94f2764c36SEd Czeck  * Extension prototype, optional implementation.
95f2764c36SEd Czeck  * Called during  rte_eth_dev_stop().
96f2764c36SEd Czeck  *
97f2764c36SEd Czeck  * @param dev
98f2764c36SEd Czeck  *   current device.
99f2764c36SEd Czeck  * @param user_data
100f2764c36SEd Czeck  *   user argument from dev_init() call.
101f2764c36SEd Czeck  * @return (0) if successful.
102f2764c36SEd Czeck  */
103f2764c36SEd Czeck void rte_pmd_ark_dev_stop(struct rte_eth_dev *dev, void *user_data);
104727b3fe2SEd Czeck 
105f2764c36SEd Czeck /**
106f2764c36SEd Czeck  * Extension prototype, optional implementation.
107f2764c36SEd Czeck  * Called during rte_eth_dev_close().
108f2764c36SEd Czeck  *
109f2764c36SEd Czeck  * @param dev
110f2764c36SEd Czeck  *   current device.
111f2764c36SEd Czeck  * @param user_data
112f2764c36SEd Czeck  *   user argument from dev_init() call.
113f2764c36SEd Czeck  * @return (0) if successful.
114f2764c36SEd Czeck  */
115f2764c36SEd Czeck void rte_pmd_ark_dev_close(struct rte_eth_dev *dev, void *user_data);
116727b3fe2SEd Czeck 
117f2764c36SEd Czeck /**
118f2764c36SEd Czeck  * Extension prototype, optional implementation.
119f2764c36SEd Czeck  * Called during link_update status event.
120f2764c36SEd Czeck  *
121f2764c36SEd Czeck  * @param dev
122f2764c36SEd Czeck  *   current device.
123f2764c36SEd Czeck  * @param wait_to_complete
124f2764c36SEd Czeck  *    argument from update event.
125f2764c36SEd Czeck  * @param user_data
126f2764c36SEd Czeck  *   user argument from dev_init() call.
127f2764c36SEd Czeck  * @return (0) if successful.
128f2764c36SEd Czeck  */
129f2764c36SEd Czeck int rte_pmd_ark_link_update(struct rte_eth_dev *dev,
130727b3fe2SEd Czeck 			    int wait_to_complete,
131727b3fe2SEd Czeck 			    void *user_data);
132727b3fe2SEd Czeck 
133f2764c36SEd Czeck /**
134f2764c36SEd Czeck  * Extension prototype, optional implementation.
135f2764c36SEd Czeck  * Called during rte_eth_dev_set_link_up().
136f2764c36SEd Czeck  *
137f2764c36SEd Czeck  * @param dev
138f2764c36SEd Czeck  *   current device.
139f2764c36SEd Czeck  * @param user_data
140f2764c36SEd Czeck  *   user argument from dev_init() call.
141f2764c36SEd Czeck  * @return (0) if successful.
142f2764c36SEd Czeck  */
143f2764c36SEd Czeck int rte_pmd_ark_dev_set_link_up(struct rte_eth_dev *dev, void *user_data);
144727b3fe2SEd Czeck 
145f2764c36SEd Czeck /**
146f2764c36SEd Czeck  * Extension prototype, optional implementation.
147f2764c36SEd Czeck  * Called during rte_eth_dev_set_link_down().
148f2764c36SEd Czeck  *
149f2764c36SEd Czeck  * @param dev
150f2764c36SEd Czeck  *   current device.
151f2764c36SEd Czeck  * @param user_data
152f2764c36SEd Czeck  *   user argument from dev_init() call.
153f2764c36SEd Czeck  * @return (0) if successful.
154f2764c36SEd Czeck  */
155f2764c36SEd Czeck int rte_pmd_ark_dev_set_link_down(struct rte_eth_dev *dev, void *user_data);
156727b3fe2SEd Czeck 
157f2764c36SEd Czeck /**
158f2764c36SEd Czeck  * Extension prototype, optional implementation.
159f2764c36SEd Czeck  * Called during rte_eth_stats_get(); allows updates to the stats
160f2764c36SEd Czeck  * struct in addition Ark's PMD operations.
161f2764c36SEd Czeck  *
162f2764c36SEd Czeck  * @param dev
163f2764c36SEd Czeck  *   current device.
164f2764c36SEd Czeck  * @param stats
165f2764c36SEd Czeck  *   statistics struct already populated by Ark PMD.
166f2764c36SEd Czeck  * @param user_data
167f2764c36SEd Czeck  *   user argument from dev_init() call.
168f2764c36SEd Czeck  * @return (0) if successful.
169f2764c36SEd Czeck  */
170f2764c36SEd Czeck int rte_pmd_ark_stats_get(struct rte_eth_dev *dev,
171727b3fe2SEd Czeck 			  struct rte_eth_stats *stats,
172727b3fe2SEd Czeck 			  void *user_data);
173727b3fe2SEd Czeck 
174f2764c36SEd Czeck /**
175f2764c36SEd Czeck  * Extension prototype, optional implementation.
176f2764c36SEd Czeck  * Called during rte_eth_dev_stats_reset().
177f2764c36SEd Czeck  *
178f2764c36SEd Czeck  * @param dev
179f2764c36SEd Czeck  *   current device.
180f2764c36SEd Czeck  * @param user_data
181f2764c36SEd Czeck  *   user argument from dev_init() call.
182f2764c36SEd Czeck  * @return (0) if successful.
183f2764c36SEd Czeck  */
184f2764c36SEd Czeck void rte_pmd_ark_stats_reset(struct rte_eth_dev *dev, void *user_data);
185727b3fe2SEd Czeck 
186f2764c36SEd Czeck /**
187f2764c36SEd Czeck  * Extension prototype, optional implementation.
188f2764c36SEd Czeck  * Called during rte_eth_dev_mac_addr_add().
189f2764c36SEd Czeck  *
190f2764c36SEd Czeck  * @param dev
191f2764c36SEd Czeck  *   current device.
192f2764c36SEd Czeck  * @param macaddr
193f2764c36SEd Czeck  *   The MAC address to add
194f2764c36SEd Czeck  * @param index
195f2764c36SEd Czeck  *   The index into the MAC address array.
196f2764c36SEd Czeck  * @param pool
197f2764c36SEd Czeck  *   VMDq pool index from caller
198f2764c36SEd Czeck  * @param user_data
199f2764c36SEd Czeck  *   user argument from dev_init() call.
200f2764c36SEd Czeck  * @return (0) if successful.
201f2764c36SEd Czeck  */
202f2764c36SEd Czeck void rte_pmd_ark_mac_addr_add(struct rte_eth_dev *dev,
203f2764c36SEd Czeck 			      struct rte_ether_addr *macaddr,
204727b3fe2SEd Czeck 			      uint32_t index,
205727b3fe2SEd Czeck 			      uint32_t pool,
206727b3fe2SEd Czeck 			      void *user_data);
207727b3fe2SEd Czeck 
208f2764c36SEd Czeck /**
209f2764c36SEd Czeck  * Extension prototype, optional implementation.
210f2764c36SEd Czeck  * Called during rte_eth_dev_mac_addr_remove().
211f2764c36SEd Czeck  *
212f2764c36SEd Czeck  * @param dev
213f2764c36SEd Czeck  *   current device.
214f2764c36SEd Czeck  * @param index
215f2764c36SEd Czeck  *   The index into the MAC address array.
216f2764c36SEd Czeck  * @param user_data
217f2764c36SEd Czeck  *   user argument from dev_init() call.
218f2764c36SEd Czeck  * @return (0) if successful.
219f2764c36SEd Czeck  */
220f2764c36SEd Czeck void rte_pmd_ark_mac_addr_remove(struct rte_eth_dev *dev,
221727b3fe2SEd Czeck 				 uint32_t index,
222727b3fe2SEd Czeck 				 void *user_data);
223727b3fe2SEd Czeck 
224f2764c36SEd Czeck /**
225f2764c36SEd Czeck  * Extension prototype, optional implementation.
226f2764c36SEd Czeck  * Called during rte_eth_dev_default_mac_addr_set().
227f2764c36SEd Czeck  *
228f2764c36SEd Czeck  * @param dev
229f2764c36SEd Czeck  *   current device.
230f2764c36SEd Czeck  * @param mac_addr
231f2764c36SEd Czeck  *   The new default MAC address.
232f2764c36SEd Czeck  * @param user_data
233f2764c36SEd Czeck  *   user argument from dev_init() call.
234f2764c36SEd Czeck  * @return (0) if successful.
235f2764c36SEd Czeck  */
236f2764c36SEd Czeck void rte_pmd_ark_mac_addr_set(struct rte_eth_dev *dev,
2376d13ea8eSOlivier Matz 			      struct rte_ether_addr *mac_addr,
238727b3fe2SEd Czeck 			      void *user_data);
239727b3fe2SEd Czeck 
240f2764c36SEd Czeck /**
241f2764c36SEd Czeck  * Extension prototype, optional implementation.
242f2764c36SEd Czeck  * Called during rte_eth_dev_set_mtu().
243f2764c36SEd Czeck  *
244f2764c36SEd Czeck  * @param dev
245f2764c36SEd Czeck  *   current device.
246f2764c36SEd Czeck  * @param size
247f2764c36SEd Czeck  *   The MTU to be applied
248f2764c36SEd Czeck  * @param user_data
249f2764c36SEd Czeck  *   user argument from dev_init() call.
250f2764c36SEd Czeck  * @return (0) if successful.
251f2764c36SEd Czeck  */
252f2764c36SEd Czeck int rte_pmd_ark_set_mtu(struct rte_eth_dev *dev,
2539ae74488SJohn Miller 			uint16_t size,
2549ae74488SJohn Miller 			void *user_data);
2559ae74488SJohn Miller 
2566c7f491eSEd Czeck /**
2576c7f491eSEd Czeck  * Extension prototype, optional implementation.
2586c7f491eSEd Czeck  * Called during rte_eth_rx_burst() for each packet. This extension
2596c7f491eSEd Czeck  * function allows the transfer of meta data from the user's FPGA to
2606c7f491eSEd Czeck  * mbuf fields.
2616c7f491eSEd Czeck  *
2626c7f491eSEd Czeck  * @param mbuf
2636c7f491eSEd Czeck  *   The newly received mbuf
2646c7f491eSEd Czeck  * @param meta
2656c7f491eSEd Czeck  *   The meta data from the user, up to 20 bytes. The
2666c7f491eSEd Czeck  *   underlying data in the PMD is of type uint32_t meta[5];
2676c7f491eSEd Czeck  * @param user_data
2686c7f491eSEd Czeck  *   user argument from dev_init() call.
2696c7f491eSEd Czeck  */
2706c7f491eSEd Czeck void rte_pmd_ark_rx_user_meta_hook(struct rte_mbuf *mbuf,
2716c7f491eSEd Czeck 				   const uint32_t *meta,
2726c7f491eSEd Czeck 				   void *user_data);
2736c7f491eSEd Czeck 
2746c7f491eSEd Czeck /**
2756c7f491eSEd Czeck  * Extension prototype, optional implementation.
2766c7f491eSEd Czeck  * Called during rte_eth_tx_burst() for each packet. This extension
2776c7f491eSEd Czeck  * function allows the transfer of data from the mbuf to the user's
2786c7f491eSEd Czeck  * FPGA.  Up to 20 bytes (5 32-bit words) are transferable
2796c7f491eSEd Czeck  *
2806c7f491eSEd Czeck  * @param mbuf
2816c7f491eSEd Czeck  *   The mbuf about to be transmitted.
2826c7f491eSEd Czeck  * @param meta
2836c7f491eSEd Czeck  *   The meta data to be populate by this call. The
2846c7f491eSEd Czeck  *   underlying in the PMD is of type uint32_t meta[5];
2856c7f491eSEd Czeck  * @param meta_cnt
2866c7f491eSEd Czeck  *   The count in 32-bit words of the meta data populated, 0 to 5.
2876c7f491eSEd Czeck  * @param user_data
2886c7f491eSEd Czeck  *   user argument from dev_init() call.
2896c7f491eSEd Czeck  */
2906c7f491eSEd Czeck void rte_pmd_ark_tx_user_meta_hook(const struct rte_mbuf *mbuf,
2916c7f491eSEd Czeck 				   uint32_t *meta,
2926c7f491eSEd Czeck 				   uint8_t *meta_cnt,
2936c7f491eSEd Czeck 				   void *user_data);
294f2764c36SEd Czeck 
295727b3fe2SEd Czeck #endif
296