New upstream version 18.02
[deb_dpdk.git] / drivers / net / sfc / sfc_ev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2016-2018 Solarflare Communications Inc.
4  * All rights reserved.
5  *
6  * This software was jointly developed between OKTET Labs (under contract
7  * for Solarflare) and Solarflare Communications, Inc.
8  */
9
10 #ifndef _SFC_EV_H_
11 #define _SFC_EV_H_
12
13 #include <rte_ethdev_driver.h>
14
15 #include "efx.h"
16
17 #include "sfc.h"
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /* Number of entries in the management event queue */
24 #define SFC_MGMT_EVQ_ENTRIES    (EFX_EVQ_MINNEVS)
25
26 struct sfc_adapter;
27 struct sfc_dp_rxq;
28 struct sfc_dp_txq;
29
30 enum sfc_evq_state {
31         SFC_EVQ_UNINITIALIZED = 0,
32         SFC_EVQ_INITIALIZED,
33         SFC_EVQ_STARTING,
34         SFC_EVQ_STARTED,
35
36         SFC_EVQ_NSTATES
37 };
38
39 enum sfc_evq_type {
40         SFC_EVQ_TYPE_MGMT = 0,
41         SFC_EVQ_TYPE_RX,
42         SFC_EVQ_TYPE_TX,
43
44         SFC_EVQ_NTYPES
45 };
46
47 struct sfc_evq {
48         /* Used on datapath */
49         efx_evq_t                       *common;
50         const efx_ev_callbacks_t        *callbacks;
51         unsigned int                    read_ptr;
52         boolean_t                       exception;
53         efsys_mem_t                     mem;
54         struct sfc_dp_rxq               *dp_rxq;
55         struct sfc_dp_txq               *dp_txq;
56
57         /* Not used on datapath */
58         struct sfc_adapter              *sa;
59         unsigned int                    evq_index;
60         enum sfc_evq_state              init_state;
61         enum sfc_evq_type               type;
62         unsigned int                    entries;
63 };
64
65 /*
66  * Functions below define event queue to transmit/receive queue and vice
67  * versa mapping.
68  * Own event queue is allocated for management, each Rx and each Tx queue.
69  * Zero event queue is used for management events.
70  * Rx event queues from 1 to RxQ number follow management event queue.
71  * Tx event queues follow Rx event queues.
72  */
73
74 static inline unsigned int
75 sfc_evq_index_by_rxq_sw_index(__rte_unused struct sfc_adapter *sa,
76                               unsigned int rxq_sw_index)
77 {
78         return 1 + rxq_sw_index;
79 }
80
81 static inline unsigned int
82 sfc_evq_index_by_txq_sw_index(struct sfc_adapter *sa, unsigned int txq_sw_index)
83 {
84         return 1 + sa->eth_dev->data->nb_rx_queues + txq_sw_index;
85 }
86
87 int sfc_ev_attach(struct sfc_adapter *sa);
88 void sfc_ev_detach(struct sfc_adapter *sa);
89 int sfc_ev_start(struct sfc_adapter *sa);
90 void sfc_ev_stop(struct sfc_adapter *sa);
91
92 int sfc_ev_qinit(struct sfc_adapter *sa,
93                  enum sfc_evq_type type, unsigned int type_index,
94                  unsigned int entries, int socket_id, struct sfc_evq **evqp);
95 void sfc_ev_qfini(struct sfc_evq *evq);
96 int sfc_ev_qstart(struct sfc_evq *evq, unsigned int hw_index);
97 void sfc_ev_qstop(struct sfc_evq *evq);
98
99 int sfc_ev_qprime(struct sfc_evq *evq);
100 void sfc_ev_qpoll(struct sfc_evq *evq);
101
102 void sfc_ev_mgmt_qpoll(struct sfc_adapter *sa);
103
104 #ifdef __cplusplus
105 }
106 #endif
107 #endif /* _SFC_EV_H_ */