net/sfc: implement port representor start and 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 #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         struct sfc_repr_proxy_rxq               rxq[SFC_REPR_RXQ_MAX];
68         struct sfc_repr_proxy_txq               txq[SFC_REPR_TXQ_MAX];
69         struct sfc_mae_rule                     *mae_rule;
70         bool                                    enabled;
71         bool                                    started;
72 };
73
74 struct sfc_repr_proxy_dp_rxq {
75         struct rte_mempool              *mp;
76         unsigned int                    ref_count;
77
78         sfc_sw_index_t                  sw_index;
79 };
80
81 struct sfc_repr_proxy_dp_txq {
82         sfc_sw_index_t                  sw_index;
83 };
84
85 enum sfc_repr_proxy_mbox_op {
86         SFC_REPR_PROXY_MBOX_ADD_PORT,
87         SFC_REPR_PROXY_MBOX_DEL_PORT,
88         SFC_REPR_PROXY_MBOX_START_PORT,
89         SFC_REPR_PROXY_MBOX_STOP_PORT,
90 };
91
92 struct sfc_repr_proxy_mbox {
93         struct sfc_repr_proxy_port      *port;
94         enum sfc_repr_proxy_mbox_op     op;
95
96         bool                            write_marker;
97         bool                            ack;
98 };
99
100 TAILQ_HEAD(sfc_repr_proxy_ports, sfc_repr_proxy_port);
101
102 struct sfc_repr_proxy {
103         uint32_t                        service_core_id;
104         uint32_t                        service_id;
105         efx_mport_id_t                  mport_alias;
106         struct sfc_repr_proxy_ports     ports;
107         bool                            started;
108         struct sfc_repr_proxy_dp_rxq    dp_rxq[SFC_REPR_PROXY_NB_RXQ_MAX];
109         struct sfc_repr_proxy_dp_txq    dp_txq[SFC_REPR_PROXY_NB_TXQ_MAX];
110         struct sfc_repr_proxy_filter    mport_filter;
111
112         struct sfc_repr_proxy_mbox      mbox;
113 };
114
115 struct sfc_adapter;
116
117 int sfc_repr_proxy_attach(struct sfc_adapter *sa);
118 void sfc_repr_proxy_pre_detach(struct sfc_adapter *sa);
119 void sfc_repr_proxy_detach(struct sfc_adapter *sa);
120 int sfc_repr_proxy_txq_init(struct sfc_adapter *sa);
121 void sfc_repr_proxy_txq_fini(struct sfc_adapter *sa);
122 int sfc_repr_proxy_start(struct sfc_adapter *sa);
123 void sfc_repr_proxy_stop(struct sfc_adapter *sa);
124
125 #ifdef __cplusplus
126 }
127 #endif
128 #endif  /* _SFC_REPR_PROXY_H */