xref: /dpdk/drivers/net/sfc/sfc_switch.h (revision f8dbaebbf1c9efcbb2e2354b341ed62175466a57)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2021 Xilinx, Inc.
4  * Copyright(c) 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_SWITCH_H
11 #define _SFC_SWITCH_H
12 
13 #include <stdint.h>
14 
15 #include "efx.h"
16 
17 #include "sfc.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /** Options for MAE switch port type */
24 enum sfc_mae_switch_port_type {
25 	/**
26 	 * The switch port is operated by a self-sufficient RTE ethdev
27 	 * and thus refers to its underlying PCIe function
28 	 */
29 	SFC_MAE_SWITCH_PORT_INDEPENDENT = 0,
30 	/**
31 	 * The switch port is operated by a representor RTE ethdev
32 	 * and thus refers to the represented PCIe function
33 	 */
34 	SFC_MAE_SWITCH_PORT_REPRESENTOR,
35 };
36 
37 struct sfc_mae_switch_port_indep_data {
38 	bool					mae_admin;
39 };
40 
41 struct sfc_mae_switch_port_repr_data {
42 	efx_pcie_interface_t			intf;
43 	uint16_t				pf;
44 	uint16_t				vf;
45 };
46 
47 union sfc_mae_switch_port_data {
48 	struct sfc_mae_switch_port_indep_data	indep;
49 	struct sfc_mae_switch_port_repr_data	repr;
50 };
51 
52 struct sfc_mae_switch_port_request {
53 	enum sfc_mae_switch_port_type		type;
54 	const efx_mport_sel_t			*entity_mportp;
55 	const efx_mport_sel_t			*ethdev_mportp;
56 	uint16_t				ethdev_port_id;
57 	union sfc_mae_switch_port_data		port_data;
58 };
59 
60 typedef void (sfc_mae_switch_port_iterator_cb)(
61 		enum sfc_mae_switch_port_type type,
62 		const efx_mport_sel_t *ethdev_mportp,
63 		uint16_t ethdev_port_id,
64 		const efx_mport_sel_t *entity_mportp,
65 		uint16_t switch_port_id,
66 		union sfc_mae_switch_port_data *port_datap,
67 		void *user_datap);
68 
69 int sfc_mae_switch_ports_iterate(uint16_t switch_domain_id,
70 				 sfc_mae_switch_port_iterator_cb *cb,
71 				 void *data);
72 
73 int sfc_mae_assign_switch_domain(struct sfc_adapter *sa,
74 				 uint16_t *switch_domain_id);
75 
76 int sfc_mae_switch_domain_controllers(uint16_t switch_domain_id,
77 				      const efx_pcie_interface_t **controllers,
78 				      size_t *nb_controllers);
79 
80 int sfc_mae_switch_domain_map_controllers(uint16_t switch_domain_id,
81 					  efx_pcie_interface_t *controllers,
82 					  size_t nb_controllers);
83 
84 int sfc_mae_switch_controller_from_mapping(
85 		const efx_pcie_interface_t *controllers,
86 		size_t nb_controllers,
87 		efx_pcie_interface_t intf,
88 		int *controller);
89 
90 int sfc_mae_switch_domain_get_controller(uint16_t switch_domain_id,
91 				   efx_pcie_interface_t intf,
92 				   int *controller);
93 
94 int sfc_mae_switch_domain_get_intf(uint16_t switch_domain_id,
95 				   int controller,
96 				   efx_pcie_interface_t *intf);
97 
98 int sfc_mae_assign_switch_port(uint16_t switch_domain_id,
99 			       const struct sfc_mae_switch_port_request *req,
100 			       uint16_t *switch_port_id);
101 
102 int sfc_mae_clear_switch_port(uint16_t switch_domain_id,
103 			      uint16_t switch_port_id);
104 
105 int sfc_mae_switch_get_ethdev_mport(uint16_t switch_domain_id,
106 				    uint16_t ethdev_port_id,
107 				    efx_mport_sel_t *mport_sel);
108 
109 int sfc_mae_switch_get_entity_mport(uint16_t switch_domain_id,
110 				    uint16_t ethdev_port_id,
111 				    efx_mport_sel_t *mport_sel);
112 
113 int sfc_mae_switch_port_id_by_entity(uint16_t switch_domain_id,
114 				     const efx_mport_sel_t *entity_mportp,
115 				     enum sfc_mae_switch_port_type type,
116 				     uint16_t *switch_port_id);
117 
118 int sfc_mae_get_switch_domain_admin(uint16_t switch_domain_id,
119 				    uint16_t *port_id);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 #endif /* _SFC_SWITCH_H */
125