Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #include <inttypes.h>
6 : : #include <math.h>
7 : :
8 : : #include "cnxk_ethdev.h"
9 : :
10 : : struct sdp_channel {
11 : : bool is_sdp_mask_set;
12 : : uint16_t channel;
13 : : uint16_t mask;
14 : : };
15 : :
16 : : struct flow_pre_l2_size_info {
17 : : uint8_t pre_l2_size_off;
18 : : uint8_t pre_l2_size_off_mask;
19 : : uint8_t pre_l2_size_shift_dir;
20 : : };
21 : :
22 : : static int
23 : 0 : parse_outb_nb_desc(const char *key, const char *value, void *extra_args)
24 : : {
25 : : RTE_SET_USED(key);
26 : : uint32_t val;
27 : :
28 : : val = atoi(value);
29 : :
30 : 0 : *(uint16_t *)extra_args = val;
31 : :
32 : 0 : return 0;
33 : : }
34 : :
35 : : static int
36 : 0 : parse_outb_nb_crypto_qs(const char *key, const char *value, void *extra_args)
37 : : {
38 : : RTE_SET_USED(key);
39 : : uint32_t val;
40 : :
41 : 0 : val = atoi(value);
42 : :
43 [ # # ]: 0 : if (val < 1 || val > 64)
44 : : return -EINVAL;
45 : :
46 : 0 : *(uint16_t *)extra_args = val;
47 : :
48 : 0 : return 0;
49 : : }
50 : :
51 : : static int
52 : 0 : parse_ipsec_in_spi_range(const char *key, const char *value, void *extra_args)
53 : : {
54 : : RTE_SET_USED(key);
55 : : uint32_t val;
56 : :
57 : 0 : errno = 0;
58 : 0 : val = strtoul(value, NULL, 0);
59 [ # # ]: 0 : if (errno)
60 : : val = 0;
61 : :
62 : 0 : *(uint32_t *)extra_args = val;
63 : :
64 : 0 : return 0;
65 : : }
66 : :
67 : : static int
68 : 0 : parse_ipsec_out_max_sa(const char *key, const char *value, void *extra_args)
69 : : {
70 : : RTE_SET_USED(key);
71 : : uint32_t val;
72 : :
73 : 0 : errno = 0;
74 : 0 : val = strtoul(value, NULL, 0);
75 [ # # ]: 0 : if (errno)
76 : : val = 0;
77 : :
78 : 0 : *(uint32_t *)extra_args = val;
79 : :
80 : 0 : return 0;
81 : : }
82 : :
83 : : static int
84 : 0 : parse_flow_max_priority(const char *key, const char *value, void *extra_args)
85 : : {
86 : : RTE_SET_USED(key);
87 : : uint16_t val;
88 : :
89 : 0 : val = atoi(value);
90 : :
91 : : /* Limit the max priority to 32 */
92 [ # # ]: 0 : if (val < 1 || val > 32)
93 : : return -EINVAL;
94 : :
95 : 0 : *(uint16_t *)extra_args = val;
96 : :
97 : 0 : return 0;
98 : : }
99 : :
100 : : static int
101 : 0 : parse_flow_prealloc_size(const char *key, const char *value, void *extra_args)
102 : : {
103 : : RTE_SET_USED(key);
104 : : uint16_t val;
105 : :
106 : 0 : val = atoi(value);
107 : :
108 : : /* Limit the prealloc size to 32 */
109 [ # # ]: 0 : if (val < 1 || val > 32)
110 : : return -EINVAL;
111 : :
112 : 0 : *(uint16_t *)extra_args = val;
113 : :
114 : 0 : return 0;
115 : : }
116 : :
117 : : static int
118 : 0 : parse_reta_size(const char *key, const char *value, void *extra_args)
119 : : {
120 : : RTE_SET_USED(key);
121 : : uint32_t val;
122 : :
123 : 0 : val = atoi(value);
124 : :
125 [ # # ]: 0 : if (val <= RTE_ETH_RSS_RETA_SIZE_64)
126 : : val = ROC_NIX_RSS_RETA_SZ_64;
127 [ # # ]: 0 : else if (val > RTE_ETH_RSS_RETA_SIZE_64 && val <= RTE_ETH_RSS_RETA_SIZE_128)
128 : : val = ROC_NIX_RSS_RETA_SZ_128;
129 [ # # ]: 0 : else if (val > RTE_ETH_RSS_RETA_SIZE_128 && val <= RTE_ETH_RSS_RETA_SIZE_256)
130 : : val = ROC_NIX_RSS_RETA_SZ_256;
131 : : else
132 : : val = ROC_NIX_RSS_RETA_SZ_64;
133 : :
134 : 0 : *(uint16_t *)extra_args = val;
135 : :
136 : 0 : return 0;
137 : : }
138 : :
139 : : static int
140 : 0 : parse_pre_l2_hdr_info(const char *key, const char *value, void *extra_args)
141 : : {
142 : : struct flow_pre_l2_size_info *info =
143 : : (struct flow_pre_l2_size_info *)extra_args;
144 : 0 : char *tok1 = NULL, *tok2 = NULL;
145 : : uint16_t off, off_mask, dir;
146 : :
147 : : RTE_SET_USED(key);
148 : 0 : off = strtol(value, &tok1, 16);
149 : 0 : tok1++;
150 : 0 : off_mask = strtol(tok1, &tok2, 16);
151 : 0 : tok2++;
152 : 0 : dir = strtol(tok2, 0, 16);
153 [ # # # # ]: 0 : if (off >= 256 || off_mask < 1 || off_mask >= 256 || dir > 1)
154 : : return -EINVAL;
155 : 0 : info->pre_l2_size_off = off;
156 : 0 : info->pre_l2_size_off_mask = off_mask;
157 : 0 : info->pre_l2_size_shift_dir = dir;
158 : :
159 : 0 : return 0;
160 : : }
161 : :
162 : : static int
163 : 0 : parse_flag(const char *key, const char *value, void *extra_args)
164 : : {
165 : : RTE_SET_USED(key);
166 : :
167 : 0 : *(uint16_t *)extra_args = atoi(value);
168 : :
169 : 0 : return 0;
170 : : }
171 : :
172 : : static int
173 : 0 : parse_sqb_count(const char *key, const char *value, void *extra_args)
174 : : {
175 : : RTE_SET_USED(key);
176 : : uint32_t val;
177 : :
178 : : val = atoi(value);
179 : :
180 : 0 : *(uint16_t *)extra_args = val;
181 : :
182 : 0 : return 0;
183 : : }
184 : :
185 : : static int
186 : 0 : parse_meta_bufsize(const char *key, const char *value, void *extra_args)
187 : : {
188 : : RTE_SET_USED(key);
189 : : uint32_t val;
190 : :
191 : 0 : errno = 0;
192 : 0 : val = strtoul(value, NULL, 0);
193 [ # # ]: 0 : if (errno)
194 : : val = 0;
195 : :
196 : 0 : *(uint32_t *)extra_args = val;
197 : :
198 : 0 : return 0;
199 : : }
200 : :
201 : : static int
202 : 0 : parse_switch_header_type(const char *key, const char *value, void *extra_args)
203 : : {
204 : : RTE_SET_USED(key);
205 : :
206 [ # # ]: 0 : if (strcmp(value, "higig2") == 0)
207 : 0 : *(uint16_t *)extra_args = ROC_PRIV_FLAGS_HIGIG;
208 : :
209 [ # # ]: 0 : if (strcmp(value, "dsa") == 0)
210 : 0 : *(uint16_t *)extra_args = ROC_PRIV_FLAGS_EDSA;
211 : :
212 [ # # ]: 0 : if (strcmp(value, "chlen90b") == 0)
213 : 0 : *(uint16_t *)extra_args = ROC_PRIV_FLAGS_LEN_90B;
214 : :
215 [ # # ]: 0 : if (strcmp(value, "exdsa") == 0)
216 : 0 : *(uint16_t *)extra_args = ROC_PRIV_FLAGS_EXDSA;
217 : :
218 [ # # ]: 0 : if (strcmp(value, "vlan_exdsa") == 0)
219 : 0 : *(uint16_t *)extra_args = ROC_PRIV_FLAGS_VLAN_EXDSA;
220 : :
221 [ # # ]: 0 : if (strcmp(value, "pre_l2") == 0)
222 : 0 : *(uint16_t *)extra_args = ROC_PRIV_FLAGS_PRE_L2;
223 : :
224 : 0 : return 0;
225 : : }
226 : :
227 : : static int
228 : 0 : parse_sdp_channel_mask(const char *key, const char *value, void *extra_args)
229 : : {
230 : : RTE_SET_USED(key);
231 : : uint16_t chan = 0, mask = 0;
232 : 0 : char *next = 0;
233 : :
234 : : /* next will point to the separator '/' */
235 : 0 : chan = strtol(value, &next, 16);
236 : 0 : mask = strtol(++next, 0, 16);
237 : :
238 [ # # ]: 0 : if (chan > GENMASK(11, 0) || mask > GENMASK(11, 0))
239 : : return -EINVAL;
240 : :
241 : 0 : ((struct sdp_channel *)extra_args)->channel = chan;
242 : 0 : ((struct sdp_channel *)extra_args)->mask = mask;
243 : 0 : ((struct sdp_channel *)extra_args)->is_sdp_mask_set = true;
244 : :
245 : 0 : return 0;
246 : : }
247 : :
248 : : static int
249 : 0 : parse_val_u16(const char *key, const char *value, void *extra_args)
250 : : {
251 : : RTE_SET_USED(key);
252 : : uint16_t val;
253 : :
254 : 0 : val = atoi(value);
255 : :
256 : 0 : *(uint16_t *)extra_args = val;
257 : :
258 : 0 : return 0;
259 : : }
260 : :
261 : : #define CNXK_RSS_RETA_SIZE "reta_size"
262 : : #define CNXK_SCL_ENABLE "scalar_enable"
263 : : #define CNXK_TX_COMPL_ENA "tx_compl_ena"
264 : : #define CNXK_MAX_SQB_COUNT "max_sqb_count"
265 : : #define CNXK_FLOW_PREALLOC_SIZE "flow_prealloc_size"
266 : : #define CNXK_FLOW_MAX_PRIORITY "flow_max_priority"
267 : : #define CNXK_SWITCH_HEADER_TYPE "switch_header"
268 : : #define CNXK_RSS_TAG_AS_XOR "tag_as_xor"
269 : : #define CNXK_LOCK_RX_CTX "lock_rx_ctx"
270 : : #define CNXK_IPSEC_IN_MIN_SPI "ipsec_in_min_spi"
271 : : #define CNXK_IPSEC_IN_MAX_SPI "ipsec_in_max_spi"
272 : : #define CNXK_IPSEC_OUT_MAX_SA "ipsec_out_max_sa"
273 : : #define CNXK_OUTB_NB_DESC "outb_nb_desc"
274 : : #define CNXK_NO_INL_DEV "no_inl_dev"
275 : : #define CNXK_OUTB_NB_CRYPTO_QS "outb_nb_crypto_qs"
276 : : #define CNXK_SDP_CHANNEL_MASK "sdp_channel_mask"
277 : : #define CNXK_FLOW_PRE_L2_INFO "flow_pre_l2_info"
278 : : #define CNXK_CUSTOM_SA_ACT "custom_sa_act"
279 : : #define CNXK_SQB_SLACK "sqb_slack"
280 : : #define CNXK_NIX_META_BUF_SZ "meta_buf_sz"
281 : : #define CNXK_FLOW_AGING_POLL_FREQ "aging_poll_freq"
282 : : #define CNXK_NIX_RX_INJ_ENABLE "rx_inj_ena"
283 : : #define CNXK_CUSTOM_META_AURA_DIS "custom_meta_aura_dis"
284 : : #define CNXK_CUSTOM_INB_SA "custom_inb_sa"
285 : :
286 : : int
287 : 0 : cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev)
288 : : {
289 : 0 : uint16_t aging_thread_poll_freq = ROC_NPC_AGE_POLL_FREQ_MIN;
290 : 0 : uint16_t reta_sz = ROC_NIX_RSS_RETA_SZ_64;
291 : 0 : uint16_t sqb_count = CNXK_NIX_TX_MAX_SQB;
292 : : struct flow_pre_l2_size_info pre_l2_info;
293 : 0 : uint32_t ipsec_in_max_spi = BIT(8) - 1;
294 : 0 : uint16_t sqb_slack = ROC_NIX_SQB_SLACK;
295 : 0 : uint32_t ipsec_out_max_sa = BIT(12);
296 : 0 : uint16_t custom_meta_aura_dis = 0;
297 : 0 : uint16_t flow_prealloc_size = 1;
298 : 0 : uint16_t switch_header_type = 0;
299 : 0 : uint16_t flow_max_priority = 3;
300 : 0 : uint16_t outb_nb_crypto_qs = 1;
301 : 0 : uint32_t ipsec_in_min_spi = 0;
302 : 0 : uint16_t outb_nb_desc = 8200;
303 : : struct sdp_channel sdp_chan;
304 : 0 : uint16_t rss_tag_as_xor = 0;
305 : 0 : uint16_t scalar_enable = 0;
306 : 0 : uint16_t tx_compl_ena = 0;
307 : 0 : uint16_t custom_sa_act = 0;
308 : 0 : uint16_t custom_inb_sa = 0;
309 : : struct rte_kvargs *kvlist;
310 : 0 : uint32_t meta_buf_sz = 0;
311 : 0 : uint16_t lock_rx_ctx = 0;
312 : 0 : uint16_t rx_inj_ena = 0;
313 [ # # ]: 0 : uint16_t no_inl_dev = 0;
314 : :
315 : : memset(&sdp_chan, 0, sizeof(sdp_chan));
316 : : memset(&pre_l2_info, 0, sizeof(struct flow_pre_l2_size_info));
317 : :
318 [ # # ]: 0 : if (devargs == NULL)
319 : 0 : goto null_devargs;
320 : :
321 : 0 : kvlist = rte_kvargs_parse(devargs->args, NULL);
322 [ # # ]: 0 : if (kvlist == NULL)
323 : 0 : goto exit;
324 : :
325 : 0 : rte_kvargs_process(kvlist, CNXK_RSS_RETA_SIZE, &parse_reta_size,
326 : : &reta_sz);
327 : 0 : rte_kvargs_process(kvlist, CNXK_SCL_ENABLE, &parse_flag,
328 : : &scalar_enable);
329 : 0 : rte_kvargs_process(kvlist, CNXK_TX_COMPL_ENA, &parse_flag,
330 : : &tx_compl_ena);
331 : 0 : rte_kvargs_process(kvlist, CNXK_MAX_SQB_COUNT, &parse_sqb_count,
332 : : &sqb_count);
333 : 0 : rte_kvargs_process(kvlist, CNXK_FLOW_PREALLOC_SIZE,
334 : : &parse_flow_prealloc_size, &flow_prealloc_size);
335 : 0 : rte_kvargs_process(kvlist, CNXK_FLOW_MAX_PRIORITY,
336 : : &parse_flow_max_priority, &flow_max_priority);
337 : 0 : rte_kvargs_process(kvlist, CNXK_SWITCH_HEADER_TYPE,
338 : : &parse_switch_header_type, &switch_header_type);
339 : 0 : rte_kvargs_process(kvlist, CNXK_RSS_TAG_AS_XOR, &parse_flag,
340 : : &rss_tag_as_xor);
341 : 0 : rte_kvargs_process(kvlist, CNXK_LOCK_RX_CTX, &parse_flag, &lock_rx_ctx);
342 : 0 : rte_kvargs_process(kvlist, CNXK_IPSEC_IN_MIN_SPI,
343 : : &parse_ipsec_in_spi_range, &ipsec_in_min_spi);
344 : 0 : rte_kvargs_process(kvlist, CNXK_IPSEC_IN_MAX_SPI,
345 : : &parse_ipsec_in_spi_range, &ipsec_in_max_spi);
346 : 0 : rte_kvargs_process(kvlist, CNXK_IPSEC_OUT_MAX_SA,
347 : : &parse_ipsec_out_max_sa, &ipsec_out_max_sa);
348 : 0 : rte_kvargs_process(kvlist, CNXK_OUTB_NB_DESC, &parse_outb_nb_desc,
349 : : &outb_nb_desc);
350 : 0 : rte_kvargs_process(kvlist, CNXK_OUTB_NB_CRYPTO_QS,
351 : : &parse_outb_nb_crypto_qs, &outb_nb_crypto_qs);
352 : 0 : rte_kvargs_process(kvlist, CNXK_NO_INL_DEV, &parse_flag, &no_inl_dev);
353 : 0 : rte_kvargs_process(kvlist, CNXK_SDP_CHANNEL_MASK,
354 : : &parse_sdp_channel_mask, &sdp_chan);
355 : 0 : rte_kvargs_process(kvlist, CNXK_FLOW_PRE_L2_INFO,
356 : : &parse_pre_l2_hdr_info, &pre_l2_info);
357 : 0 : rte_kvargs_process(kvlist, CNXK_CUSTOM_SA_ACT, &parse_flag,
358 : : &custom_sa_act);
359 : 0 : rte_kvargs_process(kvlist, CNXK_SQB_SLACK, &parse_sqb_count,
360 : : &sqb_slack);
361 : 0 : rte_kvargs_process(kvlist, CNXK_NIX_META_BUF_SZ, &parse_meta_bufsize, &meta_buf_sz);
362 : 0 : rte_kvargs_process(kvlist, CNXK_FLOW_AGING_POLL_FREQ, &parse_val_u16,
363 : : &aging_thread_poll_freq);
364 : 0 : rte_kvargs_process(kvlist, CNXK_NIX_RX_INJ_ENABLE, &parse_flag, &rx_inj_ena);
365 : 0 : rte_kvargs_process(kvlist, CNXK_CUSTOM_META_AURA_DIS, &parse_flag,
366 : : &custom_meta_aura_dis);
367 : 0 : rte_kvargs_process(kvlist, CNXK_CUSTOM_INB_SA, &parse_flag, &custom_inb_sa);
368 : 0 : rte_kvargs_free(kvlist);
369 : :
370 : 0 : null_devargs:
371 : 0 : dev->scalar_ena = !!scalar_enable;
372 : 0 : dev->tx_compl_ena = !!tx_compl_ena;
373 : 0 : dev->inb.no_inl_dev = !!no_inl_dev;
374 : 0 : dev->inb.min_spi = ipsec_in_min_spi;
375 : 0 : dev->inb.max_spi = ipsec_in_max_spi;
376 : 0 : dev->inb.custom_meta_aura_dis = custom_meta_aura_dis;
377 : 0 : dev->outb.max_sa = ipsec_out_max_sa;
378 : 0 : dev->outb.nb_desc = outb_nb_desc;
379 : 0 : dev->outb.nb_crypto_qs = outb_nb_crypto_qs;
380 : 0 : dev->nix.ipsec_out_max_sa = ipsec_out_max_sa;
381 : 0 : dev->nix.rss_tag_as_xor = !!rss_tag_as_xor;
382 : 0 : dev->nix.max_sqb_count = sqb_count;
383 : 0 : dev->nix.reta_sz = reta_sz;
384 : 0 : dev->nix.lock_rx_ctx = lock_rx_ctx;
385 : 0 : dev->nix.custom_sa_action = custom_sa_act;
386 : 0 : dev->nix.sqb_slack = sqb_slack;
387 [ # # ]: 0 : dev->nix.custom_inb_sa = custom_inb_sa;
388 : :
389 [ # # ]: 0 : if (roc_feature_nix_has_own_meta_aura())
390 : 0 : dev->nix.meta_buf_sz = meta_buf_sz;
391 : :
392 : 0 : dev->npc.flow_prealloc_size = flow_prealloc_size;
393 : 0 : dev->npc.flow_max_priority = flow_max_priority;
394 : 0 : dev->npc.switch_header_type = switch_header_type;
395 : 0 : dev->npc.sdp_channel = sdp_chan.channel;
396 : 0 : dev->npc.sdp_channel_mask = sdp_chan.mask;
397 : 0 : dev->npc.is_sdp_mask_set = sdp_chan.is_sdp_mask_set;
398 : 0 : dev->npc.pre_l2_size_offset = pre_l2_info.pre_l2_size_off;
399 : 0 : dev->npc.pre_l2_size_offset_mask = pre_l2_info.pre_l2_size_off_mask;
400 : 0 : dev->npc.pre_l2_size_shift_dir = pre_l2_info.pre_l2_size_shift_dir;
401 [ # # ]: 0 : dev->npc.flow_age.aging_poll_freq = aging_thread_poll_freq;
402 [ # # ]: 0 : if (roc_feature_nix_has_rx_inject())
403 : 0 : dev->nix.rx_inj_ena = rx_inj_ena;
404 : : return 0;
405 : : exit:
406 : 0 : return -EINVAL;
407 : : }
408 : :
409 : : RTE_PMD_REGISTER_PARAM_STRING(net_cnxk,
410 : : CNXK_RSS_RETA_SIZE "=<64|128|256>"
411 : : CNXK_SCL_ENABLE "=1"
412 : : CNXK_TX_COMPL_ENA "=1"
413 : : CNXK_MAX_SQB_COUNT "=<8-512>"
414 : : CNXK_FLOW_PREALLOC_SIZE "=<1-32>"
415 : : CNXK_FLOW_MAX_PRIORITY "=<1-32>"
416 : : CNXK_SWITCH_HEADER_TYPE "=<higig2|dsa|chlen90b>"
417 : : CNXK_RSS_TAG_AS_XOR "=1"
418 : : CNXK_IPSEC_IN_MAX_SPI "=<1-65535>"
419 : : CNXK_OUTB_NB_DESC "=<1-65535>"
420 : : CNXK_FLOW_PRE_L2_INFO "=<0-255>/<1-255>/<0-1>"
421 : : CNXK_OUTB_NB_CRYPTO_QS "=<1-64>"
422 : : CNXK_NO_INL_DEV "=0"
423 : : CNXK_SDP_CHANNEL_MASK "=<1-4095>/<1-4095>"
424 : : CNXK_CUSTOM_SA_ACT "=1"
425 : : CNXK_SQB_SLACK "=<12-512>"
426 : : CNXK_FLOW_AGING_POLL_FREQ "=<10-65535>"
427 : : CNXK_NIX_RX_INJ_ENABLE "=1"
428 : : CNXK_CUSTOM_META_AURA_DIS "=1");
|