net/sfc: implement representor Tx 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 #define SFC_REPR_PROXY_TX_DESC_COUNT    256
40 #define SFC_REPR_PROXY_TXQ_FREE_THRESH  (SFC_REPR_PROXY_TX_DESC_COUNT / 4)
41 #define SFC_REPR_PROXY_TX_BURST         32
42
43 struct sfc_repr_proxy_rxq {
44         struct rte_ring                 *ring;
45         struct rte_mempool              *mb_pool;
46 };
47
48 struct sfc_repr_proxy_txq {
49         struct rte_ring                 *ring;
50 };
51
52 struct sfc_repr_proxy_port {
53         TAILQ_ENTRY(sfc_repr_proxy_port)        entries;
54         uint16_t                                repr_id;
55         uint16_t                                rte_port_id;
56         efx_mport_id_t                          egress_mport;
57         struct sfc_repr_proxy_rxq               rxq[SFC_REPR_RXQ_MAX];
58         struct sfc_repr_proxy_txq               txq[SFC_REPR_TXQ_MAX];
59 };
60
61 struct sfc_repr_proxy_dp_rxq {
62         struct rte_mempool              *mp;
63         unsigned int                    ref_count;
64
65         sfc_sw_index_t                  sw_index;
66 };
67
68 struct sfc_repr_proxy_dp_txq {
69         sfc_sw_index_t                  sw_index;
70 };
71
72 enum sfc_repr_proxy_mbox_op {
73         SFC_REPR_PROXY_MBOX_ADD_PORT,
74         SFC_REPR_PROXY_MBOX_DEL_PORT,
75 };
76
77 struct sfc_repr_proxy_mbox {
78         struct sfc_repr_proxy_port      *port;
79         enum sfc_repr_proxy_mbox_op     op;
80
81         bool                            write_marker;
82         bool                            ack;
83 };
84
85 TAILQ_HEAD(sfc_repr_proxy_ports, sfc_repr_proxy_port);
86
87 struct sfc_repr_proxy {
88         uint32_t                        service_core_id;
89         uint32_t                        service_id;
90         efx_mport_id_t                  mport_alias;
91         struct sfc_repr_proxy_ports     ports;
92         bool                            started;
93         struct sfc_repr_proxy_dp_rxq    dp_rxq[SFC_REPR_PROXY_NB_RXQ_MAX];
94         struct sfc_repr_proxy_dp_txq    dp_txq[SFC_REPR_PROXY_NB_TXQ_MAX];
95
96         struct sfc_repr_proxy_mbox      mbox;
97 };
98
99 struct sfc_adapter;
100
101 int sfc_repr_proxy_attach(struct sfc_adapter *sa);
102 void sfc_repr_proxy_pre_detach(struct sfc_adapter *sa);
103 void sfc_repr_proxy_detach(struct sfc_adapter *sa);
104 int sfc_repr_proxy_txq_init(struct sfc_adapter *sa);
105 void sfc_repr_proxy_txq_fini(struct sfc_adapter *sa);
106 int sfc_repr_proxy_start(struct sfc_adapter *sa);
107 void sfc_repr_proxy_stop(struct sfc_adapter *sa);
108
109 #ifdef __cplusplus
110 }
111 #endif
112 #endif  /* _SFC_REPR_PROXY_H */