DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] config/arm: split march cfg into arch and features
@ 2021-06-29  9:39 Juraj Linkeš
  2021-06-29  9:39 ` [dpdk-dev] [PATCH v1] config/arm: split march cfg to " Juraj Linkeš
  2021-07-06  8:21 ` [dpdk-dev] [PATCH v2] config/arm: split march cfg into " Juraj Linkeš
  0 siblings, 2 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-06-29  9:39 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk
  Cc: dev, Juraj Linkeš

Older compilers may not support all arch versions and all features that
the target SoC supports, in which case it's better figure out the
highest arch version and features that the compiler supports. Implement
a way to achieve this:
1. Find the highest arch version that the compiler supports, keeping in
mind the SoC arch version we're building. For example, if the SoC arch
version is arm8.2-a, but the compiler only supports arm8.1-a, use
arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
higher), use armv8.2-a.
2. With the architecture version locked, iterate over SoC features and
use all that are supported.

In all cases, emit a warning if there's something unsupported by the
compiler.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 122 +++++++++++++++++++++++++++++++++--------
 1 file changed, 98 insertions(+), 24 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 9b147c0b93..9114d8a59c 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -37,20 +37,26 @@ implementer_generic = {
         ['RTE_MAX_NUMA_NODES', 4]
     ],
     'part_number_config': {
-        'generic': {'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']}
+        'generic': {
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
+        }
     }
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -60,7 +66,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -94,19 +101,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -116,7 +125,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -137,7 +148,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -149,7 +164,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -158,7 +175,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -179,7 +197,10 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']}
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -458,13 +479,66 @@ else
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported marchs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if check_compiler_support and
+                cc.has_argument('-march=' + supported_march)
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
+        else
+            if candidate_march != part_number_config['march']
+                warning('Configuration march version is ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march'], candidate_march))
+            endif
+            candidate_march = '-march=' + candidate_march
         endif
-    endforeach
+        if part_number_config.has_key('march_features')
+            feature_unsupported = false
+            foreach feature: part_number_config['march_features']
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    feature_unsupported = true
+                endif
+            endforeach
+            if feature_unsupported
+                warning('Configuration march features are ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march_features'],
+                                candidate_march))
+            endif
+        endif
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v1] config/arm: split march cfg to arch and features
  2021-06-29  9:39 [dpdk-dev] [PATCH v1] config/arm: split march cfg into arch and features Juraj Linkeš
@ 2021-06-29  9:39 ` Juraj Linkeš
  2021-07-06  8:21 ` [dpdk-dev] [PATCH v2] config/arm: split march cfg into " Juraj Linkeš
  1 sibling, 0 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-06-29  9:39 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk
  Cc: dev, Juraj Linkeš

Older compilers may not support all arch versions and all features that
the target SoC supports, in which case it's better figure out the
highest arch version and features that the compiler supports. Implement
a way to achieve this:
1. Find the highest arch version that the compiler supports, keeping in
mind the SoC arch version we're building. For example, if the SoC arch
version is arm8.2-a, but the compiler only supports arm8.1-a, use
arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
higher), use armv8.2-a.
2. With the architecture version locked, iterate over SoC features and
use all that are supported.

In all cases, emit a warning if there's something unsupported by the
compiler.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 122 +++++++++++++++++++++++++++++++++--------
 1 file changed, 98 insertions(+), 24 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 9b147c0b93..9114d8a59c 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -37,20 +37,26 @@ implementer_generic = {
         ['RTE_MAX_NUMA_NODES', 4]
     ],
     'part_number_config': {
-        'generic': {'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']}
+        'generic': {
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
+        }
     }
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -60,7 +66,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -94,19 +101,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -116,7 +125,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -137,7 +148,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -149,7 +164,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -158,7 +175,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -179,7 +197,10 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']}
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -458,13 +479,66 @@ else
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported marchs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if check_compiler_support and
+                cc.has_argument('-march=' + supported_march)
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
+        else
+            if candidate_march != part_number_config['march']
+                warning('Configuration march version is ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march'], candidate_march))
+            endif
+            candidate_march = '-march=' + candidate_march
         endif
-    endforeach
+        if part_number_config.has_key('march_features')
+            feature_unsupported = false
+            foreach feature: part_number_config['march_features']
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    feature_unsupported = true
+                endif
+            endforeach
+            if feature_unsupported
+                warning('Configuration march features are ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march_features'],
+                                candidate_march))
+            endif
+        endif
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v2] config/arm: split march cfg into arch and features
  2021-06-29  9:39 [dpdk-dev] [PATCH v1] config/arm: split march cfg into arch and features Juraj Linkeš
  2021-06-29  9:39 ` [dpdk-dev] [PATCH v1] config/arm: split march cfg to " Juraj Linkeš
@ 2021-07-06  8:21 ` Juraj Linkeš
  2021-07-12 13:02   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  1 sibling, 1 reply; 17+ messages in thread
From: Juraj Linkeš @ 2021-07-06  8:21 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk
  Cc: dev, Juraj Linkeš

Older compilers may not support all arch versions and all features that
the target SoC supports, in which case it's better figure out the
highest arch version and features that the compiler supports. Implement
a way to achieve this:
1. Find the highest arch version that the compiler supports, keeping in
mind the SoC arch version we're building. For example, if the SoC arch
version is arm8.2-a, but the compiler only supports arm8.1-a, use
arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
higher), use armv8.2-a.
2. With the architecture version locked, iterate over SoC features and
use all that are supported.

In all cases, emit a warning if there's something unsupported by the
compiler.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 122 +++++++++++++++++++++++++++++++++--------
 1 file changed, 98 insertions(+), 24 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 9b147c0b93..8272b4e2bc 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -37,20 +37,26 @@ implementer_generic = {
         ['RTE_MAX_NUMA_NODES', 4]
     ],
     'part_number_config': {
-        'generic': {'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']}
+        'generic': {
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
+        }
     }
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -60,7 +66,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -94,19 +101,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -116,7 +125,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -137,7 +148,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -149,7 +164,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -158,7 +175,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -179,7 +197,10 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']}
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -458,13 +479,66 @@ else
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported marchs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if (check_compiler_support and
+                cc.has_argument('-march=' + supported_march))
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
+        else
+            if candidate_march != part_number_config['march']
+                warning('Configuration march version is ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march'], candidate_march))
+            endif
+            candidate_march = '-march=' + candidate_march
         endif
-    endforeach
+        if part_number_config.has_key('march_features')
+            feature_unsupported = false
+            foreach feature: part_number_config['march_features']
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    feature_unsupported = true
+                endif
+            endforeach
+            if feature_unsupported
+                warning('Configuration march features are ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march_features'],
+                                candidate_march))
+            endif
+        endif
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v3] config/arm: split march cfg into arch and features
  2021-07-06  8:21 ` [dpdk-dev] [PATCH v2] config/arm: split march cfg into " Juraj Linkeš
@ 2021-07-12 13:02   ` Juraj Linkeš
  2021-07-14  9:24     ` Ruifeng Wang
                       ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-07-12 13:02 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj
  Cc: dev, Juraj Linkeš

Older compilers may not support all arch versions and all features that
the target SoC supports, in which case it's better to figure out the
highest arch version and features that the compiler supports. Implement
a way to achieve this:
1. Find the highest arch version that the compiler supports, keeping in
mind the SoC arch version we're building. For example, if the SoC arch
version is arm8.2-a, but the compiler only supports arm8.1-a, use
arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
higher), use armv8.2-a.
2. With the architecture version locked, iterate over SoC features and
use all that are supported.

In all cases, emit a warning if there's something unsupported by the
compiler.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v3: rebase
---
 config/arm/meson.build | 125 ++++++++++++++++++++++++++++++++---------
 1 file changed, 100 insertions(+), 25 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 14987c634a..f5cd30f4f0 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -38,7 +38,9 @@ implementer_generic = {
     ],
     'part_number_config': {
         'generic': {
-            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
         },
         'generic_aarch32': {
             'machine_args': ['-march=armv8-a', '-mfpu=neon'],
@@ -53,15 +55,17 @@ implementer_generic = {
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -71,7 +75,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -105,19 +110,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,7 +134,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -148,7 +157,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -160,7 +173,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -169,7 +184,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -190,8 +206,14 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
+        '0x800': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        },
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -500,13 +522,66 @@ if update_flags
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported marchs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if (check_compiler_support and
+                cc.has_argument('-march=' + supported_march))
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
+        else
+            if candidate_march != part_number_config['march']
+                warning('Configuration march version is ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march'], candidate_march))
+            endif
+            candidate_march = '-march=' + candidate_march
         endif
-    endforeach
+        if part_number_config.has_key('march_features')
+            feature_unsupported = false
+            foreach feature: part_number_config['march_features']
+                if cc.has_argument('+'.join([candidate_march, feature]))
+                    candidate_march = '+'.join([candidate_march, feature])
+                else
+                    feature_unsupported = true
+                endif
+            endforeach
+            if feature_unsupported
+                warning('Configuration march features are ' +
+                        '@0@, but the compiler supports only @1@.'
+                        .format(part_number_config['march_features'],
+                                candidate_march))
+            endif
+        endif
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v3] config/arm: split march cfg into arch and features
  2021-07-12 13:02   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
@ 2021-07-14  9:24     ` Ruifeng Wang
  2021-07-16  3:42       ` fengchengwen
  2021-07-20  7:25     ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
  2021-07-20 12:33     ` [dpdk-dev] [PATCH v3 1/2] " Juraj Linkeš
  2 siblings, 1 reply; 17+ messages in thread
From: Ruifeng Wang @ 2021-07-14  9:24 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa Nagarahalli,
	fengchengwen, ferruh.yigit, jerinjacobk, jerinj, Pavan Nikhilesh
  Cc: dev, nd

+Pavan 

Hi Chengwen, Pavan,

You had patches to add ability of picking supported march/extension.
Can you help to review this patch and see if the generic infrastructure fulfills your needs?

Regards.
Ruifeng

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Monday, July 12, 2021 9:02 PM
> To: thomas@monjalon.net; david.marchand@redhat.com;
> bruce.richardson@intel.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; fengchengwen@huawei.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v3] config/arm: split march cfg into arch and features
> 
> Older compilers may not support all arch versions and all features that the
> target SoC supports, in which case it's better to figure out the highest arch
> version and features that the compiler supports. Implement a way to achieve
> this:
> 1. Find the highest arch version that the compiler supports, keeping in mind
> the SoC arch version we're building. For example, if the SoC arch version is
> arm8.2-a, but the compiler only supports arm8.1-a, use arm8.1-a. On the
> other hand, if the compiler supports arm8.3-a (or higher), use armv8.2-a.
> 2. With the architecture version locked, iterate over SoC features and use all
> that are supported.
> 
> In all cases, emit a warning if there's something unsupported by the compiler.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> v3: rebase
> ---
>  config/arm/meson.build | 125 ++++++++++++++++++++++++++++++++-----
> ----
>  1 file changed, 100 insertions(+), 25 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> 14987c634a..f5cd30f4f0 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -38,7 +38,9 @@ implementer_generic = {
>      ],
>      'part_number_config': {
>          'generic': {
> -            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
> +            'march': 'armv8-a',
> +            'march_features': ['crc'],
> +            'compiler_options': ['-moutline-atomics']
>          },
>          'generic_aarch32': {
>              'machine_args': ['-march=armv8-a', '-mfpu=neon'], @@ -53,15 +55,17
> @@ implementer_generic = {  }
> 
>  part_number_config_arm = {
> -    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
> -    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
> -    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
> -    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
> -    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
> -    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
> -    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
> +    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> +    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> +    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> +    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> +    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> +    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> +    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
>      '0xd0c': {
> -        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
> +        'march': 'armv8.2-a',
> +        'march_features': ['crypto'],
> +        'compiler_options':  ['-mcpu=neoverse-n1'],
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n1"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -71,7 +75,8 @@
> part_number_config_arm = {
>          ]
>      },
>      '0xd49': {
> -        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
> +        'march': 'armv8.5-a',
> +        'march_features': ['crypto', 'sve2'],
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -105,19 +110,21 @@
> implementer_cavium = {
>      ],
>      'part_number_config': {
>          '0xa1': {
> -            'machine_args': ['-mcpu=thunderxt88'],
> +            'compiler_options': ['-mcpu=thunderxt88'],
>              'flags': flags_part_number_thunderx
>          },
>          '0xa2': {
> -            'machine_args': ['-mcpu=thunderxt81'],
> +            'compiler_options': ['-mcpu=thunderxt81'],
>              'flags': flags_part_number_thunderx
>          },
>          '0xa3': {
> -            'machine_args': ['-mcpu=thunderxt83'],
> +            'compiler_options': ['-mcpu=thunderxt83'],
>              'flags': flags_part_number_thunderx
>          },
>          '0xaf': {
> -            'machine_args': ['-march=armv8.1-a+crc+crypto', '-
> mcpu=thunderx2t99'],
> +            'march': 'armv8.1-a',
> +            'march_features': ['crc', 'crypto'],
> +            'compiler_options': ['-mcpu=thunderx2t99'],
>              'flags': [
>                  ['RTE_MACHINE', '"thunderx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,7 +134,9 @@
> implementer_cavium = {
>              ]
>          },
>          '0xb2': {
> -            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-
> mcpu=octeontx2'],
> +            'march': 'armv8.2-a',
> +            'march_features': ['crc', 'crypto', 'lse'],
> +            'compiler_options': ['-mcpu=octeontx2'],
>              'flags': [
>                  ['RTE_MACHINE', '"octeontx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -148,7 +157,11 @@
> implementer_ampere = {
>          ['RTE_MAX_NUMA_NODES', 1]
>      ],
>      'part_number_config': {
> -        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
> +        '0x0': {
> +            'march': 'armv8-a',
> +            'march_features': ['crc', 'crypto'],
> +            'compiler_options':  ['-mtune=emag']
> +        }
>      }
>  }
> 
> @@ -160,7 +173,9 @@ implementer_hisilicon = {
>      ],
>      'part_number_config': {
>          '0xd01': {
> -            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
> +            'march': 'armv8.2-a',
> +            'march_features': ['crypto'],
> +            'compiler_options': ['-mtune=tsv110'],
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 920"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -169,7 +184,8 @@
> implementer_hisilicon = {
>              ]
>          },
>          '0xd02': {
> -            'machine_args': ['-march=armv8.2-a+crypto+sve'],
> +            'march': 'armv8.2-a',
> +            'march_features': ['crypto', 'sve'],
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 930"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -190,8 +206,14 @@
> implementer_qualcomm = {
>          ['RTE_MAX_NUMA_NODES', 1]
>      ],
>      'part_number_config': {
> -        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
> -        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
> +        '0x800': {
> +            'march': 'armv8-a',
> +            'march_features': ['crc']
> +        },
> +        '0xc00': {
> +            'march': 'armv8-a',
> +            'march_features': ['crc']
> +        }
>      }
>  }
> 
> @@ -500,13 +522,66 @@ if update_flags
>      # add/overwrite flags in the proper order
>      dpdk_flags = flags_common + implementer_config['flags'] +
> part_number_config.get('flags', []) + soc_flags
> 
> -    # apply supported machine args
>      machine_args = [] # Clear previous machine args
> -    foreach flag: part_number_config['machine_args']
> -        if cc.has_argument(flag)
> -            machine_args += flag
> +
> +    # probe supported marchs and their features
> +    candidate_march = ''
> +    if part_number_config.has_key('march')
> +        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> +                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
> +        check_compiler_support = false
> +        foreach supported_march: supported_marchs
> +            if supported_march == part_number_config['march']
> +                # start checking from this version downwards
> +                check_compiler_support = true
> +            endif
> +            if (check_compiler_support and
> +                cc.has_argument('-march=' + supported_march))
> +                candidate_march = supported_march
> +                # highest supported march version found
> +                break
> +            endif
> +        endforeach
> +        if candidate_march == ''
> +            error('No suitable armv8 march version found.')
> +        else
> +            if candidate_march != part_number_config['march']
> +                warning('Configuration march version is ' +
> +                        '@0@, but the compiler supports only @1@.'
> +                        .format(part_number_config['march'], candidate_march))
> +            endif
> +            candidate_march = '-march=' + candidate_march
>          endif
> -    endforeach
> +        if part_number_config.has_key('march_features')
> +            feature_unsupported = false
> +            foreach feature: part_number_config['march_features']
> +                if cc.has_argument('+'.join([candidate_march, feature]))
> +                    candidate_march = '+'.join([candidate_march, feature])
> +                else
> +                    feature_unsupported = true
> +                endif
> +            endforeach
> +            if feature_unsupported
> +                warning('Configuration march features are ' +
> +                        '@0@, but the compiler supports only @1@.'
> +                        .format(part_number_config['march_features'],
> +                                candidate_march))
> +            endif
> +        endif
> +        machine_args += candidate_march
> +    endif
> +
> +    # apply supported compiler options
> +    if part_number_config.has_key('compiler_options')
> +        foreach flag: part_number_config['compiler_options']
> +            if cc.has_argument(flag)
> +                machine_args += flag
> +            else
> +                warning('Configuration compiler option ' +
> +                        '@0@ isn\'t supported.'.format(flag))
> +            endif
> +        endforeach
> +    endif
> 
>      # apply flags
>      foreach flag: dpdk_flags
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v3] config/arm: split march cfg into arch and features
  2021-07-14  9:24     ` Ruifeng Wang
@ 2021-07-16  3:42       ` fengchengwen
  2021-07-16 12:22         ` Juraj Linkeš
  0 siblings, 1 reply; 17+ messages in thread
From: fengchengwen @ 2021-07-16  3:42 UTC (permalink / raw)
  To: Ruifeng Wang, Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa Nagarahalli,
	ferruh.yigit, jerinjacobk, jerinj, Pavan Nikhilesh
  Cc: dev, nd


[snip]

>> +
>> +    # probe supported marchs and their features
>> +    candidate_march = ''
>> +    if part_number_config.has_key('march')
>> +        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
>> +                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
>> +        check_compiler_support = false
>> +        foreach supported_march: supported_marchs
>> +            if supported_march == part_number_config['march']
>> +                # start checking from this version downwards
>> +                check_compiler_support = true
>> +            endif
>> +            if (check_compiler_support and
>> +                cc.has_argument('-march=' + supported_march))
>> +                candidate_march = supported_march
>> +                # highest supported march version found
>> +                break
>> +            endif

I think breaking it down into two steps is more intuitive.
step1: find the march version which target config.
       If not find then error exit.
step2: start checking from step1's version.

>> +        endforeach
>> +        if candidate_march == ''
>> +            error('No suitable armv8 march version found.')
>> +        else

There no need use else, because meson will halt when execute error.

>> +            if candidate_march != part_number_config['march']
>> +                warning('Configuration march version is ' +
>> +                        '@0@, but the compiler supports only @1@.'
>> +                        .format(part_number_config['march'], candidate_march))
>> +            endif
>> +            candidate_march = '-march=' + candidate_march
>>          endif
>> -    endforeach
>> +        if part_number_config.has_key('march_features')
>> +            feature_unsupported = false
>> +            foreach feature: part_number_config['march_features']
>> +                if cc.has_argument('+'.join([candidate_march, feature]))
>> +                    candidate_march = '+'.join([candidate_march, feature])
>> +                else
>> +                    feature_unsupported = true
>> +                endif
>> +            endforeach
>> +            if feature_unsupported
>> +                warning('Configuration march features are ' +
>> +                        '@0@, but the compiler supports only @1@.'
>> +                        .format(part_number_config['march_features'],
>> +                                candidate_march))

the march_feature is some like 'crc sve', but candidate_march is '-march=armv8.2a+crc'.
These two displays may be a little weird because later one has -march=armv8.2 prefix.

I think it's better move warning to place which feature_unsupported was set true.

>> +            endif
>> +        endif
>> +        machine_args += candidate_march
>> +    endif
>> +
>> +    # apply supported compiler options
>> +    if part_number_config.has_key('compiler_options')
>> +        foreach flag: part_number_config['compiler_options']
>> +            if cc.has_argument(flag)

Is it possible that -mcpu= conflicts with -march ?

>> +                machine_args += flag
>> +            else
>> +                warning('Configuration compiler option ' +
>> +                        '@0@ isn\'t supported.'.format(flag))
>> +            endif
>> +        endforeach
>> +    endif
>>
>>      # apply flags
>>      foreach flag: dpdk_flags
>> --
>> 2.20.1
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v3] config/arm: split march cfg into arch and features
  2021-07-16  3:42       ` fengchengwen
@ 2021-07-16 12:22         ` Juraj Linkeš
  0 siblings, 0 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-07-16 12:22 UTC (permalink / raw)
  To: fengchengwen, Ruifeng Wang, thomas, david.marchand,
	bruce.richardson, Honnappa Nagarahalli, ferruh.yigit,
	jerinjacobk, jerinj, Pavan Nikhilesh
  Cc: dev, nd



> -----Original Message-----
> From: fengchengwen <fengchengwen@huawei.com>
> Sent: Friday, July 16, 2021 5:42 AM
> To: Ruifeng Wang <Ruifeng.Wang@arm.com>; Juraj Linkeš
> <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> david.marchand@redhat.com; bruce.richardson@intel.com; Honnappa
> Nagarahalli <Honnappa.Nagarahalli@arm.com>; ferruh.yigit@intel.com;
> jerinjacobk@gmail.com; jerinj@marvell.com; Pavan Nikhilesh
> <pbhagavatula@marvell.com>
> Cc: dev@dpdk.org; nd <nd@arm.com>
> Subject: Re: [PATCH v3] config/arm: split march cfg into arch and features
> 
> 
> [snip]
> 
> >> +
> >> +    # probe supported marchs and their features
> >> +    candidate_march = ''
> >> +    if part_number_config.has_key('march')
> >> +        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> >> +                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
> >> +        check_compiler_support = false
> >> +        foreach supported_march: supported_marchs
> >> +            if supported_march == part_number_config['march']
> >> +                # start checking from this version downwards
> >> +                check_compiler_support = true
> >> +            endif
> >> +            if (check_compiler_support and
> >> +                cc.has_argument('-march=' + supported_march))
> >> +                candidate_march = supported_march
> >> +                # highest supported march version found
> >> +                break
> >> +            endif
> 
> I think breaking it down into two steps is more intuitive.
> step1: find the march version which target config.
>        If not find then error exit.
> step2: start checking from step1's version.
> 

Ok, so you want to move the error check? Meson doesn't have good tools in terms of loops and arrays and if we move the check we'd have to either go through the list twice or have otherwise ugly code. If you know how to implement this neatly then we can change it.

> >> +        endforeach
> >> +        if candidate_march == ''
> >> +            error('No suitable armv8 march version found.')
> >> +        else
> 
> There no need use else, because meson will halt when execute error.
> 

Ok, I'll remove it since this pattern is used elsewhere in DPDK meson.

> >> +            if candidate_march != part_number_config['march']
> >> +                warning('Configuration march version is ' +
> >> +                        '@0@, but the compiler supports only @1@.'
> >> +                        .format(part_number_config['march'], candidate_march))
> >> +            endif
> >> +            candidate_march = '-march=' + candidate_march
> >>          endif
> >> -    endforeach
> >> +        if part_number_config.has_key('march_features')
> >> +            feature_unsupported = false
> >> +            foreach feature: part_number_config['march_features']
> >> +                if cc.has_argument('+'.join([candidate_march, feature]))
> >> +                    candidate_march = '+'.join([candidate_march, feature])
> >> +                else
> >> +                    feature_unsupported = true
> >> +                endif
> >> +            endforeach
> >> +            if feature_unsupported
> >> +                warning('Configuration march features are ' +
> >> +                        '@0@, but the compiler supports only @1@.'
> >> +                        .format(part_number_config['march_features'],
> >> +                                candidate_march))
> 
> the march_feature is some like 'crc sve', but candidate_march is '-
> march=armv8.2a+crc'.
> These two displays may be a little weird because later one has -march=armv8.2
> prefix.
> 
> I think it's better move warning to place which feature_unsupported was set
> true.
> 

We'll have more warning this way but it'll result in less confusing messages and nicer code - I'll make the change.

> >> +            endif
> >> +        endif
> >> +        machine_args += candidate_march
> >> +    endif
> >> +
> >> +    # apply supported compiler options
> >> +    if part_number_config.has_key('compiler_options')
> >> +        foreach flag: part_number_config['compiler_options']
> >> +            if cc.has_argument(flag)
> 
> Is it possible that -mcpu= conflicts with -march ?
> 

Maybe, but I think this sort of check is out of scope of this change. We can do this in a separate patch if there's a need (and if it's actually possible to do the check).

> >> +                machine_args += flag
> >> +            else
> >> +                warning('Configuration compiler option ' +
> >> +                        '@0@ isn\'t supported.'.format(flag))
> >> +            endif
> >> +        endforeach
> >> +    endif
> >>
> >>      # apply flags
> >>      foreach flag: dpdk_flags
> >> --
> >> 2.20.1
> >


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [EXT] [PATCH v3] config/arm: split march cfg into arch and features
  2021-07-12 13:02   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  2021-07-14  9:24     ` Ruifeng Wang
@ 2021-07-20  7:25     ` Pavan Nikhilesh Bhagavatula
  2021-07-20 11:58       ` Juraj Linkeš
  2021-07-20 12:33     ` [dpdk-dev] [PATCH v3 1/2] " Juraj Linkeš
  2 siblings, 1 reply; 17+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2021-07-20  7:25 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk,
	Jerin Jacob Kollanukkaran
  Cc: dev

>Older compilers may not support all arch versions and all features that
>the target SoC supports, in which case it's better to figure out the
>highest arch version and features that the compiler supports.
>Implement
>a way to achieve this:
>1. Find the highest arch version that the compiler supports, keeping in
>mind the SoC arch version we're building. For example, if the SoC arch
>version is arm8.2-a, but the compiler only supports arm8.1-a, use
>arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
>higher), use armv8.2-a.
>2. With the architecture version locked, iterate over SoC features and
>use all that are supported.
>
>In all cases, emit a warning if there's something unsupported by the
>compiler.
>
>Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>


Should we add soc_features to allow individual SoCs to configure additional extensions 
they support?
As we discussed previously [1] default Neoverse-n2 shouldn’t have crypto extension as
it's an optional feature[2]. SoCs that are based on n2 can define it in soc_features.


[1] http://patches.dpdk.org/project/dpdk/patch/20210505121423.850-1-pbhagavatula@marvell.com/
[2] https://developer.arm.com/ip-products/processors/neoverse/neoverse-n2


>---
>v3: rebase
>---
> config/arm/meson.build | 125
>++++++++++++++++++++++++++++++++---------
> 1 file changed, 100 insertions(+), 25 deletions(-)
>
>diff --git a/config/arm/meson.build b/config/arm/meson.build
>index 14987c634a..f5cd30f4f0 100644
>--- a/config/arm/meson.build
>+++ b/config/arm/meson.build
>@@ -38,7 +38,9 @@ implementer_generic = {
>     ],
>     'part_number_config': {
>         'generic': {
>-            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
>+            'march': 'armv8-a',
>+            'march_features': ['crc'],
>+            'compiler_options': ['-moutline-atomics']
>         },
>         'generic_aarch32': {
>             'machine_args': ['-march=armv8-a', '-mfpu=neon'],
>@@ -53,15 +55,17 @@ implementer_generic = {
> }
>
> part_number_config_arm = {
>-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
>-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
>-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
>-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
>-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
>-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
>-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
>+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
>+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
>+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
>+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
>+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
>+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
>+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
>     '0xd0c': {
>-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-
>n1'],
>+        'march': 'armv8.2-a',
>+        'march_features': ['crypto'],
>+        'compiler_options':  ['-mcpu=neoverse-n1'],
>         'flags': [
>             ['RTE_MACHINE', '"neoverse-n1"'],
>             ['RTE_ARM_FEATURE_ATOMICS', true],
>@@ -71,7 +75,8 @@ part_number_config_arm = {
>         ]
>     },
>     '0xd49': {
>-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
>+        'march': 'armv8.5-a',
>+        'march_features': ['crypto', 'sve2'],
>         'flags': [
>             ['RTE_MACHINE', '"neoverse-n2"'],
>             ['RTE_ARM_FEATURE_ATOMICS', true],
>@@ -105,19 +110,21 @@ implementer_cavium = {
>     ],
>     'part_number_config': {
>         '0xa1': {
>-            'machine_args': ['-mcpu=thunderxt88'],
>+            'compiler_options': ['-mcpu=thunderxt88'],
>             'flags': flags_part_number_thunderx
>         },
>         '0xa2': {
>-            'machine_args': ['-mcpu=thunderxt81'],
>+            'compiler_options': ['-mcpu=thunderxt81'],
>             'flags': flags_part_number_thunderx
>         },
>         '0xa3': {
>-            'machine_args': ['-mcpu=thunderxt83'],
>+            'compiler_options': ['-mcpu=thunderxt83'],
>             'flags': flags_part_number_thunderx
>         },
>         '0xaf': {
>-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-
>mcpu=thunderx2t99'],
>+            'march': 'armv8.1-a',
>+            'march_features': ['crc', 'crypto'],
>+            'compiler_options': ['-mcpu=thunderx2t99'],
>             'flags': [
>                 ['RTE_MACHINE', '"thunderx2"'],
>                 ['RTE_ARM_FEATURE_ATOMICS', true],
>@@ -127,7 +134,9 @@ implementer_cavium = {
>             ]
>         },
>         '0xb2': {
>-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-
>mcpu=octeontx2'],
>+            'march': 'armv8.2-a',
>+            'march_features': ['crc', 'crypto', 'lse'],
>+            'compiler_options': ['-mcpu=octeontx2'],
>             'flags': [
>                 ['RTE_MACHINE', '"octeontx2"'],
>                 ['RTE_ARM_FEATURE_ATOMICS', true],
>@@ -148,7 +157,11 @@ implementer_ampere = {
>         ['RTE_MAX_NUMA_NODES', 1]
>     ],
>     'part_number_config': {
>-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-
>mtune=emag']}
>+        '0x0': {
>+            'march': 'armv8-a',
>+            'march_features': ['crc', 'crypto'],
>+            'compiler_options':  ['-mtune=emag']
>+        }
>     }
> }
>
>@@ -160,7 +173,9 @@ implementer_hisilicon = {
>     ],
>     'part_number_config': {
>         '0xd01': {
>-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
>+            'march': 'armv8.2-a',
>+            'march_features': ['crypto'],
>+            'compiler_options': ['-mtune=tsv110'],
>             'flags': [
>                 ['RTE_MACHINE', '"Kunpeng 920"'],
>                 ['RTE_ARM_FEATURE_ATOMICS', true],
>@@ -169,7 +184,8 @@ implementer_hisilicon = {
>             ]
>         },
>         '0xd02': {
>-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
>+            'march': 'armv8.2-a',
>+            'march_features': ['crypto', 'sve'],
>             'flags': [
>                 ['RTE_MACHINE', '"Kunpeng 930"'],
>                 ['RTE_ARM_FEATURE_ATOMICS', true],
>@@ -190,8 +206,14 @@ implementer_qualcomm = {
>         ['RTE_MAX_NUMA_NODES', 1]
>     ],
>     'part_number_config': {
>-        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
>-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
>+        '0x800': {
>+            'march': 'armv8-a',
>+            'march_features': ['crc']
>+        },
>+        '0xc00': {
>+            'march': 'armv8-a',
>+            'march_features': ['crc']
>+        }
>     }
> }
>
>@@ -500,13 +522,66 @@ if update_flags
>     # add/overwrite flags in the proper order
>     dpdk_flags = flags_common + implementer_config['flags'] +
>part_number_config.get('flags', []) + soc_flags
>
>-    # apply supported machine args
>     machine_args = [] # Clear previous machine args
>-    foreach flag: part_number_config['machine_args']
>-        if cc.has_argument(flag)
>-            machine_args += flag
>+
>+    # probe supported marchs and their features
>+    candidate_march = ''
>+    if part_number_config.has_key('march')
>+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a',
>'armv8.3-a',
>+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
>+        check_compiler_support = false
>+        foreach supported_march: supported_marchs
>+            if supported_march == part_number_config['march']
>+                # start checking from this version downwards
>+                check_compiler_support = true
>+            endif
>+            if (check_compiler_support and
>+                cc.has_argument('-march=' + supported_march))
>+                candidate_march = supported_march
>+                # highest supported march version found
>+                break
>+            endif
>+        endforeach
>+        if candidate_march == ''
>+            error('No suitable armv8 march version found.')
>+        else
>+            if candidate_march != part_number_config['march']
>+                warning('Configuration march version is ' +
>+                        '@0@, but the compiler supports only @1@.'
>+                        .format(part_number_config['march'], candidate_march))
>+            endif
>+            candidate_march = '-march=' + candidate_march
>         endif
>-    endforeach
>+        if part_number_config.has_key('march_features')
>+            feature_unsupported = false
>+            foreach feature: part_number_config['march_features']
>+                if cc.has_argument('+'.join([candidate_march, feature]))
>+                    candidate_march = '+'.join([candidate_march, feature])
>+                else
>+                    feature_unsupported = true
>+                endif
>+            endforeach
>+            if feature_unsupported
>+                warning('Configuration march features are ' +
>+                        '@0@, but the compiler supports only @1@.'
>+                        .format(part_number_config['march_features'],
>+                                candidate_march))
>+            endif
>+        endif
>+        machine_args += candidate_march
>+    endif
>+
>+    # apply supported compiler options
>+    if part_number_config.has_key('compiler_options')
>+        foreach flag: part_number_config['compiler_options']
>+            if cc.has_argument(flag)
>+                machine_args += flag
>+            else
>+                warning('Configuration compiler option ' +
>+                        '@0@ isn\'t supported.'.format(flag))
>+            endif
>+        endforeach
>+    endif
>
>     # apply flags
>     foreach flag: dpdk_flags
>--
>2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [EXT] [PATCH v3] config/arm: split march cfg into arch and features
  2021-07-20  7:25     ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
@ 2021-07-20 11:58       ` Juraj Linkeš
  0 siblings, 0 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-07-20 11:58 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula, thomas, david.marchand,
	bruce.richardson, Honnappa.Nagarahalli, Ruifeng.Wang,
	fengchengwen, ferruh.yigit, jerinjacobk,
	Jerin Jacob Kollanukkaran
  Cc: dev



> -----Original Message-----
> From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Sent: Tuesday, July 20, 2021 9:25 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> david.marchand@redhat.com; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> fengchengwen@huawei.com; ferruh.yigit@intel.com; jerinjacobk@gmail.com;
> Jerin Jacob Kollanukkaran <jerinj@marvell.com>
> Cc: dev@dpdk.org
> Subject: RE: [EXT] [dpdk-dev] [PATCH v3] config/arm: split march cfg into arch
> and features
> 
> >Older compilers may not support all arch versions and all features that
> >the target SoC supports, in which case it's better to figure out the
> >highest arch version and features that the compiler supports.
> >Implement
> >a way to achieve this:
> >1. Find the highest arch version that the compiler supports, keeping in
> >mind the SoC arch version we're building. For example, if the SoC arch
> >version is arm8.2-a, but the compiler only supports arm8.1-a, use
> >arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
> >higher), use armv8.2-a.
> >2. With the architecture version locked, iterate over SoC features and
> >use all that are supported.
> >
> >In all cases, emit a warning if there's something unsupported by the
> >compiler.
> >
> >Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> 
> 
> Should we add soc_features to allow individual SoCs to configure additional
> extensions they support?
> As we discussed previously [1] default Neoverse-n2 shouldn’t have crypto
> extension as it's an optional feature[2]. SoCs that are based on n2 can define it
> in soc_features.
> 
> 
> [1] http://patches.dpdk.org/project/dpdk/patch/20210505121423.850-1-
> pbhagavatula@marvell.com/
> [2] https://developer.arm.com/ip-products/processors/neoverse/neoverse-n2

Thanks for reminding me, there seemed to be an agreement between you and Honnappa about this, so I'll add it.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] config/arm: split march cfg into arch and features
  2021-07-12 13:02   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  2021-07-14  9:24     ` Ruifeng Wang
  2021-07-20  7:25     ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
@ 2021-07-20 12:33     ` Juraj Linkeš
  2021-07-20 12:33       ` [dpdk-dev] [PATCH v3 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
  2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
  2 siblings, 2 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-07-20 12:33 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj,
	pbhagavatula
  Cc: dev, Juraj Linkeš

Older compilers may not support all arch versions and all features that
the target SoC supports, in which case it's better to figure out the
highest arch version and features that the compiler supports. Implement
a way to achieve this:
1. Find the highest arch version that the compiler supports, keeping in
mind the SoC arch version we're building. For example, if the SoC arch
version is arm8.2-a, but the compiler only supports arm8.1-a, use
arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
higher), use armv8.2-a.
2. With the architecture version locked, iterate over SoC features and
use all that are supported.

In all cases, emit a warning if there's something unsupported by the
compiler.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 124 ++++++++++++++++++++++++++++++++---------
 1 file changed, 99 insertions(+), 25 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 14987c634a..c11efa1583 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -38,7 +38,9 @@ implementer_generic = {
     ],
     'part_number_config': {
         'generic': {
-            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
         },
         'generic_aarch32': {
             'machine_args': ['-march=armv8-a', '-mfpu=neon'],
@@ -53,15 +55,17 @@ implementer_generic = {
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -71,7 +75,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -105,19 +110,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,7 +134,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -148,7 +157,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -160,7 +173,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -169,7 +184,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -190,8 +206,14 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
+        '0x800': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        },
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -500,13 +522,65 @@ if update_flags
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported marchs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if (check_compiler_support and
+                cc.has_argument('-march=' + supported_march))
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
         endif
-    endforeach
+        if candidate_march != part_number_config['march']
+            warning('Configuration march version is ' +
+                    '@0@, but the compiler supports only @1@.'
+                    .format(part_number_config['march'], candidate_march))
+        endif
+        candidate_march = '-march=' + candidate_march
+
+        march_features = []
+        if part_number_config.has_key('march_features')
+            march_features += part_number_config['march_features']
+        endif
+        if soc_config.has_key('extra_march_features')
+            march_features += soc_config['extra_march_features']
+        endif
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_march, feature]))
+                candidate_march = '+'.join([candidate_march, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] config/arm: make n2 'crypto' an optional feature
  2021-07-20 12:33     ` [dpdk-dev] [PATCH v3 1/2] " Juraj Linkeš
@ 2021-07-20 12:33       ` Juraj Linkeš
  2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
  1 sibling, 0 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-07-20 12:33 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj,
	pbhagavatula
  Cc: dev, Juraj Linkeš

Not all Neoverse-N2 cpus must support the crypto feature/extension which
makes it an optional feature. Only enable the feature for SoCs which
support it.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index c11efa1583..c9bcd089df 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -76,7 +76,7 @@ part_number_config_arm = {
     },
     '0xd49': {
         'march': 'armv8.5-a',
-        'march_features': ['crypto', 'sve2'],
+        'march_features': ['sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -278,6 +278,7 @@ soc_cn10k = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number': '0xd49',
+    'extra_march_features': ['crypto'],
     'numa': false
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features
  2021-07-20 12:33     ` [dpdk-dev] [PATCH v3 1/2] " Juraj Linkeš
  2021-07-20 12:33       ` [dpdk-dev] [PATCH v3 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
@ 2021-08-17 10:56       ` Juraj Linkeš
  2021-08-17 10:56         ` [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
                           ` (3 more replies)
  1 sibling, 4 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-08-17 10:56 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj,
	pbhagavatula
  Cc: dev, Juraj Linkeš

Older compilers may not support all arch versions and all features that
the target SoC supports, in which case it's better to figure out the
highest arch version and features that the compiler supports. Implement
a way to achieve this:
1. Find the highest arch version that the compiler supports, keeping in
mind the SoC arch version we're building. For example, if the SoC arch
version is arm8.2-a, but the compiler only supports arm8.1-a, use
arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
higher), use armv8.2-a.
2. With the architecture version locked, iterate over SoC features and
use all that are supported.

In all cases, emit a warning if there's something unsupported by the
compiler.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v4: rebase
---
 config/arm/meson.build | 124 ++++++++++++++++++++++++++++++++---------
 1 file changed, 99 insertions(+), 25 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 14987c634a..c11efa1583 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -38,7 +38,9 @@ implementer_generic = {
     ],
     'part_number_config': {
         'generic': {
-            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
         },
         'generic_aarch32': {
             'machine_args': ['-march=armv8-a', '-mfpu=neon'],
@@ -53,15 +55,17 @@ implementer_generic = {
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -71,7 +75,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -105,19 +110,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,7 +134,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -148,7 +157,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -160,7 +173,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -169,7 +184,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -190,8 +206,14 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
+        '0x800': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        },
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -500,13 +522,65 @@ if update_flags
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported marchs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if (check_compiler_support and
+                cc.has_argument('-march=' + supported_march))
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
         endif
-    endforeach
+        if candidate_march != part_number_config['march']
+            warning('Configuration march version is ' +
+                    '@0@, but the compiler supports only @1@.'
+                    .format(part_number_config['march'], candidate_march))
+        endif
+        candidate_march = '-march=' + candidate_march
+
+        march_features = []
+        if part_number_config.has_key('march_features')
+            march_features += part_number_config['march_features']
+        endif
+        if soc_config.has_key('extra_march_features')
+            march_features += soc_config['extra_march_features']
+        endif
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_march, feature]))
+                candidate_march = '+'.join([candidate_march, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature
  2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
@ 2021-08-17 10:56         ` Juraj Linkeš
  2021-09-06  8:38           ` Ruifeng Wang
  2021-08-17 10:59         ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Juraj Linkeš @ 2021-08-17 10:56 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj,
	pbhagavatula
  Cc: dev, Juraj Linkeš

Not all Neoverse-N2 cpus must support the crypto feature/extension which
makes it an optional feature. Only enable the feature for SoCs which
support it.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v4: rebase
---
 config/arm/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index c11efa1583..c9bcd089df 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -76,7 +76,7 @@ part_number_config_arm = {
     },
     '0xd49': {
         'march': 'armv8.5-a',
-        'march_features': ['crypto', 'sve2'],
+        'march_features': ['sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -278,6 +278,7 @@ soc_cn10k = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number': '0xd49',
+    'extra_march_features': ['crypto'],
     'numa': false
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features
  2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
  2021-08-17 10:56         ` [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
@ 2021-08-17 10:59         ` Juraj Linkeš
  2021-09-06  8:26         ` Ruifeng Wang
  2021-09-16 16:17         ` Thomas Monjalon
  3 siblings, 0 replies; 17+ messages in thread
From: Juraj Linkeš @ 2021-08-17 10:59 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj,
	pbhagavatula
  Cc: dev

Resending, since there was an error when sending to Chengwen.

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Tuesday, August 17, 2021 12:57 PM
> To: thomas@monjalon.net; david.marchand@redhat.com;
> bruce.richardson@intel.com; Honnappa.Nagarahalli@arm.com;
> Ruifeng.Wang@arm.com; fengchengwen@huawei.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> pbhagavatula@marvell.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v4 1/2] config/arm: split march cfg into arch and features
> 
> Older compilers may not support all arch versions and all features that the target
> SoC supports, in which case it's better to figure out the highest arch version and
> features that the compiler supports. Implement a way to achieve this:
> 1. Find the highest arch version that the compiler supports, keeping in mind the
> SoC arch version we're building. For example, if the SoC arch version is arm8.2-
> a, but the compiler only supports arm8.1-a, use arm8.1-a. On the other hand, if
> the compiler supports arm8.3-a (or higher), use armv8.2-a.
> 2. With the architecture version locked, iterate over SoC features and use all
> that are supported.
> 
> In all cases, emit a warning if there's something unsupported by the compiler.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> v4: rebase
> ---
>  config/arm/meson.build | 124 ++++++++++++++++++++++++++++++++---------
>  1 file changed, 99 insertions(+), 25 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> 14987c634a..c11efa1583 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -38,7 +38,9 @@ implementer_generic = {
>      ],
>      'part_number_config': {
>          'generic': {
> -            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
> +            'march': 'armv8-a',
> +            'march_features': ['crc'],
> +            'compiler_options': ['-moutline-atomics']
>          },
>          'generic_aarch32': {
>              'machine_args': ['-march=armv8-a', '-mfpu=neon'], @@ -53,15 +55,17
> @@ implementer_generic = {  }
> 
>  part_number_config_arm = {
> -    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
> -    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
> -    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
> -    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
> -    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
> -    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
> -    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
> +    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
> +    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
> +    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
> +    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
> +    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
> +    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
> +    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
>      '0xd0c': {
> -        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
> +        'march': 'armv8.2-a',
> +        'march_features': ['crypto'],
> +        'compiler_options':  ['-mcpu=neoverse-n1'],
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n1"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -71,7 +75,8 @@
> part_number_config_arm = {
>          ]
>      },
>      '0xd49': {
> -        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
> +        'march': 'armv8.5-a',
> +        'march_features': ['crypto', 'sve2'],
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -105,19 +110,21 @@
> implementer_cavium = {
>      ],
>      'part_number_config': {
>          '0xa1': {
> -            'machine_args': ['-mcpu=thunderxt88'],
> +            'compiler_options': ['-mcpu=thunderxt88'],
>              'flags': flags_part_number_thunderx
>          },
>          '0xa2': {
> -            'machine_args': ['-mcpu=thunderxt81'],
> +            'compiler_options': ['-mcpu=thunderxt81'],
>              'flags': flags_part_number_thunderx
>          },
>          '0xa3': {
> -            'machine_args': ['-mcpu=thunderxt83'],
> +            'compiler_options': ['-mcpu=thunderxt83'],
>              'flags': flags_part_number_thunderx
>          },
>          '0xaf': {
> -            'machine_args': ['-march=armv8.1-a+crc+crypto', '-
> mcpu=thunderx2t99'],
> +            'march': 'armv8.1-a',
> +            'march_features': ['crc', 'crypto'],
> +            'compiler_options': ['-mcpu=thunderx2t99'],
>              'flags': [
>                  ['RTE_MACHINE', '"thunderx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -127,7 +134,9 @@
> implementer_cavium = {
>              ]
>          },
>          '0xb2': {
> -            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-
> mcpu=octeontx2'],
> +            'march': 'armv8.2-a',
> +            'march_features': ['crc', 'crypto', 'lse'],
> +            'compiler_options': ['-mcpu=octeontx2'],
>              'flags': [
>                  ['RTE_MACHINE', '"octeontx2"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -148,7 +157,11 @@
> implementer_ampere = {
>          ['RTE_MAX_NUMA_NODES', 1]
>      ],
>      'part_number_config': {
> -        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
> +        '0x0': {
> +            'march': 'armv8-a',
> +            'march_features': ['crc', 'crypto'],
> +            'compiler_options':  ['-mtune=emag']
> +        }
>      }
>  }
> 
> @@ -160,7 +173,9 @@ implementer_hisilicon = {
>      ],
>      'part_number_config': {
>          '0xd01': {
> -            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
> +            'march': 'armv8.2-a',
> +            'march_features': ['crypto'],
> +            'compiler_options': ['-mtune=tsv110'],
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 920"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -169,7 +184,8 @@
> implementer_hisilicon = {
>              ]
>          },
>          '0xd02': {
> -            'machine_args': ['-march=armv8.2-a+crypto+sve'],
> +            'march': 'armv8.2-a',
> +            'march_features': ['crypto', 'sve'],
>              'flags': [
>                  ['RTE_MACHINE', '"Kunpeng 930"'],
>                  ['RTE_ARM_FEATURE_ATOMICS', true], @@ -190,8 +206,14 @@
> implementer_qualcomm = {
>          ['RTE_MAX_NUMA_NODES', 1]
>      ],
>      'part_number_config': {
> -        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
> -        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
> +        '0x800': {
> +            'march': 'armv8-a',
> +            'march_features': ['crc']
> +        },
> +        '0xc00': {
> +            'march': 'armv8-a',
> +            'march_features': ['crc']
> +        }
>      }
>  }
> 
> @@ -500,13 +522,65 @@ if update_flags
>      # add/overwrite flags in the proper order
>      dpdk_flags = flags_common + implementer_config['flags'] +
> part_number_config.get('flags', []) + soc_flags
> 
> -    # apply supported machine args
>      machine_args = [] # Clear previous machine args
> -    foreach flag: part_number_config['machine_args']
> -        if cc.has_argument(flag)
> -            machine_args += flag
> +
> +    # probe supported marchs and their features
> +    candidate_march = ''
> +    if part_number_config.has_key('march')
> +        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
> +                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
> +        check_compiler_support = false
> +        foreach supported_march: supported_marchs
> +            if supported_march == part_number_config['march']
> +                # start checking from this version downwards
> +                check_compiler_support = true
> +            endif
> +            if (check_compiler_support and
> +                cc.has_argument('-march=' + supported_march))
> +                candidate_march = supported_march
> +                # highest supported march version found
> +                break
> +            endif
> +        endforeach
> +        if candidate_march == ''
> +            error('No suitable armv8 march version found.')
>          endif
> -    endforeach
> +        if candidate_march != part_number_config['march']
> +            warning('Configuration march version is ' +
> +                    '@0@, but the compiler supports only @1@.'
> +                    .format(part_number_config['march'], candidate_march))
> +        endif
> +        candidate_march = '-march=' + candidate_march
> +
> +        march_features = []
> +        if part_number_config.has_key('march_features')
> +            march_features += part_number_config['march_features']
> +        endif
> +        if soc_config.has_key('extra_march_features')
> +            march_features += soc_config['extra_march_features']
> +        endif
> +        foreach feature: march_features
> +            if cc.has_argument('+'.join([candidate_march, feature]))
> +                candidate_march = '+'.join([candidate_march, feature])
> +            else
> +                warning('The compiler does not support feature @0@'
> +                    .format(feature))
> +            endif
> +        endforeach
> +        machine_args += candidate_march
> +    endif
> +
> +    # apply supported compiler options
> +    if part_number_config.has_key('compiler_options')
> +        foreach flag: part_number_config['compiler_options']
> +            if cc.has_argument(flag)
> +                machine_args += flag
> +            else
> +                warning('Configuration compiler option ' +
> +                        '@0@ isn\'t supported.'.format(flag))
> +            endif
> +        endforeach
> +    endif
> 
>      # apply flags
>      foreach flag: dpdk_flags
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features
  2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
  2021-08-17 10:56         ` [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
  2021-08-17 10:59         ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
@ 2021-09-06  8:26         ` Ruifeng Wang
  2021-09-16 16:17         ` Thomas Monjalon
  3 siblings, 0 replies; 17+ messages in thread
From: Ruifeng Wang @ 2021-09-06  8:26 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa Nagarahalli,
	fengchengwen, ferruh.yigit, jerinjacobk, jerinj, pbhagavatula
  Cc: dev, nd

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Tuesday, August 17, 2021 6:57 PM
> To: thomas@monjalon.net; david.marchand@redhat.com;
> bruce.richardson@intel.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; fengchengwen@huawei.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> pbhagavatula@marvell.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v4 1/2] config/arm: split march cfg into arch and features
> 
> Older compilers may not support all arch versions and all features that the
> target SoC supports, in which case it's better to figure out the highest arch
> version and features that the compiler supports. Implement a way to achieve
> this:
> 1. Find the highest arch version that the compiler supports, keeping in mind
> the SoC arch version we're building. For example, if the SoC arch version is
> arm8.2-a, but the compiler only supports arm8.1-a, use arm8.1-a. On the
> other hand, if the compiler supports arm8.3-a (or higher), use armv8.2-a.
> 2. With the architecture version locked, iterate over SoC features and use all
> that are supported.
> 
> In all cases, emit a warning if there's something unsupported by the compiler.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> v4: rebase
> ---
>  config/arm/meson.build | 124 ++++++++++++++++++++++++++++++++-----
> ----
>  1 file changed, 99 insertions(+), 25 deletions(-)
> 

Looks good to me.
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature
  2021-08-17 10:56         ` [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
@ 2021-09-06  8:38           ` Ruifeng Wang
  0 siblings, 0 replies; 17+ messages in thread
From: Ruifeng Wang @ 2021-09-06  8:38 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa Nagarahalli,
	fengchengwen, ferruh.yigit, jerinjacobk, jerinj, pbhagavatula
  Cc: dev, nd

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Tuesday, August 17, 2021 6:57 PM
> To: thomas@monjalon.net; david.marchand@redhat.com;
> bruce.richardson@intel.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; fengchengwen@huawei.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> pbhagavatula@marvell.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature
> 
> Not all Neoverse-N2 cpus must support the crypto feature/extension which
> makes it an optional feature. Only enable the feature for SoCs which support
> it.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> v4: rebase
> ---
>  config/arm/meson.build | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> c11efa1583..c9bcd089df 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -76,7 +76,7 @@ part_number_config_arm = {
>      },
>      '0xd49': {
>          'march': 'armv8.5-a',
> -        'march_features': ['crypto', 'sve2'],
> +        'march_features': ['sve2'],
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'],
>              ['RTE_ARM_FEATURE_ATOMICS', true], @@ -278,6 +278,7 @@
> soc_cn10k = {
>          ['RTE_MAX_NUMA_NODES', 1]
>      ],
>      'part_number': '0xd49',
> +    'extra_march_features': ['crypto'],
>      'numa': false
>  }
> 
> --
> 2.20.1

Yes, 'crypto' is an optional extension. N2 has this extension enabled, and there could be variants without crypto extension.
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features
  2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
                           ` (2 preceding siblings ...)
  2021-09-06  8:26         ` Ruifeng Wang
@ 2021-09-16 16:17         ` Thomas Monjalon
  3 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2021-09-16 16:17 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, fengchengwen, ferruh.yigit, jerinjacobk, jerinj,
	pbhagavatula, dev

17/08/2021 12:56, Juraj Linkeš:
> Older compilers may not support all arch versions and all features that
> the target SoC supports, in which case it's better to figure out the
> highest arch version and features that the compiler supports. Implement
> a way to achieve this:
> 1. Find the highest arch version that the compiler supports, keeping in
> mind the SoC arch version we're building. For example, if the SoC arch
> version is arm8.2-a, but the compiler only supports arm8.1-a, use
> arm8.1-a. On the other hand, if the compiler supports arm8.3-a (or
> higher), use armv8.2-a.
> 2. With the architecture version locked, iterate over SoC features and
> use all that are supported.
> 
> In all cases, emit a warning if there's something unsupported by the
> compiler.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>

Series applied, thanks.




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-09-16 16:17 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29  9:39 [dpdk-dev] [PATCH v1] config/arm: split march cfg into arch and features Juraj Linkeš
2021-06-29  9:39 ` [dpdk-dev] [PATCH v1] config/arm: split march cfg to " Juraj Linkeš
2021-07-06  8:21 ` [dpdk-dev] [PATCH v2] config/arm: split march cfg into " Juraj Linkeš
2021-07-12 13:02   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
2021-07-14  9:24     ` Ruifeng Wang
2021-07-16  3:42       ` fengchengwen
2021-07-16 12:22         ` Juraj Linkeš
2021-07-20  7:25     ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
2021-07-20 11:58       ` Juraj Linkeš
2021-07-20 12:33     ` [dpdk-dev] [PATCH v3 1/2] " Juraj Linkeš
2021-07-20 12:33       ` [dpdk-dev] [PATCH v3 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
2021-08-17 10:56       ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
2021-08-17 10:56         ` [dpdk-dev] [PATCH v4 2/2] config/arm: make n2 'crypto' an optional feature Juraj Linkeš
2021-09-06  8:38           ` Ruifeng Wang
2021-08-17 10:59         ` [dpdk-dev] [PATCH v4 1/2] config/arm: split march cfg into arch and features Juraj Linkeš
2021-09-06  8:26         ` Ruifeng Wang
2021-09-16 16:17         ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).