net/sfc: implement representor queue setup and release
[dpdk.git] / drivers / net / sfc / sfc_repr_proxy.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_REPR_PROXY_H
11 #define _SFC_REPR_PROXY_H
12
13 #include <stdint.h>
14
15 #include <rte_ring.h>
16 #include <rte_mempool.h>
17
18 #include "efx.h"
19
20 #include "sfc_repr.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /* Number of supported RxQs with different mbuf memory pools */
27 #define SFC_REPR_PROXY_NB_RXQ_MIN       (1)
28 #define SFC_REPR_PROXY_NB_RXQ_MAX       (1)
29
30 /* One TxQ is required and sufficient for port representors support */
31 #define SFC_REPR_PROXY_NB_TXQ_MIN       (1)
32 #define SFC_REPR_PROXY_NB_TXQ_MAX       (1)
33
34 struct sfc_repr_proxy_rxq {
35         struct rte_ring                 *ring;
36         struct rte_mempool              *mb_pool;
37 };
38
39 struct sfc_repr_proxy_txq {
40         struct rte_ring                 *ring;
41 };
42
43 struct sfc_repr_proxy_port {
44         TAILQ_ENTRY(sfc_repr_proxy_port)        entries;
45         uint16_t                                repr_id;
46         uint16_t                                rte_port_id;
47         efx_mport_id_t                          egress_mport;
48         struct sfc_repr_proxy_rxq               rxq[SFC_REPR_RXQ_MAX];
49         struct sfc_repr_proxy_txq               txq[SFC_REPR_TXQ_MAX];
50 };
51
52 struct sfc_repr_proxy_dp_rxq {
53         struct rte_mempool              *mp;
54         unsigned int                    ref_count;
55 };
56
57 enum sfc_repr_proxy_mbox_op {
58         SFC_REPR_PROXY_MBOX_ADD_PORT,
59         SFC_REPR_PROXY_MBOX_DEL_PORT,
60 };
61
62 struct sfc_repr_proxy_mbox {
63         struct sfc_repr_proxy_port      *port;
64         enum sfc_repr_proxy_mbox_op     op;
65
66         bool                            write_marker;
67         bool                            ack;
68 };
69
70 TAILQ_HEAD(sfc_repr_proxy_ports, sfc_repr_proxy_port);
71
72 struct sfc_repr_proxy {
73         uint32_t                        service_core_id;
74         uint32_t                        service_id;
75         efx_mport_id_t                  mport_alias;
76         struct sfc_repr_proxy_ports     ports;
77         bool                            started;
78         struct sfc_repr_proxy_dp_rxq    dp_rxq[SFC_REPR_PROXY_NB_RXQ_MAX];
79
80         struct sfc_repr_proxy_mbox      mbox;
81 };
82
83 struct sfc_adapter;
84
85 int sfc_repr_proxy_attach(struct sfc_adapter *sa);
86 void sfc_repr_proxy_pre_detach(struct sfc_adapter *sa);
87 void sfc_repr_proxy_detach(struct sfc_adapter *sa);
88 int sfc_repr_proxy_start(struct sfc_adapter *sa);
89 void sfc_repr_proxy_stop(struct sfc_adapter *sa);
90
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif  /* _SFC_REPR_PROXY_H */