net/cnxk: add cn9k segregated Rx functions
[dpdk.git] / drivers / event / cnxk / cn9k_worker.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #include "roc_api.h"
6
7 #include "cn9k_worker.h"
8 #include "cn9k_cryptodev_ops.h"
9
10 uint16_t __rte_hot
11 cn9k_sso_hws_enq(void *port, const struct rte_event *ev)
12 {
13         struct cn9k_sso_hws *ws = port;
14
15         switch (ev->op) {
16         case RTE_EVENT_OP_NEW:
17                 return cn9k_sso_hws_new_event(ws, ev);
18         case RTE_EVENT_OP_FORWARD:
19                 cn9k_sso_hws_forward_event(ws, ev);
20                 break;
21         case RTE_EVENT_OP_RELEASE:
22                 cnxk_sso_hws_swtag_flush(ws->base + SSOW_LF_GWS_TAG,
23                                          ws->base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
24                 break;
25         default:
26                 return 0;
27         }
28
29         return 1;
30 }
31
32 uint16_t __rte_hot
33 cn9k_sso_hws_enq_burst(void *port, const struct rte_event ev[],
34                        uint16_t nb_events)
35 {
36         RTE_SET_USED(nb_events);
37         return cn9k_sso_hws_enq(port, ev);
38 }
39
40 uint16_t __rte_hot
41 cn9k_sso_hws_enq_new_burst(void *port, const struct rte_event ev[],
42                            uint16_t nb_events)
43 {
44         struct cn9k_sso_hws *ws = port;
45         uint16_t i, rc = 1;
46
47         for (i = 0; i < nb_events && rc; i++)
48                 rc = cn9k_sso_hws_new_event(ws, &ev[i]);
49
50         return nb_events;
51 }
52
53 uint16_t __rte_hot
54 cn9k_sso_hws_enq_fwd_burst(void *port, const struct rte_event ev[],
55                            uint16_t nb_events)
56 {
57         struct cn9k_sso_hws *ws = port;
58
59         RTE_SET_USED(nb_events);
60         cn9k_sso_hws_forward_event(ws, ev);
61
62         return 1;
63 }
64
65 /* Dual ws ops. */
66
67 uint16_t __rte_hot
68 cn9k_sso_hws_dual_enq(void *port, const struct rte_event *ev)
69 {
70         struct cn9k_sso_hws_dual *dws = port;
71         uint64_t base;
72
73         base = dws->base[!dws->vws];
74         switch (ev->op) {
75         case RTE_EVENT_OP_NEW:
76                 return cn9k_sso_hws_dual_new_event(dws, ev);
77         case RTE_EVENT_OP_FORWARD:
78                 cn9k_sso_hws_dual_forward_event(dws, base, ev);
79                 break;
80         case RTE_EVENT_OP_RELEASE:
81                 cnxk_sso_hws_swtag_flush(base + SSOW_LF_GWS_TAG,
82                                          base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
83                 break;
84         default:
85                 return 0;
86         }
87
88         return 1;
89 }
90
91 uint16_t __rte_hot
92 cn9k_sso_hws_dual_enq_burst(void *port, const struct rte_event ev[],
93                             uint16_t nb_events)
94 {
95         RTE_SET_USED(nb_events);
96         return cn9k_sso_hws_dual_enq(port, ev);
97 }
98
99 uint16_t __rte_hot
100 cn9k_sso_hws_dual_enq_new_burst(void *port, const struct rte_event ev[],
101                                 uint16_t nb_events)
102 {
103         struct cn9k_sso_hws_dual *dws = port;
104         uint16_t i, rc = 1;
105
106         for (i = 0; i < nb_events && rc; i++)
107                 rc = cn9k_sso_hws_dual_new_event(dws, &ev[i]);
108
109         return nb_events;
110 }
111
112 uint16_t __rte_hot
113 cn9k_sso_hws_dual_enq_fwd_burst(void *port, const struct rte_event ev[],
114                                 uint16_t nb_events)
115 {
116         struct cn9k_sso_hws_dual *dws = port;
117
118         RTE_SET_USED(nb_events);
119         cn9k_sso_hws_dual_forward_event(dws, dws->base[!dws->vws], ev);
120
121         return 1;
122 }
123
124 uint16_t __rte_hot
125 cn9k_sso_hws_ca_enq(void *port, struct rte_event ev[], uint16_t nb_events)
126 {
127         struct cn9k_sso_hws *ws = port;
128
129         RTE_SET_USED(nb_events);
130
131         return cn9k_cpt_crypto_adapter_enqueue(ws->base + SSOW_LF_GWS_TAG,
132                                                ev->event_ptr);
133 }
134
135 uint16_t __rte_hot
136 cn9k_sso_hws_dual_ca_enq(void *port, struct rte_event ev[], uint16_t nb_events)
137 {
138         struct cn9k_sso_hws_dual *dws = port;
139
140         RTE_SET_USED(nb_events);
141
142         return cn9k_cpt_crypto_adapter_enqueue(
143                 dws->base[!dws->vws] + SSOW_LF_GWS_TAG, ev->event_ptr);
144 }