eal/linux: allow hugepage file reuse
[dpdk.git] / config / arm / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation.
3 # Copyright(c) 2017 Cavium, Inc
4 # Copyright(c) 2021 PANTHEON.tech s.r.o.
5
6 # common flags to all aarch64 builds, with lowest priority
7 flags_common = [
8         # Accelerate rte_memcpy. Be sure to run unit test (memcpy_perf_autotest)
9         # to determine the best threshold in code. Refer to notes in source file
10         # (lib/eal/arm/include/rte_memcpy_64.h) for more info.
11         ['RTE_ARCH_ARM64_MEMCPY', false],
12         #    ['RTE_ARM64_MEMCPY_ALIGNED_THRESHOLD', 2048],
13         #    ['RTE_ARM64_MEMCPY_UNALIGNED_THRESHOLD', 512],
14         # Leave below RTE_ARM64_MEMCPY_xxx options commented out,
15         # unless there are strong reasons.
16         #    ['RTE_ARM64_MEMCPY_SKIP_GCC_VER_CHECK', false],
17         #    ['RTE_ARM64_MEMCPY_ALIGN_MASK', 0xF],
18         #    ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false],
19
20         ['RTE_SCHED_VECTOR', false],
21         ['RTE_ARM_USE_WFE', false],
22         ['RTE_ARCH_ARM64', true],
23         ['RTE_CACHE_LINE_SIZE', 128]
24 ]
25
26 ## Part numbers are specific to Arm implementers
27 # implementer specific armv8 flags have middle priority
28 #     (will overwrite common flags)
29 # part number specific armv8 flags have higher priority
30 #     (will overwrite both common and implementer specific flags)
31 implementer_generic = {
32     'description': 'Generic armv8',
33     'flags': [
34         ['RTE_MACHINE', '"armv8a"'],
35         ['RTE_USE_C11_MEM_MODEL', true],
36         ['RTE_MAX_LCORE', 256],
37         ['RTE_MAX_NUMA_NODES', 4]
38     ],
39     'part_number_config': {
40         'generic': {
41             'march': 'armv8-a',
42             'march_features': ['crc'],
43             'compiler_options': ['-moutline-atomics']
44         },
45         'generic_aarch32': {
46             'march': 'armv8-a',
47             'compiler_options': ['-mfpu=neon'],
48             'flags': [
49                 ['RTE_ARCH_ARM_NEON_MEMCPY', false],
50                 ['RTE_ARCH_STRICT_ALIGN', true],
51                 ['RTE_ARCH_ARMv8_AARCH32', true],
52                 ['RTE_ARCH', 'armv8_aarch32'],
53                 ['RTE_CACHE_LINE_SIZE', 64]
54             ]
55         }
56     }
57 }
58
59 part_number_config_arm = {
60     '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
61     '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
62     '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
63     '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
64     '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
65     '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
66     '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
67     '0xd0c': {
68         'march': 'armv8.2-a',
69         'march_features': ['crypto'],
70         'compiler_options':  ['-mcpu=neoverse-n1'],
71         'flags': [
72             ['RTE_MACHINE', '"neoverse-n1"'],
73             ['RTE_ARM_FEATURE_ATOMICS', true],
74             ['RTE_MAX_MEM_MB', 1048576],
75             ['RTE_MAX_LCORE', 160],
76             ['RTE_MAX_NUMA_NODES', 2]
77         ]
78     },
79     '0xd49': {
80         'march': 'armv8.5-a',
81         'march_features': ['sve2'],
82         'flags': [
83             ['RTE_MACHINE', '"neoverse-n2"'],
84             ['RTE_ARM_FEATURE_ATOMICS', true],
85             ['RTE_MAX_LCORE', 64],
86             ['RTE_MAX_NUMA_NODES', 1]
87         ]
88     }
89 }
90 implementer_arm = {
91     'description': 'Arm',
92     'flags': [
93         ['RTE_MACHINE', '"armv8a"'],
94         ['RTE_USE_C11_MEM_MODEL', true],
95         ['RTE_CACHE_LINE_SIZE', 64],
96         ['RTE_MAX_LCORE', 64],
97         ['RTE_MAX_NUMA_NODES', 4]
98     ],
99     'part_number_config': part_number_config_arm
100 }
101
102 flags_part_number_thunderx = [
103     ['RTE_MACHINE', '"thunderx"'],
104     ['RTE_USE_C11_MEM_MODEL', false]
105 ]
106 implementer_cavium = {
107     'description': 'Cavium',
108     'flags': [
109         ['RTE_MAX_VFIO_GROUPS', 128],
110         ['RTE_MAX_LCORE', 96],
111         ['RTE_MAX_NUMA_NODES', 2]
112     ],
113     'part_number_config': {
114         '0xa1': {
115             'compiler_options': ['-mcpu=thunderxt88'],
116             'flags': flags_part_number_thunderx
117         },
118         '0xa2': {
119             'compiler_options': ['-mcpu=thunderxt81'],
120             'flags': flags_part_number_thunderx
121         },
122         '0xa3': {
123             'compiler_options': ['-mcpu=thunderxt83'],
124             'flags': flags_part_number_thunderx
125         },
126         '0xaf': {
127             'march': 'armv8.1-a',
128             'march_features': ['crc', 'crypto'],
129             'compiler_options': ['-mcpu=thunderx2t99'],
130             'flags': [
131                 ['RTE_MACHINE', '"thunderx2"'],
132                 ['RTE_ARM_FEATURE_ATOMICS', true],
133                 ['RTE_USE_C11_MEM_MODEL', true],
134                 ['RTE_CACHE_LINE_SIZE', 64],
135                 ['RTE_MAX_LCORE', 256]
136             ]
137         },
138         '0xb2': {
139             'march': 'armv8.2-a',
140             'march_features': ['crc', 'crypto', 'lse'],
141             'compiler_options': ['-mcpu=octeontx2'],
142             'flags': [
143                 ['RTE_MACHINE', '"cn9k"'],
144                 ['RTE_ARM_FEATURE_ATOMICS', true],
145                 ['RTE_USE_C11_MEM_MODEL', true],
146                 ['RTE_MAX_LCORE', 36],
147                 ['RTE_MAX_NUMA_NODES', 1]
148             ]
149         }
150     }
151 }
152
153 implementer_ampere = {
154     'description': 'Ampere Computing',
155     'flags': [
156         ['RTE_MACHINE', '"emag"'],
157         ['RTE_CACHE_LINE_SIZE', 64],
158         ['RTE_MAX_LCORE', 32],
159         ['RTE_MAX_NUMA_NODES', 1]
160     ],
161     'part_number_config': {
162         '0x0': {
163             'march': 'armv8-a',
164             'march_features': ['crc', 'crypto'],
165             'compiler_options':  ['-mtune=emag']
166         }
167     }
168 }
169
170 implementer_hisilicon = {
171     'description': 'HiSilicon',
172     'flags': [
173         ['RTE_USE_C11_MEM_MODEL', true],
174         ['RTE_CACHE_LINE_SIZE', 128]
175     ],
176     'part_number_config': {
177         '0xd01': {
178             'march': 'armv8.2-a',
179             'march_features': ['crypto'],
180             'compiler_options': ['-mtune=tsv110'],
181             'flags': [
182                 ['RTE_MACHINE', '"Kunpeng 920"'],
183                 ['RTE_ARM_FEATURE_ATOMICS', true],
184                 ['RTE_MAX_LCORE', 256],
185                 ['RTE_MAX_NUMA_NODES', 8]
186             ]
187         },
188         '0xd02': {
189             'march': 'armv8.2-a',
190             'march_features': ['crypto', 'sve'],
191             'flags': [
192                 ['RTE_MACHINE', '"Kunpeng 930"'],
193                 ['RTE_ARM_FEATURE_ATOMICS', true],
194                 ['RTE_MAX_LCORE', 1280],
195                 ['RTE_MAX_NUMA_NODES', 16]
196             ]
197         }
198     }
199 }
200
201 implementer_qualcomm = {
202     'description': 'Qualcomm',
203     'flags': [
204         ['RTE_MACHINE', '"armv8a"'],
205         ['RTE_USE_C11_MEM_MODEL', true],
206         ['RTE_CACHE_LINE_SIZE', 64],
207         ['RTE_MAX_LCORE', 64],
208         ['RTE_MAX_NUMA_NODES', 1]
209     ],
210     'part_number_config': {
211         '0x800': {
212             'march': 'armv8-a',
213             'march_features': ['crc']
214         },
215         '0xc00': {
216             'march': 'armv8-a',
217             'march_features': ['crc']
218         }
219     }
220 }
221
222 ## Arm implementers (ID from MIDR in Arm Architecture Reference Manual)
223 implementers = {
224     'generic': implementer_generic,
225     '0x41': implementer_arm,
226     '0x43': implementer_cavium,
227     '0x48': implementer_hisilicon,
228     '0x50': implementer_ampere,
229     '0x51': implementer_qualcomm
230 }
231
232 # SoC specific armv8 flags have the highest priority
233 #     (will overwrite all other flags)
234 soc_generic = {
235     'description': 'Generic un-optimized build for armv8 aarch64 exec mode',
236     'implementer': 'generic',
237     'part_number': 'generic'
238 }
239
240 soc_generic_aarch32 = {
241     'description': 'Generic un-optimized build for armv8 aarch32 exec mode',
242     'implementer': 'generic',
243     'part_number': 'generic_aarch32'
244 }
245
246 soc_armada = {
247     'description': 'Marvell ARMADA',
248     'implementer': '0x41',
249     'part_number': '0xd08',
250     'flags': [
251         ['RTE_MAX_LCORE', 16],
252         ['RTE_MAX_NUMA_NODES', 1]
253     ],
254     'numa': false
255 }
256
257 soc_bluefield = {
258     'description': 'NVIDIA BlueField',
259     'implementer': '0x41',
260     'part_number': '0xd08',
261     'flags': [
262         ['RTE_MAX_LCORE', 16],
263         ['RTE_MAX_NUMA_NODES', 1]
264     ],
265     'numa': false
266 }
267
268 soc_centriq2400 = {
269     'description': 'Qualcomm Centriq 2400',
270     'implementer': '0x51',
271     'part_number': '0xc00',
272     'numa': false
273 }
274
275 soc_cn10k = {
276     'description' : 'Marvell OCTEON 10',
277     'implementer' : '0x41',
278     'flags': [
279         ['RTE_MAX_LCORE', 24],
280         ['RTE_MAX_NUMA_NODES', 1]
281     ],
282     'part_number': '0xd49',
283     'extra_march_features': ['crypto'],
284     'numa': false
285 }
286
287 soc_dpaa = {
288     'description': 'NXP DPAA',
289     'implementer': '0x41',
290     'part_number': '0xd08',
291     'flags': [
292         ['RTE_MACHINE', '"dpaa"'],
293         ['RTE_LIBRTE_DPAA2_USE_PHYS_IOVA', false],
294         ['RTE_MAX_LCORE', 16],
295         ['RTE_MAX_NUMA_NODES', 1]
296     ],
297     'numa': false
298 }
299
300 soc_emag = {
301     'description': 'Ampere eMAG',
302     'implementer': '0x50',
303     'part_number': '0x0'
304 }
305
306 soc_graviton2 = {
307     'description': 'AWS Graviton2',
308     'implementer': '0x41',
309     'part_number': '0xd0c',
310     'numa': false
311 }
312
313 soc_kunpeng920 = {
314     'description': 'HiSilicon Kunpeng 920',
315     'implementer': '0x48',
316     'part_number': '0xd01',
317     'numa': true
318 }
319
320 soc_kunpeng930 = {
321     'description': 'HiSilicon Kunpeng 930',
322     'implementer': '0x48',
323     'part_number': '0xd02',
324     'numa': true
325 }
326
327 soc_n1sdp = {
328     'description': 'Arm Neoverse N1SDP',
329     'implementer': '0x41',
330     'part_number': '0xd0c',
331     'flags': [
332         ['RTE_MAX_LCORE', 4]
333     ],
334     'numa': false
335 }
336
337 soc_n2 = {
338     'description': 'Arm Neoverse N2',
339     'implementer': '0x41',
340     'part_number': '0xd49',
341     'numa': false
342 }
343
344 soc_cn9k = {
345     'description': 'Marvell OCTEON 9',
346     'implementer': '0x43',
347     'part_number': '0xb2',
348     'numa': false
349 }
350
351 soc_stingray = {
352     'description': 'Broadcom Stingray',
353     'implementer': '0x41',
354     'flags': [
355         ['RTE_MAX_LCORE', 16],
356         ['RTE_MAX_NUMA_NODES', 1]
357     ],
358     'part_number': '0xd08',
359     'numa': false
360 }
361
362 soc_thunderx2 = {
363     'description': 'Marvell ThunderX2 T99',
364     'implementer': '0x43',
365     'part_number': '0xaf'
366 }
367
368 soc_thunderxt88 = {
369     'description': 'Marvell ThunderX T88',
370     'implementer': '0x43',
371     'part_number': '0xa1'
372 }
373
374 '''
375 Start of SoCs list
376 generic:         Generic un-optimized build for armv8 aarch64 execution mode.
377 generic_aarch32: Generic un-optimized build for armv8 aarch32 execution mode.
378 armada:          Marvell ARMADA
379 bluefield:       NVIDIA BlueField
380 centriq2400:     Qualcomm Centriq 2400
381 cn9k:            Marvell OCTEON 9
382 cn10k:           Marvell OCTEON 10
383 dpaa:            NXP DPAA
384 emag:            Ampere eMAG
385 graviton2:       AWS Graviton2
386 kunpeng920:      HiSilicon Kunpeng 920
387 kunpeng930:      HiSilicon Kunpeng 930
388 n1sdp:           Arm Neoverse N1SDP
389 n2:              Arm Neoverse N2
390 stingray:        Broadcom Stingray
391 thunderx2:       Marvell ThunderX2 T99
392 thunderxt88:     Marvell ThunderX T88
393 End of SoCs list
394 '''
395 # The string above is included in the documentation, keep it in sync with the
396 # SoCs list below.
397 socs = {
398     'generic': soc_generic,
399     'generic_aarch32': soc_generic_aarch32,
400     'armada': soc_armada,
401     'bluefield': soc_bluefield,
402     'centriq2400': soc_centriq2400,
403     'cn9k': soc_cn9k,
404     'cn10k' : soc_cn10k,
405     'dpaa': soc_dpaa,
406     'emag': soc_emag,
407     'graviton2': soc_graviton2,
408     'kunpeng920': soc_kunpeng920,
409     'kunpeng930': soc_kunpeng930,
410     'n1sdp': soc_n1sdp,
411     'n2': soc_n2,
412     'stingray': soc_stingray,
413     'thunderx2': soc_thunderx2,
414     'thunderxt88': soc_thunderxt88
415 }
416
417 dpdk_conf.set('RTE_ARCH_ARM', 1)
418 dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)
419
420 update_flags = false
421 soc_flags = []
422 if dpdk_conf.get('RTE_ARCH_32')
423     # 32-bit build
424     dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
425     if meson.is_cross_build()
426         update_flags = true
427         soc = meson.get_cross_property('platform', '')
428         if soc == ''
429             error('Arm SoC must be specified in the cross file.')
430         endif
431         soc_config = socs.get(soc, {'not_supported': true})
432         flags_common = []
433     else
434         # armv7 build
435         dpdk_conf.set('RTE_ARCH_ARMv7', true)
436         dpdk_conf.set('RTE_ARCH', 'armv7')
437         # the minimum architecture supported, armv7-a, needs the following,
438         machine_args += '-mfpu=neon'
439     endif
440 else
441     # armv8 build
442     dpdk_conf.set('RTE_ARCH', 'armv8')
443     update_flags = true
444     soc_config = {}
445     if not meson.is_cross_build()
446         # for backwards compatibility:
447         #   machine=native is the same behavior as soc=native
448         #   machine=generic/default is the same as soc=generic
449         # cpu_instruction_set holds the proper value - native, generic or cpu
450         # the old behavior only distinguished between generic and native build
451         if machine != 'auto'
452             if cpu_instruction_set == 'generic'
453                 soc = 'generic'
454             else
455                 soc = 'native'
456             endif
457         else
458             soc = platform
459         endif
460         if soc == 'native'
461             # native build
462             # The script returns ['Implementer', 'Variant', 'Architecture',
463             # 'Primary Part number', 'Revision']
464             detect_vendor = find_program(join_paths(meson.current_source_dir(),
465                                                     'armv8_machine.py'))
466             cmd = run_command(detect_vendor.path(), check: false)
467             if cmd.returncode() == 0
468                 cmd_output = cmd.stdout().to_lower().strip().split(' ')
469                 implementer_id = cmd_output[0]
470                 part_number = cmd_output[3]
471             else
472                 error('Error when getting Arm Implementer ID and part number.')
473             endif
474         else
475             # SoC build
476             soc_config = socs.get(soc, {'not_supported': true})
477         endif
478     else
479         # cross build
480         soc = meson.get_cross_property('platform', '')
481         if soc == ''
482             error('Arm SoC must be specified in the cross file.')
483         endif
484         soc_config = socs.get(soc, {'not_supported': true})
485     endif
486 endif
487
488 if update_flags
489     if soc_config.has_key('not_supported')
490         error('SoC @0@ not supported.'.format(soc))
491     elif soc_config != {}
492         implementer_id = soc_config['implementer']
493         implementer_config = implementers[implementer_id]
494         part_number = soc_config['part_number']
495         soc_flags = soc_config.get('flags', [])
496         if not soc_config.get('numa', true)
497             has_libnuma = 0
498         endif
499
500         disable_drivers += ',' + soc_config.get('disable_drivers', '')
501         enable_drivers += ',' + soc_config.get('enable_drivers', '')
502     endif
503
504     if implementers.has_key(implementer_id)
505         implementer_config = implementers[implementer_id]
506     else
507         error('Unsupported Arm implementer: @0@. '.format(implementer_id) +
508               'Please add support for it or use the generic ' +
509               '(-Dplatform=generic) build.')
510     endif
511
512     message('Arm implementer: ' + implementer_config['description'])
513     message('Arm part number: ' + part_number)
514
515     part_number_config = implementer_config['part_number_config']
516     if part_number_config.has_key(part_number)
517         # use the specified part_number machine args if found
518         part_number_config = part_number_config[part_number]
519     else
520         # unknown part number
521         error('Unsupported part number @0@ of implementer @1@. '
522               .format(part_number, implementer_id) +
523               'Please add support for it or use the generic ' +
524               '(-Dplatform=generic) build.')
525     endif
526
527     # add/overwrite flags in the proper order
528     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
529
530     machine_args = [] # Clear previous machine args
531
532     # probe supported archs and their features
533     candidate_march = ''
534     if part_number_config.has_key('march')
535         supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
536                             'armv8.2-a', 'armv8.1-a', 'armv8-a']
537         check_compiler_support = false
538         foreach supported_march: supported_marchs
539             if supported_march == part_number_config['march']
540                 # start checking from this version downwards
541                 check_compiler_support = true
542             endif
543             if (check_compiler_support and
544                 cc.has_argument('-march=' + supported_march))
545                 candidate_march = supported_march
546                 # highest supported march version found
547                 break
548             endif
549         endforeach
550         if candidate_march == ''
551             error('No suitable armv8 march version found.')
552         endif
553         if candidate_march != part_number_config['march']
554             warning('Configuration march version is ' +
555                     '@0@, but the compiler supports only @1@.'
556                     .format(part_number_config['march'], candidate_march))
557         endif
558         candidate_march = '-march=' + candidate_march
559
560         march_features = []
561         if part_number_config.has_key('march_features')
562             march_features += part_number_config['march_features']
563         endif
564         if soc_config.has_key('extra_march_features')
565             march_features += soc_config['extra_march_features']
566         endif
567         foreach feature: march_features
568             if cc.has_argument('+'.join([candidate_march, feature]))
569                 candidate_march = '+'.join([candidate_march, feature])
570             else
571                 warning('The compiler does not support feature @0@'
572                     .format(feature))
573             endif
574         endforeach
575         machine_args += candidate_march
576     endif
577
578     # apply supported compiler options
579     if part_number_config.has_key('compiler_options')
580         foreach flag: part_number_config['compiler_options']
581             if cc.has_argument(flag)
582                 machine_args += flag
583             else
584                 warning('Configuration compiler option ' +
585                         '@0@ isn\'t supported.'.format(flag))
586             endif
587         endforeach
588     endif
589
590     # apply flags
591     foreach flag: dpdk_flags
592         if flag.length() > 0
593             dpdk_conf.set(flag[0], flag[1])
594         endif
595     endforeach
596 endif
597 message('Using machine args: @0@'.format(machine_args))
598
599 if (cc.get_define('__ARM_NEON', args: machine_args) != '' or
600     cc.get_define('__aarch64__', args: machine_args) != '')
601     compile_time_cpuflags += ['RTE_CPUFLAG_NEON']
602 endif
603
604 if cc.get_define('__ARM_FEATURE_SVE', args: machine_args) != ''
605     compile_time_cpuflags += ['RTE_CPUFLAG_SVE']
606     if (cc.check_header('arm_sve.h'))
607         dpdk_conf.set('RTE_HAS_SVE_ACLE', 1)
608     endif
609 endif
610
611 if cc.get_define('__ARM_FEATURE_CRC32', args: machine_args) != ''
612     compile_time_cpuflags += ['RTE_CPUFLAG_CRC32']
613 endif
614
615 if cc.get_define('__ARM_FEATURE_CRYPTO', args: machine_args) != ''
616     compile_time_cpuflags += ['RTE_CPUFLAG_AES', 'RTE_CPUFLAG_PMULL',
617     'RTE_CPUFLAG_SHA1', 'RTE_CPUFLAG_SHA2']
618 endif