Skip to content

Commit 081c44e

Browse files
authored
[Mellanox] Add restricted sysfs list for fw control modules (sonic-net#4175)
- What I did Added a restricted list for FW control modules. If control == 0, do not copy them to dump as we have no access for them. - How I did it Update Mellanox code in generate_dump script - How to verify it take dump (show techsupport) in sonic. check that for FW controlled ports, we copy only allowed sysfs. Signed-off-by: noaOrMlnx <[email protected]>
1 parent 1ae65e3 commit 081c44e

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

scripts/generate_dump

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,14 +921,19 @@ save_sdk_sysfs() {
921921
shift 2
922922
# sys files we do not want to include in dump
923923
local excludes=("$@")
924-
924+
# there are module's sysfs which we cannot access while the module is in fw control
925+
local fw_control_skip_list=(frequency_support frequency hw_present hw_reset low_power_mode power_good power_limit)
925926
$MKDIR $V -p "$dest"
926927

927928
should_skip() {
928929
local base="$1"
929-
for ex in "${excludes[@]}"; do
930-
[[ "$base" == "$ex" ]] && return 0
930+
shift
931+
local skip_list=("$@")
932+
933+
for skip in "${skip_list[@]}"; do
934+
[[ "$base" == "$skip" ]] && return 0
931935
done
936+
932937
return 1
933938
}
934939

@@ -946,7 +951,7 @@ save_sdk_sysfs() {
946951
for f in "$src"/*; do
947952
if [[ -f "$f" ]]; then
948953
local base="$(basename "$f")"
949-
should_skip "$base" && continue
954+
should_skip "$base" "${excludes[@]}" && continue
950955
copy_file_content "$f" "$dest/$base"
951956
fi
952957
done
@@ -957,10 +962,12 @@ save_sdk_sysfs() {
957962
local subdir_dest="$dest/$(basename "$d")"
958963
$MKDIR $V -p "$subdir_dest"
959964

960-
local present=0 hw_present="" frequency_support=0 only_copy_presence_files=false
965+
local present=0 hw_present="" control="" frequency_support=0 only_copy_presence_files=false
966+
[[ -f "$d/control" ]] && control=$(<"$d/control")
961967
[[ -f "$d/present" ]] && present=$(<"$d/present")
962968
[[ -f "$d/hw_present" ]] && hw_present=$(<"$d/hw_present")
963-
[[ -f "$d/frequency_support" ]] && frequency_support=$(<"$d/frequency_support")
969+
# frequency_support is supported only for SW control modules
970+
[[ "$control" == "1" && -f "$d/frequency_support" ]] && frequency_support=$(<"$d/frequency_support")
964971

965972
# if the module is unplugged, skip the rest of the files
966973
if [[ -n "$hw_present" ]]; then
@@ -975,7 +982,8 @@ save_sdk_sysfs() {
975982
for f in "$d"/*; do
976983
if [[ -f "$f" ]]; then
977984
local base="$(basename "$f")"
978-
should_skip "$base" && continue
985+
should_skip "$base" "${excludes[@]}" && continue
986+
[[ "$control" == "0" ]] && should_skip "$base" "${fw_control_skip_list[@]}" && continue
979987

980988
[[ "$only_copy_presence_files" == true && "$base" != "present" && "$base" != "hw_present" ]] && continue
981989
[[ "$frequency_support" == "0" && "$base" == "frequency" ]] && continue

0 commit comments

Comments
 (0)