1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 Xilinx, Inc.
4 * Copyright(c) 2019 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
10 #ifndef _SFC_REPR_PROXY_H
11 #define _SFC_REPR_PROXY_H
16 #include <rte_mempool.h>
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)
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)
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
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
45 struct sfc_repr_proxy_rxq {
46 struct rte_ring *ring;
47 struct rte_mempool *mb_pool;
50 struct sfc_repr_proxy_txq {
51 struct rte_ring *ring;
54 struct sfc_repr_proxy_filter {
56 * 2 filters are required to match all incoming traffic, unknown
57 * unicast and unknown multicast.
59 efx_filter_spec_t specs[2];
62 struct sfc_repr_proxy_port {
63 TAILQ_ENTRY(sfc_repr_proxy_port) entries;
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;
74 struct sfc_repr_proxy_dp_rxq {
75 struct rte_mempool *mp;
76 unsigned int ref_count;
78 eth_rx_burst_t pkt_burst;
79 struct sfc_dp_rxq *dp;
81 uint16_t route_port_id;
83 unsigned int available;
84 unsigned int forwarded;
86 struct rte_mbuf *pkts[SFC_REPR_PROXY_TX_BURST];
88 sfc_sw_index_t sw_index;
91 struct sfc_repr_proxy_dp_txq {
92 eth_tx_burst_t pkt_burst;
93 struct sfc_dp_txq *dp;
95 unsigned int available;
96 unsigned int transmitted;
97 struct rte_mbuf *tx_pkts[SFC_REPR_PROXY_TX_BURST];
99 sfc_sw_index_t sw_index;
102 enum sfc_repr_proxy_mbox_op {
103 SFC_REPR_PROXY_MBOX_ADD_PORT,
104 SFC_REPR_PROXY_MBOX_DEL_PORT,
105 SFC_REPR_PROXY_MBOX_START_PORT,
106 SFC_REPR_PROXY_MBOX_STOP_PORT,
109 struct sfc_repr_proxy_mbox {
110 struct sfc_repr_proxy_port *port;
111 enum sfc_repr_proxy_mbox_op op;
117 TAILQ_HEAD(sfc_repr_proxy_ports, sfc_repr_proxy_port);
119 struct sfc_repr_proxy {
120 uint32_t service_core_id;
122 efx_mport_id_t mport_alias;
123 struct sfc_repr_proxy_ports ports;
125 struct sfc_repr_proxy_dp_rxq dp_rxq[SFC_REPR_PROXY_NB_RXQ_MAX];
126 struct sfc_repr_proxy_dp_txq dp_txq[SFC_REPR_PROXY_NB_TXQ_MAX];
127 struct sfc_repr_proxy_filter mport_filter;
129 struct sfc_repr_proxy_mbox mbox;
136 int sfc_repr_proxy_attach(struct sfc_adapter *sa);
137 void sfc_repr_proxy_pre_detach(struct sfc_adapter *sa);
138 void sfc_repr_proxy_detach(struct sfc_adapter *sa);
139 int sfc_repr_proxy_txq_init(struct sfc_adapter *sa);
140 void sfc_repr_proxy_txq_fini(struct sfc_adapter *sa);
141 int sfc_repr_proxy_start(struct sfc_adapter *sa);
142 void sfc_repr_proxy_stop(struct sfc_adapter *sa);
147 #endif /* _SFC_REPR_PROXY_H */