xref: /dpdk/drivers/event/dlb2/pf/dlb2_main.h (revision a7ba40b2b1bf7ab11fda4050a585d2ca3b159f19)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2020 Intel Corporation
3  */
4 
5 #ifndef __DLB2_MAIN_H
6 #define __DLB2_MAIN_H
7 
8 #include <rte_debug.h>
9 #include <rte_log.h>
10 #include <rte_spinlock.h>
11 #include <rte_pci.h>
12 #include <bus_pci_driver.h>
13 #include <rte_eal_paging.h>
14 
15 #include "base/dlb2_hw_types.h"
16 #include "../dlb2_user.h"
17 
18 #define DLB2_EAL_PROBE_CORE 2
19 #define DLB2_NUM_PROBE_ENQS 1000
20 #define DLB2_HCW_MEM_SIZE 8
21 #define DLB2_HCW_64B_OFF 4
22 #define DLB2_HCW_ALIGN_MASK 0x3F
23 
24 struct dlb2_dev;
25 
26 struct dlb2_port_memory {
27 	struct dlb2_list_head list;
28 	void *cq_base;
29 	bool valid;
30 };
31 
32 struct dlb2_dev {
33 	struct rte_pci_device *pdev;
34 	struct dlb2_hw hw;
35 	/* struct list_head list; */
36 	struct device *dlb2_device;
37 	bool domain_reset_failed;
38 	/* The enqueue_four function enqueues four HCWs (one cache-line worth)
39 	 * to the HQM, using whichever mechanism is supported by the platform
40 	 * on which this driver is running.
41 	 */
42 	void (*enqueue_four)(void *qe4, void *pp_addr);
43 	/* The resource mutex serializes access to driver data structures and
44 	 * hardware registers.
45 	 */
46 	rte_spinlock_t resource_mutex;
47 	bool worker_launched;
48 	u8 revision;
49 	u8 version;
50 };
51 
52 struct dlb2_pp_thread_data {
53 	struct dlb2_hw *hw;
54 	int pp;
55 	bool is_ldb;
56 	int cycles;
57 };
58 
59 struct dlb2_dev *dlb2_probe(struct rte_pci_device *pdev, const void *probe_args);
60 
61 
62 int dlb2_pf_reset(struct dlb2_dev *dlb2_dev);
63 int dlb2_pf_create_sched_domain(struct dlb2_hw *hw,
64 				struct dlb2_create_sched_domain_args *args,
65 				struct dlb2_cmd_response *resp);
66 int dlb2_pf_create_ldb_queue(struct dlb2_hw *hw,
67 			     u32 domain_id,
68 			     struct dlb2_create_ldb_queue_args *args,
69 			     struct dlb2_cmd_response *resp);
70 int dlb2_pf_create_dir_queue(struct dlb2_hw *hw,
71 			     u32 domain_id,
72 			     struct dlb2_create_dir_queue_args *args,
73 			     struct dlb2_cmd_response *resp);
74 int dlb2_pf_create_ldb_port(struct dlb2_hw *hw,
75 			    u32 domain_id,
76 			    struct dlb2_create_ldb_port_args *args,
77 			    uintptr_t cq_dma_base,
78 			    struct dlb2_cmd_response *resp);
79 int dlb2_pf_create_dir_port(struct dlb2_hw *hw,
80 			    u32 domain_id,
81 			    struct dlb2_create_dir_port_args *args,
82 			    uintptr_t cq_dma_base,
83 			    struct dlb2_cmd_response *resp);
84 int dlb2_pf_start_domain(struct dlb2_hw *hw,
85 			 u32 domain_id,
86 			 struct dlb2_start_domain_args *args,
87 			 struct dlb2_cmd_response *resp);
88 int dlb2_pf_enable_ldb_port(struct dlb2_hw *hw,
89 			    u32 domain_id,
90 			    struct dlb2_enable_ldb_port_args *args,
91 			    struct dlb2_cmd_response *resp);
92 int dlb2_pf_disable_ldb_port(struct dlb2_hw *hw,
93 			     u32 domain_id,
94 			     struct dlb2_disable_ldb_port_args *args,
95 			     struct dlb2_cmd_response *resp);
96 int dlb2_pf_enable_dir_port(struct dlb2_hw *hw,
97 			    u32 domain_id,
98 			    struct dlb2_enable_dir_port_args *args,
99 			    struct dlb2_cmd_response *resp);
100 int dlb2_pf_disable_dir_port(struct dlb2_hw *hw,
101 			     u32 domain_id,
102 			     struct dlb2_disable_dir_port_args *args,
103 			     struct dlb2_cmd_response *resp);
104 int dlb2_pf_reset_domain(struct dlb2_hw *hw, u32 domain_id);
105 int dlb2_pf_ldb_port_owned_by_domain(struct dlb2_hw *hw,
106 				     u32 domain_id,
107 				     u32 port_id);
108 int dlb2_pf_dir_port_owned_by_domain(struct dlb2_hw *hw,
109 				     u32 domain_id,
110 				     u32 port_id);
111 
112 #endif /* __DLB2_MAIN_H */
113