xref: /dpdk/drivers/common/sfc_efx/sfc_efx_mcdi.h (revision 1094dd940ec0cc4e3ce2c5cd94807350855a17f9)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2021 Xilinx, Inc.
4  * Copyright(c) 2016-2019 Solarflare Communications Inc.
5  *
6  * This software was jointly developed between OKTET Labs (under contract
7  * for Solarflare) and Solarflare Communications, Inc.
8  */
9 
10 #ifndef _SFC_EFX_MCDI_H
11 #define _SFC_EFX_MCDI_H
12 
13 #include <stdint.h>
14 
15 #include <rte_compat.h>
16 #include <rte_spinlock.h>
17 
18 #include "efsys.h"
19 #include "efx.h"
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 enum sfc_efx_mcdi_state {
27 	SFC_EFX_MCDI_UNINITIALIZED = 0,
28 	SFC_EFX_MCDI_INITIALIZED,
29 	SFC_EFX_MCDI_BUSY,
30 	SFC_EFX_MCDI_COMPLETED,
31 	SFC_EFX_MCDI_DEAD,
32 
33 	SFC_EFX_MCDI_NSTATES
34 };
35 
36 typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name,
37 					  size_t len, efsys_mem_t *esmp);
38 
39 typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp);
40 
41 typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie);
42 
43 typedef void (sfc_efx_mcdi_mgmt_evq_poll_cb)(void *cookie);
44 
45 struct sfc_efx_mcdi_ops {
46 	sfc_efx_mcdi_dma_alloc_cb	*dma_alloc;
47 	sfc_efx_mcdi_dma_free_cb	*dma_free;
48 	sfc_efx_mcdi_sched_restart_cb	*sched_restart;
49 	sfc_efx_mcdi_mgmt_evq_poll_cb	*mgmt_evq_poll;
50 };
51 
52 struct sfc_efx_mcdi {
53 	rte_spinlock_t			lock;
54 	const struct sfc_efx_mcdi_ops	*ops;
55 	void				*ops_cookie;
56 	efx_nic_t			*nic;
57 	efsys_mem_t			mem;
58 	enum sfc_efx_mcdi_state		state;
59 	efx_mcdi_transport_t		transport;
60 	uint32_t			logtype;
61 	uint32_t			proxy_handle;
62 	efx_rc_t			proxy_result;
63 	const char			*log_prefix;
64 };
65 
66 __rte_internal
67 int sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi,
68 		      uint32_t logtype, const char *log_prefix,
69 		      efx_nic_t *nic,
70 		      const struct sfc_efx_mcdi_ops *ops, void *ops_cookie);
71 __rte_internal
72 void sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif  /* _SFC_EFX_MCDI_H */
79