net/ena: fix build with GCC 12
[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 #include "sfc_flow.h"
23 #include "sfc_mae.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /* Number of supported RxQs with different mbuf memory pools */
30 #define SFC_REPR_PROXY_NB_RXQ_MIN       (1)
31 #define SFC_REPR_PROXY_NB_RXQ_MAX       (1)
32
33 /* One TxQ is required and sufficient for port representors support */
34 #define SFC_REPR_PROXY_NB_TXQ_MIN       (1)
35 #define SFC_REPR_PROXY_NB_TXQ_MAX       (1)
36
37 #define SFC_REPR_PROXY_RX_DESC_COUNT    256
38 #define SFC_REPR_PROXY_RXQ_REFILL_LEVEL (SFC_REPR_PROXY_RX_DESC_COUNT / 4)
39 #define SFC_REPR_PROXY_RX_BURST         32
40
41 #define SFC_REPR_PROXY_TX_DESC_COUNT    256
42 #define SFC_REPR_PROXY_TXQ_FREE_THRESH  (SFC_REPR_PROXY_TX_DESC_COUNT / 4)
43 #define SFC_REPR_PROXY_TX_BURST         32
44
45 struct sfc_repr_proxy_rxq {
46         struct rte_ring                 *ring;
47         struct rte_mempool              *mb_pool;
48 };
49
50 struct sfc_repr_proxy_txq {
51         struct rte_ring                 *ring;
52 };
53
54 struct sfc_repr_proxy_filter {
55         /*
56          * 2 filters are required to match all incoming traffic, unknown
57          * unicast and unknown multicast.
58          */
59         efx_filter_spec_t specs[2];
60 };
61
62 struct sfc_repr_proxy_port {
63         TAILQ_ENTRY(sfc_repr_proxy_port)        entries;
64         uint16_t                                repr_id;
65         uint16_t                                rte_port_id;
66         efx_mport_id_t                          egress_mport;
67         uint32_t                                remote_vnic_mcdi_client_handle;
68         struct sfc_repr_proxy_rxq               rxq[SFC_REPR_RXQ_MAX];
69         struct sfc_repr_proxy_txq               txq[SFC_REPR_TXQ_MAX];
70         struct sfc_mae_rule                     *mae_rule;
71         bool                                    enabled;
72         bool                                    started;
73 };
74
75 struct sfc_repr_proxy_dp_rxq {
76         struct rte_mempool              *mp;
77         unsigned int                    ref_count;
78
79         eth_rx_burst_t                  pkt_burst;
80         struct sfc_dp_rxq               *dp;
81
82         uint16_t                        route_port_id;
83         bool                            stop_route;
84         unsigned int                    available;
85         unsigned int                    forwarded;
86         unsigned int                    routed;
87         struct rte_mbuf                 *pkts[SFC_REPR_PROXY_TX_BURST];
88
89         sfc_sw_index_t                  sw_index;
90 };
91
92 struct sfc_repr_proxy_dp_txq {
93         eth_tx_burst_t                  pkt_burst;
94         struct sfc_dp_txq               *dp;
95
96         unsigned int                    available;
97         unsigned int                    transmitted;
98         struct rte_mbuf                 *tx_pkts[SFC_REPR_PROXY_TX_BURST];
99
100         sfc_sw_index_t                  sw_index;
101 };
102
103 enum sfc_repr_proxy_mbox_op {
104         SFC_REPR_PROXY_MBOX_ADD_PORT,
105         SFC_REPR_PROXY_MBOX_DEL_PORT,
106         SFC_REPR_PROXY_MBOX_START_PORT,
107         SFC_REPR_PROXY_MBOX_STOP_PORT,
108 };
109
110 struct sfc_repr_proxy_mbox {
111         struct sfc_repr_proxy_port      *port;
112         enum sfc_repr_proxy_mbox_op     op;
113
114         bool                            write_marker;
115         bool                            ack;
116 };
117
118 TAILQ_HEAD(sfc_repr_proxy_ports, sfc_repr_proxy_port);
119
120 struct sfc_repr_proxy {
121         uint32_t                        service_core_id;
122         uint32_t                        service_id;
123         efx_mport_id_t                  mport_alias;
124         struct sfc_repr_proxy_ports     ports;
125         bool                            started;
126         struct sfc_repr_proxy_dp_rxq    dp_rxq[SFC_REPR_PROXY_NB_RXQ_MAX];
127         struct sfc_repr_proxy_dp_txq    dp_txq[SFC_REPR_PROXY_NB_TXQ_MAX];
128         struct sfc_repr_proxy_filter    mport_filter;
129
130         struct sfc_repr_proxy_mbox      mbox;
131         unsigned int                    nb_txq;
132         unsigned int                    nb_rxq;
133 };
134
135 struct sfc_adapter;
136
137 int sfc_repr_proxy_attach(struct sfc_adapter *sa);
138 void sfc_repr_proxy_pre_detach(struct sfc_adapter *sa);
139 void sfc_repr_proxy_detach(struct sfc_adapter *sa);
140 int sfc_repr_proxy_txq_init(struct sfc_adapter *sa);
141 void sfc_repr_proxy_txq_fini(struct sfc_adapter *sa);
142 int sfc_repr_proxy_start(struct sfc_adapter *sa);
143 void sfc_repr_proxy_stop(struct sfc_adapter *sa);
144
145 #ifdef __cplusplus
146 }
147 #endif
148 #endif  /* _SFC_REPR_PROXY_H */