mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
Merge pull request #27846 from keszybz/link-mode-generation
Autogenerate list of link modes
This commit is contained in:
commit
18cad4ebda
@ -20,7 +20,9 @@ xsltproc_flags = [
|
||||
'--stringparam', 'man.copyright.section.enabled', '0',
|
||||
'--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
|
||||
'--path',
|
||||
'@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]
|
||||
'@0@:@1@:@2@'.format(meson.current_build_dir(),
|
||||
meson.current_source_dir(),
|
||||
libshared_build_dir)]
|
||||
|
||||
custom_man_xsl = files('custom-man.xsl')
|
||||
custom_html_xsl = files('custom-html.xsl')
|
||||
@ -32,6 +34,8 @@ custom_entities_ent = custom_target(
|
||||
output : 'custom-entities.ent',
|
||||
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
|
||||
|
||||
man_page_depends += custom_entities_ent
|
||||
|
||||
man_pages = []
|
||||
html_pages = []
|
||||
source_xml_files = []
|
||||
@ -68,7 +72,7 @@ foreach tuple : manpages
|
||||
input : xml,
|
||||
output : [man] + manaliases,
|
||||
command : xslt_cmd + [custom_man_xsl, '@INPUT@'],
|
||||
depends : custom_entities_ent,
|
||||
depends : man_page_depends,
|
||||
install : want_man,
|
||||
install_dir : mandirn)
|
||||
man_pages += p1
|
||||
@ -93,7 +97,7 @@ foreach tuple : manpages
|
||||
input : xml,
|
||||
output : html,
|
||||
command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
|
||||
depends : [custom_entities_ent, p2],
|
||||
depends : [man_page_depends, p2],
|
||||
install : want_html,
|
||||
install_dir : docdir / 'html')
|
||||
html_pages += p3
|
||||
@ -114,7 +118,7 @@ systemd_directives_xml = custom_target(
|
||||
'systemd.directives.xml',
|
||||
input : ['directives-template.xml', source_xml_files],
|
||||
output : 'systemd.directives.xml',
|
||||
depends : custom_entities_ent,
|
||||
depends : man_page_depends,
|
||||
command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
|
||||
|
||||
nonindex_xml_files = source_xml_files + [systemd_directives_xml]
|
||||
@ -166,7 +170,7 @@ foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directiv
|
||||
input : xml,
|
||||
output : html,
|
||||
command : xslt_cmd + [custom_html_xsl, '@INPUT@'],
|
||||
depends : [custom_entities_ent, p2],
|
||||
depends : [man_page_depends, p2],
|
||||
install : want_html and have_lxml,
|
||||
install_dir : docdir / 'html')
|
||||
html_pages += p3
|
||||
@ -237,4 +241,4 @@ update_man_rules = custom_target(
|
||||
command : [update_man_rules_py,
|
||||
'@0@/man/*.xml'.format(project_source_root),
|
||||
'@0@/rules/meson.build'.format(meson.current_source_dir())],
|
||||
depends : custom_entities_ent)
|
||||
depends : man_page_depends)
|
||||
|
@ -3,7 +3,8 @@
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
||||
|
||||
<refentry id="systemd.link">
|
||||
<refentry id="systemd.link"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refentryinfo>
|
||||
<title>systemd.link</title>
|
||||
<productname>systemd</productname>
|
||||
@ -709,49 +710,7 @@
|
||||
<entry>Speed (Mbps)</entry>
|
||||
<entry>Duplex Mode</entry>
|
||||
</row></thead>
|
||||
<tbody>
|
||||
<row><entry><option>10baset-half</option></entry>
|
||||
<entry>10</entry><entry>half</entry></row>
|
||||
|
||||
<row><entry><option>10baset-full</option></entry>
|
||||
<entry>10</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>100baset-half</option></entry>
|
||||
<entry>100</entry><entry>half</entry></row>
|
||||
|
||||
<row><entry><option>100baset-full</option></entry>
|
||||
<entry>100</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>1000baset-half</option></entry>
|
||||
<entry>1000</entry><entry>half</entry></row>
|
||||
|
||||
<row><entry><option>1000baset-full</option></entry>
|
||||
<entry>1000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>10000baset-full</option></entry>
|
||||
<entry>10000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>2500basex-full</option></entry>
|
||||
<entry>2500</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>1000basekx-full</option></entry>
|
||||
<entry>1000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>10000basekx4-full</option></entry>
|
||||
<entry>10000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>10000basekr-full</option></entry>
|
||||
<entry>10000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>10000baser-fec</option></entry>
|
||||
<entry>10000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>20000basemld2-full</option></entry>
|
||||
<entry>20000</entry><entry>full</entry></row>
|
||||
|
||||
<row><entry><option>20000basekr2-full</option></entry>
|
||||
<entry>20000</entry><entry>full</entry></row>
|
||||
</tbody>
|
||||
<xi:include href="ethtool-link-mode.xml" />
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
|
@ -2173,6 +2173,8 @@ userspace = declare_dependency(
|
||||
link_args : userspace_c_ld_args,
|
||||
)
|
||||
|
||||
man_page_depends = []
|
||||
|
||||
############################################################
|
||||
|
||||
# binaries that have --help and are intended for use by humans,
|
||||
|
61
src/shared/ethtool-link-mode.py
Normal file
61
src/shared/ethtool-link-mode.py
Normal file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
OVERRIDES = {
|
||||
'autoneg' : 'autonegotiation',
|
||||
}
|
||||
|
||||
mode, cpp, header = sys.argv[1:]
|
||||
xml = mode == '--xml'
|
||||
|
||||
command = [*shlex.split(cpp), '-include', header, '-']
|
||||
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, universal_newlines=True)
|
||||
|
||||
lines = iter(out.splitlines())
|
||||
for line in lines:
|
||||
if line.startswith('enum ethtool_link_mode_bit_indices {'):
|
||||
break
|
||||
|
||||
entries = []
|
||||
for line in lines:
|
||||
if line.startswith('}'):
|
||||
break
|
||||
# ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0,
|
||||
m = re.match(r'^\s*(ETHTOOL_LINK_MODE_((\d*).*)_BIT)\s*=\s*(\d+),', line)
|
||||
if not m:
|
||||
continue
|
||||
enum, name, speed, value = m.groups()
|
||||
|
||||
name = name.lower().replace('_', '-')
|
||||
name = OVERRIDES.get(name, name)
|
||||
|
||||
duplex = name.split('-')[-1].lower()
|
||||
if duplex not in {'half', 'full'}:
|
||||
duplex = ''
|
||||
|
||||
entries += [(enum, name, speed, value, duplex)]
|
||||
|
||||
if xml:
|
||||
print(' <tbody>')
|
||||
|
||||
entries.sort(key=lambda entry: (int(entry[2]) if entry[2] else 1e20, entry[4], entry[1], entry[3]))
|
||||
|
||||
for enum, name, speed, value, duplex in entries:
|
||||
if xml:
|
||||
print(f'''\
|
||||
<row><entry><option>{name}</option></entry>
|
||||
<entry>{speed}</entry><entry>{duplex}</entry></row>
|
||||
''')
|
||||
else:
|
||||
enum = f'[{enum}]'
|
||||
print(f' {enum:50} = "{name}",')
|
||||
|
||||
if xml:
|
||||
print(' </tbody>')
|
||||
|
||||
assert len(entries) >= 99
|
@ -151,98 +151,7 @@ static const char* const netdev_feature_table[_NET_DEV_FEAT_MAX] = {
|
||||
};
|
||||
|
||||
static const char* const ethtool_link_mode_bit_table[] = {
|
||||
[ETHTOOL_LINK_MODE_10baseT_Half_BIT] = "10baset-half",
|
||||
[ETHTOOL_LINK_MODE_10baseT_Full_BIT] = "10baset-full",
|
||||
[ETHTOOL_LINK_MODE_100baseT_Half_BIT] = "100baset-half",
|
||||
[ETHTOOL_LINK_MODE_100baseT_Full_BIT] = "100baset-full",
|
||||
[ETHTOOL_LINK_MODE_1000baseT_Half_BIT] = "1000baset-half",
|
||||
[ETHTOOL_LINK_MODE_1000baseT_Full_BIT] = "1000baset-full",
|
||||
[ETHTOOL_LINK_MODE_Autoneg_BIT] = "autonegotiation",
|
||||
[ETHTOOL_LINK_MODE_TP_BIT] = "tp",
|
||||
[ETHTOOL_LINK_MODE_AUI_BIT] = "aui",
|
||||
[ETHTOOL_LINK_MODE_MII_BIT] = "mii",
|
||||
[ETHTOOL_LINK_MODE_FIBRE_BIT] = "fibre",
|
||||
[ETHTOOL_LINK_MODE_BNC_BIT] = "bnc",
|
||||
[ETHTOOL_LINK_MODE_10000baseT_Full_BIT] = "10000baset-full",
|
||||
[ETHTOOL_LINK_MODE_Pause_BIT] = "pause",
|
||||
[ETHTOOL_LINK_MODE_Asym_Pause_BIT] = "asym-pause",
|
||||
[ETHTOOL_LINK_MODE_2500baseX_Full_BIT] = "2500basex-full",
|
||||
[ETHTOOL_LINK_MODE_Backplane_BIT] = "backplane",
|
||||
[ETHTOOL_LINK_MODE_1000baseKX_Full_BIT] = "1000basekx-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT] = "10000basekx4-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseKR_Full_BIT] = "10000basekr-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseR_FEC_BIT] = "10000baser-fec",
|
||||
[ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT] = "20000basemld2-full",
|
||||
[ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT] = "20000basekr2-full",
|
||||
[ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT] = "40000basekr4-full",
|
||||
[ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT] = "40000basecr4-full",
|
||||
[ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT] = "40000basesr4-full",
|
||||
[ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT] = "40000baselr4-full",
|
||||
[ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT] = "56000basekr4-full",
|
||||
[ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT] = "56000basecr4-full",
|
||||
[ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT] = "56000basesr4-full",
|
||||
[ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT] = "56000baselr4-full",
|
||||
[ETHTOOL_LINK_MODE_25000baseCR_Full_BIT] = "25000basecr-full",
|
||||
[ETHTOOL_LINK_MODE_25000baseKR_Full_BIT] = "25000basekr-full",
|
||||
[ETHTOOL_LINK_MODE_25000baseSR_Full_BIT] = "25000basesr-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT] = "50000basecr2-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT] = "50000basekr2-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT] = "100000basekr4-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT] = "100000basesr4-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT] = "100000basecr4-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT] = "100000baselr4-er4-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT] = "50000basesr2-full",
|
||||
[ETHTOOL_LINK_MODE_1000baseX_Full_BIT] = "1000basex-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseCR_Full_BIT] = "10000basecr-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseSR_Full_BIT] = "10000basesr-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseLR_Full_BIT] = "10000baselr-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT] = "10000baselrm-full",
|
||||
[ETHTOOL_LINK_MODE_10000baseER_Full_BIT] = "10000baseer-full",
|
||||
[ETHTOOL_LINK_MODE_2500baseT_Full_BIT] = "2500baset-full",
|
||||
[ETHTOOL_LINK_MODE_5000baseT_Full_BIT] = "5000baset-full",
|
||||
[ETHTOOL_LINK_MODE_FEC_NONE_BIT] = "fec-none",
|
||||
[ETHTOOL_LINK_MODE_FEC_RS_BIT] = "fec-rs",
|
||||
[ETHTOOL_LINK_MODE_FEC_BASER_BIT] = "fec-baser",
|
||||
[ETHTOOL_LINK_MODE_50000baseKR_Full_BIT] = "50000basekr-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseSR_Full_BIT] = "50000basesr-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseCR_Full_BIT] = "50000basecr-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT] = "50000baselr-er-fr-full",
|
||||
[ETHTOOL_LINK_MODE_50000baseDR_Full_BIT] = "50000basedr-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT] = "100000basekr2-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT] = "100000basesr2-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT] = "100000basecr2-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT] = "100000baselr2-er2-fr2-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT] = "100000basedr2-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT] = "200000basekr4-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT] = "200000basesr4-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT] = "200000baselr4-er4-fr4-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT] = "200000basedr4-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT] = "200000basecr4-full",
|
||||
[ETHTOOL_LINK_MODE_100baseT1_Full_BIT] = "100baset1-full",
|
||||
[ETHTOOL_LINK_MODE_1000baseT1_Full_BIT] = "1000baset1-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseKR8_Full_BIT] = "400000basekr8-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseSR8_Full_BIT] = "400000basesr8-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseLR8_ER8_FR8_Full_BIT] = "400000baselr8-er8-fr8-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT] = "400000basedr8-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT] = "400000basecr8-full",
|
||||
[ETHTOOL_LINK_MODE_FEC_LLRS_BIT] = "fec-llrs",
|
||||
[ETHTOOL_LINK_MODE_100000baseKR_Full_BIT] = "100000basekr-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseSR_Full_BIT] = "100000basesr-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseLR_ER_FR_Full_BIT] = "100000baselr-er-fr-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseCR_Full_BIT] = "100000basecr-full",
|
||||
[ETHTOOL_LINK_MODE_100000baseDR_Full_BIT] = "100000basedr-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseKR2_Full_BIT] = "200000basekr2-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseSR2_Full_BIT] = "200000basesr2-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseLR2_ER2_FR2_Full_BIT] = "200000baselr2-er2-fr2-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseDR2_Full_BIT] = "200000basedr2-full",
|
||||
[ETHTOOL_LINK_MODE_200000baseCR2_Full_BIT] = "200000basecr2-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseKR4_Full_BIT] = "400000basekr4-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseSR4_Full_BIT] = "400000basesr4-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT] = "400000baselr4-er4-fr4-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT] = "400000basedr4-full",
|
||||
[ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT] = "400000basecr4-full",
|
||||
[ETHTOOL_LINK_MODE_100baseFX_Half_BIT] = "100basefx-half",
|
||||
[ETHTOOL_LINK_MODE_100baseFX_Full_BIT] = "100basefx-full",
|
||||
# include "ethtool-link-mode.h"
|
||||
};
|
||||
/* Make sure the array is large enough to fit all bits */
|
||||
assert_cc((ELEMENTSOF(ethtool_link_mode_bit_table)-1) / 32 < N_ADVERTISE);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "conf-parser.h"
|
||||
#include "ether-addr-util.h"
|
||||
|
||||
#define N_ADVERTISE 3
|
||||
#define N_ADVERTISE 4
|
||||
|
||||
/* we can't use DUPLEX_ prefix, as it
|
||||
* clashes with <linux/ethtool.h> */
|
||||
|
@ -270,6 +270,24 @@ target2 = custom_target(
|
||||
shared_generated_gperf_headers = [target1, target2]
|
||||
shared_sources += shared_generated_gperf_headers
|
||||
|
||||
fname = 'ethtool-link-mode.h'
|
||||
ethtool_link_mode_h = custom_target(
|
||||
fname,
|
||||
input : ['ethtool-link-mode.py', 'linux/ethtool.h'],
|
||||
output : fname,
|
||||
command : [python, '@INPUT0@', '--header', cpp, '@INPUT1@'],
|
||||
capture : true)
|
||||
shared_sources += ethtool_link_mode_h
|
||||
|
||||
fname = 'ethtool-link-mode.xml'
|
||||
ethtool_link_mode_xml = custom_target(
|
||||
fname,
|
||||
input : ['ethtool-link-mode.py', 'linux/ethtool.h'],
|
||||
output : fname,
|
||||
command : [python, '@INPUT0@', '--xml', cpp, '@INPUT1@'],
|
||||
capture : true)
|
||||
man_page_depends += ethtool_link_mode_xml
|
||||
|
||||
libshared_name = 'systemd-shared-@0@'.format(shared_lib_tag)
|
||||
|
||||
libshared_deps = [threads,
|
||||
@ -295,6 +313,7 @@ libshared_deps = [threads,
|
||||
versiondep]
|
||||
|
||||
libshared_sym_path = '@0@/libshared.sym'.format(meson.current_source_dir())
|
||||
libshared_build_dir = meson.current_build_dir()
|
||||
|
||||
libshared_static = static_library(
|
||||
libshared_name,
|
||||
|
@ -7,6 +7,8 @@ class CustomResolver(tree.Resolver):
|
||||
def resolve(self, url, id, context):
|
||||
if 'custom-entities.ent' in url:
|
||||
return self.resolve_filename('man/custom-entities.ent', context)
|
||||
if 'ethtool-link-mode' in url:
|
||||
return self.resolve_filename('src/shared/ethtool-link-mode.xml', context)
|
||||
|
||||
_parser = tree.XMLParser()
|
||||
_parser.resolvers.add(CustomResolver())
|
||||
|
Loading…
Reference in New Issue
Block a user