├── .github ├── problem-matchers │ └── compiler-source.json └── workflows │ └── main.yml ├── .gitignore ├── .travis.yml ├── COPYING ├── Changelog ├── Makefile.am ├── README ├── addon ├── Makefile ├── README └── powerpc-utils-sles10-addons.spec ├── autogen.sh ├── configure.ac ├── doc ├── activate_firmware.doxycfg ├── nvram.doxycfg ├── rtas_ibm_get_vpd.doxycfg ├── serv_config.doxycfg ├── set_poweron_time.doxycfg └── uesensor.doxycfg ├── m4 ├── ax_append_compile_flags.m4 ├── ax_append_flag.m4 ├── ax_check_compile_flag.m4 ├── ax_check_link_flag.m4 └── ax_require_defined.m4 ├── man ├── activate_firmware.8 ├── amsstat.1 ├── bootlist.8 ├── drmgr-hooks.8 ├── drmgr.8 ├── errinjct.8 ├── hvcsadmin.8 ├── lparcfg.5 ├── lparnumascore.8 ├── lparstat.8 ├── lsslot.8 ├── nvram.8 ├── ofpathname.8 ├── ppc64_cpu.8 ├── rtas_dbg.8 ├── rtas_dump.8 ├── rtas_ibm_get_vpd.8 ├── serv_config.8 ├── set_poweron_time.8 ├── smtstate.8 ├── snap.8 ├── sys_ident.8 ├── uesensor.8 ├── update_flash.8 └── vcpustat.8 ├── powerpc-utils.spec.in ├── scripts ├── Makefile.am ├── amsstat ├── bootlist ├── functions.suse ├── hcnmgr ├── hvcsadmin ├── ls-vdev ├── ls-veth ├── ls-vscsi ├── lsdevinfo ├── nvsetenv ├── ofpathname ├── pseries_platform ├── rtas_dump ├── smtstate.in ├── snap ├── update_flash └── update_flash_nv ├── src ├── activate_fw.c ├── common │ ├── cpu_info_helpers.c │ ├── cpu_info_helpers.h │ ├── librtas_error.c │ ├── librtas_error.h │ ├── pseries_platform.c │ └── pseries_platform.h ├── drmgr │ ├── common.c │ ├── common_cpu.c │ ├── common_numa.c │ ├── common_numa.h │ ├── common_ofdt.c │ ├── common_pci.c │ ├── dr.h │ ├── dracc_chrp_acc.c │ ├── drcpu.h │ ├── drmem.h │ ├── drmgr.c │ ├── drmig_chrp_pmig.c │ ├── drpci.h │ ├── drslot_chrp_cpu.c │ ├── drslot_chrp_hea.c │ ├── drslot_chrp_mem.c │ ├── drslot_chrp_pci.c │ ├── drslot_chrp_phb.c │ ├── drslot_chrp_slot.c │ ├── lparnumascore.c │ ├── lsslot.c │ ├── lsslot_chrp_cpu.c │ ├── ofdt.h │ ├── options.c │ ├── prrn.c │ ├── rtas_calls.c │ └── rtas_calls.h ├── errinjct │ ├── dcache.c │ ├── errinjct.c │ ├── errinjct.h │ ├── icache.c │ ├── ioa_bus_error.c │ ├── open_close.c │ ├── platform.c │ ├── slb.c │ └── tlb.c ├── lparstat.c ├── lparstat.h ├── lsprop.c ├── nvram.c ├── nvram.h ├── ppc64_cpu.c ├── rtas_dbg.c ├── rtas_event_decode.c ├── rtas_ibm_get_vpd.c ├── serv_config.c ├── set_poweron_time.c ├── sys_ident.c ├── uesensor.c └── vcpustat.c ├── systemd ├── hcn-init.service.in.in ├── smt_off.service.in └── smtstate.service.in └── var └── lib └── powerpc-utils └── smt.state /.github/problem-matchers/compiler-source.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "gcc-problem-matcher", 5 | "pattern": [ 6 | { 7 | "regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", 8 | "file": 1, 9 | "line": 2, 10 | "column": 3, 11 | "severity": 4, 12 | "message": 5 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | # Controls when the workflow will run. 4 | on: 5 | # This allows the build to be triggered manually via the github UI. 6 | workflow_dispatch: 7 | 8 | # Push to any branch 9 | push: 10 | 11 | # Any pull request 12 | pull_request: 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-22.04 17 | 18 | strategy: 19 | matrix: 20 | host: [powerpc-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, x86_64-linux-gnu] 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | with: 25 | repository: ibm-power-utilities/librtas 26 | path: ./librtas 27 | 28 | - name: Install powerpc cross compiler 29 | if: matrix.host != 'x86_64-linux-gnu' 30 | run: | 31 | sudo apt update 32 | sudo apt install -y gcc-${{ matrix.host }} 33 | 34 | - name: Install libnuma-dev.x86_64 35 | if: matrix.host == 'x86_64-linux-gnu' 36 | run: sudo apt install -y libnuma-dev 37 | 38 | - name: Build and install librtas 39 | run: | 40 | cd ./librtas 41 | ./autogen.sh 42 | ./configure --prefix=/usr --host=${{ matrix.host }} --build=x86_64-linux-gnu 43 | make 44 | sudo make install 45 | cd .. 46 | 47 | - uses: actions/checkout@v4 48 | with: 49 | repository: madler/zlib 50 | ref: v1.2.11 51 | path: ./zlib 52 | 53 | - name: Build and install zlib for powerpc 54 | if: matrix.host != 'x86_64-linux-gnu' 55 | run: | 56 | cd ./zlib 57 | CHOST=${{ matrix.host }} ./configure --prefix=/usr 58 | make 59 | sudo make install 60 | cd .. 61 | 62 | - uses: actions/checkout@v4 63 | with: 64 | repository: numactl/numactl 65 | ref: v2.0.14 66 | path: ./numactl 67 | 68 | - name: Build and install libnuma for powerpc 69 | if: matrix.host != 'x86_64-linux-gnu' 70 | run: | 71 | cd ./numactl 72 | ./autogen.sh 73 | ./configure --prefix=/usr --host=${{ matrix.host }} --build=x86_64-linux-gnu 74 | make 75 | sudo make install 76 | cd .. 77 | 78 | - uses: actions/checkout@v4 79 | 80 | - name: Register problem matchers 81 | run: | 82 | echo "::add-matcher::.github/problem-matchers/compiler-source.json" 83 | 84 | - name: autogen 85 | run: ./autogen.sh 86 | 87 | - name: configure 88 | run: | 89 | ./configure --prefix=/usr --host=${{ matrix.host }} --enable-werror --build=x86_64-linux-gnu CFLAGS='-O2 -g' 90 | 91 | - name: Collect config.log 92 | if: ${{ failure() }} 93 | uses: actions/upload-artifact@v4 94 | with: 95 | name: config.log 96 | path: ./config.log 97 | 98 | - name: make 99 | run: make V=1 100 | 101 | - name: distcheck 102 | run: | 103 | make distcheck V=1 DISTCHECK_CONFIGURE_FLAGS='--enable-werror --host=${{ matrix.host }}' 104 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE! Don't add files that are generated in specific 3 | # subdirectories here. Add them in the ".gitignore" file 4 | # in that subdirectory instead. 5 | # 6 | # NOTE! Please use 'git ls-files -i --exclude-standard' 7 | # command after changing this file, to see if there are 8 | # any tracked files which get ignored after the change. 9 | # 10 | # Normal rules 11 | # 12 | *.o 13 | *.o.* 14 | *.a 15 | *.s 16 | *.so 17 | *.so.dbg 18 | *.mod.c 19 | *.i 20 | *.order 21 | *.gz 22 | *.bz2 23 | *.lzma 24 | *.zip 25 | *.lzo 26 | *.patch 27 | *.gcno 28 | 29 | # 30 | # Build files 31 | # 32 | /aclocal.m4 33 | /autom4te.cache/ 34 | /config/ 35 | /config.log 36 | /config.status 37 | /configure 38 | /Makefile 39 | /Makefile.in 40 | /man/Makefile 41 | /man/Makefile.in 42 | /powerpc-utils.spec 43 | /scripts/Makefile 44 | /scripts/Makefile.in 45 | /scripts/smtstate 46 | /src/Makefile 47 | /src/Makefile.in 48 | /src/drmgr/Makefile 49 | /src/drmgr/Makefile.in 50 | /systemd/smt_off.service 51 | /systemd/smtstate.service 52 | /systemd/hcn-init.service.in 53 | /systemd/hcn-init-NetworkManager.service 54 | /systemd/hcn-init-wicked.service 55 | 56 | # 57 | # git files that we don't want to ignore even it they are dot-files 58 | # 59 | !.gitignore 60 | 61 | # 62 | # Generated include files 63 | # 64 | include/config 65 | include/linux/version.h 66 | include/generated 67 | 68 | # stgit generated dirs 69 | patches-* 70 | 71 | # quilt's files 72 | patches 73 | series 74 | 75 | # cscope files 76 | cscope.* 77 | ncscope.* 78 | 79 | # ctags 80 | tags 81 | TAGS 82 | 83 | # gnu global files 84 | GPATH 85 | GRTAGS 86 | GSYMS 87 | GTAGS 88 | 89 | # Executables 90 | /src/activate_firmware 91 | /src/drmgr/drmgr 92 | /src/drmgr/lsslot 93 | /src/drmgr/lparnumascore 94 | /src/lparstat 95 | /src/lsprop 96 | /src/nvram 97 | /src/ppc64_cpu 98 | /src/rtas_event_decode 99 | /src/rtas_ibm_get_vpd 100 | /src/serv_config 101 | /src/set_poweron_time 102 | /src/sys_ident 103 | /src/uesensor 104 | /src/usysattn 105 | /src/usysident 106 | /src/errinjct/errinjct 107 | /src/rtas_dbg 108 | /src/vcpustat 109 | 110 | *.orig 111 | *~ 112 | \#*# 113 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | os: linux 3 | arch: ppc64le 4 | dist: bionic 5 | 6 | addons: 7 | apt: 8 | packages: 9 | - librtas-dev 10 | - librtasevent-dev 11 | - libnuma-dev 12 | 13 | script: 14 | - ./autogen.sh 15 | - ./configure 16 | - make 17 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | powerpc-utils package 2 | ========================== 3 | 4 | Mailing List: powerpc-utils-devel@googlegroups.com 5 | Subscribe: https://groups.google.com/forum/#!forum/powerpc-utils-devel/join 6 | 7 | This package contains utilities which are intended for maintenance of IBM 8 | powerpc platforms that follow the POWER Architecture Platform Reference (PAPR), 9 | This package requires the librtas package in order to function properly. 10 | All of these utilities must be run as root. 11 | 12 | The virtual IO administration utilities included in this package require the 13 | systool application. 14 | 15 | Further documentation for each of these utilities is available in their 16 | corresponding man pages. 17 | 18 | update_flash: system firmware update utility 19 | ------------ 20 | A script that uses the rtas_flash kernel module to flash firmware. 21 | 22 | set_poweron_time: configure time for system power-on 23 | ---------------- 24 | A utility to set a time in the future for the system to automatically 25 | power on, if the system is powered off at that time. 26 | 27 | serv_config: configure serviceability settings 28 | ----------- 29 | A series of menus that can be used to update system service settings 30 | stored in NVRAM, which are used by the system's service processor. 31 | These settings include surveillance, boot, and remote maintenance 32 | policies. Different system configurations may expose different kinds 33 | of serviceability parameters. 34 | 35 | hvcsadmin: HVCS driver administration utility 36 | ------- 37 | This is the hvcs driver administration utility which simplifies hvcs 38 | administration by providing a set of options for such functions as closing 39 | adapter targets using device mapping, querying console adapters, querying 40 | adapters based upon device node, gathering status, and closing all open 41 | adapters. Documentation is provided in man page hvcsadmin (8). 42 | 43 | drmgr: 44 | ----- 45 | Dynamic reconfiguration manager. This isn't neccessarily meant to be invoked 46 | from the command line, but rather is the command invoked via the RMC connection 47 | from an HMC. 48 | 49 | lsslot: 50 | ------ 51 | Tool used to determine dyanmic reconfiguration capable slots/cpus/memory 52 | on a partition. 53 | 54 | lparnumascore: 55 | ------ 56 | Tool used to compute the NUMA affinity score reflecting the difference 57 | between NUMA topology exposed by the hypervisor and the one the linux 58 | kernel has taken in account. 59 | 60 | ppc64_cpu: 61 | --------- 62 | This allows users to set the smt state and other settings on ppc64 processors. 63 | It also allows users to control the number of processor cores which are online 64 | (not in the sleep state). 65 | 66 | Previously this allowed setting of smt-snooze-delay, but Linux has not 67 | supported this since 3.14. 68 | 69 | lsdevinfo: 70 | --------- 71 | This utility provides the HMC or IVM with name information for 72 | virtual devices so they can be matched against the VIOS names. 73 | 74 | usysident, usysattn, usysfault: 75 | ------------------------------- 76 | Deprecated. Moved to ppc64-diag package. 77 | https://github.com/power-ras/ppc64-diag 78 | 79 | =================== 80 | 81 | The following tools are used by other maintenance utilities to gather 82 | necessary information. These tools are not typically invoked on the 83 | command line. 84 | 85 | activate_firmware: concurrent firmware activation 86 | ----------------- 87 | Used during concurrent firmware update operations to activate the new 88 | firmware image locally. This utility is invoked automatically when 89 | necessary. 90 | 91 | rtas_ibm_get_vpd: 92 | ---------------- 93 | Used by the lsvpd utility to gather Vital Product Data that changes 94 | dynamically. 95 | 96 | hcnmgr: 97 | --------- 98 | This utility provides the HMC tools to hybrid virtual network to allow 99 | SR_IOV VFs on LPAR capable for live partition migration. 100 | -------------------------------------------------------------------------------- /addon/Makefile: -------------------------------------------------------------------------------- 1 | ## Makefile for powerpc-utils-sles10-addons 2 | 3 | PPU_ADDONS_NAME = powerpc-utils-sles10-addons 4 | VERSION = 1.0.2 5 | 6 | SCRIPTS = ../scripts/lsdevinfo ../scripts/ls-vdev ../scripts/ls-veth ../scripts/ls-vscsi 7 | UTILS = ../src/drmgr/drmgr ../src/drmgr/lsslot ../src/drmgr/lparnumascore 8 | DOCS = ../COPYRIGHT README 9 | 10 | INSTALL = /usr/bin/install 11 | SBIN_DIR = /usr/sbin 12 | DOC_DIR = /usr/share/doc/packages/$(PPU_ADDONS_NAME) 13 | 14 | PPU_TARNAME = powerpc-utils-1.2.8 15 | PPU_ADDONS_TARNAME = $(PPU_ADDONS_NAME)-$(VERSION) 16 | 17 | all: 18 | 19 | install: 20 | $(INSTALL) -d -m 755 $(DESTDIR)$(SBIN_DIR) 21 | $(foreach f,$(SCRIPTS),$(INSTALL) -m 744 $f $(DESTDIR)$(SBIN_DIR);) 22 | $(foreach f,$(UTILS),$(INSTALL) -m 744 $f $(DESTDIR)$(SBIN_DIR);) 23 | $(INSTALL) -d -m 755 $(DESTDIR)$(DOC_DIR) 24 | $(foreach f,$(DOCS),$(INSTALL) -m 744 $f $(DESTDIR)$(DOC_DIR);) 25 | 26 | dist: 27 | $(MAKE) -C .. dist 28 | tar -xzf ../$(PPU_TARNAME).tar.gz 29 | mv $(PPU_TARNAME) $(PPU_ADDONS_TARNAME) 30 | mkdir $(PPU_ADDONS_TARNAME)/addon 31 | cp Makefile $(PPU_ADDONS_TARNAME)/addon 32 | cp README $(PPU_ADDONS_TARNAME)/addon 33 | cp powerpc-utils-sles10-addons.spec $(PPU_ADDONS_TARNAME)/addon 34 | tar -chof $(PPU_ADDONS_TARNAME).tar $(PPU_ADDONS_TARNAME) 35 | gzip $(PPU_ADDONS_TARNAME).tar 36 | rm -rf $(PPU_ADDONS_TARNAME) 37 | -------------------------------------------------------------------------------- /addon/README: -------------------------------------------------------------------------------- 1 | powerpc-utils-sles10-addons package 2 | =================================== 3 | This package is meant as an addon for the SLES 10 SP3 release to bring 4 | the installed powerpc-utilities up to par with the latest ppowerpc-utils 5 | release. the packages installed are those that are not installed with the 6 | version of powerpc-utils shipped with SLES 10 SP3. 7 | 8 | This package contains utilities which are intended for maintenance of IBM 9 | powerpc platforms that follow the POWER Architecture Platform Reference (PAPR), 10 | This package requires the librtas package in order to function properly. 11 | All of these utilities must be run as root. 12 | 13 | drmgr 14 | ----- 15 | Dynamic reconfiguration manager. This isn't neccessarily meant to be invoked 16 | from the command line, but rather is the command invoked via the RMC connection 17 | from an HMC. 18 | 19 | lsslot: 20 | ------ 21 | Tool used to determine dyanmic reconfiguration capable slots/cpus/memory 22 | on a partition. 23 | 24 | lsdevinfo, ls-vdev, ls-veth, ls-vscsi: 25 | --------- 26 | These utilities provides the HMC or IVM with name information for 27 | virtual devices so they can be matched against the VIOS names. 28 | -------------------------------------------------------------------------------- /addon/powerpc-utils-sles10-addons.spec: -------------------------------------------------------------------------------- 1 | %define name powerpc-utils-sles10-addons 2 | %define version 1.0.2 3 | %define release 0 4 | Summary: Powerpc-utils Add-ons for SLES10 SP3 5 | Name: %{name} 6 | Version: %{version} 7 | Release: %{release} 8 | License: IBM Common Public License (CPL) 9 | Group: System Environment 10 | Source: powerpc-utils-sles10-addons-%{version}.tar.gz 11 | BuildRoot: /tmp/%{name}-buildroot/ 12 | Requires: /bin/bash, /bin/sh, /bin/sed, /usr/bin/perl, librtas >= 1.3.0 13 | 14 | %description 15 | Additional utilities for maintaining and servicing PowerPC systems on SLES10 16 | SP3 releases. 17 | 18 | %prep 19 | %setup -q 20 | 21 | %build 22 | %configure 23 | %{__make} %{?_smp_mflags} 24 | 25 | %install 26 | %{__rm} -rf $RPM_BULD_ROOT 27 | %{__make} install -C addon DESTDIR=$RPM_BUILD_ROOT 28 | 29 | %files 30 | %defattr(-,root,root) 31 | /usr/share/doc/packages/powerpc-utils-sles10-addons/README 32 | /usr/share/doc/packages/powerpc-utils-sles10-addons/COPYRIGHT 33 | 34 | /usr/sbin/drmgr 35 | /usr/sbin/lsslot 36 | /usr/sbin/lsdevinfo 37 | /usr/sbin/ls-veth 38 | /usr/sbin/ls-vdev 39 | /usr/sbin/ls-vscsi 40 | 41 | %post 42 | # Post-install script ----------------------------------------------- 43 | ln -sf /usr/sbin/drmgr /usr/sbin/drslot_chrp_slot 44 | ln -sf /usr/sbin/drmgr /usr/sbin/drslot_chrp_pci 45 | ln -sf /usr/sbin/drmgr /usr/sbin/drslot_chrp_cpu 46 | ln -sf /usr/sbin/drmgr /usr/sbin/drslot_chrp_phb 47 | ln -sf /usr/sbin/drmgr /usr/sbin/drslot_chrp_mem 48 | ln -sf /usr/sbin/drmgr /usr/sbin/drslot_chrp_hea 49 | ln -sf /usr/sbin/drmgr /usr/sbin/drmig_chrp_pmig 50 | 51 | %postun 52 | # Post-uninstall script --------------------------------------------- 53 | if [ "$1" = "0" ]; then 54 | # last uninstall 55 | rm /usr/sbin/drslot_chrp_slot 56 | rm /usr/sbin/drslot_chrp_pci 57 | rm /usr/sbin/drslot_chrp_cpu 58 | rm /usr/sbin/drslot_chrp_phb 59 | rm /usr/sbin/drslot_chrp_mem 60 | rm /usr/sbin/drslot_chrp_hea 61 | rm /usr/sbin/drmig_chrp_pmig 62 | fi 63 | 64 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ ! -d config ]; 6 | then 7 | mkdir config; 8 | fi 9 | 10 | autoreconf --install --verbose --force 11 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | m4_define([ppu_version], 1.3.13) 4 | 5 | AC_PREREQ([2.63]) 6 | AC_INIT([powerpc-utils], ppu_version, [tyreld@linux.ibm.com]) 7 | AC_CONFIG_AUX_DIR([config]) 8 | AC_CONFIG_MACRO_DIR([m4]) 9 | 10 | AM_INIT_AUTOMAKE([1.10 -Wall subdir-objects -Werror foreign]) 11 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 12 | AC_CONFIG_SRCDIR([src/rtas_ibm_get_vpd.c]) 13 | 14 | # Checks for programs. 15 | AC_PROG_CC 16 | AC_PROG_INSTALL 17 | AM_PROG_CC_C_O 18 | 19 | # Checks for header files. 20 | AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h memory.h netinet/in.h nl_types.h stdint.h stdlib.h string.h sys/ioctl.h syslog.h unistd.h linux/perf_event.h sys/time.h]) 21 | 22 | # Checks for typedefs, structures, and compiler characteristics. 23 | AC_C_INLINE 24 | AC_TYPE_INT8_T 25 | AC_TYPE_MODE_T 26 | AC_TYPE_PID_T 27 | AC_TYPE_SIZE_T 28 | AC_TYPE_UINT16_T 29 | AC_TYPE_UINT32_T 30 | AC_TYPE_UINT64_T 31 | AC_TYPE_UINT8_T 32 | 33 | # Checks for library functions. 34 | AC_FUNC_FORK 35 | AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK 36 | #AC_FUNC_MALLOC 37 | AC_FUNC_MKTIME 38 | AC_CHECK_FUNCS([memset strchr strcspn strdup strerror strrchr strstr strtol strtoul strtoull gettimeofday]) 39 | 40 | # check for zlib 41 | AC_CHECK_HEADER(zlib.h, 42 | [AC_CHECK_LIB(z, inflate, [], [AC_MSG_FAILURE([zlib library is required for compilation])])], 43 | [AC_MSG_FAILURE([zlib.h is required for compiliation])]) 44 | 45 | AC_CHECK_HEADER(numa.h, 46 | [AC_CHECK_LIB(numa, numa_available, [], [AC_MSG_FAILURE([numa library is required for compilation])])], 47 | [AC_MSG_FAILURE([numa.h is required for compiliation])]) 48 | 49 | # check for librtas 50 | AC_ARG_WITH([librtas], 51 | [AS_HELP_STRING([--without-librtas], 52 | [disable building utilities that require librtas])], 53 | [], 54 | [with_librtas=yes] 55 | ) 56 | 57 | AS_IF([test "x$with_librtas" != "xno"], 58 | [AC_CHECK_HEADER(librtas.h, [], [AC_MSG_FAILURE([librtas.h is required (--without-librtas to disable)])])] 59 | [AC_CHECK_LIB(rtas, rtas_errinjct_open, [], [AC_MSG_FAILURE([librtas library is missing (--without-librtas to disable)])])] 60 | [AC_CHECK_HEADER(librtasevent.h, [], [AC_MSG_FAILURE([librtasevent.h is required (--without-librtas to disable)])])] 61 | [AC_CHECK_LIB(rtasevent, parse_rtas_event, [], [AC_MSG_FAILURE([librtasevent library is missing (--without-librtas to disable)])])] 62 | 63 | AC_DEFINE(WITH_LIBRTAS) 64 | ) 65 | 66 | AM_CONDITIONAL([WITH_LIBRTAS], [test "x$with_librtas" = "xyes"]) 67 | 68 | # Check what OS you are running 69 | AC_CANONICAL_HOST 70 | case $host_os in 71 | linux*) 72 | LIBDL="-ldl" 73 | ;; 74 | *freebsd*) 75 | LIBDL="" 76 | ;; 77 | *) 78 | #Default Case 79 | AC_MSG_ERROR([Your platform is not currently supported]) 80 | ;; 81 | esac 82 | AC_SUBST(LIBDL) 83 | 84 | # check for systemd 85 | systemd_unit_dir=/lib/systemd/system 86 | AC_ARG_WITH([systemd], 87 | [AS_HELP_STRING([--with-systemd@<:@=DIR@:>@], 88 | [install systemd unit files (not default and unit dir is /lib/systemd/system)])], 89 | [if test "$withval" = "no"; then 90 | with_systemd=0 91 | else 92 | with_systemd=1 93 | test $withval != "yes" && systemd_unit_dir=$withval 94 | fi], 95 | with_systemd=0 96 | ) 97 | AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = 1]) 98 | AC_SUBST(systemd_unit_dir) 99 | 100 | AC_ARG_ENABLE([werror], 101 | AS_HELP_STRING([--enable-werror], [treat compiler warnings as fatal errors])) 102 | 103 | AC_DEFUN([LOCAL_CHECK_FLAGS],[ 104 | AC_REQUIRE([AX_CHECK_LINK_FLAG]) 105 | AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) 106 | AC_LANG_PUSH([C]) 107 | AX_APPEND_COMPILE_FLAGS([-Wall]) 108 | AS_IF([test "x$enable_werror" == "xyes"], [AX_APPEND_COMPILE_FLAGS([-Werror])]) 109 | AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2 -fstack-protector-all]) 110 | AX_APPEND_COMPILE_FLAGS([-fwrapv -fPIE -Wstack-protector]) 111 | AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1]) 112 | AX_CHECK_LINK_FLAG([-z relro -z now]) 113 | AX_CHECK_LINK_FLAG([-pie]) 114 | AC_LANG_POP 115 | ]) 116 | LOCAL_CHECK_FLAGS 117 | 118 | AC_CONFIG_FILES([Makefile powerpc-utils.spec systemd/smt_off.service]) 119 | AC_CONFIG_FILES([systemd/smtstate.service scripts/smtstate]) 120 | AC_CONFIG_FILES([systemd/hcn-init.service.in]) 121 | AC_OUTPUT 122 | -------------------------------------------------------------------------------- /m4/ax_append_compile_flags.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # For every FLAG1, FLAG2 it is checked whether the compiler works with the 12 | # flag. If it does, the flag is added FLAGS-VARIABLE 13 | # 14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g. 15 | # CFLAGS) is used. During the check the flag is always added to the 16 | # current language's flags. 17 | # 18 | # If EXTRA-FLAGS is defined, it is added to the current language's default 19 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with 20 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 21 | # force the compiler to issue an error when a bad flag is given. 22 | # 23 | # NOTE: This macro depends on the AX_APPEND_FLAG and 24 | # AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with 25 | # AX_APPEND_LINK_FLAGS. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2011 Maarten Bosmans 30 | # 31 | # This program is free software: you can redistribute it and/or modify it 32 | # under the terms of the GNU General Public License as published by the 33 | # Free Software Foundation, either version 3 of the License, or (at your 34 | # option) any later version. 35 | # 36 | # This program is distributed in the hope that it will be useful, but 37 | # WITHOUT ANY WARRANTY; without even the implied warranty of 38 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 39 | # Public License for more details. 40 | # 41 | # You should have received a copy of the GNU General Public License along 42 | # with this program. If not, see . 43 | # 44 | # As a special exception, the respective Autoconf Macro's copyright owner 45 | # gives unlimited permission to copy, distribute and modify the configure 46 | # scripts that are the output of Autoconf when processing the Macro. You 47 | # need not follow the terms of the GNU General Public License when using 48 | # or distributing such scripts, even though portions of the text of the 49 | # Macro appear in them. The GNU General Public License (GPL) does govern 50 | # all other use of the material that constitutes the Autoconf Macro. 51 | # 52 | # This special exception to the GPL applies to versions of the Autoconf 53 | # Macro released by the Autoconf Archive. When you make and distribute a 54 | # modified version of the Autoconf Macro, you may extend this special 55 | # exception to the GPL to apply to your modified version as well. 56 | 57 | #serial 4 58 | 59 | AC_DEFUN([AX_APPEND_COMPILE_FLAGS], 60 | [AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) 61 | AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 62 | for flag in $1; do 63 | AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3]) 64 | done 65 | ])dnl AX_APPEND_COMPILE_FLAGS 66 | -------------------------------------------------------------------------------- /m4/ax_append_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_append_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space 12 | # added in between. 13 | # 14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g. 15 | # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains 16 | # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly 17 | # FLAG. 18 | # 19 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. 20 | # 21 | # LICENSE 22 | # 23 | # Copyright (c) 2008 Guido U. Draheim 24 | # Copyright (c) 2011 Maarten Bosmans 25 | # 26 | # This program is free software: you can redistribute it and/or modify it 27 | # under the terms of the GNU General Public License as published by the 28 | # Free Software Foundation, either version 3 of the License, or (at your 29 | # option) any later version. 30 | # 31 | # This program is distributed in the hope that it will be useful, but 32 | # WITHOUT ANY WARRANTY; without even the implied warranty of 33 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 34 | # Public License for more details. 35 | # 36 | # You should have received a copy of the GNU General Public License along 37 | # with this program. If not, see . 38 | # 39 | # As a special exception, the respective Autoconf Macro's copyright owner 40 | # gives unlimited permission to copy, distribute and modify the configure 41 | # scripts that are the output of Autoconf when processing the Macro. You 42 | # need not follow the terms of the GNU General Public License when using 43 | # or distributing such scripts, even though portions of the text of the 44 | # Macro appear in them. The GNU General Public License (GPL) does govern 45 | # all other use of the material that constitutes the Autoconf Macro. 46 | # 47 | # This special exception to the GPL applies to versions of the Autoconf 48 | # Macro released by the Autoconf Archive. When you make and distribute a 49 | # modified version of the Autoconf Macro, you may extend this special 50 | # exception to the GPL to apply to your modified version as well. 51 | 52 | #serial 2 53 | 54 | AC_DEFUN([AX_APPEND_FLAG], 55 | [AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX 56 | AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl 57 | AS_VAR_SET_IF(FLAGS, 58 | [case " AS_VAR_GET(FLAGS) " in 59 | *" $1 "*) 60 | AC_RUN_LOG([: FLAGS already contains $1]) 61 | ;; 62 | *) 63 | AC_RUN_LOG([: FLAGS="$FLAGS $1"]) 64 | AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) 65 | ;; 66 | esac], 67 | [AS_VAR_SET(FLAGS,["$1"])]) 68 | AS_VAR_POPDEF([FLAGS])dnl 69 | ])dnl AX_APPEND_FLAG 70 | -------------------------------------------------------------------------------- /m4/ax_check_compile_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the current language's compiler 12 | # or gives an error. (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the current language's default 18 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with 19 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 20 | # force the compiler to issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # This program is free software: you can redistribute it and/or modify it 33 | # under the terms of the GNU General Public License as published by the 34 | # Free Software Foundation, either version 3 of the License, or (at your 35 | # option) any later version. 36 | # 37 | # This program is distributed in the hope that it will be useful, but 38 | # WITHOUT ANY WARRANTY; without even the implied warranty of 39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 40 | # Public License for more details. 41 | # 42 | # You should have received a copy of the GNU General Public License along 43 | # with this program. If not, see . 44 | # 45 | # As a special exception, the respective Autoconf Macro's copyright owner 46 | # gives unlimited permission to copy, distribute and modify the configure 47 | # scripts that are the output of Autoconf when processing the Macro. You 48 | # need not follow the terms of the GNU General Public License when using 49 | # or distributing such scripts, even though portions of the text of the 50 | # Macro appear in them. The GNU General Public License (GPL) does govern 51 | # all other use of the material that constitutes the Autoconf Macro. 52 | # 53 | # This special exception to the GPL applies to versions of the Autoconf 54 | # Macro released by the Autoconf Archive. When you make and distribute a 55 | # modified version of the Autoconf Macro, you may extend this special 56 | # exception to the GPL to apply to your modified version as well. 57 | 58 | #serial 3 59 | 60 | AC_DEFUN([AX_CHECK_COMPILE_FLAG], 61 | [AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX 62 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 63 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 64 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 65 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 66 | AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 67 | [AS_VAR_SET(CACHEVAR,[yes])], 68 | [AS_VAR_SET(CACHEVAR,[no])]) 69 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 70 | AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], 71 | [m4_default([$2], :)], 72 | [m4_default([$3], :)]) 73 | AS_VAR_POPDEF([CACHEVAR])dnl 74 | ])dnl AX_CHECK_COMPILE_FLAGS 75 | -------------------------------------------------------------------------------- /m4/ax_check_link_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the linker or gives an error. 12 | # (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags 18 | # when the check is done. The check is thus made with the flags: "LDFLAGS 19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to 20 | # issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_LINK_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # This program is free software: you can redistribute it and/or modify it 33 | # under the terms of the GNU General Public License as published by the 34 | # Free Software Foundation, either version 3 of the License, or (at your 35 | # option) any later version. 36 | # 37 | # This program is distributed in the hope that it will be useful, but 38 | # WITHOUT ANY WARRANTY; without even the implied warranty of 39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 40 | # Public License for more details. 41 | # 42 | # You should have received a copy of the GNU General Public License along 43 | # with this program. If not, see . 44 | # 45 | # As a special exception, the respective Autoconf Macro's copyright owner 46 | # gives unlimited permission to copy, distribute and modify the configure 47 | # scripts that are the output of Autoconf when processing the Macro. You 48 | # need not follow the terms of the GNU General Public License when using 49 | # or distributing such scripts, even though portions of the text of the 50 | # Macro appear in them. The GNU General Public License (GPL) does govern 51 | # all other use of the material that constitutes the Autoconf Macro. 52 | # 53 | # This special exception to the GPL applies to versions of the Autoconf 54 | # Macro released by the Autoconf Archive. When you make and distribute a 55 | # modified version of the Autoconf Macro, you may extend this special 56 | # exception to the GPL to apply to your modified version as well. 57 | 58 | #serial 3 59 | 60 | AC_DEFUN([AX_CHECK_LINK_FLAG], 61 | [AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl 62 | AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ 63 | ax_check_save_flags=$LDFLAGS 64 | LDFLAGS="$LDFLAGS $4 $1" 65 | AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 66 | [AS_VAR_SET(CACHEVAR,[yes])], 67 | [AS_VAR_SET(CACHEVAR,[no])]) 68 | LDFLAGS=$ax_check_save_flags]) 69 | AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], 70 | [m4_default([$2], :)], 71 | [m4_default([$3], :)]) 72 | AS_VAR_POPDEF([CACHEVAR])dnl 73 | ])dnl AX_CHECK_LINK_FLAGS 74 | -------------------------------------------------------------------------------- /m4/ax_require_defined.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_require_defined.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_REQUIRE_DEFINED(MACRO) 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have 12 | # been defined and thus are available for use. This avoids random issues 13 | # where a macro isn't expanded. Instead the configure script emits a 14 | # non-fatal: 15 | # 16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found 17 | # 18 | # It's like AC_REQUIRE except it doesn't expand the required macro. 19 | # 20 | # Here's an example: 21 | # 22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) 23 | # 24 | # LICENSE 25 | # 26 | # Copyright (c) 2014 Mike Frysinger 27 | # 28 | # Copying and distribution of this file, with or without modification, are 29 | # permitted in any medium without royalty provided the copyright notice 30 | # and this notice are preserved. This file is offered as-is, without any 31 | # warranty. 32 | 33 | #serial 1 34 | 35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl 36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) 37 | ])dnl AX_REQUIRE_DEFINED 38 | -------------------------------------------------------------------------------- /man/activate_firmware.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" 4 | .TH ACTIVATE_FIRMWARE 8 "May 2004" Linux "Power Service Tools" 5 | .SH NAME 6 | activate_firmware - activate a firmware image that has been updated concurrently 7 | .SH SYNOPSIS 8 | \fB/usr/sbin/activate_firmware [-e [keyfile]] 9 | .SH DESCRIPTION 10 | When used without options, the activate_firmware utility will cause a firmware 11 | image that has already been flashed to be activated concurrently. This utility 12 | will be invoked automatically when necessary, and as such should not be manually 13 | invoked at the command line. 14 | .SH OPTIONS 15 | .TP 16 | .B \-e [keyfile] 17 | When used with this option, the command either fetches the current Update Access 18 | Key expiry date or sets the Update Access Key expiry date if is 19 | provided. 20 | .SH "EXIT STATUS" 21 | .TP 22 | .B 0 23 | Success. 24 | .TP 25 | .B 1 26 | This platform does not support concurrent activation of firmware. 27 | .TP 28 | .B 2 29 | There is no new firmware ready to activate. 30 | .TP 31 | .B 3 32 | You must have root authority to run this command. 33 | .TP 34 | .B 4 35 | Hardware failure. 36 | .TP 37 | .B 5 38 | Memory/resource allocation error. 39 | .TP 40 | .B 6 41 | General error. 42 | .TP 43 | .B 7 44 | Error in case of getting UAK expiry date or setting UAK. Exact error description is written to stderr. 45 | .TP 46 | .B 8 47 | Parameter error when activating firmware. 48 | -------------------------------------------------------------------------------- /man/bootlist.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" Nathan Fontenot 4 | .\" 5 | .TH BOOTLIST 8 "May 2013" Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | bootlist - update and view the bootlist 8 | .SH SYNOPSIS 9 | .nf 10 | \fB/usr/sbin/bootlist \-m \fR{\fBnormal\fR|\fBservice\fR|\fBboth\fR}\fB -o\fR|\fB-r\fR 11 | \fB/usr/sbin/bootlist \-m \fR{\fBnormal\fR|\fBservice\fR|\fBboth\fR} [\fB-o\fR|\fB-r\fR] \fB-f \fIfile 12 | \fB/usr/sbin/bootlist \-m \fR{\fBnormal\fR|\fBservice\fR|\fBboth\fR} [\fB-o\fR|\fB-r\fR] <\fIdev_list\fR> 13 | .fi 14 | .SH DESCRIPTION 15 | The bootlist command allows users to view and update the system bootlist 16 | stored in NVRAM for PowerPC-64 machines. To update the list of boot devices 17 | one or more boot devices can be specified directly or read from a file. This 18 | list of devices may be specified as either logical device names or the 19 | full Open Firmware device path. The bootlist command uses the \fIofpathanme\fR 20 | script to convert between logical device names and Open Firmware device 21 | paths, and the \fInvram\fR command to update the stored boot list. 22 | 23 | If a list of devices is not specified, or the -o or -r options are specified, 24 | the current boot list stored in nvram is displayed. 25 | 26 | .SH OPTIONS 27 | .TP 28 | \fB\-m normal\fR|\fBservice\fR|\fBboth 29 | Required; specify whether the normal or service mode boot list should be 30 | viewed/updated. Specifying "both" will update the normal and service mode 31 | boot lists. 32 | .TP 33 | \fB\-o 34 | Display the current boot list entries as logical device names. 35 | .TP 36 | \fB\-r 37 | Display the current boot list entries as Open Firmware device path names 38 | (default). 39 | .TP 40 | \fB\-f \fIfile 41 | Read the bootlist device names from \fIfile\fR, one entry per line. 42 | .TP 43 | \fIdev_list 44 | A space-separated list of devices, specified as logical device names or OF 45 | device path names, depending on whether the \fB-o\fR or \fB-r\fR option is 46 | specified. 47 | .SH EXAMPLES 48 | .nf 49 | View the normal mode boot list as logical device names: 50 | 51 | /usr/sbin/bootlist -o -m normal 52 | 53 | Update the service mode boot list: 54 | 55 | /usr/sbin/bootlist -o -m service /dev/sda3 /dev/cdrom 56 | .fi 57 | .SH AUTHOR 58 | Written by Nathan Fontenot 59 | .SH "SEE ALSO" 60 | .BR ofpathname (8), 61 | .BR nvram (8) 62 | -------------------------------------------------------------------------------- /man/drmgr-hooks.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2022 International Business Machines 3 | .\" 4 | .TH DRMGR-HOOKS 8 "May 24, 2022" Linux "Linux on Power Service Tools" 5 | .SH NAME 6 | drmgr\-hooks \- Hooks run by drmgr 7 | .SH DESCRIPTION 8 | When 9 | .B drmgr 10 | is run to perform PowerVM Dynamic Logical Partitioning (DLPAR) operations, 11 | a set of hooks may be triggered to validate, and, or be aware of the incoming operation. 12 | .P 13 | Not all the DLPAR operations are providing hook calls. 14 | Currently only the LPAR Migration operation (LPM) is concerned. 15 | .P 16 | The hooks are executable files stored in a directory named "DRC TYPE" in 17 | .IR /etc/drmgr.d/ . 18 | For instance, hooks run when a LPAR migration is done are stored in 19 | .IR /etc/drmgr.d/pmig . 20 | .P 21 | Hook files can be symbolic links to executable files. All the hooks can be stored in 22 | .IR /etc/drmgr.d 23 | and linked into multiple directories to provide multiple DRC type's hooks. 24 | .SH ARGUMENTS 25 | .P 26 | Hooks are called without any arguments but with these environment variables set: 27 | .TP 28 | .BI "DRC_TYPE" 29 | The Dynamic reconfiguration connector type to act upon from the following list: 30 | .BR pmig ", " pci ", " cpu ", " mem ", " port ", " slot ", " phb "." 31 | .TP 32 | .BI "PHASE" 33 | The phase of the operation from the following list: 34 | .BR check ", " undocheck ", " pre ", " post "." 35 | .TP 36 | .BI "ACTION" 37 | The action in progress from the following list: 38 | .BR add ", " remove ", " migrate "." 39 | .TP 40 | .BI "DRC_COUNT" 41 | The number of impacted items. 42 | .SH LPAR MIGRATION 43 | .P 44 | When a LPAR migration is initiated the 45 | .B check 46 | phase is first triggered. Hooks called at check phase may returned a non zero value to prevent the migration operation to happen. 47 | The error messages displayed in 48 | .BR STDOUT " or " STDERR 49 | would be reported to the end user through the HMC. 50 | .P 51 | If the 52 | .B check 53 | phase has failed, because at least one hook has returned a non null value, the 54 | .B undocheck 55 | phase is launched. Return value for the 56 | .B 57 | undocheck 58 | phase is ignored. 59 | .P 60 | If the 61 | .B check 62 | phase succeeded, the 63 | .BR pre " and later " post 64 | phases are triggered. Returned values for these 2 phases are ignored, and the 65 | .B post 66 | phase is triggered even if the LPM operation has failed. 67 | .P 68 | The 69 | .B ACTION 70 | variable is set always to 71 | .B migrate 72 | .P 73 | The DRC_COUNT variable is set to 0. 74 | .SH CPU 75 | When a CPU DLPAR add or remove operation is initiated, the 76 | .B pre 77 | and then 78 | .B post 79 | phases are triggered with the 80 | .B ACTION 81 | variable set to either 82 | .B add 83 | or 84 | .B remove 85 | value. 86 | .P 87 | When the 88 | .B pre 89 | phase is called, the 90 | .B DRC_COUNT 91 | variable contains the desired number of CPU to add or remove. When the 92 | .B post 93 | phase is called, 94 | .B DRC_COUNT 95 | contains the number of CPU effectively added or removed. 96 | .P 97 | Return values for these 2 phases are ignored. 98 | .P 99 | The 100 | .B post 101 | phase is triggered even if the operation has failed. 102 | .SH ENVIRONMENT 103 | .P 104 | The drmgr's hooks are called while holding the DLPAR lock, so any other 105 | DLPAR operation initiated from a hook is expected to fail. 106 | .P 107 | The hooks standard input 108 | .B STDIN 109 | is redirected to 110 | .I /dev/null 111 | while 112 | .BR STDOUT " and " STDERR 113 | are redirected to pipes. 114 | The outputs done in these pipes are reported to the end user when a hook has returned an error value and that error value is not ignored (e.g in the LPM, the 115 | .B check 116 | phase but not the 117 | .BR pre " or " post 118 | phase) 119 | .P 120 | Except the variables specified in the ARGUMENTS section, all the environment variables are unset before calling the hook. 121 | .SH FILES 122 | .IR /etc/drmgr.d/pmig/ 123 | .P 124 | .IR /etc/drmgr.d/cpu/ 125 | .SH AUTHOR 126 | Laurent Dufour 127 | .SH SEE ALSO 128 | .BR drmgr (8) 129 | -------------------------------------------------------------------------------- /man/drmgr.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2020 International Business Machines 3 | .\" 4 | .TH DRMGR "8" "June 2020" "Linux" "Linux on Power Service Tools" 5 | .SH NAME 6 | drmgr \- Manage DLPAR resources of a virtualized ppc64 system. 7 | 8 | 9 | .SH SYNOPSIS 10 | .B drmgr 11 | .RB [ \-d 12 | .IR detail_level ] 13 | .RB [ \-w 14 | .IR minutes ] 15 | .RB [ \-C | \-\-capabilities ] 16 | .RB [ \-h | \-\-help ] 17 | 18 | .B drmgr 19 | .BR \-c " {" pci " | " cpu " | " mem " | " port " | " slot " | " phb "}" 20 | 21 | .B drmgr \-c pci \-s 22 | .I slot_location_code 23 | .RB { "\-i " | " \-a " | " \-r " | " \-R "}\ [ "\-I" ] 24 | 25 | .B drmgr \-c cpu 26 | .RB { \-a " | " \-r "} {" \-q 27 | .I quantity 28 | .RB "| " \-s 29 | .RI { drc_index " | " drc_name }} 30 | 31 | .B drmgr \-c mem 32 | .RB { \-a " | " \-r "} {" \-q 33 | .I quantity 34 | .RB "| " \-s 35 | .RI { drc_index " | " drc_name }} 36 | 37 | .B drmgr \-c 38 | .RB { port " | " slot " | " phb } 39 | .RB { \-a " | " \-r "} " \-s 40 | .RI { drc_index " | " drc_name } 41 | 42 | 43 | .SH DESCRIPTION 44 | .B drmgr 45 | is a utility for managing logical and physical hot plug capable resources of a PowerVM LPAR or QEMU/KVM pSeries virtual machine via Dynamic Logical Partitioning (DLPAR) operations. Outside of hot plugging a physical PCI I/O slot the 46 | .B drmgr 47 | utility is intended to be invoked remotely by a Hardware Management Console (HMC), or by a local monitoring daemon in response to a hotplug interrupt from the controlling hypervisor. 48 | 49 | .PP 50 | Unless directed by IBM support or performing a PCI hotplug operation use caution invoking \fBdrmgr\fR from the commandline as it can result in inconsistent state between the LPAR and management system. 51 | 52 | 53 | .SH OPTIONS 54 | .TP 55 | .BI \-d " detail_level" 56 | Set logging verbosity level. 57 | 58 | .TP 59 | .BI \-w " timeout" 60 | Specify a timeout in minutes to wait on acquiring dynamic resource lock. 61 | 62 | .TP 63 | .B \-C, \-\-capabilities 64 | Display DLPAR capabilities of the logical partition. 65 | 66 | .TP 67 | .BI \-c " drc_type" 68 | Dynamic reconfiguration connector type to act upon from the following list: 69 | .BR pci ", " cpu ", " mem ", " port ", " slot ", " phb "." 70 | 71 | .SS "drmgr -c pci -s \fIslot_location_code\fR {\fB\-i\fR | \fB\-a\fR | \fB\-r\fR | \fB\-R\fR} [\fB\-I\fR]" 72 | Add, remove, identify, or replace a physical PCI adapter. 73 | 74 | .TP 75 | .BI \-s " slot_location_code" 76 | The physical slot location code to act upon. 77 | 78 | .TP 79 | .B \-i 80 | Identify the specified \fIslot_location_code\fR by turning on its visual indicator LED. 81 | 82 | .TP 83 | .B \-R 84 | Interactively replace the physical PCI adapter, with \fIslot_location_code\fR, by turning on the visual indicator LED to locate the physical slot, then powering down the slot so that the current card can be removed, and finally powering the slot back up after the new adapter has been inserted into the slot. 85 | 86 | .TP 87 | .B \-r 88 | Interactively remove a physical PCI adapter, from \fIslot_location_code\fR, by turning on the visual indicator LED to locate the physical slot, and then powering down the slot so that the current card can be removed. 89 | 90 | .TP 91 | .B \-a 92 | Interactively add a physical PCI adapter, to \fIslot_location_code\fR, by turning on the visual indicator LED to locate the physical slot, and then powering up the slot once the new adapter has been inserted into the slot. 93 | 94 | .TP 95 | .B \-I 96 | Do not perform the identify step during interactive add, remove, or replacement operations. 97 | 98 | 99 | .SS "drmgr -c cpu \fR{\fB-s \fR{\fIdrc_index\fR | \fIdrc_name\fR} | \fB-q \fIcount\fR} {\fB-a\fR | \fB-r\fR}" 100 | Add or remove logical cpus from the system. 101 | 102 | .TP 103 | .BI \-s " drc_index " | " drc_name" 104 | The dynamic reconfiguration connector (DRC) index or name is used to identify one specific CPU on which to perform the requested DLPAR operation. 105 | 106 | .TP 107 | .BI \-q " quantity" 108 | Specify a quantity of CPUs on which to perform the requested DLPAR operation. 109 | 110 | .TP 111 | .B \-a 112 | Perform a DLPAR CPU(s) add operation. 113 | 114 | .TP 115 | .B \-r 116 | Perform a DLPAR CPU(s) remove operation. 117 | 118 | 119 | .SS "drmgr -c mem \fR{\fB-s \fR{\fIdrc_index\fR | \fIdrc_name\fR} | \fB-q \fIcount\fR} {\fB-a\fR | \fB-r\fR}" 120 | Add or remove logical memory blocks (LMBs) from the system. 121 | 122 | .TP 123 | .BI \-s " drc_index " | " drc_name" 124 | The dynamic reconfiguration connector (DRC) index or name is used to identify one specific logical memory block (LMB) on which to perform the requested DLPAR operation. 125 | 126 | .TP 127 | .BI \-q " quantity" 128 | Specify a quantity of LMBs on which to perform the requested DLPAR operation. 129 | 130 | .TP 131 | .B \-a 132 | Perform a DLPAR LMB(s) add operation. 133 | 134 | .TP 135 | .B \-r 136 | Perform a DLPAR LMB(s) remove operation. 137 | 138 | 139 | .SS "drmgr -c \fR{\fBport \fR|\fB slot \fR|\fB phb\fR} {\fB-a \fR|\fB -r\fR} \fB-s \fR{\fIdrc_index \fR|\fI drc_name\fr}" 140 | Add or remove a logical IOA resource such as virtualized storage and network adapters, or a logical PCI Host Bus that physical PCI devices reside under including hotpluggable slots. 141 | 142 | .TP 143 | .BI \-s " drc_index " | " drc_name" 144 | The dynamic reconfiguration connector (DRC) index or name is used to identify the logical resource on which to perform the associated DLPAR operation. 145 | 146 | .TP 147 | .B \-a 148 | Perform a DLPAR add operation of the specified logical resource type. 149 | 150 | .TP 151 | .B \-r 152 | Perform a DLPAR remove operation of the specified logical resource type. 153 | 154 | .SH AUTHOR 155 | .B drmgr 156 | was written by IBM Corporation 157 | 158 | 159 | .SH SEE ALSO 160 | .BR lsslot "(8)" 161 | .BR drmgr-hooks "(8)" 162 | -------------------------------------------------------------------------------- /man/hvcsadmin.8: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2005 International Business Machines. 2 | .\" Common Public License Version 1.0 (see COPYRIGHT) 3 | .\" 4 | .\" Author(s) 5 | .\" Ryan S. Arnold 6 | .\" Original version: January 14, 2005. 7 | .\" 8 | .Dd January 18, 2005 9 | .Os LINUX 10 | .Dt HVCSADMIN 8 11 | .Sh NAME 12 | .Nm hvcsadmin 13 | .Nd hypervisor virtual console server administration utility 14 | .Sh SYNOPSIS 15 | .Nm Fl all Op Fl noisy 16 | .Op Fl noisy 17 | .Pp 18 | .Nm Fl close Ar hvcs Op Fl noisy 19 | .Op Fl noisy 20 | .Pp 21 | .Nm Fl console Ar partition Op Fl noisy 22 | .Op Fl noisy 23 | .Pp 24 | .Nm Fl help 25 | .Pp 26 | .Nm Fl node Ar hvcs Op Fl noisy 27 | .Op Fl noisy 28 | .Pp 29 | .Nm Fl rescan Op Fl noisy 30 | .Op Fl noisy 31 | .Pp 32 | .Nm Fl status Op Fl noisy 33 | .Op Fl noisy 34 | .Pp 35 | .Nm Fl version 36 | .Pp 37 | .Sh DESCRIPTION 38 | This is the IBM hypervisor virtual console server 39 | .Pq \fBhvcs\fR 40 | administration utility. 41 | .Sh OPTIONS 42 | .Bl -tag -width -indent 43 | .It Fl all 44 | Close all open vty-server adapter connections. 45 | .Pp 46 | Inclusion of a single 47 | .Sq Fl noisy 48 | flag will direct the utility to output a list of all the adapters that were 49 | closed. 50 | .It Fl close Ar hvcs 51 | Close the vty-server adapter connection that maps to the hvcs device node 52 | specified in the option. 53 | .Pp 54 | By default this operation only exhibits output on error. It is silent on 55 | success and silent if the adapter is already closed. When accompanied by a 56 | .Sq Fl noisy 57 | flag this option will output the device to adapter mapping and a message 58 | indicating that the adapter has been closed. 59 | .It Fl console Ar partition 60 | Which /dev/hvcs node provides the console for the option specified 61 | partition? This option takes a partition number and returns a status string 62 | which contains the device node that maps to the target partition's slot zero 63 | vty-server adapter [A console adapter is always in slot zero]. 64 | .Pp 65 | Inclusion of a single 66 | .Sq Fl noisy 67 | flag does not change the default output of this option. 68 | .It Fl help 69 | Output the utility help text. 70 | .It Fl node Ar hvcs 71 | Which vty-server adapter is mapped to the option specified /dev/hvcs 72 | node? This option takes a device node and returns a status string which 73 | contains the vty-server adapter mapped to that node. 74 | .Pp 75 | Inclusion of a single 76 | .Sq Fl noisy 77 | flag does not change the default output of this option. 78 | .It Fl noisy 79 | This directive is optional. Without a 80 | .Sq Fl noisy 81 | directive the hvcsadmin utility is in \fBsilent\fR mode by default (except in 82 | the case of errors and output requests). The output verbosity of the utility 83 | is managed by stacking 84 | .Sq Fl noisy 85 | directives. A single instance of 86 | .Sq Fl noisy 87 | indicates that the utility should output in \fBstatus\fR mode. A second 88 | instance of 89 | .Sq Fl noisy 90 | indicates that the utility should output in \fBverbose\fR mode. Verbose mode 91 | is generally used for script tracing and won't be used by a casual user unless 92 | problems arise. 93 | .It Fl rescan 94 | Direct the hvcs driver to rescan partner information for all vty-server 95 | adapters it manages. This may expose additional adapters and partners. 96 | .It Fl status 97 | Outputs a table with each row containing a vty-server, adapter, its 98 | /dev/hvcs device node mapping, and the adapter connection status. 99 | "vterm_state:0" means it is free/disconnected and "vterm_state:0" means the 100 | vty-server is connected to its vty partner adapter. 101 | .Pp 102 | An example of \fBhvcsadmin -status\fR output follows: 103 | .Pp 104 | .Bd -literal 105 | \fBvty-server@30000003 partition:1 slot:2 /dev/hvcs0 vterm-state:0 106 | vty-server@30000004 partition:15 slot:0 /dev/hvcs1 vterm-state:0\fR 107 | .Ed 108 | .Pp 109 | When this option is accompanied by a 110 | .Sq Fl noisy 111 | flag it will output a line for each hvcs device node which doesn't have a 112 | current vty-server adapter mapping as well as the status demonstrated above. 113 | .It Fl version 114 | Out the hvcsadmin script's version number. 115 | .El 116 | .Sh AUTHOR(S) 117 | .An Ryan S. Arnold Aq rsa@us.ibm.com 118 | 119 | -------------------------------------------------------------------------------- /man/lparnumascore.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2021 International Business Machines 3 | .\" Laurent Dufour 4 | .\" 5 | .TH LPARNUMASCORE 8 2021-04-14 Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | lparnumascore \- display the NUMA affinity score for the running LPAR 8 | .SH SYNOPSIS 9 | .BI "lparnumascore [-c | -d ]" 10 | .SH DESCRIPTION 11 | The 12 | .B lparnumascore 13 | command can be used to display the NUMA affinity score for the running 14 | LPAR. Each score reflect the amount of resources the Linux kernel is seeing as 15 | bound to a node while the hypervisor has moved that resource to another node. 16 | 17 | The score is a number between 0 and 100. A score of 100 means that all the 18 | resources are seen correctly, while a score of 0 means that all the resources 19 | have been moved to different nodes. There is a dedicated score for 20 | each resource type. 21 | .SH OPTIONS 22 | .TP 23 | .B \-c 24 | Display the score for this type of resources. The valid resource types are 25 | "mem" for memory, and "cpu" for cpu's. By default, the score for each of 26 | supported resources is reported. 27 | .TP 28 | .B \-d 29 | Enable debugging output. When displaying memory information this flag will 30 | also enable printing information about LMBs not currently owned by the system. 31 | .SH AUTHOR 32 | Laurent Dufour -------------------------------------------------------------------------------- /man/lsslot.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2011 International Business Machines 3 | .\" Brian King 4 | .\" 5 | .TH LSSLOT 8 "December 2011" Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | lsslot \- display hot plug capable slots and resources 8 | .SH SYNOPSIS 9 | .BI "lsslot [-c | -a | -b | -p | -o | -s | -F | -d | -w]" 10 | .SH DESCRIPTION 11 | The 12 | .B lsslot 13 | command can be used to display hot plug capable I/O slots, CPUs and caches. 14 | Please note that this command does not display all I/O slots, only slots 15 | which are physically capable of hot plug. Slots which are capable of DLPAR 16 | but not hot plug capable will not be listed. 17 | .SH OPTIONS 18 | .TP 19 | .B \-c 20 | Display the slots of the specified connector type. The valid 21 | connector types are "pci" for hotplug PCI slots, "slot" for 22 | logical slots, "phb" for PHB's, "port" for LHEA ports, "mem" 23 | for memory, and "cpu" for cpu's. The default is "slot" if 24 | no -c option is specified. 25 | .TP 26 | .B \-a 27 | Display available slots, valid for "pci" slots only. 28 | .TP 29 | .B \-b 30 | Display cpu's and caches, valid for "cpu" only. 31 | .TP 32 | .B \-o 33 | Display occupied slots, valid for "pci" slots only. 34 | .TP 35 | .B \-p 36 | Display caches, valid for "cpu" slots only. 37 | .TP 38 | .B \-s [ | ] 39 | Display characteristics of the specified slot or the LMB with the specified 40 | drc index. 41 | .TP 42 | .B \-F 43 | Specified a single character to delimit the output. The 44 | heading is not displayed and the columns are delimited by the 45 | specified character. 46 | .TP 47 | .B \-d 48 | Enable debugging output. When displaying memory information this flag will 49 | also enable printing information about LMBs not currently owned by the system. 50 | .TP 51 | .B \-w 52 | Specify a timeout when attempting to acquire locks. 53 | .SH AUTHOR 54 | Brian King 55 | -------------------------------------------------------------------------------- /man/nvram.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2002 - 2004 International Business Machines 3 | .\" 4 | .TH NVRAM 8 "May 2004" Linux "Linux on Power Service Tools" 5 | .SH NAME 6 | nvram \- format data stored in non-volatile RAM 7 | .SH SYNOPSIS 8 | .B /usr/sbin/nvram 9 | [ options ] 10 | .SH DESCRIPTION 11 | .I Nvram 12 | is used to print and modify data stored in the non-volatile RAM (NVRAM) 13 | on a PowerPC-64 system. NVRAM on these systems is partitioned into data 14 | sections that each have their own format. The print options to this 15 | command selects what to print and how to format it. 16 | 17 | .P 18 | The 19 | .I nvram 20 | utility can also be used to update the data in certain NVRAM partitions of 21 | PowerPC-64 systems. 22 | .I Nvram 23 | can update the value of a name/value pair for NVRAM partitions formatted 24 | as a set of name=value pairs. On many systems, the following NVRAM 25 | partitions contain data formatted as name=value pairs: common, of-config, 26 | and ibm,setupcfg. 27 | .SH OPTIONS 28 | .TP 29 | \fB\--print-config\fR[=\fIvar\fR] 30 | print value of a config variable, or print all variables in the specified 31 | (or all) partitions. 32 | .TP 33 | \fB\--update-config \fIname\fR=\fIvalue 34 | update the config variable in the specified partition; the -p option 35 | must also be specified.. 36 | .TP 37 | \fB\-p \fIpartition 38 | specify a partition; required with the --update-config option, optional 39 | with the --print-config option. 40 | .TP 41 | \fB\--print-vpd 42 | print vital product data (VPD) collected by the system in NVRAM. 43 | This data may also be viewed with the lscfg(1) command directly from the 44 | devices. 45 | .TP 46 | \fB\--print-all-vpd 47 | print viral product data (VPD) collected by the system in NVRAM including 48 | vendor specific data. 49 | .TP 50 | \fB\--print-err-log 51 | print the checkstop error log generated by the service processor whenever 52 | the system checkstops. 53 | .TP 54 | \fB\--print-event-scan 55 | print the event scan log stored in NVRAM. 56 | .TP 57 | \fB\--partitions 58 | print the contents of all the NVRAM partition headers. 59 | .TP 60 | \fB\--nvram-file \fIpath 61 | read nvram data from a given file rather than /dev/nvram. To capture NVRAM 62 | for later use, simply copy /dev/nvram into a file. 63 | .TP 64 | \fB\--verbose \fR(\fB-v\fR) 65 | be more verbose. 66 | .TP 67 | \fB\--help 68 | print usage information including other low level options useful for 69 | debugging nvram. 70 | .TP 71 | \fB\--ascii \fIname 72 | print partition contents as ASCII text 73 | .TP 74 | \fB\--dump \fIname 75 | raw dump of partition (use --partitions to see names) 76 | .TP 77 | \fB\--nvram-size 78 | specify size of nvram data, must in multiples of 16 Bytes (for repair 79 | operations) 80 | .TP 81 | \fB\--unzip \fIname 82 | decompress and print compressed data from partition 83 | .TP 84 | \fB\--zero | 0 \fR 85 | terminate config pairs with a NULL character 86 | .SH FILES 87 | /dev/nvram 88 | .SH AUTHOR 89 | Writtem by Todd Inglett, Nathan Fontenot, and Michael Strosaker 90 | -------------------------------------------------------------------------------- /man/ofpathname.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" Nathan Fontenot 4 | .\" 5 | .TH OFPATHNAME 8 "April 2004" Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | ofpathname \- translate between Open Firmware and logical device names 8 | .SH SYNOPSIS 9 | \fB/usr/sbin/ofpathname \fR[\fB-laqVh\fR] \fIname 10 | .SH DESCRIPTION 11 | .I Ofpathname 12 | provides the ability to translate logical device names to their Open Firmware 13 | device path names for PowerPC-64 systems. It can also translate an Open 14 | Firmware device path to its logical device name using the -l option. 15 | .SH OPTIONS 16 | .TP 17 | \fB\-l 18 | Translate the \fIname \fRparameter to the corresponding logical device name. 19 | .TP 20 | \fB\-a 21 | Find a matching Open Firmware device alias[es]. 22 | .TP 23 | \fB\--quiet \fR(\fB\-q\fR) 24 | Do not report any failures, exit quietly. 25 | .TP 26 | \fB\--version \fR(\fB\-V\fR) 27 | Display version information and exit. 28 | .TP 29 | \fB\--help \fR(\fB\-h\fR) 30 | print usage information. 31 | .SH AUTHOR 32 | Written by Nathan Fontenot 33 | .SH "SEE ALSO" 34 | .BR bootlist (8), 35 | .BR nvram (8) 36 | 37 | -------------------------------------------------------------------------------- /man/ppc64_cpu.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2015 International Business Machines 3 | .\" 4 | .TH PPC64_CPU 8 "January 2015" Linux "Linux on Power Service Tools" 5 | .SH NAME 6 | ppc64_cpu \- Display cpu characteristics of PowerPC systems 7 | .SH SYNOPSIS 8 | .B /usr/sbin/ppc64_cpu 9 | [ command ] [ options ] 10 | .SH DESCRIPTION 11 | The 12 | .I ppc64_cpu 13 | command is used to display and set cpu characteristics on PowerPC 14 | platforms. 15 | 16 | .SH OPTIONS 17 | .TP 18 | \fB\-\-smt\fR [-n] 19 | Display the current smt setting for the system. The output will state 20 | whether smt is off indicating there is only one thread per core online, smt 21 | is on indicating that all threads of every core is online, the smt is in 22 | a mixed state indicating that the number of threads online varies per core, or 23 | \fISMT=X\fR indicating a specific smt state. 24 | 25 | Option -n dumps a numeric output instead of a verbose output. 26 | 27 | .TP 28 | \fB\-\-smt\fR={\fIon\fR|\fIoff\fR} 29 | Set the current smt state for the system to either \fIon\fR, which will online 30 | every thread in every core on the system, or \fIoff\fR which will leave each 31 | core on the system with only one thread online. 32 | 33 | .TP 34 | \fB\-\-smt\fR=\fIvalue\fR 35 | Set the smt state for each core to the specified \fIvalue\fR. 36 | 37 | .TP 38 | \fB\-\-cores\-present\fR 39 | Display the number of cores present. 40 | 41 | .TP 42 | \fB\-\-cores\-on\fR 43 | Display the number of cores online. 44 | 45 | .TP 46 | \fB\-\-cores\-on\fR=\fIvalue\fR 47 | Put exactly \fIvalue\fR number of cores online. Note that this will either 48 | online or offline cores to achieve the desired result. 49 | 50 | .TP 51 | \fB\-\-dscr\fR 52 | Display the current Data Stream Control Register (DSCR) setting for the system. 53 | 54 | .TP 55 | \fB\-\-dscr\fR=\fIvalue\fR 56 | Set the DSCR setting for the system to \fIvalue\fr. 57 | 58 | .TP 59 | \fB\-\-dscr\fR [\fIpid\fR] 60 | Display the DSCR setting for process \fIpid\fR. 61 | 62 | .TP 63 | \fB\-\-dscr\fR=\fIvalue\fR [\fIpid\fR] 64 | Set the DSCR to the specified \fIvalue\fR for process \fIpid\fR. 65 | 66 | .TP 67 | \fB\-\-run-mode\fR 68 | Display the current diagnostics run mode. 69 | 70 | .TP 71 | \fB\-\-run\-mode\fR=\fIvalue\fR 72 | Set the current diagnostics run mode to \fIvalue\fR. 73 | 74 | .TP 75 | \fB\-\-frequency\fR [\-t \fItime\fR] 76 | Determine the cpu frequency. The default sampling period is one second unless 77 | a time is specified with the \fB\-t \fItime\fR option. 78 | 79 | .TP 80 | \fB\-\-subcores\-per\-core\fR 81 | Display the number of subcores per core. 82 | 83 | .TP 84 | \fB\-\-subcores\-per\-core\fR=\fIvalue\fR 85 | Set the number of subcores per core to \fIvalue\fR. 86 | 87 | .TP 88 | \fB\-\-threads\-per\-core\fR 89 | Display the number of threads per core. 90 | 91 | .TP 92 | \fB\-\-info\fR 93 | Display system state information. The output will print a line for each core 94 | and possible sub\-core along with the thread numbers for each thread in the 95 | core with an asterick next to it if the thread is online. 96 | 97 | .TP 98 | \fB\-\-version\fR 99 | Print the version number. 100 | 101 | .SH AUTHOR 102 | Written by Anton Blanchard and Nathan Fontenot 103 | -------------------------------------------------------------------------------- /man/rtas_dbg.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2015 International Business Machines 3 | .\" 4 | .TH RTAS_DBG 8 "September 2015" Linux "Linux on Power Service Tools" 5 | .SH NAME 6 | rtas_dbg \- enable debug output for a particular rtas call 7 | .SH SYNOPSIS 8 | .B /usr/local/sbin/rtas_dbg 9 | -l | \fIfunction\fR | \fItoken\fR 10 | 11 | .SH DESCRIPTION 12 | The \fIrtas_dbg\fR tool enables RTAS debug output for a particular RTAS call. 13 | Users can either supply the -l option to list the available functions or 14 | supply the function name or token value to enable RTAS debug output for that 15 | function. Currently, this tool is only supported on PowerVM systems. 16 | .SH OPTIONS 17 | .TP 18 | \fB\-l\fR 19 | list the rtas calls available to display debug output 20 | -------------------------------------------------------------------------------- /man/rtas_dump.8: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2005 International Business Machines. 2 | .\" Common Public License Version 1.0 (see COPYRIGHT) 3 | .\" 4 | .\" Author(s) 5 | .\" Nathan Fontenot 6 | .\" 7 | .TH RTAS_DUMP 8 "May 2005" Linux "Linux on Power Service Tools" 8 | .SH NAME 9 | rtas_dump \- dump the contents of an RTAS event. 10 | .SH SYNOPSIS 11 | .B /usr/sbin/rtas_dump 12 | [ options ] 13 | .SH DESCRIPTION 14 | The \fIrtas_dump\fR icommand is used to dump the contents of an RTAS event 15 | into a human readable form. The tool is able to parse the contents of 16 | /var/log/messages, /var/log/platform and /var/log/boot.msg to extract dump 17 | the contents of RTAS events. RTAS events can also be read in from a specified 18 | file or stdin. The real work of de-coding RTAS events is handled by 19 | \fI/usr/sbin/rtas_event_decode\fR, the rtas_dump command simply parses the 20 | input and files and passes on the data to \fIrtas_event_decode\fR. 21 | .SH OPTIONS 22 | .TP 23 | \fB\-d\fR 24 | debug flag, passed through to rtas_event_decode 25 | .TP 26 | \fB\-f\fI file\fR 27 | dump the RTAS event(s) from \fIfile\fR 28 | .TP 29 | \fB\-h\fI 30 | print the usage message and exit 31 | .TP 32 | \fB\-n\fI num\fR 33 | Only dump RTAS event number \fInum\fR 34 | .TP 35 | \fB\-v\fR 36 | dump the entire contents of the RTAS event(s), not just the header 37 | .TP 38 | \fB\-w\fR 39 | set the output character width 40 | .SH AUTHOR 41 | Nathan Fontenot 42 | -------------------------------------------------------------------------------- /man/rtas_ibm_get_vpd.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" Michael Strosaker 4 | .\" 5 | .TH RTAS_IBM_GET_VPD 8 "May 2004" Linux "Power Service Tools" 6 | .SH NAME 7 | rtas_ibm_get_vpd \- retrieve dynamically changing Vital Product Data 8 | .SH SYNOPSIS 9 | .nf 10 | \fB/usr/sbin/rtas_ibm_get_vpd \-h 11 | \fB/usr/sbin/rtas_ibm_get_vpd \fR[\fB\-l \fIlocation_code\fR] 12 | .fi 13 | .SH DESCRIPTION 14 | .P 15 | The 16 | .I rtas_ibm_get_vpd 17 | utility is a utility to assist inventory retrieval applications by gathering dynamically changing vital product data on IBM ppc64 systems. The output of this utility is formatted to be parsed by other applications; as such, it is not intended for general command-line usage, though there is no reason that it should not be used in that manner. 18 | .SH OPTIONS 19 | .TP 20 | .B \-l \fIlocation_code 21 | Specify the location code of the device from which dynamic VPD should be gathered. If this option is not specified, dynamic VPD for all appropriate devices will be gathered. 22 | .TP 23 | .B \-h 24 | Print a usage message. 25 | .SH EXIT STATUS 26 | .TP 27 | .B 0 28 | Success. 29 | .TP 30 | .B 1 31 | Usage or parameter error. 32 | .TP 33 | .B 2 34 | Hardware error. 35 | .TP 36 | .B 3 37 | The library used to invoke firmware routines, librtas, has experienced an error. 38 | .TP 39 | .B 4 40 | The necessary firmware routine is not available on this system. 41 | .TP 42 | .B 5 43 | Out of memory. 44 | 45 | .SH "SEE ALSO" 46 | .BR lsvpd (8), 47 | .BR lscfg (8) 48 | -------------------------------------------------------------------------------- /man/serv_config.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" Michael Strosaker 4 | .\" 5 | .TH SERV_CONFIG 8 "May 2004" Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | serv_config \- view and configure system service policies and settings on IBM ppc64 platforms 8 | .SH SYNOPSIS 9 | .nf 10 | \fB/usr/sbin/serv_config \fR[\fB-b\fR] [\fB-s\fR] [\fB-r\fR] [\fB-m\fR] 11 | \fB/usr/sbin/serv_config -l 12 | \fB/usr/sbin/serv_config -z \fIfilename 13 | \fB/usr/sbin/serv_config -e \fIvar\fR[\fB=\fIvalue\fR] 14 | \fB/usr/sbin/serv_config \fR[\fB--surveillance\fR[\fB=\fIsettings\fR]] 15 | \fR[\fB--reboot-policy\fR[\fB=\fIsettings\fR]] 16 | \fR[\fB--ring-indicate\fR[\fB=\fIsettings\fR]] 17 | \fR[\fB--remote-maint\fR[\fB=\fIsettings\fR]] 18 | \fR[\fB--force\fR] 19 | .fi 20 | .SH DESCRIPTION 21 | .P 22 | The 23 | .I serv_config 24 | utility is used to view and manipulate various system service policies and 25 | settings on PAPR-compliant PowerPC-64 machines, such as IBM pSeries, iSeries, 26 | System p or System i machines. 27 | .P 28 | .I serv_config 29 | can be run in one of two modes; interactive mode, in which the user will be 30 | prompted for the value of each variable in the specified category, or macro 31 | mode, in which the string provided on the command line will be parsed for the 32 | values of the variables in the category. Macro mode is for expert use only; 33 | most users should be utilizing the interactive options (\fB\-s\fR, \fB\-b\fR, 34 | \fB\-r\fR, and \fB\-m\fR). 35 | .P 36 | .B NOTE: 37 | It is recommended that the current service settings are backed up with the 38 | \fB\-l\fR option before the settings are manipulated with this utility. 39 | Should a value be mistakenly updated to an incorrect value, all the settings 40 | can be restored to the backed up values with the \fB\-z\fR option. 41 | 42 | .SH OPTIONS 43 | .TP 44 | .B \-l 45 | List all of the current service settings. If this output is stored to a file, 46 | these settings can be later restored with the \fB\-z\fR option. 47 | .TP 48 | \fB\-e \fIvar\fR[\fB=\fIvalue\fR] 49 | If only \fIvar\fR is specified, the value of the specified service 50 | setting is displayed; if a \fIvalue\fR is also specified, the value 51 | of the specified service setting is updated to the specified value. 52 | .TP 53 | .B \-s 54 | Interactively update the Surveillance settings. 55 | .TP 56 | .B \-b 57 | Interactively update the Reboot policies. 58 | .TP 59 | .B \-r 60 | Interactively update the Remote Power-On settings (either Ring Indicate 61 | Power-On or Wake On LAN). 62 | .TP 63 | .B \-m 64 | Interactively update the Remote Maintenance settings. 65 | .TP 66 | .B \-z \fIfilename 67 | Restore the service settings that were previously stored to \fIfilename\fR 68 | (using the \fB\-a\fR option). 69 | 70 | .SH ADVANCED OPTIONS 71 | .P 72 | The following options are for expert users only. They are intended to be 73 | used by scripts and utilities which have been designed to automate the 74 | retrieval/manipulation of service settings. 75 | .TP 76 | \fB\-\-surveillance\fR[\fB=\fIsettings\fR] 77 | View or update the Surveillance settings in macro mode. 78 | If the \fIsettings\fR argument is not specified, all of the Surveillance 79 | variables are printed along with their corresponding values. If the 80 | \fIsettings\fR argument is specified, the Surveillance settings are updated 81 | to the specified values. The \fIsettings\fR argument should be in the 82 | following format: 83 | .nf 84 | \fIsp-sen\fB,\fIsp-sti\fB,\fIsp-del\fB,\fIimmediate 85 | .fi 86 | .TP 87 | \fB\-\-reboot\-policy\fR[\fB=\fIsettings\fR] 88 | View or update the Reboot policies in macro mode. 89 | If the \fIsettings\fR argument is not specified, all of the Reboot policy 90 | variables are printed along with their corresponding values. If the 91 | \fIsettings\fR argument is specified, the Reboot policies are updated 92 | to the specified values. The \fIsettings\fR argument should be in the 93 | following format on legacy systems: 94 | .nf 95 | \fIsp-bootrt-limit\fB,\fIsp-os-plt-reboot\fB,\fIsp-plt-reboot\fB, 96 | \fIsp-dookc\fB,\fIsp-ac-reboot\fR 97 | On recent systems, the following format is used: 98 | \fIpartition_auto_restart\fB,\fIplatform_auto_power_restart 99 | .fi 100 | .TP 101 | \fB\-\-remote\-pon\fR[\fB=\fIsettings\fR] 102 | View or update the Remote Power-On settings in macro mode. 103 | If the \fIsettings\fR argument is not specified, all of the Remote 104 | Power-On variables are printed along with their corresponding values. If the 105 | \fIsettings\fR argument is specified, the Remote Power-On settings are 106 | updated to the specified values. The \fIsettings\fR argument should be in the 107 | following format for systems with support for Ring Indicate Power-On: 108 | .nf 109 | \fIsp-ri-pon\fB,\fIsp-rb4-pon\fR 110 | On systems with support for Wake On LAN, the format 111 | is as follows: 112 | \fIsp-remote-pon 113 | .fi 114 | .TP 115 | \fB\-\-remote\-maint\fR[\fB=\fIsettings\fR] 116 | View or update the Remote Maintenance settings in macro mode. 117 | If the \fIsettings\fR argument is not specified, all of the Remote Maintenance 118 | variables are printed along with their corresponding values. If the 119 | \fIsettings\fR argument is specified, the Remote Maintenance settings are 120 | updated to the specified values. 121 | .TP 122 | .B \-\-force 123 | Do not prompt for confirmation before modifying system settings; only valid 124 | in macro mode (ignored in interactive mode). 125 | 126 | .SH "SEE ALSO" 127 | .BR bootlist (8), 128 | .BR lscfg (8), 129 | .BR nvram (8) 130 | -------------------------------------------------------------------------------- /man/set_poweron_time.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" Michael Strosaker 4 | .\" 5 | .TH SET_POWERON_TIME 8 "May 2004" Linux "Power Service Tools" 6 | .SH NAME 7 | set_poweron_time \- set a time in the future for the system to be powered on 8 | .SH SYNOPSIS 9 | .nf 10 | \fB/usr/sbin/set_poweron_time \fR[\fB-s\fR] \fB-t \fIabsolute_time 11 | \fB/usr/sbin/set_poweron_time \fR[\fB-s\fR] \fB-d \fIdelta_time 12 | .B /usr/sbin/set_poweron_time -m 13 | .B /usr/sbin/set_poweron_time -h 14 | .fi 15 | .SH DESCRIPTION 16 | .P 17 | The 18 | .I set_poweron_time 19 | utility is used to set a time in the future to power on the system. The utility uses firmware interfaces provided by IBM ppc64 systems to provide this functionality. 20 | .P 21 | When used with the 22 | .B -t 23 | option, the utility will configure the system to power-on at the specified date and time. This is usefule for specifying that the sysetm should be restarted at 6 AM on Monday morning, for example. 24 | 25 | When used with the 26 | .B -d 27 | option, the utility will treat the specified time as a delta from the present. This is useful for specifying that the system should be restarted in 2 days, for example. 28 | 29 | Times for the 30 | .B -t 31 | and 32 | .B -d 33 | options should be specified in the following format: 34 | .P 35 | \fBY\fR\fBM\fR\fBD\fR\fBh\fR\fBm\fR\fBs\fR 36 | .P 37 | The month, if specified, should be in the range of 1-12. 38 | The day, if specified, should be in the range of 1-31. 39 | The hour, if specified, should be in the range of 0-23. 40 | The minute and second, if specified, should be in the range of 0-59. 41 | .TP 42 | For the -t option: 43 | Year, month, and day default to the current date if not specified. 44 | Hour, minute, and second default to 0 if not specified. 45 | .TP 46 | For the -d option: 47 | Year, month, day, hour, minute, and second default to 0 if not specified. 48 | 49 | .P 50 | When used with the 51 | .B -m 52 | option, the utility will print the maximum amount of time in the future that the power-on time can be set (in days). This option cannot be used with any others. 53 | 54 | When used with the 55 | .B -s 56 | option, the utility will shut down the system with 57 | .B shutdown -h now 58 | after the power-on time has been set. If the utility is unable to set the power-on time for any reason, the system will not be shut down. 59 | 60 | .SH OPTIONS 61 | .TP 62 | \fB\-t \fIabsolute_time 63 | specify the power-on time 64 | .TP 65 | \fB\-d \fIdelta_time 66 | specify the power-on time as a delta from the current time 67 | .TP 68 | .B \-m 69 | print the maximum amount of time in the future that the power-on time can be set (in days) 70 | .TP 71 | .B \-s 72 | shut down the system after setting the power-on time. The system will not be shut down if the power-on time cannot be set for any reason. 73 | .TP 74 | .B \-h 75 | print a usage message with examples 76 | 77 | .SH EXAMPLES 78 | .nf 79 | Shut down the system and schedule it to restart in 12 hours 80 | and 10 minutes: 81 | 82 | set_poweron_time -d h12m10 -s 83 | 84 | Schedule the system to restart at noon on June 15th of this 85 | year: 86 | 87 | set_poweron_time -t M6D15h12 88 | .fi 89 | 90 | -------------------------------------------------------------------------------- /man/smtstate.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2020 International Business Machines 3 | .\" 4 | .TH SMTSTATE 8 "January 2020" Linux "Linux on Power Service Tools" 5 | .SH NAME 6 | smtstate \- Save and restore the current SMT state 7 | .SH SYNOPSIS 8 | .B /usr/sbin/smtstate [ option ] 9 | .SH DESCRIPTION 10 | The 11 | .I smtstate 12 | script is used to persist the current SMT state and to restore it at a convenient time. The idea behind it is to use the script together with a systemd service to save SMT state at any shutdown event and to restore it at an early stage of the boot process. Such implementation creates a way to persist the SMT state across reboots, without requiring any other configuration from system administrators. 13 | 14 | .SH OPTIONS 15 | .TP 16 | \fB\-\-save\fR 17 | Save the value read from "ppc64_cpu --smt -n" into the state file stored at /var/lib/powerpc-utils/. 18 | 19 | .TP 20 | \fB\-\-load\fR 21 | Read the saved SMT value from the state file stored at /var/lib/powerpc-utils/ and set "ppc64_cpu --smt=value". 22 | 23 | .TP 24 | \fB\-\-help\fR 25 | Display a concise command usage statement. 26 | 27 | .SH AUTHOR 28 | Written by Jose Ricardo Ziviani 29 | -------------------------------------------------------------------------------- /man/snap.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2002 - 2012 International Business Machines 3 | .\" Todd Inglett 4 | .\" Michael Strosaker 5 | .\" Vasant Hegde 6 | .\" 7 | .TH SNAP 8 "30 May 2012" Linux "Linux on Power Service Tools" 8 | .SH NAME 9 | snap \- generate a configuration snapshot for service 10 | .SH SYNOPSIS 11 | \fB/usr/sbin/snap \fR[\fB-athv\fR] [\fB-d \fIdir\fR] [\fB-o \fIfile\fR] 12 | .SH DESCRIPTION 13 | The 14 | .I snap 15 | script copies several system status and config files and the output of 16 | several commands from the system into snap.tar.gz in the current directory. 17 | System servicers may ask that this be run in order collect data to diagnose 18 | a problem. 19 | 20 | .SH OPTIONS 21 | .TP 22 | .B \-a 23 | All data; collect detailed information (more files and output). 24 | .TP 25 | \fB\-d \fIdir 26 | Specify the directory where files and ouput will be collected (default: 27 | /tmp/ibmsupt). 28 | .TP 29 | .B \-h 30 | Print a help message. 31 | .TP 32 | \fB\-o \fIfile 33 | Specify the output path and filename (.tar required, .tar.gz optional) 34 | (default: snap.tar.gz). 35 | .TP 36 | \fB\-t 37 | Add hostname and timestamp to output filename. 38 | .TP 39 | .B \-v 40 | verbose output 41 | 42 | .SH FILES 43 | These are some of the files that are archived: 44 | .P 45 | /var/log/messages 46 | .br 47 | /var/log/scanoutlog.* 48 | .br 49 | /proc (select files) 50 | .br 51 | /dev/nvram 52 | .br 53 | /etc/yaboot.conf 54 | -------------------------------------------------------------------------------- /man/sys_ident.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2006 International Business Machines 3 | .\" Michael Strosaker 4 | .\" 5 | .TH SYS_IDENT 8 "Jan 2006" Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | sys_ident \- generate unique identification numbers 8 | .SH SYNOPSIS 9 | .nf 10 | \fB/usr/sbin/sys_ident -s\fR 11 | \fB/usr/sbin/sys_ident -p\fR 12 | .fi 13 | .SH DESCRIPTION 14 | .P 15 | The \fIsys_ident\fR utility implements algorithms for generating 16 | identification numbers that are uniqe to each system. These numbers are 17 | generated with the same algorithm as the numbers generated by 18 | \fIuname -f\fR on AIX. 19 | 20 | .P 21 | When invoked with the \fB-s\fR option, a 64-bit identification number 22 | will be printed (as a 16-character hexadecimal number). The number will 23 | also be unique for each partition on a partitioned system. 24 | 25 | .P 26 | When invoked with the \fB-p\fR option, a 32-bit processor serial number 27 | will be printed (as an 8-character hexadecimal number). 28 | 29 | .SH OPTIONS 30 | .TP 31 | .B \-s 32 | Generate a unique system/partition identification 64-bit number 33 | .TP 34 | .B \-p 35 | Generate the processor serial number 36 | 37 | -------------------------------------------------------------------------------- /man/uesensor.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (C) 2004 International Business Machines 3 | .\" Michael Strosaker 4 | .\" 5 | .TH UESENSOR 8 "May 2004" Linux "Linux on Power Service Tools" 6 | .SH NAME 7 | uesensor \- view the state of system environmental sensors 8 | .SH SYNOPSIS 9 | .nf 10 | \fB/usr/sbin/uesensor -l \fR| \fB -a 11 | \fB/usr/sbin/uesensor -t \fItoken \fB-i \fIindex \fR[\fB-v\fR] 12 | .fi 13 | .SH DESCRIPTION 14 | .P 15 | The \fIuesensor\fR utility is used to view the state of environmental 16 | sensors on PowerPC-64 machines. 17 | 18 | .P 19 | There are 4 types of system sensors that can be retrieved with 20 | \fIuesensor\fR; each sensor has an identifying token: 21 | 22 | .TP 23 | .B 3 24 | Thermal sensor 25 | .TP 26 | .B 9001 27 | Fan speed sensor 28 | .TP 29 | .B 9002 30 | Voltage sensor 31 | .TP 32 | .B 9004 33 | Power supply sensor 34 | 35 | .P 36 | Each sensor is uniquely identified by a combination of token and 37 | index number; index numbers start at 0 and are contiguous. For example, 38 | the second fan on the system would be identified by token number 9001 39 | and index 1. 40 | 41 | .P 42 | The state of each sensor consists of a status and a measured value. 43 | The status value is one of the following: 44 | 45 | .TP 46 | .B 9 47 | Critical low 48 | .TP 49 | .B 10 50 | Warning low 51 | .TP 52 | .B 11 53 | Normal 54 | .TP 55 | .B 12 56 | Warning high 57 | .TP 58 | .B 13 59 | Critical high 60 | 61 | .P 62 | The measured value depends on the type of sensor. Thermal sensors are 63 | measured in degrees Celcius; fan speed is measured in revolutions per 64 | minute; voltage is measured in millivolts; power supply measurements are 65 | defined as follows: 66 | 67 | .TP 68 | .B 0 69 | Not present 70 | .TP 71 | .B 1 72 | Present and not operational 73 | .TP 74 | .B 2 75 | Status unknown 76 | .TP 77 | .B 3 78 | Present and operational 79 | 80 | .P 81 | Each sensor is also associated with a location code; this location code 82 | may not be unique (for example, there may be multiple voltage sensors on 83 | a planar). 84 | 85 | .SH OPTIONS 86 | .TP 87 | .B \-l 88 | List all the sensors in human-readable format. 89 | .TP 90 | .B \-a 91 | List all the sensors in a tabular, numerical format. One line will be 92 | printed for each sensor in the following format: 93 | .nf 94 | .I 95 | .fi 96 | .TP 97 | \fB\-t \fItoken 98 | Specify the token of a specific sensor to query. Also requires the 99 | \fB\-i\fR option to be specified. 100 | .TP 101 | \fB\-i \fIindex 102 | Specify the index of a specific sensor to query. Also requires the 103 | \fB\-t\fR option to be specified. 104 | .TP 105 | .B \-v 106 | Print the measured value rather than the sensor status, which is the 107 | default value printed. Requires both the \fB\-t\fR and \fB-i\fR options 108 | to be specified. 109 | 110 | .SH "SEE ALSO" 111 | .BR usysident (8), 112 | .BR usysattn (8) 113 | -------------------------------------------------------------------------------- /man/vcpustat.8: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2020 International Business Machines. 2 | .\" 3 | .TH VCPUSTAT 8 "Mar 2020" Linux "Linux on Power Service Tools" 4 | .SH NAME 5 | vcpustat \- Report logical partition (LPAR) dispatch statistics. 6 | .SH SYNOPSIS 7 | .B /usr/sbin/vcpustat [ options ] [ [ count ] ] 8 | .SH DESCRIPTION 9 | 10 | The \fIvcpustat\fR command provides a report of logical processor (vcpu) dispatch statistics. This command provides a display of the logical processor dispatch dispersions, relative to the previous dispatch, as well as relative to the logical processor's home node as indicated by the Hypervisor. 11 | 12 | The \fIvcpustat\fR command with no options will generate a single report containing raw dispatch counts since the last time statistics were enabled. This is useful if dispatch statistics have been previously enabled persistently using the -e option. 13 | 14 | The following information is displayed in the report for each logical processor: 15 | .TP 16 | .B dispatch dispersions: 17 | Represents logical processor dispatch dispersions, relative to the previous dispatch and includes the below columns: 18 | .RS 19 | .TP 20 | total 21 | Indicates the total number of dispatches of this logical processor. This is only displayed if numeric or raw values are being shown. 22 | .TP 23 | core 24 | Indicates the number of times this logical processor was dispatched within the same core. 25 | .TP 26 | chip 27 | Indicates the number of times this logical processor was dispatched in a different core, but within the same chip. 28 | .TP 29 | socket 30 | Indicates the number of times this logical processor was dispatched in a different chip, but within the same socket. This is only seen on Multi Chip Modules. 31 | .TP 32 | cec 33 | Indicates the number of times this logical processor was dispatched outside the socket. 34 | .RE 35 | .TP 36 | .B numa dispersions: 37 | Represents logical processor dispatch dispersions, relative to the logical processor's home node and includes the below columns: 38 | .RS 39 | .TP 40 | home 41 | Indicates the number of times this logical processor was dispatched in its home node. 42 | .TP 43 | adj 44 | Indicates the number of times this logical processor was dispatched in the adjacent node. 45 | .TP 46 | far 47 | Indicates the number of times this logical processor was dispatched in a further node. 48 | .RE 49 | 50 | .SH OPTIONS 51 | .TP 52 | \fB\-e, --enable\fR 53 | Enable gathering dispatch statistics persistently, and not only when this command is active. 54 | .TP 55 | \fB\-d, --disable\fR 56 | Disable gathering dispatch statistics. 57 | .TP 58 | \fB\-n, --numeric\fR 59 | Display the values in numbers, rather than percentages. 60 | .TP 61 | \fB\-r, --raw\fR 62 | Display the raw values, rather than the delta. 63 | .TP 64 | \fB\-h, --help\fR 65 | Display the usage of vcpustat. 66 | .TP 67 | \fB\-V, --version\fR 68 | Display the vcpustat version information. 69 | .TP 70 | interval 71 | The 72 | .B interval 73 | parameter specifies the amount of time between each report. 74 | .TP 75 | count 76 | The 77 | .B count 78 | parameter specifies how many reports will be displayed. 79 | 80 | .SH NOTES 81 | The preferred invocation of 82 | .B vcpustat 83 | is by specifying 84 | .B interval 85 | and an optional 86 | .B count 87 | to monitor logical processor dispatch dispersions over a desired interval of time. This enables in-kernel gathering of logical processor dispatch dispersions and provides a view of the same at the desired monitoring interval. With this form of invocation, the statistics are only gathered when the program is active resulting in minimal kernel overhead. 88 | 89 | Long-term statistics can be obtained by enabling gathering of statistics in-kernel through the use of 90 | .B -e 91 | option, followed by invocations of 92 | .B vcpustat 93 | without any options, or using the 94 | .B -r 95 | option to display raw values, rather than the difference in each monitoring interval. This should only be used when long-term statistics are desired and results in additional kernel load. It is imperative that the statistics be disabled using 96 | .B -d 97 | option once monitoring is complete. 98 | 99 | .SH FILES 100 | .TP 101 | .B /proc/powerpc/vcpudispatch_stats 102 | 103 | .SH AUTHOR 104 | Written by Naveen N. Rao . 105 | -------------------------------------------------------------------------------- /powerpc-utils.spec.in: -------------------------------------------------------------------------------- 1 | %bcond_with systemd 2 | %define name powerpc-utils 3 | %define version @PACKAGE_VERSION@ 4 | %define release 1 5 | Summary: Utilities for PowerPC platforms 6 | Name: %{name} 7 | Version: %{version} 8 | Release: %{release} 9 | License: GNU General Public License (GPL) 10 | Group: System Environment 11 | Source: powerpc-utils-%{version}.tar.gz 12 | BuildRoot: /tmp/%{name}-buildroot/ 13 | Vendor: IBM Corp. 14 | Requires: /bin/bash, /bin/sh, /bin/sed, /usr/bin/perl, librtas >= 1.4.0, zlib, numactl-libs 15 | Requires: coreutils 16 | Requires: findutils 17 | Requires: gawk 18 | Requires: grep 19 | Requires: /sbin/modprobe 20 | Requires: /sbin/shutdown 21 | Requires: udev 22 | Requires: util-linux 23 | Requires: which 24 | 25 | %description 26 | Utilities for maintaining and servicing PowerPC systems. 27 | 28 | %prep 29 | %setup -q 30 | 31 | %build 32 | %configure %{?_with_systemd} --disable-werror 33 | %{__make} %{?_smp_mflags} 34 | 35 | %install 36 | %{__rm} -rf $RPM_BUILD_ROOT 37 | %{__make} install DESTDIR=$RPM_BUILD_ROOT 38 | 39 | %files 40 | %defattr(-,root,root) 41 | /usr/share/doc/packages/powerpc-utils/README 42 | /usr/share/doc/packages/powerpc-utils/COPYING 43 | 44 | /usr/sbin/update_flash 45 | /usr/sbin/update_flash_nv 46 | /usr/sbin/activate_firmware 47 | /usr/sbin/set_poweron_time 48 | /usr/sbin/rtas_ibm_get_vpd 49 | /usr/sbin/serv_config 50 | /usr/sbin/uesensor 51 | /usr/sbin/hvcsadmin 52 | /usr/sbin/rtas_dump 53 | /usr/sbin/rtas_event_decode 54 | /usr/sbin/sys_ident 55 | /usr/sbin/drmgr 56 | /usr/sbin/lsslot 57 | /usr/sbin/lparnumascore 58 | /usr/sbin/lsprop 59 | /usr/sbin/nvram 60 | /usr/sbin/nvsetenv 61 | /usr/sbin/snap 62 | /usr/sbin/bootlist 63 | /usr/sbin/ofpathname 64 | /usr/sbin/ppc64_cpu 65 | /usr/sbin/lsdevinfo 66 | /usr/sbin/ls-veth 67 | /usr/sbin/ls-vdev 68 | /usr/sbin/ls-vscsi 69 | /usr/sbin/lparstat 70 | /usr/sbin/pseries_platform 71 | /usr/sbin/errinjct 72 | /usr/sbin/rtas_dbg 73 | /usr/sbin/vcpustat 74 | /usr/sbin/hcnmgr 75 | /usr/sbin/hcncfgdrc 76 | /usr/sbin/hcnqrydev 77 | /usr/sbin/hcnrmdev 78 | /usr/sbin/hcnrmhcn 79 | /usr/sbin/hcnversion 80 | 81 | /usr/bin/amsstat 82 | 83 | %if 0%{?suse_version} 84 | /usr/lib/powerpc-utils/functions.suse 85 | %endif 86 | 87 | %if %{with systemd} 88 | /usr/sbin/smtstate 89 | /var/lib/powerpc-utils/smt.state 90 | /lib/systemd/system/smtstate.service 91 | /lib/systemd/system/smt_off.service 92 | /lib/systemd/system/hcn-init-NetworkManager.service 93 | /lib/systemd/system/hcn-init-wicked.service 94 | /usr/share/man/man8/smtstate.8.gz 95 | %endif 96 | 97 | /usr/share/man/man8/update_flash.8.gz 98 | /usr/share/man/man8/activate_firmware.8.gz 99 | /usr/share/man/man8/set_poweron_time.8.gz 100 | /usr/share/man/man8/rtas_ibm_get_vpd.8.gz 101 | /usr/share/man/man8/serv_config.8.gz 102 | /usr/share/man/man8/uesensor.8.gz 103 | /usr/share/man/man8/hvcsadmin.8.gz 104 | /usr/share/man/man8/rtas_dump.8.gz 105 | /usr/share/man/man8/sys_ident.8.gz 106 | /usr/share/man/man8/nvram.8.gz 107 | /usr/share/man/man8/snap.8.gz 108 | /usr/share/man/man8/bootlist.8.gz 109 | /usr/share/man/man8/ofpathname.8.gz 110 | /usr/share/man/man5/lparcfg.5.gz 111 | /usr/share/man/man8/lparstat.8.gz 112 | /usr/share/man/man8/lsslot.8.gz 113 | /usr/share/man/man8/ppc64_cpu.8.gz 114 | /usr/share/man/man1/amsstat.1.gz 115 | /usr/share/man/man8/errinjct.8.gz 116 | /usr/share/man/man8/rtas_dbg.8.gz 117 | /usr/share/man/man8/vcpustat.8.gz 118 | /usr/share/man/man8/drmgr.8.gz 119 | /usr/share/man/man8/lparnumascore.8.gz 120 | 121 | %post 122 | # Post-install script ----------------------------------------------- 123 | ln -sf /usr/sbin/serv_config usr/sbin/uspchrp 124 | ln -sf /usr/share/man/man8/serv_config.8 usr/share/man/man8/uspchrp.8 125 | 126 | %if %{with systemd} 127 | systemctl daemon-reload 128 | for i in NetworkManager wicked ; do 129 | systemctl start hcn-init-${i}.service 130 | systemctl enable hcn-init-${i}.service 131 | done 132 | # update the smt.state file with current SMT 133 | /usr/sbin/smtstate --save 134 | %endif 135 | 136 | %preun 137 | # Pre-uninstall script ---------------------------------------------- 138 | %if %{with systemd} 139 | svc=$(systemctl list-units -la | grep -Fq smtstate.service; echo $?) 140 | if [ "$svc" = "0" ]; then 141 | systemctl stop smtstate.service 142 | systemctl disable smtstate.service 143 | fi 144 | for i in NetworkManager wicked ; do 145 | if systemctl is-enabled hcn-init-${i}.service |grep -q "enabled"; then 146 | systemctl stop hcn-init-${i}.service 147 | systemctl disable hcn-init-${i}.service 148 | fi 149 | done 150 | %endif 151 | 152 | %postun 153 | # Post-uninstall script --------------------------------------------- 154 | if [ "$1" = "0" ]; then 155 | # last uninstall 156 | rm -f /usr/sbin/uspchrp 157 | rm -f /usr/share/man/man8/uspchrp.8.gz 158 | fi 159 | 160 | %if %{with systemd} 161 | systemctl daemon-reload 162 | %endif 163 | 164 | %changelog 165 | * Wed Apr 14 2021 Laurent Dufour 166 | - Added lparnumascore 167 | * Fri Mar 06 2020 Naveen N. Rao 168 | - Added vcpustat utility 169 | * Wed Dec 7 2011 Brian King 170 | - Added lsslot man page 171 | * Fri May 13 2011 Brian King 172 | - Fixed some ofpathname issues with various SAS and FC adapters 173 | 174 | * Fri Mar 11 2011 Brian King 175 | - Do not install vscsi server scripts, since they are deprecated 176 | -------------------------------------------------------------------------------- /scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | dist_bin_SCRIPTS = amsstat 2 | 3 | dist_sbin_SCRIPTS = update_flash update_flash_nv hvcsadmin rtas_dump \ 4 | snap bootlist ofpathname lsdevinfo ls-veth ls-vscsi \ 5 | ls-vdev pseries_platform nvsetenv hcnmgr 6 | -------------------------------------------------------------------------------- /scripts/amsstat: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # IBM "amsstat": Active Memory Sharing statistics gathering tool 4 | # 5 | # Copyright (c) 2009 International Business Machines. 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # as published by the Free Software Foundation; either version 2 10 | # of the License, or (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | # 21 | # Authors: 22 | # Andrew Theurer 23 | # Robert Jennings 24 | # 25 | # This script will gather AMS related information on supported Linux systems 26 | # usage: 27 | # amstat 28 | # 29 | # If you do not provide an interval, amsstat will display stats only once 30 | # 31 | # For further details on this tool and the fields it displays please 32 | # reference man page amsstat.1 33 | 34 | sleep_interval=$1 35 | indent=-4 36 | devstat_data_spacing=-30 37 | lparcfg_data_spacing=-30 38 | lparcfg_file=/proc/ppc64/lparcfg 39 | # Hardcoding pseries_platform path as amstat will be placed in bin 40 | PSERIES_PLATFORM=/usr/sbin/pseries_platform 41 | 42 | function print_meminfo_stats { 43 | echo "System Memory Statistics:" 44 | OLD_IFS=${IFS} 45 | IFS=" 46 | " 47 | for stat in `cat /proc/meminfo`; do 48 | IFS=${OLD_IFS} 49 | if echo $stat | grep "^MemTotal\|^MemFree\|^Buffers\|^Cached\|^Inactive\|SwapTotal\|SwapFree" >/dev/null; then 50 | this_stat=`echo $stat | awk -F: '{print $1}'` 51 | this_value=`echo $stat | awk -F: '{print $2}'` 52 | printf "%${indent}s %${lparcfg_data_spacing}s %${lparcfg_data_spacing}s\n" " " "$this_stat:" "${this_value##\ }" 53 | fi 54 | done 55 | 56 | # Include Desired Memory value from /proc/ppc64/lparcfg 57 | stat=`grep "^DesMem" $lparcfg_file` 58 | if [ ! -z "${stat}" ]; then 59 | this_stat=`echo $stat | awk -F= '{print $1}'` 60 | this_value=`echo $stat | awk -F= '{print $2}'` 61 | printf "%${indent}s %${lparcfg_data_spacing}s %${lparcfg_data_spacing}s\n" " " "$this_stat:" "$this_value MB" 62 | fi 63 | } 64 | 65 | function print_entitlement_data { 66 | echo "Entitlement Information:" 67 | for stat in `cat $lparcfg_file`; do 68 | if echo $stat | grep "^entitled_memory\|^mapped_entitled_memory\|^entitled_memory_weight\|entitled_memory_pool_size\|^backing_memory\|^cmo_enabled\|^cmo_faults\|^cmo_fault_time_usec\|cmo_primary_psp\|^cmo_secondary_psp\|^coalesced_bytes\|^pool_coalesced_bytes" >/dev/null; then 69 | this_stat=`echo $stat | awk -F= '{print $1}'` 70 | this_value=`echo $stat | awk -F= '{print $2}'` 71 | printf "%${indent}s %${lparcfg_data_spacing}s %${lparcfg_data_spacing}s\n" " " "$this_stat:" "$this_value" 72 | fi 73 | done 74 | } 75 | 76 | function print_cmm_stats { 77 | # CMM kernel parameters 78 | echo "CMM Statistics:" 79 | 80 | local path=/sys/module/cmm/parameters 81 | pushd $path >/dev/null 2>&1 82 | if [ $? -ne 0 ] ; then 83 | printf "%${indent}s Could not get CMM Statistics.\n" " " 84 | return 85 | fi 86 | 87 | for stat in `find . -mindepth 1 -maxdepth 1 -print`; do 88 | printf "%${indent}s %${devstat_data_spacing}s %${devstat_data_spacing}s\n" " " "${stat#\.\/}:" "`cat $stat`" 89 | done 90 | popd >/dev/null 91 | 92 | # CMM statistics 93 | local path=/sys/devices/system/cmm/cmm0 94 | pushd $path >/dev/null 2>&1 95 | if [ $? -ne 0 ] ; then 96 | return 97 | fi 98 | for stat in `find . -mindepth 1 -maxdepth 1 -print`; do 99 | printf "%${indent}s %${devstat_data_spacing}s %${devstat_data_spacing}s\n" " " "${stat#\.\/}:" "`cat $stat`" 100 | done 101 | popd >/dev/null 102 | } 103 | 104 | function print_vio_bus_stats { 105 | echo "VIO Bus Statistics:" 106 | local found=0 107 | local path=/sys/bus/vio 108 | pushd $path >/dev/null 2>&1 109 | if [ $? -ne 0 ] ; then 110 | printf "%${indent}s Could not get VIO Bus Statistics.\n" " " 111 | return 112 | fi 113 | 114 | for stat in `find . -mindepth 1 -maxdepth 1 -name "cmo*" -print`; do 115 | found=1 116 | printf "%${indent}s %${devstat_data_spacing}s %${devstat_data_spacing}s\n" " " "${stat#\.\/}:" "`cat $stat`" 117 | done 118 | popd >/dev/null 119 | 120 | if [ "$found" -eq "0" ]; then 121 | printf "%${indent}s No AMS Busses found.\n" " " 122 | fi 123 | } 124 | 125 | 126 | function print_vio_dev_stats { 127 | echo "VIO Device Statistics:" 128 | 129 | local found=0 130 | local path=/sys/bus/vio/devices 131 | pushd $path >/dev/null 2>&1 132 | if [ $? -ne 0 ] ; then 133 | printf "%${indent}s Could not get VIO Device Statistics.\n" " " 134 | return 135 | fi 136 | 137 | for dir in `find . -mindepth 1 -print`; do 138 | pushd $dir >/dev/null 2>&1 139 | if [ $? -ne 0 ] ; then 140 | break 141 | fi 142 | 143 | # Skip printing devices that are not using entitlement 144 | if [ ! -e "cmo_entitled" ]; then 145 | popd >/dev/null 146 | continue 147 | fi 148 | 149 | value=`cat cmo_entitled` 150 | if [ ${value} -eq "0" ]; then 151 | popd >/dev/null 152 | continue 153 | fi 154 | 155 | NAME=$(cat devspec) 156 | echo " ${NAME##/*/}:" 157 | for stat in `find . -mindepth 1 -maxdepth 1 -name "cmo*" -print`; do 158 | found=1 159 | printf "%${indent}s %${devstat_data_spacing}s %${devstat_data_spacing}s\n" " " "${stat#\.\/}:" "`cat $stat`" 160 | done 161 | popd >/dev/null 162 | done 163 | popd >/dev/null 164 | 165 | if [ "$found" -eq "0" ]; then 166 | printf "%${indent}s No AMS devices found.\n" " " 167 | fi 168 | } 169 | 170 | if [ ! -f $PSERIES_PLATFORM ]; then 171 | echo "$PSERIES_PLATFORM does not exist" 172 | echo "amstat: is not supported on the Unknown platform" 173 | exit 1; 174 | fi 175 | 176 | . $PSERIES_PLATFORM 177 | if [[ $platform != $PLATFORM_PSERIES_LPAR ]]; then 178 | echo "amstat: is not supported on the $platform_name platform" 179 | exit 1 180 | fi 181 | 182 | # Verify CMO is present and enabled 183 | enabled=`cat $lparcfg_file | grep "^cmo_enabled" | awk -F= '{print $2}'` 184 | if [ -z $enabled ]; then 185 | echo "This system is not capable of Active Memory Sharing." 186 | exit -1 187 | elif [ "$enabled" -eq "0" ]; then 188 | echo "Active Memory Sharing is not enabled on this system." 189 | exit -1 190 | fi 191 | 192 | if [ -z $sleep_interval ]; then 193 | date 194 | print_meminfo_stats 195 | print_entitlement_data 196 | print_cmm_stats 197 | print_vio_bus_stats 198 | print_vio_dev_stats 199 | else 200 | while [ 1 ]; do 201 | date 202 | print_meminfo_stats 203 | print_entitlement_data 204 | print_cmm_stats 205 | print_vio_bus_stats 206 | print_vio_dev_stats 207 | sleep $sleep_interval 208 | echo 209 | done 210 | fi 211 | -------------------------------------------------------------------------------- /scripts/ls-vdev: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Copyright (c) 2010 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | # 19 | # Author Brian King 20 | # 21 | # ls-vdev - This utility provides the HMC or IVM with name information for 22 | # virtual scsi adapters and devices 23 | # 24 | 25 | LSVDEV="ls-vdev" 26 | VERSION="0.1" 27 | LS="/bin/ls" 28 | GREP="/bin/grep" 29 | SED="/bin/sed" 30 | PSERIES_PLATFORM=$(dirname $0)/pseries_platform 31 | 32 | usage() 33 | { 34 | echo "Usage: $LSVDEV" 35 | echo "Provide information on Virtual SCSI adapters and devices" 36 | echo "" 37 | echo "Optional arguments." 38 | echo " -V Display version information and exit" 39 | echo " -h Display this help information and exit" 40 | echo "" 41 | } 42 | 43 | show_version() 44 | { 45 | echo "$LSVDEV: Version $VERSION" 46 | echo "Written by: Brian King " 47 | } 48 | 49 | . $PSERIES_PLATFORM 50 | if [[ $platform != $PLATFORM_PSERIES_LPAR ]]; then 51 | echo "$LSVDEV: is not supported on the $platform_name platform" 52 | exit 1 53 | fi 54 | 55 | while getopts ":Vh" flag ; do 56 | case "$flag" in 57 | V) show_version 58 | exit 0 ;; 59 | 60 | h) usage 61 | exit 0 ;; 62 | \?) usage 63 | exit 1 ;; 64 | esac 65 | done 66 | 67 | # Look at every ibmvscsi (Virtual SCSI) device 68 | for dev in $($LS -d /proc/device-tree/vdevice/v-scsi* 2> /dev/null) ; do 69 | # find the slot so it can be used in sysfs 70 | slot=$(echo $dev | $SED -e "s/\/proc\/device-tree\/vdevice\/v-scsi@//") 71 | 72 | # there is only one host per device, assign it to the path's name 73 | for host in $($LS -d /sys/devices/vio/$slot/host* 2> /dev/null) ; do 74 | parent=$(echo $host | $SED -e "s/.*\///") 75 | host=$($LS -d /sys/devices/vio/$slot/host*/) 76 | 77 | # loop through the targets for this host. 78 | for t in $($LS -d $host/target* 2> /dev/null); do 79 | target=$(echo $($LS -d $t/$($LS $t | $GREP -v uevent | $GREP -v power | $GREP -v subsystem))) 80 | if [[ ! -d $target/block ]]; then 81 | name=$(echo $($LS -d $target/block*) | $SED -e "s/.*://") 82 | else 83 | name=$($LS $target/block) 84 | fi 85 | 86 | echo "$parent $name" 87 | done 88 | done 89 | done 90 | 91 | exit 0 92 | 93 | # end 94 | -------------------------------------------------------------------------------- /scripts/ls-veth: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Copyright (c) 2010 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | # 19 | # Author Brian King 20 | # 21 | # ls-veth - This utility provides the HMC or IVM with name information for 22 | # virtual ethernet devices 23 | # 24 | 25 | LSVETH="ls-veth" 26 | VERSION="0.1" 27 | OFPATHNAME="/usr/sbin/ofpathname" 28 | CAT="/bin/cat" 29 | LS="/bin/ls" 30 | SED="/bin/sed" 31 | PSERIES_PLATFORM=$(dirname $0)/pseries_platform 32 | 33 | usage() 34 | { 35 | echo "Usage: $LSVETH " 36 | echo "Provide information on Virtual Ethernet devices" 37 | echo "" 38 | echo "Optional arguments." 39 | echo " -V Display version information and exit" 40 | echo " -h Display this help information and exit" 41 | echo "" 42 | } 43 | 44 | show_version() 45 | { 46 | echo "$LSVETH: Version $VERSION" 47 | echo "Written by: Brian King " 48 | } 49 | 50 | . $PSERIES_PLATFORM 51 | if [[ $platform != $PLATFORM_PSERIES_LPAR ]]; then 52 | echo "$LSVETH: is not supported on the $platform_name platform" 53 | exit 1 54 | fi 55 | 56 | while getopts ":Vh" flag ; do 57 | case "$flag" in 58 | V) show_version 59 | exit 0 ;; 60 | 61 | h) usage 62 | exit 0 ;; 63 | \?) usage 64 | exit 1 ;; 65 | esac 66 | done 67 | 68 | # Look at every ibmveth (Virtual Ethernet) device 69 | for dev in $($LS -d /proc/device-tree/vdevice/l-lan* 2> /dev/null); do 70 | # use ofpathname to get the device name (i.e. eth0) 71 | name=$($OFPATHNAME -l $(echo $dev | $SED -e "s/\/proc\/device-tree//")) 72 | 73 | # get the physical location 74 | physloc=$(tr -d '\0' < $dev/ibm,loc-code) 75 | 76 | echo "$name $physloc" 77 | done 78 | 79 | exit 0 80 | 81 | # end 82 | -------------------------------------------------------------------------------- /scripts/ls-vscsi: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Copyright (c) 2010 International Business Machines 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | # 19 | # Author Brian King 20 | # 21 | # ls-vscsi - This utility provides the HMC or IVM with name information for 22 | # virtual scsi devices 23 | # 24 | 25 | LSVSCSI="ls-vscsi" 26 | VERSION="0.1" 27 | CAT="/bin/cat" 28 | LS="/bin/ls" 29 | SED="/bin/sed" 30 | PSERIES_PLATFORM=$(dirname $0)/pseries_platform 31 | 32 | usage() 33 | { 34 | echo "Usage: $LSVSCSI" 35 | echo "Provide information on Virtual devices" 36 | echo "" 37 | echo "Optional arguments." 38 | echo " -V Display version information and exit" 39 | echo " -h Display this help information and exit" 40 | echo "" 41 | } 42 | 43 | show_version() 44 | { 45 | echo "$LSVSCSI: Version $VERSION" 46 | echo "Written by: Brian King " 47 | } 48 | 49 | . $PSERIES_PLATFORM 50 | if [[ $platform != $PLATFORM_PSERIES_LPAR ]]; then 51 | echo "$LSVSCSI: is not supported on the $platform_name platform" 52 | exit 1 53 | fi 54 | 55 | while getopts ":Vh" flag ; do 56 | case "$flag" in 57 | 58 | V) show_version 59 | exit 0 ;; 60 | 61 | h) usage 62 | exit 0 ;; 63 | \?) usage 64 | exit 1 ;; 65 | esac 66 | done 67 | 68 | 69 | # Look at every ibmvscsi (Virtual SCSI) device 70 | for dev in $($LS -d /proc/device-tree/vdevice/v-scsi* 2> /dev/null) ; do 71 | # pull the physical location 72 | physloc=$(tr -d '\0' < $dev/ibm,loc-code) 73 | 74 | # find the slot so it can be used in sysfs 75 | slot=$(echo $dev | $SED -e "s/\/proc\/device-tree\/vdevice\/v-scsi@//") 76 | 77 | # there is only one host per device, assign it to the path's name 78 | for host in $($LS -d /sys/devices/vio/$slot/host*) ; do 79 | name=$(echo $host | $SED -e "s/.*\///") 80 | echo "$name $physloc" 81 | done 82 | done 83 | 84 | exit 0 85 | 86 | # end 87 | -------------------------------------------------------------------------------- /scripts/nvsetenv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "--version" ]; then 4 | echo This version of nvsetenv is just a wrapper to invoke nvram 5 | exit 0 6 | fi 7 | if [ -z "$1" ]; then 8 | nvram --print-config 9 | elif [ -z "$2" ]; then 10 | nvram --print-config="$1" 11 | else 12 | nvram --update-config "$1"="$2" 13 | fi 14 | exit $? 15 | -------------------------------------------------------------------------------- /scripts/pseries_platform: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2014 - IBM 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | SOURCE_FILE="pseries_platform" 20 | PLATFORM_FILE=/proc/cpuinfo 21 | export PLATFORM_UNKNOWN=0 22 | export PLATFORM_POWERNV=1 23 | export PLATFORM_POWERKVM_GUEST=2 24 | export PLATFORM_PSERIES_LPAR=3 25 | 26 | export platform_name 27 | export platform 28 | 29 | platform_string=$(sed -n 's/^platform\t*: \(.*\)/\1/p' $PLATFORM_FILE) 30 | case "$platform_string" in 31 | "PowerNV") 32 | platform_name="PowerNV Host" 33 | platform=$PLATFORM_POWERNV;; 34 | "IBM pSeries (emulated by qemu)") 35 | platform_name="Power KVM pSeries Guest" 36 | platform=$PLATFORM_POWERKVM_GUEST;; 37 | "pSeries") 38 | platform_name="PowerVM pSeries LPAR" 39 | platform=$PLATFORM_PSERIES_LPAR;; 40 | *) 41 | platform_name="Unknown" 42 | platform=$PLATFORM_UNKNOWN;; 43 | esac 44 | 45 | if [ $SOURCE_FILE = `basename $0` ]; then 46 | echo $platform_name 47 | fi 48 | -------------------------------------------------------------------------------- /scripts/rtas_dump: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | # 3 | # This updated version of the rtas_dump script will 4 | # do everything the original rtas_dump script does except 5 | # it does it cleaner and without as many cmdline options. 6 | # 7 | # Copyright (C) 2004 International Business Machines 8 | # 9 | # This program is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License 11 | # as published by the Free Software Foundation; either version 2 12 | # of the License, or (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | # 23 | # Author: Nathan Fontenot 24 | # 25 | 26 | use vars qw/ %opt /; 27 | 28 | use Getopt::Long; 29 | use File::Basename; 30 | 31 | $re_decode = $ENV{RTAS_EVENT_DECODE} || "/usr/sbin/rtas_event_decode"; 32 | 33 | # 34 | # usage statement 35 | # 36 | sub usage() 37 | { 38 | print "Usage: rtas_dump [OPTIONS]\n"; 39 | print "Dump the contents of an RTAS event, by default RTAS events\n"; 40 | print "are read from stdin unless the -f flag is used.\n\n"; 41 | print " -d debug flag, passed through to rtas_event_decode\n"; 42 | print " -f dump the RTAS events from \n"; 43 | print " -h print this message and exit\n"; 44 | print " -n only dump RTAS event number \n"; 45 | print " -v dump the entire RTAS event, not just the header\n"; 46 | print " -w set the output character width\n"; 47 | 48 | exit 1; 49 | } 50 | 51 | # 52 | # Read in the contents of an RTAS event and invoke rtas_event_decode on it. 53 | # 54 | sub handle_rtas_event() 55 | { 56 | my ($event_no) = @_; 57 | 58 | $re_decode_args = "$re_decode_args -n $event_no"; 59 | 60 | # create the pipe to rtas_event_decode 61 | open EVENT_DECODE, "| $re_decode $re_decode_args"; 62 | 63 | while(<$fh>) { 64 | ($crud, $data) = split (/RTAS/); 65 | $rtas_str = $rtas_str . "RTAS" . $data; 66 | if (/RTAS event end/) { 67 | print EVENT_DECODE $rtas_str; 68 | $rtas_str = ""; 69 | last; 70 | } 71 | } 72 | 73 | close EVENT_DECODE; 74 | } 75 | 76 | # 77 | # Main 78 | # 79 | my $PSERIES_PLATFORM = dirname(__FILE__) . "/pseries_platform"; 80 | 81 | my $perldumpenv='perl -MData::Dumper -e '."'". 82 | '\$Data::Dumper::Terse=1;print Dumper(\%ENV);'."'"; 83 | 84 | eval '%ENV=('.$1.')' if `bash -c " 85 | . $PSERIES_PLATFORM; 86 | $perldumpenv"` 87 | =~ /^\s*\{(.*)\}\s*$/mxs; 88 | 89 | if ($ENV{'platform'} == $ENV{'PLATFORM_UNKNOWN'} || $ENV{'platform'} == $ENV{'PLATFORM_POWERNV'}) { 90 | print "rtas_dump: is not supported on the $ENV{'platform_name'} platform\n"; 91 | exit 1; 92 | } 93 | 94 | # process cmdline args 95 | Getopt::Long::Configure("bundling"); 96 | GetOptions("help|h" => \$help_flag, 97 | "dump_raw|d" => \$debug_flag, 98 | "file|f=s" => \$filename, 99 | "n=i" => \$event_no, 100 | "w=i" => \$width, 101 | "verbose|v+" => \$verbose) or usage(); 102 | 103 | usage() if $help_flag; 104 | 105 | # make sure the rtas_event_decode application is available 106 | -e $re_decode or die "File $re_decode does not exist and is needed by rtas_dump.\n"; 107 | 108 | -x $re_decode or die "File $re_decode is not executable.\n"; 109 | 110 | # get a reference to our input filehandle 111 | if ($filename) { 112 | if (-e $filename) { 113 | open INPUT_FILE, $filename; 114 | $fh = \*INPUT_FILE; 115 | $close_input_file = 1; 116 | } else { 117 | print "File $filename does not exist\n" ; 118 | return -1; 119 | } 120 | } else { 121 | $fh = \*STDIN; 122 | } 123 | 124 | # create the arg list to rtas_event_decode 125 | $re_decode_args = "$re_decode_args -d" if $debug_flag; 126 | $re_decode_args = "$re_decode_args -v" if $verbose; 127 | $re_decode_args = "$re_decode_args -w $width" if $width; 128 | 129 | while (<$fh>) { 130 | if (/RTAS event begin/) { 131 | # found the beginning of an RTAS event, process it. 132 | ($crud, $data) = split (/RTAS:/); 133 | ($this_event_no, $d) = split (' ', $data); 134 | if ($event_no) { 135 | if ($event_no == $this_event_no) { 136 | $rtas_str = $rtas_str . "RTAS:" . $data; 137 | &handle_rtas_event($this_event_no); 138 | } 139 | } else { 140 | $rtas_str = $rtas_str . "RTAS:" . $data; 141 | &handle_rtas_event($this_event_no); 142 | } 143 | 144 | next; 145 | } 146 | } 147 | 148 | if ($close_input_file) { 149 | close INPUT_FILE; 150 | } 151 | -------------------------------------------------------------------------------- /scripts/smtstate.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2020 International Business Machines 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | # Simple script designed to save and restore the SMT state. 19 | 20 | readonly SMT_STATE=/var/lib/powerpc-utils/smt.state 21 | readonly SMT_STATE_BKP=/tmp/smt.state.backup 22 | readonly PPC64CPU=@sbindir@/ppc64_cpu 23 | 24 | update_state() { 25 | # sanity check 26 | smt_state_exist 27 | 28 | # users can online and offline individual CPUs, creating an inconsistent 29 | # SMT state. In this case ppc64_cpu --smt displays a more complex 30 | # configuration, such case is beyond the scope here so we simply ignore it 31 | if [ $($PPC64CPU --smt -n | cut -d= -f2 | grep ^[1-8]$ > /dev/null; echo $?) -ne 0 ] 32 | then 33 | return 34 | fi 35 | 36 | # create a temporary backup 37 | cp -p $SMT_STATE $SMT_STATE_BKP 38 | if [ $? -ne 0 ] 39 | then 40 | logger -t ${0##*/}[$$] "Error saving $SMT_STATE_BKP" 41 | exit 1 42 | fi 43 | 44 | # update SMT state file 45 | local current_smt=$($PPC64CPU --smt -n | cut -d= -f2) 46 | sed -i "s/SMT_VALUE=[0-9]/SMT_VALUE=$current_smt/" $SMT_STATE 47 | if [ $? -ne 0 ] 48 | then 49 | logger -t ${0##*/}[$$] "Error updating $SMT_STATE" 50 | cp -p $SMT_STATE_BKP $SMT_STATE 51 | rm $SMT_STATE_BKP 52 | exit 1 53 | fi 54 | 55 | rm $SMT_STATE_BKP 56 | } 57 | 58 | set_smt() { 59 | # sanity check 60 | smt_state_exist 61 | 62 | # get saved SMT value and set it 63 | local smt=$(grep "^SMT_VALUE=[1-8]$" $SMT_STATE | cut -d= -f2) 64 | if [ "$smt" -lt 1 ] || [ "$smt" -gt 8 ] 65 | then 66 | logger -t ${0##*/}[$$] "$smt is an invalid SMT state" 67 | exit 1 68 | fi 69 | 70 | $PPC64CPU --smt="$smt" 71 | if [ $? -ne 0 ] 72 | then 73 | logger -t ${0##*/}[$$] "Error updating SMT=$smt" 74 | exit 1 75 | fi 76 | } 77 | 78 | smt_state_exist() { 79 | if [ ! -f $SMT_STATE ] 80 | then 81 | logger -t ${0##*/}[$$] "$SMT_STATE not found" 82 | exit 1 83 | fi 84 | 85 | grep "^SMT_VALUE=[1-8]$" $SMT_STATE > /dev/null 2>&1 86 | if [ $? -ne 0 ] 87 | then 88 | logger -t ${0##*/}[$$] "$SMT_STATE does not have SMT_VALUE defined" 89 | exit 1 90 | fi 91 | } 92 | 93 | check_smt_capable() { 94 | local msg=$($PPC64CPU --smt 2>&1 | grep -q "Machine is not SMT capable"; echo $?) 95 | if [ "$msg" -eq 0 ] 96 | then 97 | logger -t ${0##*/}[$$] "Machine is not SMT capable, exiting" 98 | exit 0 99 | fi 100 | } 101 | 102 | usage() { 103 | printf "$0 is a script designed to save/restore the SMT state.\n" 104 | printf "Usage: %s [--save | --load | --help]\n" "$0" 105 | printf "\t--save (default): save current SMT state\n" 106 | printf "\t--load : set SMT to the value stored\n" 107 | printf "\t--help : print this message\n" 108 | printf "SMT state is saved in $SMT_STATE\n" 109 | } 110 | 111 | main() { 112 | # if machine is not SMT capable don't even bother to continue 113 | check_smt_capable 114 | 115 | local action="$1" 116 | 117 | case "$action" in 118 | --load) 119 | set_smt 120 | ;; 121 | 122 | --save) 123 | update_state 124 | ;; 125 | 126 | --help) 127 | usage 128 | ;; 129 | 130 | *) 131 | logger -s -t ${0##*/}[$$] "Invalid action $1" 132 | usage 133 | exit 1 134 | ;; 135 | esac 136 | } 137 | 138 | action=${1:---save} 139 | main "$action" 140 | -------------------------------------------------------------------------------- /src/common/cpu_info_helpers.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cpu_info_helpers.h 3 | * @brief Header of common routines to capture cpu information 4 | * 5 | * Copyright (c) 2007, 2020 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * @author Anton Blanchard 22 | * @author Kamalesh Babulal 23 | */ 24 | #ifndef _CPU_INFO_HELPERS_H 25 | #define _CPU_INFO_HELPERS_H 26 | 27 | #define SYSFS_CPUDIR "/sys/devices/system/cpu/cpu%d" 28 | #define SYSFS_SUBCORES "/sys/devices/system/cpu/subcores_per_core" 29 | #define INTSERV_PATH "/proc/device-tree/cpus/%s/ibm,ppc-interrupt-server#s" 30 | #define CPU_PRESENT_PATH "/sys/devices/system/cpu/present" 31 | 32 | #define SYSFS_PATH_MAX 128 33 | 34 | extern int __sysattr_is_readable(char *attribute, int threads_in_system); 35 | extern int __sysattr_is_writeable(char *attribute, int threads_in_system); 36 | extern int cpu_physical_id(int thread); 37 | extern int cpu_online(int thread); 38 | extern int is_subcore_capable(void); 39 | extern int num_subcores(void); 40 | extern int get_attribute(char *path, const char *fmt, int *value); 41 | extern int get_cpu_info(int *threads_per_cpu, int *cpus_in_system, 42 | int *threads_in_system); 43 | extern int get_present_core_list(int **present_cores, int *num_present_cores, 44 | int threads_per_cpu); 45 | extern int __is_smt_capable(int threads_in_system); 46 | extern int __get_one_smt_state(int core, int threads_per_cpu); 47 | extern int __do_smt(bool numeric, int cpus_in_system, int threads_per_cpu, 48 | bool print_smt_state); 49 | 50 | #endif /* CPU_INFO_H */ 51 | -------------------------------------------------------------------------------- /src/common/librtas_error.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file librtas_error.c 3 | * @brief Common librtas_error routine for powerpc-utils-papr commands 4 | * 5 | * Copyright (c) 2004 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * @author Nathan Fontenot 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | /** 28 | * librtas_error 29 | * @brief check for librtas specific return codes 30 | * 31 | * This will check the erro value for a librtas specific return code 32 | * and fill in the buffer with the appropraite error message 33 | * 34 | * @param error return code from librtas 35 | * @param buf buffer to fill with error string 36 | * @param size size of "buffer" 37 | */ 38 | void librtas_error(int error, char *buf, size_t size) 39 | { 40 | switch (error) { 41 | case RTAS_KERNEL_INT: 42 | snprintf(buf, size, "No kernel interface to firmware"); 43 | break; 44 | case RTAS_KERNEL_IMP: 45 | snprintf(buf, size, "No kernel implementation of function"); 46 | break; 47 | case RTAS_PERM: 48 | snprintf(buf, size, "Non-root caller"); 49 | break; 50 | case RTAS_NO_MEM: 51 | snprintf(buf, size, "Out of heap memory"); 52 | break; 53 | case RTAS_NO_LOWMEM: 54 | snprintf(buf, size, "Kernel out of low memory"); 55 | break; 56 | case RTAS_FREE_ERR: 57 | snprintf(buf, size, "Attempt to free nonexistant RMO buffer"); 58 | break; 59 | case RTAS_TIMEOUT: 60 | snprintf(buf, size, "RTAS delay exceeded specified timeout"); 61 | break; 62 | case RTAS_IO_ASSERT: 63 | snprintf(buf, size, "Unexpected librtas I/O error"); 64 | break; 65 | case RTAS_UNKNOWN_OP: 66 | snprintf(buf, size, "No firmware implementation of function"); 67 | break; 68 | default: 69 | snprintf(buf, size, "Unknown librtas error %d", error); 70 | } 71 | 72 | return; 73 | } 74 | 75 | int is_librtas_error(int error) 76 | { 77 | int rc = 0; 78 | 79 | switch (error) { 80 | case RTAS_KERNEL_INT: 81 | case RTAS_KERNEL_IMP: 82 | case RTAS_PERM: 83 | case RTAS_NO_MEM: 84 | case RTAS_NO_LOWMEM: 85 | case RTAS_FREE_ERR: 86 | case RTAS_TIMEOUT: 87 | case RTAS_IO_ASSERT: 88 | case RTAS_UNKNOWN_OP: 89 | rc = 1; 90 | } 91 | 92 | return rc; 93 | } 94 | -------------------------------------------------------------------------------- /src/common/librtas_error.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file librtas_error.h 3 | * @brief Common librtas_error routine for powerpc-utils-papr commands 4 | * 5 | * Copyright (c) 2004 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * @author Nathan Fontenot 22 | */ 23 | 24 | #ifndef _LIBRTAS_ERROR_H 25 | #define _LIBRTAS_ERROR_H 26 | 27 | void librtas_error(int, char *, size_t); 28 | int is_librtas_error(int); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/common/pseries_platform.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file platform.c 3 | * 4 | * Copyright (C) 2014 IBM Corporation 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | * 20 | * @author Aruna Balakrishnaiah 21 | */ 22 | 23 | #include 24 | #include 25 | #include "pseries_platform.h" 26 | 27 | #define LENGTH 512 28 | 29 | const char *power_platform_name[] = { 30 | "Unknown", 31 | "PowerNV", 32 | "Power KVM pSeries Guest", 33 | "PowerVM pSeries LPAR", 34 | /* Add new platforms name here */ 35 | }; 36 | 37 | const char *platform_name; 38 | 39 | int 40 | get_platform(void) 41 | { 42 | int rc = PLATFORM_UNKNOWN; 43 | FILE *fp; 44 | char line[LENGTH]; 45 | 46 | if((fp = fopen(PLATFORM_FILE, "r")) == NULL) 47 | return rc; 48 | 49 | while (fgets(line, LENGTH, fp)) { 50 | if (strstr(line, "PowerNV")) { 51 | rc = PLATFORM_POWERNV; 52 | break; 53 | } else if (strstr(line, "IBM pSeries (emulated by qemu)")) { 54 | rc = PLATFORM_POWERKVM_GUEST; 55 | break; 56 | } else if (strstr(line, "pSeries")) { 57 | rc = PLATFORM_PSERIES_LPAR; 58 | /* catch model for PowerNV guest */ 59 | continue; 60 | } 61 | } 62 | 63 | platform_name = power_platform_name[rc]; 64 | 65 | fclose(fp); 66 | return rc; 67 | } 68 | -------------------------------------------------------------------------------- /src/common/pseries_platform.h: -------------------------------------------------------------------------------- 1 | /** 2 | * file pseries_platform.h 3 | * 4 | * Copyright (C) 2014 IBM Corporation 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef PLATFORM_H 22 | #define PLARFORM_H 23 | 24 | #define PLATFORM_FILE "/proc/cpuinfo" 25 | 26 | enum { 27 | PLATFORM_UNKNOWN = 0, 28 | PLATFORM_POWERNV, 29 | PLATFORM_POWERKVM_GUEST, 30 | PLATFORM_PSERIES_LPAR, 31 | /* Add new platforms here */ 32 | PLATFORM_MAX, 33 | }; 34 | 35 | extern const char *platform_name; 36 | 37 | extern int get_platform(void); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/drmgr/common_numa.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file common_numa.c 3 | * 4 | * Copyright (C) IBM Corporation 2020 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "dr.h" 26 | #include "ofdt.h" 27 | #include "drmem.h" /* for DYNAMIC_RECONFIG_MEM */ 28 | #include "common_numa.h" 29 | 30 | struct ppcnuma_node *ppcnuma_fetch_node(struct ppcnuma_topology *numa, int nid) 31 | { 32 | struct ppcnuma_node *node; 33 | 34 | if (nid > MAX_NUMNODES) { 35 | report_unknown_error(__FILE__, __LINE__); 36 | return NULL; 37 | } 38 | 39 | node = numa->nodes[nid]; 40 | if (node) 41 | return node; 42 | 43 | node = zalloc(sizeof(struct ppcnuma_node)); 44 | if (!node) { 45 | say(ERROR, "Can't allocate a new node\n"); 46 | return NULL; 47 | } 48 | 49 | node->node_id = nid; 50 | 51 | if (!numa->node_count || nid < numa->node_min) 52 | numa->node_min = nid; 53 | if (nid > numa->node_max) 54 | numa->node_max = nid; 55 | 56 | numa->nodes[nid] = node; 57 | numa->node_count++; 58 | 59 | return node; 60 | } 61 | 62 | /* 63 | * Read the number of CPU for each node using the libnuma to get the details 64 | * from sysfs. 65 | */ 66 | static int read_numa_topology(struct ppcnuma_topology *numa) 67 | { 68 | struct bitmask *cpus; 69 | struct ppcnuma_node *node; 70 | int rc, max_node, nid, i; 71 | 72 | if (numa_available() < 0) 73 | return -ENOENT; 74 | 75 | max_node = numa_max_node(); 76 | if (max_node >= MAX_NUMNODES) { 77 | say(ERROR, "Too many nodes %d (max:%d)\n", 78 | max_node, MAX_NUMNODES); 79 | return -EINVAL; 80 | } 81 | 82 | rc = 0; 83 | 84 | /* In case of allocation error, the libnuma is calling exit() */ 85 | cpus = numa_allocate_cpumask(); 86 | 87 | for (nid = 0; nid <= max_node; nid++) { 88 | 89 | if (!numa_bitmask_isbitset(numa_nodes_ptr, nid)) 90 | continue; 91 | 92 | node = ppcnuma_fetch_node(numa, nid); 93 | if (!node) { 94 | rc = -ENOMEM; 95 | break; 96 | } 97 | 98 | rc = numa_node_to_cpus(nid, cpus); 99 | if (rc < 0) 100 | break; 101 | 102 | /* Count the CPUs in that node */ 103 | for (i = 0; i < cpus->size; i++) 104 | if (numa_bitmask_isbitset(cpus, i)) 105 | node->n_cpus++; 106 | 107 | numa->cpu_count += node->n_cpus; 108 | } 109 | 110 | numa_bitmask_free(cpus); 111 | 112 | if (rc) { 113 | ppcnuma_foreach_node(numa, nid, node) 114 | node->n_cpus = 0; 115 | numa->cpu_count = 0; 116 | } 117 | 118 | return rc; 119 | } 120 | 121 | int ppcnuma_get_topology(struct ppcnuma_topology *numa) 122 | { 123 | int rc; 124 | 125 | rc = numa_available(); 126 | if (rc < 0) 127 | return rc; 128 | 129 | rc = get_min_common_depth(); 130 | if (rc < 0) 131 | return rc; 132 | numa->min_common_depth = rc; 133 | 134 | rc = get_assoc_arrays(DYNAMIC_RECONFIG_MEM, &numa->aa, 135 | numa->min_common_depth); 136 | if (rc) 137 | return rc; 138 | 139 | rc = read_numa_topology(numa); 140 | if (rc) 141 | return rc; 142 | 143 | if (!numa->node_count) 144 | return -1; 145 | 146 | return 0; 147 | } 148 | -------------------------------------------------------------------------------- /src/drmgr/common_numa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file numa.h 3 | * 4 | * Copyright (C) IBM Corporation 2020 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | #ifndef _NUMA_H_ 21 | #define _NUMA_H_ 22 | 23 | #define MAX_NUMNODES 256 24 | #define NUMA_NO_NODE -1 25 | 26 | struct ppcnuma_node { 27 | int node_id; 28 | unsigned int n_cpus; 29 | unsigned int n_lmbs; 30 | unsigned int ratio; 31 | struct dr_node *lmbs; /* linked by lmb_numa_next */ 32 | struct ppcnuma_node *ratio_next; 33 | }; 34 | 35 | struct ppcnuma_topology { 36 | unsigned int cpu_count; 37 | unsigned int lmb_count; 38 | unsigned int cpuless_node_count; 39 | unsigned int cpuless_lmb_count; 40 | unsigned int node_count, node_min, node_max; 41 | struct ppcnuma_node *nodes[MAX_NUMNODES]; 42 | struct ppcnuma_node *ratio; 43 | int min_common_depth; 44 | struct assoc_arrays aa; 45 | }; 46 | 47 | int ppcnuma_get_topology(struct ppcnuma_topology *numa); 48 | struct ppcnuma_node *ppcnuma_fetch_node(struct ppcnuma_topology *numa, 49 | int node_id); 50 | 51 | static inline int ppcnuma_next_node(struct ppcnuma_topology *numa, int nid, 52 | struct ppcnuma_node **node) 53 | { 54 | for (nid++; nid <= numa->node_max; nid++) 55 | if (numa->nodes[nid]) { 56 | *node = numa->nodes[nid]; 57 | break; 58 | } 59 | return nid; 60 | } 61 | 62 | #define ppcnuma_foreach_node(numa, nid, node) \ 63 | for (nid = (numa)->node_min, node = (numa)->nodes[nid]; \ 64 | nid <= (numa)->node_max; \ 65 | nid = ppcnuma_next_node(numa, nid, &(node))) 66 | 67 | #define ppcnuma_foreach_node_by_ratio(numa, node) \ 68 | for (node = (numa)->ratio; node; node = node->ratio_next) 69 | 70 | #endif /* _NUMA_H_ */ 71 | -------------------------------------------------------------------------------- /src/drmgr/dr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dr.h 3 | * 4 | * Copyright (C) IBM Corporation 2006 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef _H_DR 22 | #define _H_DR 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "rtas_calls.h" 31 | #include "drpci.h" 32 | 33 | extern int output_level; 34 | extern int log_fd; 35 | 36 | extern int read_dynamic_memory_v2; 37 | 38 | /* Error Exit Codes */ 39 | #define RC_IN_USE 1 40 | #define RC_NONEXISTENT 3 41 | #define RC_DONT_OWN 4 42 | #define RC_ALREADY_OWN 5 43 | #define RC_LINUX_SLOT 6 /* Special case for ConcMaint */ 44 | 45 | /* Online/Offline */ 46 | #define OFFLINE 0 47 | #define ONLINE 1 48 | 49 | static inline int is_dot_dir(char * _p) 50 | { 51 | return (_p[0] == '.'); 52 | } 53 | 54 | void * __zalloc(size_t, const char *, int); 55 | #define zalloc(x) __zalloc((x), __func__, __LINE__); 56 | 57 | #define DR_LOCK_FILE "/var/lock/dr_config_lock" 58 | #define PLATFORMPATH "/proc/device-tree/device_type" 59 | #define OFDTPATH "/proc/ppc64/ofdt" 60 | #define DR_COMMAND "drslot_chrp_%s" 61 | #define DRMIG_COMMAND "drmig_chrp_%s" 62 | 63 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) 64 | 65 | /* Global User Specifications */ 66 | enum drmgr_action {NONE, ADD, REMOVE, QUERY, REPLACE, IDENTIFY, 67 | MIGRATE, HIBERNATE}; 68 | 69 | enum drc_type {DRC_TYPE_NONE, DRC_TYPE_PCI, DRC_TYPE_SLOT, DRC_TYPE_PHB, 70 | DRC_TYPE_CPU, DRC_TYPE_MEM, DRC_TYPE_PORT, 71 | DRC_TYPE_HIBERNATE, DRC_TYPE_MIGRATION, DRC_TYPE_ACC}; 72 | 73 | enum hook_phase {HOOK_CHECK, HOOK_UNDOCHECK, HOOK_PRE, HOOK_POST}; 74 | 75 | extern enum drmgr_action usr_action; 76 | extern int display_capabilities; 77 | extern int usr_slot_identification; 78 | extern int usr_timeout; 79 | extern char *usr_drc_name; 80 | extern uint32_t usr_drc_index; 81 | extern int usr_prompt; 82 | extern int usr_drc_count; 83 | extern enum drc_type usr_drc_type; 84 | extern char *usr_p_option; 85 | extern char *usr_t_option; 86 | extern int pci_virtio; /* qemu virtio device (legacy guest workaround) */ 87 | extern char *prrn_filename; 88 | extern int show_available_slots; 89 | extern int show_cpus_and_caches; 90 | extern int show_occupied_slots; 91 | extern int show_caches; 92 | extern char *usr_delimiter; 93 | extern int pci_hotplug_only; 94 | 95 | enum say_level { ERROR = 1, WARN, INFO, DEBUG, EXTRA_DEBUG}; 96 | 97 | /* The follwing are defined in common.c */ 98 | int say(enum say_level, char *, ...); 99 | void report_unknown_error(char *, int); 100 | int dr_init(void); 101 | void dr_fini(void); 102 | void set_timeout(int); 103 | int drmgr_timed_out(void); 104 | int dr_lock(void); 105 | int dr_unlock(void); 106 | int valid_platform(const char *); 107 | 108 | void free_of_node(struct of_node *); 109 | int add_device_tree_nodes(char *, struct of_node *); 110 | int remove_device_tree_nodes(const char *path); 111 | 112 | int update_property(const char *, size_t); 113 | int get_property(const char *, const char *, void *, size_t); 114 | int get_int_attribute(const char *, const char *, void *, size_t); 115 | int get_str_attribute(const char *, const char *, void *, size_t); 116 | int get_ofdt_uint_property(const char *, const char *, uint *); 117 | int get_property_size(const char *, const char *); 118 | int signal_handler(int, int, struct sigcontext *); 119 | int sig_setup(void); 120 | char *node_type(struct dr_node *); 121 | 122 | struct dr_node *alloc_dr_node(struct dr_connector *, int, const char *); 123 | int update_sysparm(void); 124 | 125 | int cpu_dlpar_capable(void); 126 | int mem_dlpar_capable(void); 127 | int slot_dlpar_capable(void); 128 | int phb_dlpar_capable(void); 129 | int pmig_capable(void); 130 | int phib_capable(void); 131 | int hea_dlpar_capable(void); 132 | int cpu_entitlement_capable(void); 133 | int mem_entitlement_capable(void); 134 | void print_dlpar_capabilities(void); 135 | 136 | void set_output_level(int); 137 | 138 | int run_hooks(enum drc_type drc_type, enum drmgr_action, enum hook_phase phase, 139 | int drc_count); 140 | 141 | #define DR_BUF_SZ 256 142 | 143 | int drslot_chrp_slot(void); 144 | int valid_slot_options(void); 145 | void slot_usage(char **); 146 | 147 | int drslot_chrp_cpu(void); 148 | int valid_cpu_options(void); 149 | void cpu_usage(char **); 150 | 151 | int drslot_chrp_pci(void); 152 | int valid_pci_options(void); 153 | void pci_usage(char **); 154 | 155 | int drslot_chrp_phb(void); 156 | int valid_phb_options(void); 157 | void phb_usage(char **); 158 | 159 | int drslot_chrp_mem(void); 160 | int valid_mem_options(void); 161 | void mem_usage(char **); 162 | 163 | int drslot_chrp_hea(void); 164 | int valid_hea_options(void); 165 | void hea_usage(char **); 166 | 167 | int drmig_chrp_pmig(void); 168 | int valid_pmig_options(void); 169 | void pmig_usage(char **); 170 | void phib_usage(char **); 171 | 172 | int dracc_chrp_acc(void); 173 | int valid_acc_options(void); 174 | void acc_usage(char **); 175 | 176 | int ams_balloon_active(void); 177 | 178 | int is_display_adapter(struct dr_node *); 179 | 180 | enum drc_type to_drc_type(const char *); 181 | 182 | #define PRRN_TIMEOUT 30 183 | int handle_prrn(void); 184 | 185 | int kernel_dlpar_exists(void); 186 | int do_kernel_dlpar_common(const char *, int, int); 187 | static inline int do_kernel_dlpar(const char *cmd, int len) 188 | { 189 | return do_kernel_dlpar_common(cmd, len, 0); 190 | } 191 | int do_dt_kernel_dlpar(uint32_t, int); 192 | #endif 193 | -------------------------------------------------------------------------------- /src/drmgr/dracc_chrp_acc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dracc_chrp_acc.c 3 | * 4 | * Copyright (C) IBM Corporation 2022 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "dr.h" 33 | 34 | #define SYSFS_VAS_QOSCREDIT_FILE "/sys/devices/virtual/misc/vas/vas0/gzip/qos_capabilities/update_total_credits" 35 | 36 | static char *acc_usagestr = "-c acc -t -q "; 37 | 38 | /** 39 | * acc_usage 40 | * 41 | */ 42 | void 43 | acc_usage(char **ausage) 44 | { 45 | *ausage = acc_usagestr; 46 | } 47 | 48 | int valid_acc_options(void) 49 | { 50 | if (!usr_t_option) { 51 | say(ERROR, "-t gzip must be specified\n"); 52 | return -1; 53 | } 54 | 55 | if (usr_drc_type != DRC_TYPE_ACC) { 56 | say(ERROR, "The value \"%d\" for the -c option is not valid\n", 57 | usr_drc_type); 58 | return -1; 59 | } 60 | 61 | /* 62 | * Only gzip Accelerator type is supported right now 63 | */ 64 | if (strcmp(usr_t_option, "gzip") == 0) { 65 | say(ERROR, "Invalid Accelerator type: %s\n", usr_t_option); 66 | return -1; 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | int dracc_chrp_acc(void) 73 | { 74 | int fd, rc; 75 | char buf[64]; 76 | 77 | if (strcmp(usr_t_option, "gzip") == 0) { 78 | say(ERROR, "Invalid Accelerator type: %s\n", usr_t_option); 79 | return -1; 80 | } 81 | 82 | if (usr_drc_count < 0) { 83 | say(ERROR, "Invalid QoS credit count %d\n", usr_drc_count); 84 | return -1; 85 | } 86 | 87 | fd = open(SYSFS_VAS_QOSCREDIT_FILE, O_WRONLY); 88 | if (fd < 0) { 89 | say(ERROR, "Could not open \"%s\" to write QoS credits\n", 90 | SYSFS_VAS_QOSCREDIT_FILE); 91 | return -1; 92 | } 93 | 94 | sprintf(buf, "%d", usr_drc_count); 95 | 96 | rc = write(fd, buf, strlen(buf)); 97 | close(fd); 98 | if (rc < 0) { 99 | say(ERROR, "Could not write QoS credits\n"); 100 | return errno; 101 | } 102 | 103 | say(DEBUG, "Successful update total QoS credits\n"); 104 | 105 | return 0; 106 | } 107 | -------------------------------------------------------------------------------- /src/drmgr/drcpu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drcpu.h 3 | * 4 | * Copyright (C) IBM Corporation 2006 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef _H_DRCPU 22 | #define _H_DRCPU 23 | 24 | #include "dr.h" 25 | 26 | #define CPU_PROBE_FILE "/sys/devices/system/cpu/probe" 27 | #define CPU_RELEASE_FILE "/sys/devices/system/cpu/release" 28 | 29 | struct cache_info { 30 | char name[DR_BUF_SZ]; /* node name */ 31 | const char *path; /* node path */ 32 | uint32_t phandle; 33 | uint32_t l2cache; 34 | uint32_t removed; 35 | struct cache_info *next; /* global list */ 36 | }; 37 | 38 | struct dr_info { 39 | struct dr_node *all_cpus; 40 | struct cache_info *all_caches; 41 | struct thread *all_threads; 42 | }; 43 | 44 | int init_cpu_drc_info(struct dr_info *); 45 | void free_cpu_drc_info(struct dr_info *); 46 | 47 | int get_thread_state(struct thread *); 48 | int set_thread_state(struct thread *, int); 49 | 50 | int get_cpu_state(struct dr_node *); 51 | int offline_cpu(struct dr_node *); 52 | int online_cpu(struct dr_node *, struct dr_info *); 53 | 54 | int cpu_enable_smt(struct dr_node *, struct dr_info *); 55 | int cpu_disable_smt(struct dr_node *); 56 | 57 | int smt_enabled(struct dr_info *); 58 | int system_enable_smt(struct dr_info *); 59 | int system_disable_smt(struct dr_info *); 60 | 61 | struct cache_info * cpu_get_dependent_cache(struct dr_node *, struct dr_info *); 62 | struct cache_info * cache_get_dependent_cache(struct cache_info *, 63 | struct dr_info *); 64 | int release_cpu(struct dr_node *, struct dr_info *); 65 | int probe_cpu(struct dr_node *, struct dr_info *); 66 | struct dr_node *get_available_cpu(struct dr_info *); 67 | 68 | #endif /* _H_DRCPU */ 69 | -------------------------------------------------------------------------------- /src/drmgr/drmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @file drmem.h 3 | * 4 | * Copyright (C) IBM Corporation 2006 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | #include "drpci.h" 21 | 22 | struct lmb_list_head { 23 | struct dr_node *lmbs; 24 | struct dr_node *last; 25 | char *drconf_buf; 26 | int drconf_buf_sz; 27 | int lmbs_modified; 28 | int sort; 29 | int lmbs_found; 30 | }; 31 | 32 | struct drconf_mem { 33 | uint64_t address; 34 | uint32_t drc_index; 35 | uint32_t reserved; 36 | uint32_t assoc_index; 37 | uint32_t flags; 38 | }; 39 | 40 | struct drconf_mem_v2 { 41 | uint32_t seq_lmbs; 42 | uint64_t base_addr; 43 | uint32_t drc_index; 44 | uint32_t aa_index; 45 | uint32_t flags; 46 | } __attribute__((packed)); 47 | 48 | #define DRMEM_ASSIGNED 0x00000008 49 | #define DRMEM_DRC_INVALID 0x00000020 50 | 51 | #define MEM_PROBE_FILE "/sys/devices/system/memory/probe" 52 | #define MEM_BLOCK_SIZE_BYTES "/sys/devices/system/memory/block_size_bytes" 53 | #define DYNAMIC_RECONFIG_MEM "/proc/device-tree/ibm,dynamic-reconfiguration-memory" 54 | #define DYNAMIC_RECONFIG_MEM_V1 DYNAMIC_RECONFIG_MEM "/ibm,dynamic-memory" 55 | #define DYNAMIC_RECONFIG_MEM_V2 DYNAMIC_RECONFIG_MEM "/ibm,dynamic-memory-v2" 56 | 57 | #define LMB_NORMAL_SORT 0 58 | #define LMB_REVERSE_SORT 1 59 | #define LMB_RANDOM_SORT 2 60 | 61 | extern uint64_t block_sz_bytes; 62 | 63 | struct lmb_list_head *get_lmbs(unsigned int); 64 | void free_lmbs(struct lmb_list_head *); 65 | -------------------------------------------------------------------------------- /src/drmgr/drpci.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drpci.h 3 | * 4 | * Copyright (C) IBM Corporation 2006 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef _DRPCI_H_ 22 | #define _DRPCI_H_ 23 | 24 | #include "rtas_calls.h" 25 | #include "ofdt.h" 26 | 27 | /* PCI Hot Plug defs */ 28 | #define PHP_SYSFS_ADAPTER_PATH "/sys/bus/pci/slots/%s/adapter" 29 | #define PHP_SYSFS_POWER_PATH "/sys/bus/pci/slots/%s/power" 30 | #define PHP_CONFIG_ADAPTER 1 31 | #define PHP_UNCONFIG_ADAPTER 0 32 | 33 | #define PCI_RESCAN_PATH "/sys/bus/pci/rescan" 34 | 35 | /* The following defines are used for adapter status */ 36 | #define EMPTY 0 37 | #define CONFIG 1 38 | #define NOT_CONFIG 2 39 | 40 | /* Device type definitions */ 41 | #define PCI_HP_DEV 1 42 | #define PCI_DLPAR_DEV 2 43 | #define VIO_DEV 3 44 | #define HEA_DEV 4 45 | #define HEA_PORT_DEV 5 46 | #define PHB_DEV 7 47 | #define CPU_DEV 8 48 | #define MEM_DEV 9 49 | 50 | #define ADD_SLOT_FNAME "/sys/bus/pci/slots/control/add_slot" 51 | #define ADD_SLOT_FNAME2 "/sys/bus/pci/slots/control/\"add_slot\"" 52 | #define REMOVE_SLOT_FNAME "/sys/bus/pci/slots/control/remove_slot" 53 | #define REMOVE_SLOT_FNAME2 "/sys/bus/pci/slots/control/\"remove_slot\"" 54 | 55 | #define IGNORE_HP_PO_PROP "/proc/device-tree/ibm,ignore-hp-po-fails-for-dlpar" 56 | 57 | extern char *add_slot_fname; 58 | extern char *remove_slot_fname; 59 | 60 | #define HEA_ADD_SLOT "/sys/bus/ibmebus/probe" 61 | #define HEA_REMOVE_SLOT "/sys/bus/ibmebus/remove" 62 | /* %s is the loc-code of the HEA adapter for *_PORT defines */ 63 | #define HEA_ADD_PORT "/sys/bus/ibmebus/devices/%s/probe_port" 64 | #define HEA_REMOVE_PORT "/sys/bus/ibmebus/devices/%s/remove_port" 65 | 66 | #define PCI_NODES 0x00000001 67 | #define VIO_NODES 0x00000002 68 | #define HEA_NODES 0x00000004 69 | #define PHB_NODES 0x00000010 70 | 71 | struct dr_node *get_hp_nodes(void); 72 | struct dr_node *get_dlpar_nodes(uint32_t); 73 | struct dr_node *get_node_by_name(const char *, uint32_t); 74 | void free_node(struct dr_node *); 75 | 76 | /* Function prototypes for subroutines */ 77 | int get_hp_adapter_status(char *); 78 | int set_hp_adapter_status(uint, char *); 79 | int pci_rescan_bus(); 80 | int pci_remove_device(struct dr_node *); 81 | int release_hp_children_from_node(struct dr_node *); 82 | int release_hp_children(char *); 83 | int dlpar_remove_slot(const char *); 84 | int dlpar_add_slot(const char *); 85 | int cmp_drcname(char *, char *); 86 | int acquire_hp_children(char *, int *); 87 | int enable_hp_children(char *); 88 | int disable_hp_children(char *); 89 | 90 | void print_node_list(struct dr_node *); 91 | 92 | #endif /* _DRPCI_H_ */ 93 | -------------------------------------------------------------------------------- /src/drmgr/lsslot_chrp_cpu.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lsslot_chrp_cpu.c 3 | * @brief routines for lsslot_chrp_cpu command 4 | * 5 | * Copyright (C) IBM Corporation 2006 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "dr.h" 29 | #include "drcpu.h" 30 | 31 | /** 32 | * list_cpus 33 | * @brief list all cpus 34 | * 35 | */ 36 | void 37 | list_cpus(struct dr_info *dr_info) 38 | { 39 | struct dr_node *cpu; 40 | struct thread *t; 41 | char *fmt_s = "%-10s%-20s%-11s%-13s\n"; 42 | char *fmt = "%-10s%-20s%-11x"; 43 | 44 | printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)"); 45 | 46 | for (cpu = dr_info->all_cpus; cpu != NULL; cpu = cpu->next) { 47 | if (cpu->is_owned || output_level >= DEBUG) { 48 | printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--", 49 | cpu->drc_index); 50 | for (t = cpu->cpu_threads; t; t = t->sibling) 51 | printf("%-2x ", t->id); 52 | printf("\n"); 53 | } 54 | } 55 | 56 | return; 57 | } 58 | 59 | /** 60 | * list_caches 61 | * @brief list all caches 62 | * 63 | */ 64 | void 65 | list_caches(struct dr_info *dr_info) 66 | { 67 | struct cache_info *cache = NULL; 68 | 69 | printf("cache-name phandle\n"); 70 | 71 | for (cache = dr_info->all_caches; cache != NULL; cache = cache->next) 72 | printf("%-21s%-8x\n", cache->name, cache->phandle); 73 | 74 | return; 75 | } 76 | 77 | /** 78 | * list_all_cpus_and_caches 79 | * @bried list all of the cpus and caches 80 | * 81 | */ 82 | void 83 | list_cpus_and_caches(struct dr_info *dr_info) 84 | { 85 | struct dr_node *cpu = NULL; 86 | struct thread *t; 87 | int thread_id_field_sz = 25; 88 | char *fmt_s = "%-10s%-20s%-11s%-25s%-15s%-15s\n"; 89 | char *fmt = "%-10s%-20s%-11x"; 90 | char *fmt_caches = "%-15s%-15s\n"; 91 | 92 | printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)", 93 | "l2-cache", "l3-cache"); 94 | 95 | for (cpu = dr_info->all_cpus; cpu != NULL; cpu = cpu->next) { 96 | int i, count = 0; 97 | struct cache_info *l2_cache = NULL; 98 | struct cache_info *l3_cache = NULL; 99 | 100 | printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--", 101 | cpu->drc_index); 102 | 103 | for (t = cpu->cpu_threads; t; t = t->sibling) { 104 | printf("%-2x ", t->id); 105 | count += 3; 106 | } 107 | 108 | /* pad out the thread ids field */ 109 | for (i = count; i < thread_id_field_sz; i++) 110 | printf(" "); 111 | 112 | l2_cache = cpu_get_dependent_cache(cpu, dr_info); 113 | if (l2_cache) 114 | l3_cache = cache_get_dependent_cache(l2_cache, dr_info); 115 | 116 | printf(fmt_caches, (l2_cache ? l2_cache->name : "N/A"), 117 | (l3_cache ? l3_cache->name : "N/A")); 118 | } 119 | 120 | return; 121 | } 122 | 123 | /** 124 | * lsslot_chrp_cpu 125 | * @brief main entry point for lsslot_chrp_cpu command 126 | * 127 | * @returns 0 on success, !0 otherwise 128 | */ 129 | int lsslot_chrp_cpu(void) 130 | { 131 | struct stat sb; 132 | struct dr_info dr_info; 133 | 134 | /* Mask signals so the command doesn't get interrupted */ 135 | if (sig_setup()) { 136 | fprintf(stderr, "\nUnknown failure. Rerun the command.\n\n"); 137 | return 1; 138 | } 139 | 140 | /* Check if this is an LPAR System. */ 141 | if (stat("/proc/device-tree/ibm,lpar-capable", &sb)) { 142 | fprintf(stderr, "\nThe system is not LPAR.\n\n"); 143 | return 1; 144 | } 145 | 146 | if (init_cpu_drc_info(&dr_info)) { 147 | fprintf(stderr, "\nThere are no dynamically reconfigurable " 148 | "CPUs on this system.\n\n"); 149 | return 1; 150 | } 151 | 152 | if (show_cpus_and_caches) 153 | list_cpus_and_caches(&dr_info); 154 | else if (show_caches) 155 | list_caches(&dr_info); 156 | else 157 | list_cpus(&dr_info); 158 | 159 | free_cpu_drc_info(&dr_info); 160 | return 0; 161 | } 162 | 163 | -------------------------------------------------------------------------------- /src/drmgr/ofdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ofdt.h 3 | * 4 | * Copyright (C) IBM Corporation 2006 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | #ifndef _OFDT_H_ 21 | #define _OFDT_H_ 22 | 23 | #define DRC_STR_MAX 48 24 | #define OFDT_BASE "/proc/device-tree" 25 | #define CPU_OFDT_BASE "/proc/device-tree/cpus" 26 | 27 | #define DR_PATH_MAX 1024 28 | #define DR_STR_MAX 128 29 | #define MAX_CPU_INTSERV_NUMS 8 30 | 31 | struct dr_connector { 32 | char name[DRC_STR_MAX]; 33 | char type[DRC_STR_MAX]; 34 | char ofdt_path[DR_PATH_MAX]; 35 | unsigned int index; 36 | unsigned int powerdomain; 37 | struct dr_connector *next; 38 | struct dr_connector *all_next; 39 | }; 40 | 41 | struct assoc_arrays { 42 | uint32_t n_arrays; 43 | uint32_t array_sz; 44 | uint32_t *min_array; 45 | }; 46 | 47 | struct mem_scn { 48 | struct mem_scn *next; 49 | int removable; 50 | uint64_t phys_addr; 51 | char sysfs_path[DR_PATH_MAX]; 52 | }; 53 | 54 | struct thread { 55 | int id; /* linux "logical" cpu id */ 56 | uint32_t phys_id; 57 | char path[DR_PATH_MAX]; /* node path */ 58 | struct thread *next; 59 | struct thread *sibling; 60 | struct dr_node *cpu; 61 | }; 62 | 63 | /* This structure represents a DR-capable node. Data from 64 | * the Open Firmware tree is gathered here. There is a pointer 65 | * to a linked list of the OF nodes representing the device(s) 66 | * connected to this slot (if they exist) 67 | */ 68 | struct dr_node { 69 | struct dr_node *next; 70 | struct dr_node *children; 71 | 72 | uint32_t drc_index; 73 | char drc_type[DR_STR_MAX]; 74 | char drc_name[DR_STR_MAX]; 75 | uint32_t drc_power; 76 | 77 | char loc_code[DR_STR_MAX]; 78 | char ofdt_path[DR_PATH_MAX]; 79 | char *name; /* This will just point to the name part of 80 | * the ofdt_path buffer, no need to free 81 | */ 82 | 83 | char ofdt_dname[DR_STR_MAX]; 84 | char sysfs_dev_path[DR_PATH_MAX]; 85 | uint32_t dev_type; 86 | 87 | uint32_t is_owned:1; 88 | uint32_t skip:1; 89 | uint32_t unusable:1; 90 | uint32_t is_removable:1; 91 | uint32_t post_replace_processing:1; 92 | uint32_t reserved:27; 93 | 94 | union { 95 | struct mem_info { 96 | uint64_t _address; 97 | uint64_t _lmb_size; 98 | uint32_t _lmb_aa_index; 99 | struct mem_scn *_mem_scns; 100 | struct of_node *_of_node; 101 | struct dr_node *_numa_next; 102 | } _smem; 103 | 104 | #define lmb_address _node_u._smem._address 105 | #define lmb_size _node_u._smem._lmb_size 106 | #define lmb_aa_index _node_u._smem._lmb_aa_index 107 | #define lmb_mem_scns _node_u._smem._mem_scns 108 | #define lmb_of_node _node_u._smem._of_node 109 | #define lmb_numa_next _node_u._smem._numa_next 110 | 111 | struct hea_info { 112 | uint _port_no; 113 | uint _port_tenure; 114 | }_shea; 115 | 116 | #define hea_port_no _node_u._shea._port_no 117 | #define hea_port_tenure _node_u._shea._port_tenure 118 | 119 | struct pci_info { 120 | uint _vendor_id; /* vendor ID */ 121 | uint _device_id; /* device ID */ 122 | uint _class_code; /* class code */ 123 | }_spci; 124 | 125 | #define pci_vendor_id _node_u._spci._vendor_id 126 | #define pci_device_id _node_u._spci._device_id 127 | #define pci_class_code _node_u._spci._class_code 128 | 129 | struct phb_info { 130 | char _ic_ofdt_path[DR_PATH_MAX]; 131 | }_sphb; 132 | 133 | #define phb_ic_ofdt_path _node_u._sphb._ic_ofdt_path 134 | 135 | struct cpu_info { 136 | uint32_t _intserv_nums[MAX_CPU_INTSERV_NUMS]; 137 | int _nthreads; 138 | uint32_t _reg; 139 | uint32_t _l2cache; 140 | struct thread *_threads; 141 | }_scpu; 142 | 143 | #define cpu_intserv_nums _node_u._scpu._intserv_nums 144 | #define cpu_nthreads _node_u._scpu._nthreads 145 | #define cpu_reg _node_u._scpu._reg 146 | #define cpu_l2cache _node_u._scpu._l2cache 147 | #define cpu_threads _node_u._scpu._threads 148 | 149 | } _node_u; 150 | }; 151 | 152 | static inline void 153 | set_drc_info(struct dr_node *node, struct dr_connector *drc) 154 | { 155 | node->drc_index = drc->index; 156 | node->drc_power = drc->powerdomain; 157 | 158 | snprintf(node->drc_name, DR_STR_MAX, "%s", drc->name); 159 | snprintf(node->drc_type, DR_STR_MAX, "%s", drc->type); 160 | } 161 | 162 | struct dr_connector *get_drc_info(const char *); 163 | void free_drc_info(void); 164 | 165 | char *of_to_full_path(const char *); 166 | 167 | /* Search types for search_drc_list() */ 168 | #define DRC_NAME 0 169 | #define DRC_TYPE 1 170 | #define DRC_INDEX 2 171 | #define DRC_POWERDOMAIN 3 172 | 173 | struct dr_connector *search_drc_list(struct dr_connector *, 174 | struct dr_connector *, int, void *); 175 | 176 | int get_my_drc_index(char *, uint32_t *); 177 | int get_my_partner_drc_index(struct dr_node *, uint32_t *); 178 | int drc_name_to_index(const char *, struct dr_connector *); 179 | char * drc_index_to_name(uint32_t, struct dr_connector *); 180 | int get_drc_by_name(char *, struct dr_connector *, char *, char *); 181 | int get_drc_by_index(uint32_t, struct dr_connector *, char *, char *); 182 | 183 | int get_min_common_depth(void); 184 | int get_assoc_arrays(const char *dir, struct assoc_arrays *aa, 185 | int min_common_depth); 186 | int of_associativity_to_node(const char *dir, int min_common_depth); 187 | int init_node(struct dr_node *); 188 | 189 | static inline int aa_index_to_node(struct assoc_arrays *aa, uint32_t aa_index) 190 | { 191 | if (aa_index < aa->n_arrays) 192 | return aa->min_array[aa_index]; 193 | return -1; 194 | } 195 | 196 | #endif /* _OFDT_H_ */ 197 | -------------------------------------------------------------------------------- /src/drmgr/options.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file options.c 3 | * 4 | * Copyright (C) IBM Corporation 2016 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | /* Global User Specifications */ 22 | enum drmgr_action usr_action = NONE; 23 | 24 | /* the init routines may need to know this to enable all features */ 25 | int display_capabilities = 0; 26 | 27 | /* default is to do slot identification, unless the drmgr -I 28 | * option is specified. 29 | */ 30 | int usr_slot_identification = 1; 31 | 32 | /* timeout specified with the -w option */ 33 | int usr_timeout = 0; 34 | 35 | /* user specified drc name */ 36 | char *usr_drc_name = NULL; 37 | 38 | /* user specified drc index */ 39 | uint32_t usr_drc_index = 0; 40 | 41 | /* default to prompting the user for pci hotplug operations 42 | * unless the drmgr -n option is specified. 43 | */ 44 | int usr_prompt = 1; 45 | 46 | /* user-specified quantity of devices to add/remove */ 47 | /* user-specified quantity of accelerator QoS credits to assign */ 48 | int usr_drc_count = 0; 49 | 50 | /* user specified drc type to use */ 51 | enum drc_type usr_drc_type = DRC_TYPE_NONE; 52 | 53 | /* user specified -p option, meaning varies depending on usr_drc_type */ 54 | char *usr_p_option = NULL; 55 | 56 | /* 57 | * user specified -t option, meaning varies depending on usr_drc_type 58 | * Used only for DRC_TYPE_ACCT right now to pass accelerator type 59 | * such as gzip 60 | */ 61 | char *usr_t_option = NULL; 62 | 63 | /* user specified workaround for qemu pci dlpar */ 64 | int pci_virtio = 0; 65 | 66 | /* user specified file for handling prrn events */ 67 | char *prrn_filename = NULL; 68 | 69 | /* perform hotplug only operation */ 70 | int pci_hotplug_only = 0; 71 | 72 | /* lsslot specific options */ 73 | int show_available_slots = 0; 74 | int show_cpus_and_caches = 0; 75 | int show_occupied_slots = 0; 76 | int show_caches = 0; 77 | char *usr_delimiter = NULL; 78 | -------------------------------------------------------------------------------- /src/drmgr/prrn.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 International Business Machines 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "dr.h" 23 | #include "drmem.h" 24 | #include "drcpu.h" 25 | 26 | int handle_prrn(void) 27 | { 28 | char fmt_drc[11]; 29 | char type[4]; 30 | char drc[9]; 31 | int rc = 0; 32 | FILE *fd; 33 | 34 | fd = fopen(prrn_filename, "r"); 35 | if (!fd) { 36 | say(ERROR, "Failed to open the file %s\n", prrn_filename); 37 | return -1; 38 | } 39 | 40 | set_output_level(4); 41 | 42 | while (fscanf(fd, "%3s %8s\n", type, drc) == 2) { 43 | usr_drc_type = to_drc_type(type); 44 | sprintf(fmt_drc, "0x%s", drc); 45 | usr_drc_name = fmt_drc; 46 | 47 | set_timeout(PRRN_TIMEOUT); 48 | 49 | if (!strcmp(type, "mem")) { 50 | usr_action = REMOVE; 51 | rc = drslot_chrp_mem(); 52 | if (rc) 53 | continue; 54 | 55 | usr_action = ADD; 56 | drslot_chrp_mem(); 57 | } else if (!strcmp(type, "cpu")) { 58 | usr_action = REMOVE; 59 | rc = drslot_chrp_cpu(); 60 | if (rc) 61 | continue; 62 | 63 | usr_action = ADD; 64 | drslot_chrp_cpu(); 65 | } else { 66 | say(ERROR, "Device type \"%s\" not recognized.\n", 67 | type); 68 | continue; 69 | } 70 | } 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /src/drmgr/rtas_calls.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtas_calls.h 3 | * 4 | * Copyright (C) IBM Corporation 2006 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef _RTAS_CALLS_H_ 22 | #define _RTAS_CALLS_H_ 23 | 24 | #include 25 | #include "drpci.h" 26 | 27 | /* The following definitions are used in the interfaces to various 28 | * subroutines. 29 | */ 30 | 31 | /* Indicators for rtas_set_indicator */ 32 | #define ISOLATION_STATE 9001 /* value for isolation-state */ 33 | #define DR_INDICATOR 9002 /* value for dr-indicator */ 34 | #define ALLOCATION_STATE 9003 /* value for allocation-state */ 35 | 36 | /* Error status from rtas_set_indicator */ 37 | #define HARDWARE_ERROR -1 38 | #define HARDWARE_BUSY -2 39 | #define NO_INDICATOR -3 40 | #define MULTI_LEVEL_ISO_ERROR -9000 41 | #define VALID_TRANSLATION -9001 42 | 43 | /* Error status from dr-entity-sense(get-sensor-state) */ 44 | #define NEED_POWER -9000 /* Need to turn on power to slot */ 45 | #define PWR_ONLY -9001 /* Power on slot, leave isolated */ 46 | 47 | /* Sensor values from dr-entity-sense(get-sensor-state) */ 48 | #define EMPTY 0 /* No card in slot */ 49 | #define PRESENT 1 /* Card in slot */ 50 | #define STATE_UNUSABLE 2 /* No DR operation will succeed */ 51 | #define EXCHANGE 3 /* resource unlicensed, for sparing only */ 52 | #define RECOVERY 4 /* can be recovered by platform */ 53 | 54 | /* Return status from configure-connector */ 55 | #define NOT_THIS_SYSTEM -9001 /* DR entity not supported on this system */ 56 | #define NOT_THIS_SLOT -9002 /* DR entity not supported in this slot */ 57 | #define DR_UNUSABLE -9003 /* Logical DR connector unusable */ 58 | 59 | /* Return status from ibm,suspend_me */ 60 | #define NOT_SUSPENDABLE -9004 61 | #define MULTIPLE_THREADS -9005 62 | 63 | /* State values for set-indicator dr-indicator */ 64 | #define LED_OFF 0 65 | #define LED_ON 1 66 | #define LED_ID 2 67 | #define LED_ACTION 3 68 | 69 | /* State values for isolation-state */ 70 | #define ISOLATE 0 71 | #define UNISOLATE 1 72 | 73 | /* Level values for set-power-level */ 74 | #define POWER_OFF 0 75 | #define POWER_ON 100 76 | 77 | /* State values for allocation-state */ 78 | #define ALLOC_UNUSABLE 0 /* Release Unusable Resource to FW */ 79 | #define ALLOC_USABLE 1 /* Assign Usable Resource from FW */ 80 | 81 | /* Tokens for RTAS calls */ 82 | #define DR_ENTITY_SENSE 9003 /* token value for dr-entity-sense */ 83 | 84 | /* Return status from configure-connector */ 85 | #define NEXT_SIB 1 /* Next sibling */ 86 | #define NEXT_CHILD 2 /* Next child */ 87 | #define NEXT_PROPERTY 3 /* Next property */ 88 | #define PREV_PARENT 4 /* Previous parent */ 89 | #define MORE_MEMORY 5 /* Need more memory */ 90 | #define ERR_CFG_USE -9003 /* DR connector unusable */ 91 | 92 | struct of_property { 93 | struct of_property *next; /* Ptr to next property for node */ 94 | char *name; /* OF property name */ 95 | int length; /* Length of property value in bytes */ 96 | char *value; /* Pointer to property value */ 97 | }; 98 | 99 | struct of_node { 100 | char *name; /* Node name including unit address */ 101 | struct of_property *properties; /* Pointer to OF properties */ 102 | struct of_node *parent; /* Pointer to parent node */ 103 | struct of_node *sibling; /* Pointer to next sibling node */ 104 | struct of_node *child; /* Pointer to first child node */ 105 | int added; 106 | }; 107 | 108 | extern char *hw_error; 109 | 110 | int dr_entity_sense(int index); 111 | struct of_node *configure_connector(int index); 112 | int set_power(int domain, int level); 113 | int acquire_drc(uint32_t); 114 | int release_drc(int, uint32_t); 115 | struct of_node *configure_connector(int); 116 | 117 | #endif /* _RTAS_CALLS_H_ */ 118 | -------------------------------------------------------------------------------- /src/errinjct/dcache.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dcache.c 3 | * @author Nathan Fontenot 4 | * @author Linas Vepstas 5 | * 6 | * @brief Inject corrupted-dcache-start and corrupted-dcache-end errors 7 | * 8 | * Copyright (c) 2004 IBM Corporation 9 | * 10 | * This program is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * as published by the Free Software Foundation; either version 2 13 | * of the License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "errinjct.h" 32 | 33 | /** 34 | * @var action 35 | * @brief action code for the corrupted D-cache error injection 36 | */ 37 | static int action = -1; 38 | 39 | /** 40 | * @var action_codes 41 | * @brief descriptions of the corrupted D-cache action codes 42 | */ 43 | static char *action_codes[] = { 44 | "parity error", 45 | "D-ERAT parity error", 46 | "tag parity error" 47 | }; 48 | #define MAX_DCACHE_ACTION_CODE 2 49 | 50 | /** 51 | * corrupted_dcache_usage 52 | * @brief print the "corrupted D-cache" error injection usage statement 53 | * 54 | * @param ei_func errinjct functionality 55 | */ 56 | static void corrupted_dcache_usage(ei_function *ei_func) 57 | { 58 | int i; 59 | 60 | printf("Usage: %s %s [OPTIONS]\n", progname, ei_func->name); 61 | printf(" %s %s [OPTIONS]\n", progname, ei_func->alt_name); 62 | printf("%s\n\n", ei_func->desc); 63 | 64 | printf("Mandatory arguments:\n"); 65 | printf(HELP_FMT, "-a action", "type of D-cache error to inject"); 66 | for (i = 0; i <= MAX_DCACHE_ACTION_CODE; i++) 67 | printf("%22d: %s\n", i, action_codes[i]); 68 | 69 | print_cpu_arg(); 70 | print_token_arg(); 71 | 72 | print_optional_args(); 73 | } 74 | 75 | /** 76 | * corrupted_dcache_arg 77 | * @brief check for "corrupted D-cache arg" cmdline args 78 | * 79 | * @param arg cmdline arg 80 | * @param optarg optional cmdline argument to 'arg' 81 | * @return 0 - indicates this is a corrupted dcache arg 82 | * @return 1 - indicates this is _not_ a corrupted dcache arg 83 | */ 84 | int corrupted_dcache_arg(char arg, char *optarg) 85 | { 86 | if (arg == 'a') { 87 | action = atoi(optarg); 88 | return 0; 89 | } 90 | 91 | return 1; 92 | } 93 | 94 | /** 95 | * corrupted_dcache 96 | * @brief "corrupted D-cache" error injection handler 97 | * 98 | * This will inject a corrupted D-cache error onto the system 99 | * 100 | * @param ei_func errinjct functionality 101 | * @return 0 on success, !0 otherwise 102 | */ 103 | int corrupted_dcache(ei_function *ei_func) 104 | { 105 | int rc; 106 | 107 | if (ext_help || check_cpu_arg() || check_token_arg()) { 108 | corrupted_dcache_usage(ei_func); 109 | return 1; 110 | } 111 | 112 | if ((action < 0) || (action > MAX_DCACHE_ACTION_CODE)) { 113 | perr(0, "Invalid action code (%d)", action); 114 | corrupted_dcache_usage(ei_func); 115 | return 1; 116 | } 117 | 118 | if (!be_quiet) { 119 | printf("Injecting a %s error\n", ei_func->name); 120 | printf("Action: %d - %s\n", action, action_codes[action]); 121 | } 122 | 123 | if (dryrun) 124 | return 0; 125 | 126 | err_buf[0] = action; 127 | 128 | rc = do_rtas_errinjct(ei_func); 129 | 130 | return rc; 131 | } 132 | -------------------------------------------------------------------------------- /src/errinjct/errinjct.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file errinjct.h 3 | * @brief Hardware Error Injection Tool main 4 | * @author Nathan Fontenot 5 | * 6 | * This program can be used to simulate hardware error events. 7 | * It uses librtas to inject artificial errors into the system. 8 | * 9 | * Copyright (c) 2004 IBM Corporation 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | #ifndef _ERRINJCT_H 27 | #define _ERRINJCT_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | extern int verbose; /**< verbose flag specified? */ 34 | extern int dryrun; /**< Are we doing a dry run */ 35 | extern int ei_token; /**< error injection token */ 36 | extern int logical_cpu; /**< logical cpu to bind to */ 37 | extern int ext_help; /**< print the extended help message */ 38 | extern int be_quiet; /**< Shhh... don't say anything */ 39 | 40 | extern char *progname; /**< argv[0] */ 41 | 42 | #define EI_BUFSZ 1024 43 | extern uint err_buf[]; /**< buffer for RTAS call args */ 44 | /** 45 | * struct ei_function 46 | * @brief description of an error injection capabilty 47 | * 48 | * For each erro injection capability we maintain an ei_function 49 | * structure to define the capability. 50 | */ 51 | typedef struct ei_function_s { 52 | /*cmdline name*/ 53 | char *name; 54 | /*alternate cmdline name*/ 55 | char *alt_name; 56 | /*brief description of the capability*/ 57 | char *desc; 58 | /*RTAS token for this capability*/ 59 | int rtas_token; 60 | /*arg function*/ 61 | int (*arg)(char, char *); 62 | /*capability function handler*/ 63 | int (*func)(struct ei_function_s *); 64 | } ei_function; 65 | 66 | /* Error inject open functions (errinjct.c) */ 67 | int ei_open(ei_function *); 68 | int ei_open_arg(char, char *); 69 | 70 | /* Error inject close functions (errinjct.c) */ 71 | int ei_close(ei_function *); 72 | int ei_close_arg(char, char *); 73 | 74 | /* D-cache functions (dcache.c) */ 75 | int corrupted_dcache(ei_function *); 76 | int corrupted_dcache_arg(char, char *); 77 | 78 | /* I-cache functions (icache.c) */ 79 | int corrupted_icache(ei_function *); 80 | int corrupted_icache_arg(char, char *); 81 | 82 | /* Corrupted SLB functions (slb.c) */ 83 | int corrupted_slb(ei_function *); 84 | int corrupted_slb_arg(char, char *); 85 | 86 | /* Corrupted TLB functions (tlb.c) */ 87 | int corrupted_tlb(ei_function *); 88 | int corrupted_tlb_arg(char, char *); 89 | 90 | /* IOA Bus Error (EEH) (ioa_bus_error.c) */ 91 | int ioa_bus_error32(ei_function *); 92 | int ioa_bus_error64(ei_function *); 93 | int ioa_bus_error_arg(char, char *); 94 | 95 | /* Platform Specific (platform.c) */ 96 | int platform_specific(ei_function *); 97 | int platform_specific_arg(char, char *); 98 | 99 | #define NUM_ERRINJCT_FUNCS 17 100 | 101 | /* errinjct.c */ 102 | int do_rtas_errinjct(ei_function *); 103 | void print_optional_args(void); 104 | void print_cpu_arg(void); 105 | int check_cpu_arg(void); 106 | void print_token_arg(void); 107 | int check_token_arg(void); 108 | void perr(int, const char *, ...); 109 | int open_rtas_errinjct(ei_function *); 110 | int close_rtas_errinjct(ei_function *); 111 | int sysfs_check(void); 112 | char *read_file(const char *, int *); 113 | 114 | #define HELP_FMT " %-15s%s\n" /**< common help format */ 115 | 116 | #endif /* _ERRINJCT_H */ 117 | -------------------------------------------------------------------------------- /src/errinjct/icache.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file icache.c 3 | * @brief Hardware Error Injection Tool I-cache module 4 | * @author Nathan Fontenot 5 | * @author Linas Vepstas 6 | * 7 | * Inject corrupted-icache-start and corrupted-icache-end errors. 8 | * 9 | * Copyright (c) 2004 IBM Corporation 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "errinjct.h" 33 | 34 | /** 35 | * @var action 36 | * @brief action code for I-cache error injections 37 | */ 38 | static int action = -1; 39 | /** 40 | * @var nature 41 | * @brief nature of I-cache error injection 42 | */ 43 | static int nature = -1; 44 | 45 | /** 46 | * @var action_codes 47 | * @brief descriptions of the I-cache actions codes 48 | */ 49 | static char *action_codes[] = { 50 | "Parity error", 51 | "I-ERAT partiy error", 52 | "Cache directory 0 parity error", 53 | "Cache directory 1 parity error" 54 | }; 55 | #define MAX_ICACHE_ACTION_CODE 3 56 | 57 | /** 58 | * @var nature_codes 59 | * @brief descriptions of the I-cache nature codes 60 | */ 61 | static char *nature_codes[] = { "Single", "Solid", "Hang" }; 62 | #define MAX_ICACHE_NATURE_CODE 2 63 | 64 | /** 65 | * corrupted_icache_usage 66 | * @brief Print the "corrupted I-cache" error injection usage statement 67 | * 68 | * @param ei_func errinjct functionality 69 | */ 70 | static void corrupted_icache_usage(ei_function *ei_func) 71 | { 72 | int i; 73 | 74 | printf("Usage: %s %s [OPTIONS]\n", progname, ei_func->name); 75 | printf(" %s %s [OPTIONS]\n", progname, ei_func->alt_name); 76 | printf("%s\n\n", ei_func->desc); 77 | 78 | printf("Mandatory Arguments:\n"); 79 | printf(HELP_FMT, "-a action", "type of I-cache error to inject"); 80 | for (i = 0; i <= MAX_ICACHE_ACTION_CODE; i++) 81 | printf("%22d: %s\n", i, action_codes[i]); 82 | printf(HELP_FMT, "-n nature", "nature of I-cache error to inject"); 83 | for (i = 0; i <= MAX_ICACHE_NATURE_CODE; i++) 84 | printf("%22d: %s\n", i, nature_codes[i]); 85 | 86 | print_cpu_arg(); 87 | print_token_arg(); 88 | 89 | print_optional_args(); 90 | } 91 | 92 | /** 93 | * corrupted_icache_arg 94 | * @brief check for "corruptred I-cache" cmdline args 95 | * 96 | * @param arg cmdline arg to check 97 | * @param optarg optional cmdline argument to 'arg' 98 | * @return 1 - indicates this is a corrupted I-cache arg 99 | * @return 0 - indicates this is not a corrupted I-cache arg 100 | */ 101 | int corrupted_icache_arg(char arg, char *optarg) 102 | { 103 | switch (arg) { 104 | case 'a': 105 | action = atoi(optarg); 106 | break; 107 | case 'n': 108 | nature = atoi(optarg); 109 | break; 110 | default: 111 | return 1; 112 | } 113 | 114 | return 0; 115 | } 116 | 117 | /** 118 | * corrupted_icache 119 | * @brief "corrupted I-cache" error injection handler 120 | * 121 | * @param ei_func errinjct functionality 122 | * @return 0 on success, !0 otherwise 123 | */ 124 | int corrupted_icache(ei_function *ei_func) 125 | { 126 | int rc; 127 | 128 | if (ext_help || check_cpu_arg() || check_token_arg()) { 129 | corrupted_icache_usage(ei_func); 130 | return 1; 131 | } 132 | 133 | if ((action < 0) || (action > 3)) { 134 | perr(0, "Invalid action code (%d)", action); 135 | corrupted_icache_usage(ei_func); 136 | return 1; 137 | } 138 | 139 | if ((nature < 0) || (nature > 2)) { 140 | perr(0, "Invalid nature code (%d)", nature); 141 | corrupted_icache_usage(ei_func); 142 | return 1; 143 | } 144 | 145 | err_buf[0] = action; 146 | err_buf[1] = nature; 147 | 148 | if (!be_quiet) { 149 | printf("Injecting a %s error\n", ei_func->name); 150 | printf("Action: %d - %s\n", action, action_codes[action]); 151 | printf("Nature: %d - %s\n", nature, nature_codes[nature]); 152 | } 153 | 154 | if (dryrun) 155 | return 0; 156 | 157 | rc = do_rtas_errinjct(ei_func); 158 | 159 | return rc; 160 | } 161 | -------------------------------------------------------------------------------- /src/errinjct/open_close.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file open_close.c 3 | * @brief Hardware error injection tool - open/close module 4 | * @author Nathan Fontenot 5 | * @author Linas Vepstas 6 | * 7 | * Open and close the RTAS error injection facitlity 8 | * 9 | * Copyright (c) 2004 IBM Corporation 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | #include 27 | #include "errinjct.h" 28 | 29 | /** 30 | * ei_open_usage 31 | * @brief print the "open" error injection usage statement 32 | * 33 | * @param ei_func errinjct functionality 34 | */ 35 | static void ei_open_usage(ei_function *ei_func) 36 | { 37 | printf("Usage: %s %s\n", progname, ei_func->name); 38 | printf("%s\n\n", ei_func->desc); 39 | 40 | print_optional_args(); 41 | } 42 | 43 | /** 44 | * ei_open_arg 45 | * @brief check for "open" cmdline arg 46 | * 47 | * There are no additional args to open, return failure 48 | * 49 | * @param arg cmdline arg to check 50 | * @param optarg optional cmdline argument to 'arg' 51 | * @return 1, always 52 | */ 53 | int ei_open_arg(char arg, char *optarg) 54 | { 55 | return 1; 56 | } 57 | 58 | /** 59 | * ei_open 60 | * @brief "open" error injection handler 61 | * 62 | * @param ei_func pointer to errinjct functionality 63 | * @return 0 on success, !0 otherwise 64 | */ 65 | int ei_open(ei_function *ei_func) 66 | { 67 | int rc; 68 | 69 | if (ext_help) { 70 | ei_open_usage(ei_func); 71 | return 1; 72 | } 73 | 74 | if (verbose || dryrun) 75 | printf("Opening RTAS error injection facility\n"); 76 | 77 | if (dryrun) 78 | return 0; 79 | 80 | rc = open_rtas_errinjct(ei_func); 81 | 82 | if (rc == 0) 83 | printf("RTAS error injection facility open, token = %d\n", 84 | ei_token); 85 | 86 | return rc; 87 | } 88 | 89 | /** 90 | * ei_close_usage 91 | * @brief Print the "close" usage statement error injection 92 | * 93 | * @param ei_func pointer to errinjct functionality 94 | */ 95 | static void ei_close_usage(ei_function *ei_func) 96 | { 97 | printf("Usage: %s %s\n", progname, ei_func->name); 98 | printf("%s\n\n", ei_func->desc); 99 | 100 | printf("Mandatory argument:\n"); 101 | print_token_arg(); 102 | 103 | print_optional_args(); 104 | print_cpu_arg(); 105 | } 106 | 107 | /** 108 | * ei_close_arg 109 | * @brief check for "close" specific cmdline args 110 | * 111 | * The errinjct close functionality does not take any additional 112 | * args, always return 1 (failure). 113 | * 114 | * @param arg cmdline arg to check 115 | * @param optarg optional cmdline argument to 'arg' 116 | * @return 1, always 117 | */ 118 | int ei_close_arg(char arg, char *optarg) 119 | { 120 | return 1; 121 | } 122 | 123 | /** 124 | * ei_close 125 | * @brief Closes the RTAS error injection facility 126 | * 127 | * @param ei_func errinjct functionality 128 | * @return 0 on success, !0 otherwise 129 | */ 130 | int ei_close(ei_function *ei_func) 131 | { 132 | int rc; 133 | 134 | if (ext_help || check_token_arg()) { 135 | ei_close_usage(ei_func); 136 | return 1; 137 | } 138 | 139 | if (verbose || dryrun) 140 | printf("Closing RTAS error injection facility with token %d\n", 141 | ei_token); 142 | 143 | if (dryrun) 144 | return 0; 145 | 146 | rc = close_rtas_errinjct(ei_func); 147 | 148 | if ((rc == 0) && verbose) 149 | printf("RTAS error injection facility closed.\n"); 150 | 151 | return rc; 152 | } 153 | -------------------------------------------------------------------------------- /src/errinjct/platform.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file platform.c 3 | * @brief Hardware Error Injection Tool platform specific module 4 | * @author Nathan Fontenot 5 | * @author Linas Vepstas 6 | * 7 | * Inject platform-specific errors. 8 | * 9 | * Copyright (c) 2004 IBM Corporation 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "errinjct.h" 34 | 35 | /** 36 | * @var fname 37 | * @brief file containg platform specific error injection data 38 | */ 39 | static char *fname; 40 | 41 | /** 42 | * platform_specific_usage 43 | * @brief print the "platform specific" error injection usage message 44 | * 45 | * @param ei_func errinjct functionality 46 | */ 47 | static void platform_specific_usage(ei_function *ei_func) 48 | { 49 | printf("Usage: %s %s [OPTIONS]\n", progname, ei_func->name); 50 | printf("%s\n\n", ei_func->desc); 51 | printf("Mandatory argument:\n"); 52 | printf(HELP_FMT, "-f fname", "file name to read platform specific"); 53 | printf(HELP_FMT, "", "error injection data from"); 54 | 55 | print_optional_args(); 56 | print_cpu_arg(); 57 | print_token_arg(); 58 | } 59 | 60 | /** 61 | * platform_specific_arg 62 | * @brief check for "platform specific" cmdline args 63 | * 64 | * @param arg cmdline arg to check 65 | * @param optarg optional cmdline argument to 'arg' 66 | * @return 0 - indicates this is a platform specific arg 67 | * @return 1 - indicates this is not a platform specific arg 68 | */ 69 | int platform_specific_arg(char arg, char *optarg) 70 | { 71 | switch (arg) { 72 | case 'f': 73 | fname = optarg; 74 | break; 75 | default: 76 | return 1; 77 | } 78 | 79 | return 0; 80 | } 81 | 82 | /** 83 | * platform_specific 84 | * @brief "platform specific" error injection handler 85 | * 86 | * @param ei_func errinjct functionality 87 | * @return 0 on success, !0 otherwise 88 | */ 89 | int platform_specific(ei_function *ei_func) 90 | { 91 | char *buf; 92 | int rc; 93 | 94 | if (ext_help) { 95 | platform_specific_usage(ei_func); 96 | return 1; 97 | } 98 | 99 | if (fname == NULL) { 100 | perr(0, "Please specify a file with the -f option"); 101 | platform_specific_usage(ei_func); 102 | return 1; 103 | } 104 | 105 | buf = read_file(fname, NULL); 106 | if (!buf) 107 | return 1; 108 | 109 | if (!be_quiet) 110 | printf("Injecting a %s error with data from %s\n", 111 | ei_func->name, fname); 112 | 113 | if (dryrun) { 114 | free(buf); 115 | return 0; 116 | } 117 | 118 | rc = do_rtas_errinjct(ei_func); 119 | 120 | free(buf); 121 | return rc; 122 | } 123 | -------------------------------------------------------------------------------- /src/errinjct/slb.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file slb.c 3 | * @brief Hardware Error Injection Tool slb module 4 | * @author Nathan Fontenot 5 | * @author Linas Vepstas 6 | * 7 | * Inject SLB errors. 8 | * 9 | * Copyright (c) 2004 IBM Corporation 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "errinjct.h" 33 | 34 | static unsigned long addr; /**< address at which to inject the error */ 35 | static int addr_flag; /**< indicates the address flag has been 36 | * specified */ 37 | 38 | /** 39 | * corrupted_slb_usage 40 | * @brief print the "corrupted slb" error inject usage message 41 | * 42 | * @param ei_func errinjct functionality 43 | */ 44 | static void corrupted_slb_usage(ei_function *ei_func) 45 | { 46 | printf("Usage: %s %s [OPTIONS]\n", progname, ei_func->name); 47 | printf(" %s %s [OPTIONS]\n", progname, ei_func->alt_name); 48 | printf("%s\n\n", ei_func->desc); 49 | printf("Mandatory Argument:\n"); 50 | printf(HELP_FMT, "-a addr", "effective address associated with the"); 51 | printf(HELP_FMT, "", "SLB entry to corrupt\n"); 52 | 53 | print_optional_args(); 54 | print_cpu_arg(); 55 | print_token_arg(); 56 | } 57 | 58 | /** 59 | * corrupted_alb_arg 60 | * @brief check for "corrupted alb" specific cmdline args 61 | * 62 | * @param arg cmdline arg to check 63 | * @param optarg optional argument to 'arg' 64 | * @return 0 - indicates this is a "corrupted slb" cmdline arg 65 | * @return 1 - indicates this is not a "corrupted slb" cmdline arg 66 | */ 67 | int corrupted_slb_arg(char arg, char *optarg) 68 | { 69 | switch (arg) { 70 | case 'a': 71 | addr = strtoul(optarg, NULL, 16); 72 | addr_flag = 1; 73 | break; 74 | default: 75 | return 1; 76 | } 77 | 78 | return 0; 79 | } 80 | 81 | /** 82 | * corrupted_slb 83 | * @brief "corrupted slb" error injection handler 84 | * 85 | * @param ei_func errinjct functionality 86 | * @return 0 on success, !0 otherwise 87 | */ 88 | int corrupted_slb(ei_function *ei_func) 89 | { 90 | int rc; 91 | 92 | if (ext_help) { 93 | corrupted_slb_usage(ei_func); 94 | return 1; 95 | } 96 | 97 | if (addr_flag == 0) { 98 | perr(0, "Please specify an address with the -a option"); 99 | corrupted_slb_usage(ei_func); 100 | return 1; 101 | } 102 | 103 | if (!be_quiet) { 104 | printf("Injecting a %s error\n", ei_func->name); 105 | printf("Effective address = 0x%lx\n", addr); 106 | } 107 | 108 | if (dryrun) 109 | return 0; 110 | 111 | err_buf[0] = addr; 112 | 113 | rc = do_rtas_errinjct(ei_func); 114 | 115 | return rc; 116 | } 117 | -------------------------------------------------------------------------------- /src/errinjct/tlb.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tlb.c 3 | * @brief Hardware Error Injection Tool TLB module 4 | * @author Nathan Fontenot 5 | * @author Linas Vepstas 6 | * 7 | * Inject corrupted-tlb-start and corrupted-tlb-end errors. 8 | * 9 | * Copyright (c) 2004 IBM Corporation 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation; either version 2 14 | * of the License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | #include 27 | #include "errinjct.h" 28 | 29 | /** 30 | * corrupted_tlb_usage 31 | * @brief print the "corrupted tlb" error injection usage message 32 | * 33 | * @param ei_func errinjct functionality 34 | */ 35 | static void corrupted_tlb_usage(ei_function *ei_func) 36 | { 37 | printf("Usage: %s %s\n", progname, ei_func->name); 38 | printf(" %s %s\n", progname, ei_func->alt_name); 39 | printf("%s\n\n", ei_func->desc); 40 | 41 | printf("Mandatory arguments:\n"); 42 | print_cpu_arg(); 43 | print_token_arg(); 44 | 45 | print_optional_args(); 46 | } 47 | 48 | /** 49 | * corrupted_tlb_arg 50 | * @brief check for "corrupted tlb" specific cmdline args 51 | * 52 | * There are no additional args to "corrupted tlb" error injections, 53 | * thus we always return 1 (failure) 54 | * 55 | * @param arg cmdline arg to check 56 | * @param optarg optional argument to 'arg' 57 | * @return 1, always 58 | */ 59 | int corrupted_tlb_arg(char arg, char *optarg) 60 | { 61 | return 1; 62 | } 63 | 64 | /** 65 | * corrupted_tlb 66 | * @brief "corrupted tlb" error injection handler 67 | * 68 | * @param ei_func errinjct functionality 69 | * @return 0 on success, !0 otherwise 70 | */ 71 | int corrupted_tlb(ei_function *ei_func) 72 | { 73 | int rc; 74 | 75 | if (ext_help || check_cpu_arg() || check_token_arg()) { 76 | corrupted_tlb_usage(ei_func); 77 | return 1; 78 | } 79 | 80 | if (!be_quiet) { 81 | printf("Injecting a %s error on cpu %d\n", ei_func->name, 82 | logical_cpu); 83 | } 84 | 85 | if (dryrun) 86 | return 0; 87 | 88 | rc = do_rtas_errinjct(ei_func); 89 | 90 | return rc; 91 | } 92 | -------------------------------------------------------------------------------- /src/lsprop.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1998 Paul Mackerras. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #if defined(__FreeBSD__) 27 | #include 28 | #else 29 | #include 30 | #endif 31 | 32 | int recurse; 33 | int maxbytes = 128; 34 | int words_per_line = 0; 35 | unsigned char *buf; 36 | 37 | void lsprop(FILE *f, char *name); 38 | void lsdir(char *name); 39 | 40 | static struct option long_opts[] = { 41 | {"version", no_argument, NULL, 'V'}, 42 | {"recurse", no_argument, NULL, 'R'}, 43 | {0, 0, 0, 0}, 44 | }; 45 | 46 | int main(int ac, char **av) 47 | { 48 | FILE *f; 49 | int i, opt_index = 0; 50 | struct stat sb; 51 | char *endp; 52 | 53 | while ((i = getopt_long(ac, av, "Rm:w:V", 54 | long_opts, &opt_index)) != EOF) { 55 | switch (i) { 56 | case 'R': 57 | recurse = 1; 58 | break; 59 | case 'm': 60 | maxbytes = strtol(optarg, &endp, 0); 61 | if (endp == optarg) { 62 | fprintf(stderr, "%s: bad argument (%s) to -m option\n", av[0], 63 | optarg); 64 | exit(1); 65 | } 66 | maxbytes = (maxbytes + 15) & -16; 67 | break; 68 | case 'w': 69 | words_per_line = strtol(optarg, &endp, 0); 70 | if (endp == optarg) { 71 | fprintf(stderr, "%s: bad argument (%s) to -w option\n", 72 | av[0], optarg); 73 | exit(1); 74 | } 75 | break; 76 | case 'V': 77 | printf("lsprop - %s\n", VERSION); 78 | return 0; 79 | } 80 | } 81 | 82 | buf = malloc(maxbytes); 83 | if (buf == 0) { 84 | fprintf(stderr, "%s: virtual memory exhausted\n", av[0]); 85 | exit(1); 86 | } 87 | 88 | if (optind == ac) 89 | lsdir("."); 90 | else 91 | for (i = optind; i < ac; ++i) { 92 | if (stat(av[i], &sb) < 0) { 93 | perror(av[i]); 94 | continue; 95 | } 96 | if (S_ISREG(sb.st_mode)) { 97 | f = fopen(av[i], "r"); 98 | if (f == NULL) { 99 | perror(av[i]); 100 | continue; 101 | } 102 | lsprop(f, av[i]); 103 | fclose(f); 104 | } else if (S_ISDIR(sb.st_mode)) { 105 | lsdir(av[i]); 106 | } 107 | } 108 | exit(0); 109 | } 110 | 111 | void lsdir(char *name) 112 | { 113 | DIR *d; 114 | struct dirent *de; 115 | char *p, *q; 116 | struct stat sb; 117 | FILE *f; 118 | int np = 0; 119 | 120 | d = opendir(name); 121 | if (d == NULL) { 122 | perror(name); 123 | return; 124 | } 125 | 126 | p = malloc(strlen(name) + 520); 127 | if (p == 0) { 128 | fprintf(stderr, "%s: virtual memory exhausted\n", name); 129 | closedir(d); 130 | return; 131 | } 132 | strcpy(p, name); 133 | q = p + strlen(p); 134 | while (q > p && q[-1] == '/') 135 | --q; 136 | if (q == p + 1 && p[0] == '.') 137 | q = p; 138 | else 139 | *q++ = '/'; 140 | 141 | while ((de = readdir(d)) != NULL) { 142 | if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) 143 | continue; 144 | strcpy(q, de->d_name); 145 | if (stat(p, &sb) < 0) { 146 | perror(p); 147 | continue; 148 | } 149 | if (S_ISREG(sb.st_mode)) { 150 | f = fopen(p, "r"); 151 | if (f == NULL) { 152 | perror(p); 153 | } else { 154 | lsprop(f, de->d_name); 155 | fclose(f); 156 | ++np; 157 | } 158 | } 159 | } 160 | 161 | if (recurse) { 162 | rewinddir(d); 163 | while ((de = readdir(d)) != NULL) { 164 | if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) 165 | continue; 166 | strcpy(q, de->d_name); 167 | if (lstat(p, &sb) < 0) { 168 | perror(p); 169 | continue; 170 | } 171 | if (S_ISDIR(sb.st_mode)) { 172 | if (np) 173 | printf("\n"); 174 | printf("%s:\n", p); 175 | lsdir(p); 176 | ++np; 177 | } 178 | } 179 | } 180 | free(p); 181 | closedir(d); 182 | } 183 | 184 | void lsprop(FILE *f, char *name) 185 | { 186 | int n, nw, npl, i, j; 187 | 188 | n = fread(buf, 1, maxbytes, f); 189 | if (n < 0) { 190 | printf("%s: read error\n", name); 191 | return; 192 | } 193 | printf("%-16s", name); 194 | if (strlen(name) > 16) 195 | printf("\n\t\t"); 196 | for (i = 0; i < n; ++i) 197 | if (buf[i] >= 0x7f || 198 | (buf[i] < 0x20 && buf[i] != '\r' && buf[i] != '\n' 199 | && buf[i] != '\t' && buf[i] != 0)) 200 | break; 201 | if (i == n && n != 0 && (n == 1 || buf[0] != 0) && buf[n-1] == 0) { 202 | printf(" \""); 203 | for (i = 0; i < n - 1; ++i) 204 | if (buf[i] == 0) 205 | printf("\"\n\t\t \""); 206 | else if (buf[i] == '\r' || buf[i] == '\n') 207 | printf("\n\t\t "); 208 | else 209 | putchar(buf[i]); 210 | putchar('"'); 211 | } else if ((n & 3) == 0) { 212 | nw = n >> 2; 213 | if (nw == 1) { 214 | i = be32toh(*(int *)buf); 215 | printf(" %.8x", i); 216 | if (i > -0x10000 && !(i >= 0 && i <= 9)) 217 | printf(" (%d)", i); 218 | } else { 219 | npl = words_per_line; 220 | if (npl <= 0) { 221 | if ((nw % 6) == 0) 222 | npl = 6; 223 | else if ((nw % 5) == 0) 224 | npl = 5; 225 | else 226 | npl = 4; 227 | } 228 | for (i = 0; i < nw; i += npl) { 229 | if (i != 0) 230 | printf("\n\t\t"); 231 | for (j = 0; j < npl && i + j < nw; ++j) 232 | printf(" %.8x", be32toh(((unsigned int *)buf)[i+j])); 233 | } 234 | } 235 | } else { 236 | for (i = 0; i < n; i += 16) { 237 | if (i != 0) 238 | printf("\n\t\t"); 239 | for (j = 0; j < 16 && i + j < n; ++j) 240 | printf(" %.2x", buf[i+j]); 241 | for (; j < 16; ++j) 242 | printf(" "); 243 | for (j = 0; j < 16 && i + j < n; ++j) 244 | if (buf[i+j] > 0x20 && buf[i+j] <= 0x7e) 245 | putchar(buf[i+j]); 246 | else 247 | putchar('.'); 248 | } 249 | } 250 | printf("\n"); 251 | if (n == maxbytes) { 252 | while ((i = fread(buf, 1, maxbytes, f)) > 0) 253 | n += i; 254 | if (n > maxbytes) 255 | printf("\t\t [%d bytes total]\n", n); 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /src/nvram.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nvram.h 3 | * @brief nvram access utility for powerpc platforms. 4 | * 5 | * Copyright (c) 2003, 2004 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * @author Nathan Fontenot 22 | * @author Michael Strosaker 23 | * @author Todd Inglett 24 | */ 25 | 26 | #ifndef _DEV_NVRAM_H_ 27 | #define _DEV_NVRAM_H_ 28 | 29 | #define NVRAM_SIG_SP 0x02 /**< support processor signature */ 30 | #define NVRAM_SIG_OF 0x50 /**< open firmware config signature */ 31 | #define NVRAM_SIG_FW 0x51 /**< general firmware signature */ 32 | #define NVRAM_SIG_HW 0x52 /**< hardware (VPD) signature */ 33 | #define NVRAM_SIG_SYS 0x70 /**< system env vars signature */ 34 | #define NVRAM_SIG_CFG 0x71 /**< config data signature */ 35 | #define NVRAM_SIG_ELOG 0x72 /**< error log signature */ 36 | #define NVRAM_SIG_VEND 0x7e /**< vendor defined signature */ 37 | #define NVRAM_SIG_FREE 0x7f /**< Free space signature */ 38 | #define NVRAM_SIG_OS 0xa0 /**< OS defined signature */ 39 | 40 | /** 41 | * @def printmap(ch) 42 | * @brief dertermines if 'ch' is a printable character 43 | */ 44 | #define printmap(ch) (isgraph(ch) ? (ch) : '.') 45 | 46 | #define NVRAM_BLOCK_SIZE 16 47 | #define NVRAM_READ_SIZE 512 48 | #define NVRAM_FILENAME1 "/dev/nvram" 49 | #define NVRAM_FILENAME2 "/dev/misc/nvram" 50 | 51 | #define DEFAULT_NVRAM_SZ (1024 * 1024) 52 | #define OOPS_PARTITION_SZ 4000 53 | 54 | /** 55 | * @def MAX_CPUS 56 | * @brief maximum number of CPUS for errlog dumps 57 | */ 58 | #define MAX_CPUS 128 59 | 60 | /** 61 | * @def MAX_PART_NAME 62 | * @brief maximum number of bytes in partition name 63 | */ 64 | #define MAX_PART_NAME 12 65 | 66 | /** 67 | * @struct partition_header 68 | * @brief nvram partition header data 69 | */ 70 | struct partition_header { 71 | unsigned char signature; /**< partition signature */ 72 | unsigned char checksum; /**< partition checksum */ 73 | unsigned short length; /**< partition length */ 74 | char name[MAX_PART_NAME]; /**< partition name */ 75 | }; 76 | 77 | /* sub-header for error-log partitions */ 78 | struct err_log_info { 79 | int error_type; 80 | unsigned int seq_num; 81 | }; 82 | 83 | /* lnx,oops-log header */ 84 | struct oops_log_info { 85 | unsigned short version; 86 | unsigned short report_length; 87 | unsigned long long timestamp; 88 | }__attribute__((packed)); 89 | 90 | /* Internal representation of NVRAM. */ 91 | #define MAX_PARTITIONS 50 92 | /** 93 | * @struct nvram 94 | * @brief internal representation of nvram data 95 | */ 96 | struct nvram { 97 | char *filename; /**< original filename */ 98 | int fd; /**< file descriptor */ 99 | int nparts; /**< number of partitions */ 100 | int nbytes; /**< size of data in bytes. This 101 | * cannot be changed 102 | * (i.e. hardware size) 103 | */ 104 | struct partition_header *parts[MAX_PARTITIONS]; 105 | /**< partition header pointers 106 | * into data 107 | */ 108 | char *data; /**< nvram contents */ 109 | }; 110 | 111 | /** 112 | * @var descs 113 | * @brief Array of VPD field names and descriptions 114 | */ 115 | static struct { char *name; char *desc; } descs[] = { 116 | {"PN", "Part Number"}, 117 | {"FN", "FRU Number"}, 118 | {"EC", "EC Level"}, 119 | {"MN", "Manufacture ID"}, 120 | {"SN", "Serial Number"}, 121 | {"LI", "Load ID"}, 122 | {"RL", "ROM Level"}, 123 | {"RM", "Alterable ROM Level"}, 124 | {"NA", "Network Address"}, 125 | {"DD", "Device Driver Level"}, 126 | {"DG", "Diagnostic Level"}, 127 | {"LL", "Loadable Microcode Level"}, 128 | {"VI", "Vendor ID/Device ID"}, 129 | {"FU", "Function Number"}, 130 | {"SI", "Subsystem Vendor ID/Device ID"}, 131 | {"VK", "Platform"}, /**< "RS6K" => VPD is present */ 132 | {"TM", "Model"}, /**< IBM specific? */ 133 | {"YL", "Location Code"}, /**< IBM specific? */ 134 | {"BR", "Brand"}, /**< IBM specific */ 135 | {"CI", "CEC ID"}, /**< IBM specific */ 136 | {"RD", "Rack ID"}, /**< IBM specific */ 137 | {"PA", "Op Panel Installed"}, /**< IBM specific */ 138 | {"NN", "Node Name"}, /**< IBM specific */ 139 | }; 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /src/rtas_event_decode.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtas_event_decode.c 3 | * @brief decode RTAS event messages into human readable text 4 | * 5 | * Copyright (C) 2005 International Business Machines 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * @author Nathan Fonetenot 22 | * @author Jake Moilanen 23 | * 24 | * RTAS messages are placed in the syslog encoded in a binary 25 | * format, and are unreadable. This tool will take exactly one 26 | * message, parse it, and spit out the human-readable equivalent. 27 | * This program expects ascii data on stdin. 28 | * 29 | * This tool is mostly meant to be used in conjuction with the 30 | * 'rtas_dump' shell script, which provides a suitable user 31 | * interface. 32 | * 33 | * Bug fixes June 2004 by Linas Vepstas 34 | */ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "pseries_platform.h" 43 | 44 | #define RTAS_BUF_SIZE 3000 45 | #define RTAS_STR_SIZE 1024 46 | char rtas_buf[RTAS_BUF_SIZE]; 47 | 48 | /** 49 | * get_buffer 50 | * @brief read an RTAS event in from the specified input 51 | * 52 | * @param fh file to read RTAS event from 53 | * @param msgbuf buffer to write RTAS event into 54 | * @param buflen length of "msgbuf" 55 | * @return amount read into msgbuf 56 | */ 57 | int 58 | get_buffer(FILE *fh, char *msgbuf, size_t buflen) 59 | { 60 | char tmpbuf[RTAS_STR_SIZE]; 61 | unsigned int val; 62 | size_t j = 0; 63 | int high = 1; 64 | char *p, *line; 65 | 66 | memset(msgbuf, 0, buflen); 67 | 68 | line = fgets(tmpbuf, RTAS_STR_SIZE, fh); 69 | 70 | while (line) { 71 | /* Skip over any obviously busted input ... */ 72 | if (strstr (tmpbuf, "event begin")) goto next; 73 | if (strstr (tmpbuf, "eventbegin")) goto next; 74 | if (strstr (tmpbuf, "event end")) goto done; 75 | if (strstr (tmpbuf, "eventend")) goto done; 76 | 77 | /* Skip over the initial part of the line */ 78 | p = strstr (line, "RTAS"); 79 | if (p) 80 | p = strchr (p, ':'); 81 | else 82 | p = line; 83 | 84 | while (p && *p) { 85 | val = 0xff; 86 | 87 | if (*p >= '0' && *p <= '9') 88 | val = *p - '0'; 89 | else if (*p >= 'a' && *p <= 'f') 90 | val = *p - 'a' + 0xa; 91 | else if (*p >= 'A' && *p <= 'F') 92 | val = *p - 'A' + 0xa; 93 | 94 | if (val != 0xff) { 95 | if (high) { 96 | msgbuf[j] = val << 4; 97 | high = 0; 98 | } else { 99 | msgbuf[j++] |= val; 100 | high = 1; 101 | } 102 | } 103 | 104 | /* Don't overflow the output buffer */ 105 | if (j >= buflen) 106 | goto done; 107 | p++; 108 | } 109 | next: 110 | line = fgets (tmpbuf, RTAS_STR_SIZE, fh); 111 | } 112 | 113 | done: 114 | return j; 115 | } 116 | 117 | /** 118 | * usage 119 | * @brief print the event_decode usage statement 120 | * 121 | * @param progname argv[0] 122 | */ 123 | void 124 | usage (const char *progname) 125 | { 126 | printf("Usage: %s [-dv] [-n eventnum]\n", progname); 127 | printf("-d dump the raw RTAS event\n"); 128 | printf("-n eventnum event number of the RTAS event being dumped\n"); 129 | printf("-v verbose, print all details, not just header\n"); 130 | printf("-w width limit the output to the specified width, default\n" 131 | " width is 80 characters. The width must be > 0\n" 132 | " and < 1024.\n"); 133 | } 134 | 135 | int 136 | main(int argc , char *argv[]) 137 | { 138 | struct rtas_event *re; 139 | int event_no = -1; 140 | int verbose = 0; 141 | int dump_raw = 0; 142 | int len = 0; 143 | int c, rtas_buf_len; 144 | 145 | switch (get_platform()) { 146 | case PLATFORM_UNKNOWN: 147 | case PLATFORM_POWERNV: 148 | fprintf(stderr, "%s: is not supported on the %s platform\n", 149 | argv[0], platform_name); 150 | exit(1); 151 | } 152 | /* Suppress error messages from getopt */ 153 | opterr = 0; 154 | 155 | while ((c = getopt(argc, argv, "dn:vw:")) != EOF) { 156 | switch (c) { 157 | case 'd': 158 | dump_raw = 1; 159 | break; 160 | case 'n': 161 | event_no = atoi(optarg); 162 | break; 163 | case 'v': 164 | verbose++; 165 | break; 166 | case 'w': 167 | if (rtas_set_print_width(atoi(optarg))) { 168 | fprintf(stderr, "rtas_dump: (%d) is not a valid print " 169 | "width\n", atoi(optarg)); 170 | usage(argv[0]); 171 | exit(1); 172 | } 173 | break; 174 | default: 175 | usage(argv[0]); 176 | exit(1); 177 | } 178 | } 179 | 180 | rtas_buf_len = get_buffer(stdin, rtas_buf, RTAS_BUF_SIZE); 181 | 182 | re = parse_rtas_event(rtas_buf, rtas_buf_len); 183 | 184 | while (re != NULL) { 185 | if (event_no != -1) 186 | re->event_no = event_no; 187 | 188 | if (dump_raw) { 189 | len += rtas_print_raw_event(stdout, re); 190 | fprintf(stdout, "\n"); 191 | } 192 | 193 | len += rtas_print_event(stdout, re, verbose); 194 | fflush(stdout); 195 | 196 | cleanup_rtas_event(re); 197 | 198 | rtas_buf_len = get_buffer(stdin, rtas_buf, RTAS_BUF_SIZE); 199 | re = parse_rtas_event(rtas_buf, rtas_buf_len); 200 | } 201 | 202 | return len; 203 | } 204 | -------------------------------------------------------------------------------- /src/rtas_ibm_get_vpd.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtas_ibm_get_vpd.c 3 | * @brief helper utility for retrieving dynamic VPD on IBM ppc64-based systems. 4 | */ 5 | /** 6 | * @mainpage rtas_ibm_get_vpd documentation 7 | * @section Copyright 8 | * Copyright (c) 2004 International Business Machines 9 | * 10 | * This program is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * as published by the Free Software Foundation; either version 2 13 | * of the License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 | * 24 | * @section Overview 25 | * The rtas_ibm_get_vpd utility is a utility to assist inventory retrieval 26 | * applications by gathering dynamically changing vital product data on 27 | * IBM ppc64 systems. The output of this utility is formatted to be parsed 28 | * by other applications; as such, it is not intended for general 29 | * command-line usage, though there is no reason that it should not be used 30 | * in that manner. 31 | * 32 | * @author Michael Strosaker 33 | * @author Martin Schwenke 34 | */ 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "librtas_error.h" 43 | #include "pseries_platform.h" 44 | 45 | #define PROC_FILE_RTAS_CALL "/proc/device-tree/rtas/ibm,get-vpd" 46 | #define BUF_SIZE 2048 47 | #define ERR_BUF_SIZE 40 48 | 49 | /* Return codes from the RTAS call (not already handled by librtas) */ 50 | #define SUCCESS 0 51 | #define CONTINUE 1 52 | #define HARDWARE_ERROR -1 53 | #define PARAMETER_ERROR -3 54 | #define VPD_CHANGED -4 55 | 56 | /** 57 | * @struct buf_element 58 | * @brief List element for data returned by rtas_get_vpd() 59 | */ 60 | struct buf_element { 61 | char buf[BUF_SIZE]; /**< data buffer for rtas_get_vpd() */ 62 | struct buf_element *next; 63 | unsigned int size; /**< amount of the buffer filled in 64 | * by rtas_get_vpd() */ 65 | }; 66 | 67 | /** 68 | * print_usage 69 | * @brief print the usage statement for rtas_ibm_get_vpd 70 | * 71 | * @param cmd command name for rtas_ibm_get_vpd invocation (argv[0]) 72 | */ 73 | void print_usage(char *cmd) { 74 | printf ("Usage: %s [-l location_code] [-h]\n", cmd); 75 | } 76 | 77 | /** 78 | * print_help 79 | * @brief print the help statement for rtas_ibm_get_vpd 80 | * 81 | * @param cmd command name for rtas_ibm_get_vpd invocation (argv[0]) 82 | */ 83 | void print_help(char *cmd) 84 | { 85 | print_usage(cmd); 86 | printf (" -l location_code print the dynamic VPD for the specified location code\n"); 87 | printf (" if the -l option is not used, all dynamic VPD will be printed\n"); 88 | printf (" -h print this help message\n"); 89 | } 90 | 91 | /** 92 | * check_rtas_call 93 | * @brief Ensure that the ibm,get-vpd property exists in the OF tree 94 | * 95 | * @return 0 on success, !0 otherwise 96 | */ 97 | int check_rtas_call(void) 98 | { 99 | int fd; 100 | 101 | if ((fd = open(PROC_FILE_RTAS_CALL, O_RDONLY, 0)) == -1) { 102 | return 0; 103 | } 104 | close(fd); 105 | return 1; 106 | } 107 | 108 | /** 109 | * delete_list 110 | * @brief free all of the elements on a list 111 | * 112 | * @param elem pointer to the beginning of the list to delete 113 | */ 114 | void delete_list(struct buf_element *elem) 115 | { 116 | if (!elem) 117 | return; 118 | delete_list(elem->next); 119 | free (elem); 120 | return; 121 | } 122 | 123 | int main(int argc, char **argv) 124 | { 125 | char *loc_code = ""; 126 | char err_buf[ERR_BUF_SIZE]; 127 | int rc, c; 128 | unsigned int seq = 1, next_seq; 129 | struct buf_element *list, *current; 130 | 131 | if (get_platform() != PLATFORM_PSERIES_LPAR) { 132 | fprintf(stderr, "%s: is not supported on the %s platform\n", 133 | argv[0], platform_name); 134 | exit(1); 135 | } 136 | 137 | if (!check_rtas_call()) { 138 | fprintf(stderr, "The ibm,get-vpd RTAS call is not available " 139 | "on this system.\n"); 140 | return 4; 141 | } 142 | 143 | /* Parse command line options */ 144 | opterr = 0; 145 | while ((c = getopt (argc, argv, "l:h")) != -1) { 146 | switch (c) { 147 | case 'l': 148 | loc_code = optarg; 149 | break; 150 | case 'h': 151 | print_help(argv[0]); 152 | return 0; 153 | case '?': 154 | if (isprint (optopt)) 155 | fprintf(stderr, "Unrecognized option: -%c.\n", 156 | optopt); 157 | else 158 | fprintf(stderr, "Unrecognized option character " 159 | "\\x%x.\n", optopt); 160 | print_usage(argv[0]); 161 | return 1; 162 | default: 163 | abort(); 164 | } 165 | } 166 | 167 | list = (struct buf_element *)malloc(sizeof(struct buf_element)); 168 | if (!list) { 169 | fprintf(stderr, "Out of memory\n"); 170 | return 5; 171 | } 172 | list->size = 0; 173 | list->next = NULL; 174 | current = list; 175 | 176 | do { 177 | rc = rtas_get_vpd(loc_code, current->buf, BUF_SIZE, 178 | seq, &next_seq, &(current->size)); 179 | 180 | switch (rc) { 181 | case CONTINUE: 182 | seq = next_seq; 183 | current->next = (struct buf_element *) 184 | malloc(sizeof(struct buf_element)); 185 | if (!current->next) { 186 | fprintf(stderr, "Out of memory\n"); 187 | delete_list(list); 188 | return 5; 189 | } 190 | current = current->next; 191 | current->size = 0; 192 | current->next = NULL; 193 | /* fall through */ 194 | case SUCCESS: 195 | break; 196 | case VPD_CHANGED: 197 | seq = 1; 198 | delete_list(list); 199 | list = (struct buf_element *) 200 | malloc(sizeof(struct buf_element)); 201 | if (!list) { 202 | fprintf(stderr, "Out of memory\n"); 203 | return 5; 204 | } 205 | list->size = 0; 206 | list->next = NULL; 207 | current = list; 208 | break; 209 | case PARAMETER_ERROR: 210 | delete_list(list); 211 | return 1; 212 | case HARDWARE_ERROR: 213 | delete_list(list); 214 | return 2; 215 | default: 216 | delete_list(list); 217 | if (is_librtas_error(rc)) { 218 | librtas_error(rc, err_buf, ERR_BUF_SIZE); 219 | fprintf(stderr, "Could not gather vpd\n%s\n", err_buf); 220 | } else { 221 | fprintf(stderr, "Could not gather vpd\n"); 222 | } 223 | 224 | return 3; 225 | } 226 | } while(rc != SUCCESS); 227 | 228 | current = list; 229 | do { 230 | size_t count; 231 | 232 | if (current->size <= 0) 233 | continue; 234 | 235 | count = fwrite(current->buf, 1, current->size, stdout); 236 | if (count < current->size) 237 | break; 238 | 239 | } while ((current = (current->next)) != NULL); 240 | 241 | delete_list(list); 242 | 243 | return 0; 244 | } 245 | 246 | -------------------------------------------------------------------------------- /systemd/hcn-init.service.in.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=hybrid virtual network scan and config for @CM@ 3 | After=@CM@.service 4 | Requisite=@CM@.service 5 | PartOf=@CM@.service 6 | 7 | [Service] 8 | Type=oneshot 9 | RemainAfterExit=yes 10 | ExecStart=@sbindir@/hcnmgr -s 11 | 12 | [Install] 13 | WantedBy=@CM@.service 14 | -------------------------------------------------------------------------------- /systemd/smt_off.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=ppc64 set SMT off 3 | Before=libvirt-bin.service 4 | 5 | [Service] 6 | Type=oneshot 7 | RemainAfterExit=true 8 | ExecStart=@sbindir@/ppc64_cpu --smt=off 9 | ExecStop=@sbindir@/ppc64_cpu --smt=on 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /systemd/smtstate.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=SMT automatic initialization service 3 | Documentation=man:smtstate(8) 4 | Conflicts=shutdown.target 5 | Before=shutdown.target 6 | After=sysinit.target 7 | DefaultDependencies=no 8 | 9 | [Service] 10 | Type=oneshot 11 | RemainAfterExit=yes 12 | ExecStart=@sbindir@/smtstate --load 13 | ExecStop=@sbindir@/smtstate --save 14 | StandardOutput=journal 15 | StandardError=journal 16 | 17 | [Install] 18 | WantedBy=sysinit.target 19 | -------------------------------------------------------------------------------- /var/lib/powerpc-utils/smt.state: -------------------------------------------------------------------------------- 1 | # smt.state configures the SMT default value for next 2 | # boots. 3 | 4 | # SMT state. If smt_init.service is enabled, this value will be 5 | # used to set SMT in the next boot. If smtd.service is enabled, 6 | # this value will be updated whenever ppc64_cpu --smt= 7 | # is issued. 8 | SMT_VALUE=1 9 | --------------------------------------------------------------------------------