net/sfc: use switch port ID as representor ID
[dpdk.git] / drivers / net / sfc / sfc_switch.h
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_repr_data {
38         efx_pcie_interface_t                    intf;
39         uint16_t                                pf;
40         uint16_t                                vf;
41 };
42
43 union sfc_mae_switch_port_data {
44         struct sfc_mae_switch_port_repr_data    repr;
45 };
46
47 struct sfc_mae_switch_port_request {
48         enum sfc_mae_switch_port_type           type;
49         const efx_mport_sel_t                   *entity_mportp;
50         const efx_mport_sel_t                   *ethdev_mportp;
51         uint16_t                                ethdev_port_id;
52         union sfc_mae_switch_port_data          port_data;
53 };
54
55 int sfc_mae_assign_switch_domain(struct sfc_adapter *sa,
56                                  uint16_t *switch_domain_id);
57
58 int sfc_mae_switch_domain_controllers(uint16_t switch_domain_id,
59                                       const efx_pcie_interface_t **controllers,
60                                       size_t *nb_controllers);
61
62 int sfc_mae_switch_domain_map_controllers(uint16_t switch_domain_id,
63                                           efx_pcie_interface_t *controllers,
64                                           size_t nb_controllers);
65
66 int sfc_mae_switch_domain_get_controller(uint16_t switch_domain_id,
67                                    efx_pcie_interface_t intf,
68                                    int *controller);
69
70 int sfc_mae_switch_domain_get_intf(uint16_t switch_domain_id,
71                                    int controller,
72                                    efx_pcie_interface_t *intf);
73
74 int sfc_mae_assign_switch_port(uint16_t switch_domain_id,
75                                const struct sfc_mae_switch_port_request *req,
76                                uint16_t *switch_port_id);
77
78 int sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id,
79                                   uint16_t ethdev_port_id,
80                                   efx_mport_sel_t *mport_sel);
81
82 #ifdef __cplusplus
83 }
84 #endif
85 #endif /* _SFC_SWITCH_H */