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