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