Integrated hw-mgmt automation script into SONiC
This commit is contained in:
parent
c09bc46ddc
commit
387430789b
@ -24,3 +24,84 @@ MLNX_HW_MANAGEMENT = hw-management_1.mlnx.$(MLNX_HW_MANAGEMENT_VERSION)_$(CONFIG
|
|||||||
$(MLNX_HW_MANAGEMENT)_SRC_PATH = $(PLATFORM_PATH)/hw-management
|
$(MLNX_HW_MANAGEMENT)_SRC_PATH = $(PLATFORM_PATH)/hw-management
|
||||||
$(MLNX_HW_MANAGEMENT)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
$(MLNX_HW_MANAGEMENT)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
|
||||||
SONIC_MAKE_DEBS += $(MLNX_HW_MANAGEMENT)
|
SONIC_MAKE_DEBS += $(MLNX_HW_MANAGEMENT)
|
||||||
|
|
||||||
|
TEMP_HW_MGMT_DIR = /tmp/hw_mgmt
|
||||||
|
PTCH_DIR = $(TEMP_HW_MGMT_DIR)/patch_dir/
|
||||||
|
NON_UP_PTCH_DIR = $(TEMP_HW_MGMT_DIR)/non_up_patch_dir/
|
||||||
|
PTCH_LIST = $(TEMP_HW_MGMT_DIR)/series
|
||||||
|
KCFG_LIST = $(TEMP_HW_MGMT_DIR)/kconfig
|
||||||
|
HWMGMT_NONUP_LIST = $(BUILD_WORKDIR)/$($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hwmgmt_nonup_patches
|
||||||
|
USER_OUTFILE = $(BUILD_WORKDIR)/integrate-mlnx-hw-mgmt_jenkins.out
|
||||||
|
TMPFILE = /tmp/intg-hw-mgmt.out
|
||||||
|
|
||||||
|
integrate-mlnx-hw-mgmt:
|
||||||
|
$(FLUSH_LOG)
|
||||||
|
rm -rf $(TEMP_HW_MGMT_DIR) $(TMPFILE)
|
||||||
|
mkdir -p $(PTCH_DIR) $(NON_UP_PTCH_DIR)
|
||||||
|
touch $(PTCH_LIST) $(KCFG_LIST)
|
||||||
|
|
||||||
|
# clean up existing untracked files
|
||||||
|
pushd $(BUILD_WORKDIR); git stash; git clean -f -- platform/mellanox/; popd
|
||||||
|
pushd $(BUILD_WORKDIR)/src/sonic-linux-kernel; git stash; git clean -f -- patch/; popd
|
||||||
|
|
||||||
|
echo "#### Integrate HW-MGMT ${MLNX_HW_MANAGEMENT_VERSION} Kernel Patches into SONiC" > ${USER_OUTFILE}
|
||||||
|
pushd $(BUILD_WORKDIR)/$(PLATFORM_PATH) $(LOG_SIMPLE)
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
pushd integration-scripts/tests; pytest-3 -v; popd
|
||||||
|
|
||||||
|
# Pre-processing before runing hw_mgmt script
|
||||||
|
integration-scripts/hwmgmt_kernel_patches.py pre \
|
||||||
|
--config_inclusion $(KCFG_LIST) \
|
||||||
|
--build_root $(BUILD_WORKDIR) $(LOG_SIMPLE)
|
||||||
|
|
||||||
|
$(BUILD_WORKDIR)/$($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hw-mgmt/recipes-kernel/linux/deploy_kernel_patches.py \
|
||||||
|
--dst_accepted_folder $(PTCH_DIR) \
|
||||||
|
--dst_candidate_folder $(NON_UP_PTCH_DIR) \
|
||||||
|
--series_file $(PTCH_LIST) \
|
||||||
|
--config_file $(KCFG_LIST) \
|
||||||
|
--kernel_version $(KERNEL_VERSION) \
|
||||||
|
--os_type sonic $(LOG_SIMPLE)
|
||||||
|
|
||||||
|
# Post-processing
|
||||||
|
integration-scripts/hwmgmt_kernel_patches.py post \
|
||||||
|
--patches $(PTCH_DIR) \
|
||||||
|
--non_up_patches $(NON_UP_PTCH_DIR) \
|
||||||
|
--config_inclusion $(KCFG_LIST) \
|
||||||
|
--series $(PTCH_LIST) \
|
||||||
|
--current_non_up_patches $(HWMGMT_NONUP_LIST) \
|
||||||
|
--build_root $(BUILD_WORKDIR) $(LOG_SIMPLE)
|
||||||
|
|
||||||
|
# Commit the changes in linux kernel and and log the diff
|
||||||
|
pushd $(BUILD_WORKDIR)/src/sonic-linux-kernel
|
||||||
|
git add -- patch/; git commit -m "Intgerate HW-MGMT ${MLNX_HW_MANAGEMENT_VERSION} Changes";
|
||||||
|
|
||||||
|
echo -en "\n###-> series file changes in sonic-linux-kernel <-###\n" >> ${USER_OUTFILE}
|
||||||
|
git diff --no-color HEAD~1 HEAD -- patch/series >> ${USER_OUTFILE}
|
||||||
|
|
||||||
|
echo -en "\n###-> kconfig-inclusion file changes in sonic-linux-kernel <-###\n" >> ${USER_OUTFILE}
|
||||||
|
git diff --no-color HEAD~1 HEAD -- patch/kconfig-inclusions >> ${USER_OUTFILE}
|
||||||
|
|
||||||
|
echo -en '\n###-> Summary of files updated in sonic-linux-kernel <-###\n' >> ${USER_OUTFILE}
|
||||||
|
git diff --no-color HEAD~1 HEAD --stat --output=${TMPFILE}
|
||||||
|
cat ${TMPFILE} | tee -a ${USER_OUTFILE}
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Commit the changes in buildimage and log the diff
|
||||||
|
pushd $(BUILD_WORKDIR)
|
||||||
|
git add -- $(PLATFORM_PATH); git commit -m "Intgerate HW-MGMT ${MLNX_HW_MANAGEMENT_VERSION} Changes";
|
||||||
|
|
||||||
|
echo -en '\n###-> Non Upstream series.patch changes <-###\n' >> ${USER_OUTFILE}
|
||||||
|
git diff --no-color HEAD~1 HEAD -- $(PLATFORM_PATH)/non-upstream-patches/series.patch >> ${USER_OUTFILE}
|
||||||
|
|
||||||
|
echo -en '\n###-> Non Upstream patch list file <-###\n' >> ${USER_OUTFILE}
|
||||||
|
git diff --no-color HEAD~1 HEAD -- $($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hwmgmt_nonup_patches >> ${USER_OUTFILE}
|
||||||
|
|
||||||
|
echo -en '\n###-> Summary of buildimage changes <-###\n' >> ${USER_OUTFILE}
|
||||||
|
git diff --no-color HEAD~1 HEAD --stat --output=${TMPFILE} -- $(PLATFORM_PATH)
|
||||||
|
cat ${TMPFILE} | tee -a ${USER_OUTFILE}
|
||||||
|
popd
|
||||||
|
|
||||||
|
popd $(LOG_SIMPLE)
|
||||||
|
|
||||||
|
SONIC_PHONY_TARGETS += integrate-mlnx-hw-mgmt
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9c3f6b2d6ac4be2eda936522f369ff8920deb4e2
|
Subproject commit 6526fb4aa211e75a5df04d83f69b44dde7bd3b55
|
63
platform/mellanox/hw-management/hwmgmt_nonup_patches
Normal file
63
platform/mellanox/hw-management/hwmgmt_nonup_patches
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Current non-upstream patch list, should be updated by integrate_kernel_patches.py script
|
||||||
|
0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch
|
||||||
|
0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch
|
||||||
|
0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch
|
||||||
|
0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch
|
||||||
|
0103-mlxsw-core-Remove-unnecessary-asserts.patch
|
||||||
|
0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch
|
||||||
|
0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch
|
||||||
|
0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch
|
||||||
|
0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch
|
||||||
|
0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patc
|
||||||
|
0109-mlxsw-reg-Extend-MGPIR-register-with-new-slot-fields.patch
|
||||||
|
0110-mlxsw-core_env-Pass-slot-index-during-PMAOS-register.patch
|
||||||
|
0111-mlxsw-reg-Add-new-field-to-Management-General-Periph.patch
|
||||||
|
0112-mlxsw-core-Extend-interfaces-for-cable-info-access-w.patch
|
||||||
|
0113-mlxsw-core-Extend-port-module-data-structures-for-li.patch
|
||||||
|
0114-mlxsw-core-Move-port-module-events-enablement-to-a-s.patch
|
||||||
|
0115-mlxsw-core_hwmon-Split-gearbox-initialization.patch
|
||||||
|
0116-mlxsw-core_hwmon-Extend-internal-structures-to-suppo.patch
|
||||||
|
0117-mlxsw-core_hwmon-Introduce-slot-parameter-in-hwmon-i.patch
|
||||||
|
0118-mlxsw-core_hwmon-Extend-hwmon-device-with-gearbox-ma.patch
|
||||||
|
0119-mlxsw-core_thermal-Extend-internal-structures-to-sup.patch
|
||||||
|
0120-mlxsw-core_thermal-Split-gearbox-initialization.patch
|
||||||
|
0121-mlxsw-core_thermal-Extend-thermal-area-with-gearbox-.patch
|
||||||
|
0122-mlxsw-core_thermal-Add-line-card-id-prefix-to-line-c.patch
|
||||||
|
0123-mlxsw-core_thermal-Use-exact-name-of-cooling-devices.patch
|
||||||
|
0124-mlxsw-core_thermal-Use-common-define-for-thermal-zon.patch
|
||||||
|
0125-devlink-add-support-to-create-line-card-and-expose-t.patch
|
||||||
|
0126-devlink-implement-line-card-provisioning.patch
|
||||||
|
0127-devlink-implement-line-card-active-state.patch
|
||||||
|
0128-devlink-add-port-to-line-card-relationship-set.patch
|
||||||
|
0129-devlink-introduce-linecard-info-get-message.patch
|
||||||
|
0130-devlink-introduce-linecard-info-get-message.patch
|
||||||
|
0131-mlxsw-reg-Add-Ports-Mapping-event-Configuration-Regi.patch
|
||||||
|
0132-mlxsw-reg-Add-Management-DownStream-Device-Query-Reg.patch
|
||||||
|
0133-mlxsw-reg-Add-Management-DownStream-Device-Control-R.patch
|
||||||
|
0134-mlxsw-reg-Add-Management-Binary-Code-Transfer-Regist.patch
|
||||||
|
0135-mlxsw-core_linecards-Add-line-card-objects-and-imple.patch
|
||||||
|
0136-mlxsw-core_linecards-Implement-line-card-activation-.patch
|
||||||
|
0137-mlxsw-core-Extend-driver-ops-by-remove-selected-port.patch
|
||||||
|
0138-mlxsw-spectrum-Add-port-to-linecard-mapping.patch
|
||||||
|
0139-mlxsw-reg-Introduce-Management-Temperature-Extended-.patch
|
||||||
|
0140-mlxsw-core-Add-APIs-for-thermal-sensor-mapping.patch
|
||||||
|
0141-mlxsw-reg-Add-Management-DownStream-Device-Tunneling.patch
|
||||||
|
0142-mlxsw-core_linecards-Probe-devices-for-provisioned-l.patch
|
||||||
|
0143-mlxsw-core_linecards-Expose-device-FW-version-over-d.patch
|
||||||
|
0144-mlxsw-core-Introduce-flash-update-components.patch
|
||||||
|
0145-mlxfw-Get-the-PSID-value-using-op-instead-of-passing.patch
|
||||||
|
0146-mlxsw-core_linecards-Implement-line-card-device-flas.patch
|
||||||
|
0147-mlxsw-core_linecards-Introduce-ops-for-linecards-sta.patch
|
||||||
|
0148-mlxsw-core-Add-interfaces-for-line-card-initializati.patch
|
||||||
|
0149-mlxsw-core_thermal-Add-interfaces-for-line-card-init.patch
|
||||||
|
0150-mlxsw-core_hwmon-Add-interfaces-for-line-card-initia.patch
|
||||||
|
0151-mlxsw-minimal-Prepare-driver-for-modular-system-supp.patch
|
||||||
|
0152-mlxsw-core-Extend-bus-init-function-with-event-handl.patch
|
||||||
|
0153-mlxsw-i2c-Add-support-for-system-events-handling.patch
|
||||||
|
0154-mlxsw-core-Export-line-card-API.patch
|
||||||
|
0155-mlxsw-minimal-Add-system-event-handler.patch
|
||||||
|
0156-mlxsw-minimal-Add-interfaces-for-line-card-initializ.patch
|
||||||
|
0163-platform-mellanox-Introduce-support-for-rack-manager.patch
|
||||||
|
0176-platform-mellanox-fix-reset_pwr_converter_fail-attri.patch
|
||||||
|
0177-Documentation-ABI-fix-description-of-fix-reset_pwr_c.patch
|
||||||
|
0178-platform-mellanox-Introduce-support-for-next-generat.patch
|
0
platform/mellanox/integration-scripts/__init__.py
Normal file
0
platform/mellanox/integration-scripts/__init__.py
Normal file
173
platform/mellanox/integration-scripts/helper.py
Normal file
173
platform/mellanox/integration-scripts/helper.py
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import re
|
||||||
|
|
||||||
|
MARK_ID = "###->"
|
||||||
|
MLNX_KFG_MARKER = "mellanox"
|
||||||
|
HW_MGMT_MARKER = "mellanox_hw_mgmt"
|
||||||
|
SLK_PATCH_LOC = "src/sonic-linux-kernel/patch/"
|
||||||
|
SLK_KCONFIG = SLK_PATCH_LOC + "kconfig-inclusions"
|
||||||
|
SLK_SERIES = SLK_PATCH_LOC + "series"
|
||||||
|
NON_UP_PATCH_DIR = "platform/mellanox/non-upstream-patches/"
|
||||||
|
NON_UP_PATCH_LOC = NON_UP_PATCH_DIR + "patches"
|
||||||
|
NON_UP_PATCH_DIFF = NON_UP_PATCH_DIR + "series.patch"
|
||||||
|
KCFG_HDR_RE = "\[(.*)\]"
|
||||||
|
# kconfig_inclusion headers to consider
|
||||||
|
HDRS = ["common", "amd64"]
|
||||||
|
|
||||||
|
class FileHandler:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def write_lines(path, lines, raw=False):
|
||||||
|
# Create the dir if it doesn't exist already
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
for line in lines:
|
||||||
|
if raw:
|
||||||
|
f.write(f"{line}")
|
||||||
|
else:
|
||||||
|
f.write(f"{line}\n")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_raw(path):
|
||||||
|
# Read the data line by line into a list
|
||||||
|
data = []
|
||||||
|
with open(path) as im:
|
||||||
|
data = im.readlines()
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_strip(path, as_string=False):
|
||||||
|
# Read the data line by line into a list and strip whitelines
|
||||||
|
data = FileHandler.read_raw(path)
|
||||||
|
data = [d.strip() for d in data]
|
||||||
|
if as_string:
|
||||||
|
return "\n".join(data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_strip_minimal(path, as_string=False, ignore_start_with="#"):
|
||||||
|
# Read the data line by line into a list, strip spaces and ignore comments
|
||||||
|
data = FileHandler.read_raw(path)
|
||||||
|
filtered_data = []
|
||||||
|
for l in data:
|
||||||
|
l = l.strip()
|
||||||
|
if l and not l.startswith(ignore_start_with):
|
||||||
|
filtered_data.append(l)
|
||||||
|
if as_string:
|
||||||
|
return "\n".join(filtered_data)
|
||||||
|
return filtered_data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_dir(path, ext="*") -> list:
|
||||||
|
return [os.path.basename(f) for f in glob.glob(os.path.join(path, ext))]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def find_marker_indices(lines: list, marker=None) -> tuple:
|
||||||
|
i_start = -1
|
||||||
|
i_end = len(lines)
|
||||||
|
# print("TEST", marker, lines)
|
||||||
|
if marker:
|
||||||
|
for index, line in enumerate(lines):
|
||||||
|
# assumes one unique marker per file
|
||||||
|
# if multiple marker sections are present, reads the first one
|
||||||
|
if line.strip().startswith(MARK_ID):
|
||||||
|
if marker+"-start" in line:
|
||||||
|
i_start = index
|
||||||
|
elif marker+"-end" in line:
|
||||||
|
i_end = index
|
||||||
|
# print(i_start, i_end)
|
||||||
|
return (i_start, i_end)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_kconfig_inclusion(path, marker=MLNX_KFG_MARKER):
|
||||||
|
lines = FileHandler.read_strip(path)
|
||||||
|
if not marker:
|
||||||
|
return lines
|
||||||
|
i_start, i_end = FileHandler.find_marker_indices(lines, marker)
|
||||||
|
|
||||||
|
if i_start < 0 or i_end >= len(lines):
|
||||||
|
print("-> WARNING No Marker Found")
|
||||||
|
return []
|
||||||
|
|
||||||
|
return lines[i_start+1:i_end]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def write_lines_marker(path, writable_opts: list, marker=None):
|
||||||
|
# if marker is none, just write the opts into the file,
|
||||||
|
# otherwise write the data only b/w the marker
|
||||||
|
curr_data = FileHandler.read_raw(path)
|
||||||
|
i_start, i_end = FileHandler.find_marker_indices(curr_data, marker)
|
||||||
|
newline_writ_opts = [opt + "\n" for opt in writable_opts]
|
||||||
|
if i_start < 0 or i_end >= len(curr_data):
|
||||||
|
print("-> WARNING No Marker Found, writing data at the end of file")
|
||||||
|
curr_data.extend(["\n"])
|
||||||
|
curr_data.extend(newline_writ_opts)
|
||||||
|
else:
|
||||||
|
curr_data = curr_data[0:i_start+1] + newline_writ_opts + curr_data[i_end:]
|
||||||
|
|
||||||
|
print("-> INFO Written the following opts: \n{}".format("".join(FileHandler.read_raw(path))))
|
||||||
|
FileHandler.write_lines(path, curr_data, True)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_kconfig_parser(path) -> dict:
|
||||||
|
# kconfig_inclusion output formatted to {"no_parent", "common":[,], "amd64": [,], "arm64": [,]}
|
||||||
|
lines = FileHandler.read_strip_minimal(path)
|
||||||
|
ret = dict({"no_parent":[]})
|
||||||
|
curr_hdr = ""
|
||||||
|
for line in lines:
|
||||||
|
match = re.search(KCFG_HDR_RE, line)
|
||||||
|
if match:
|
||||||
|
curr_hdr = match.group(1)
|
||||||
|
ret[curr_hdr] = []
|
||||||
|
elif curr_hdr in ret:
|
||||||
|
ret[curr_hdr].append(line)
|
||||||
|
else:
|
||||||
|
ret["no_parent"].append(line)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
class KCFG:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def parse_opt_str(opt: str) -> tuple:
|
||||||
|
if not opt.startswith("CONFIG"):
|
||||||
|
print("-> DEBUG: Malformed kconfig opt, {}".format(opt))
|
||||||
|
return ()
|
||||||
|
|
||||||
|
tmp = opt.split("=")
|
||||||
|
if len(tmp) != 2:
|
||||||
|
print("-> DEBUG: Malformed kconfig opt, {}".format(opt))
|
||||||
|
return ()
|
||||||
|
|
||||||
|
if not tmp[0].startswith("CONFIG"):
|
||||||
|
print("-> DEBUG: Malformed kconfig opt, {}".format(opt))
|
||||||
|
return ()
|
||||||
|
return (tmp[0], tmp[1])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def parse_opts_strs(kcfg_sec: list) -> list(tuple()):
|
||||||
|
opts = [] # list of tuples (CONFIG_*, "m|y|n")
|
||||||
|
for kcfg in kcfg_sec:
|
||||||
|
tmp = KCFG.parse_opt_str(kcfg)
|
||||||
|
if tmp:
|
||||||
|
opts.append(tmp)
|
||||||
|
return opts
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_writable_opts(opts):
|
||||||
|
lines = []
|
||||||
|
for opt in opts:
|
||||||
|
lines.append("{}={}".format(opt[0].upper(), opt[1]))
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
class Action():
|
||||||
|
def __init__(self, args):
|
||||||
|
self.args = args
|
||||||
|
|
||||||
|
def perform(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def write_user_out(self):
|
||||||
|
pass
|
290
platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py
Executable file
290
platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py
Executable file
@ -0,0 +1,290 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
import argparse
|
||||||
|
import copy
|
||||||
|
import difflib
|
||||||
|
|
||||||
|
from helper import *
|
||||||
|
|
||||||
|
class Data:
|
||||||
|
# list of new upstream patches
|
||||||
|
new_up = list()
|
||||||
|
# list of new non-upstream patches
|
||||||
|
new_down = list()
|
||||||
|
# current series file raw data
|
||||||
|
old_series = list()
|
||||||
|
# current non-upstream patch list
|
||||||
|
old_down = list()
|
||||||
|
# New series file written by hw_mgmt integration script
|
||||||
|
new_series = list()
|
||||||
|
# List of new opts written by hw_mgmt integration script
|
||||||
|
updated_kcfg = list(tuple())
|
||||||
|
# index of the mlnx_hw_mgmt patches start marker in old_series
|
||||||
|
i_mlnx_start = -1
|
||||||
|
# index of the mlnx_hw_mgmt patches end marker in old_series
|
||||||
|
i_mlnx_end = -1
|
||||||
|
# Updated sonic-linux-kernel/patch/series file contents
|
||||||
|
final_slk_series = list()
|
||||||
|
# SLK series file content updated with non-upstream patches, used to generate diff
|
||||||
|
non_up_slk_series = list()
|
||||||
|
# Diff to be written into the series.patch file
|
||||||
|
non_up_slk_series_diff = list()
|
||||||
|
# current kcfg opts
|
||||||
|
current_kcfg = list(tuple())
|
||||||
|
|
||||||
|
class HwMgmtAction(Action):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get(args):
|
||||||
|
action = None
|
||||||
|
if args.action.lower() == "pre":
|
||||||
|
action = PreProcess(args)
|
||||||
|
elif args.action.lower() == "post":
|
||||||
|
action = PostProcess(args)
|
||||||
|
|
||||||
|
if not action.check():
|
||||||
|
print("-> ERR: Argument Checks Failed")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
return action
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
if not self.args.config_inclusion:
|
||||||
|
print("-> ERR: onfig_inclusion is missing")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not self.args.build_root:
|
||||||
|
print("-> ERR: build_root is missing")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not os.path.isfile(self.args.config_inclusion):
|
||||||
|
print("-> ERR: config_inclusion {} doesn't exist".format(self.args.config_inclusion))
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not os.path.exists(self.args.build_root):
|
||||||
|
print("-> ERR: Build Root {} doesn't exist".format(self.args.build_root))
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
class PreProcess(HwMgmtAction):
|
||||||
|
def __init__(self, args):
|
||||||
|
super().__init__(args)
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
return super(PreProcess, self).check()
|
||||||
|
|
||||||
|
def perform(self):
|
||||||
|
""" Move MLNX Kconfig to the loc pointed by config_inclusion """
|
||||||
|
kcfg_sec = FileHandler.read_kconfig_inclusion(os.path.join(self.args.build_root, SLK_KCONFIG))
|
||||||
|
writable_opts = KCFG.get_writable_opts(KCFG.parse_opts_strs(kcfg_sec))
|
||||||
|
FileHandler.write_lines(self.args.config_inclusion, writable_opts)
|
||||||
|
print("-> OPTS written to temp config_inclusion file: \n{}".format(FileHandler.read_strip(self.args.config_inclusion, True)))
|
||||||
|
|
||||||
|
class PostProcess(HwMgmtAction):
|
||||||
|
def __init__(self, args):
|
||||||
|
super().__init__(args)
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
if not super(PostProcess, self).check():
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (self.args.patches and os.path.exists(self.args.patches)):
|
||||||
|
print("-> ERR: upstream patch directory is missing ")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (self.args.non_up_patches and os.path.exists(self.args.non_up_patches)):
|
||||||
|
print("-> ERR: non upstream patch directory is missing")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (self.args.series and os.path.isfile(self.args.series)):
|
||||||
|
print("-> ERR: series file doesn't exist {}".format(self.args.series))
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (self.args.current_non_up_patches and os.path.exists(self.args.current_non_up_patches)):
|
||||||
|
print("-> ERR: current non_up_patches doesn't exist {}".format(self.args.current_non_up_patches))
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def read_data(self):
|
||||||
|
# Read the data written by hw-mgmt script into the internal Data Structures
|
||||||
|
Data.new_series = FileHandler.read_strip_minimal(self.args.series)
|
||||||
|
Data.old_series = FileHandler.read_raw(os.path.join(self.args.build_root, SLK_SERIES))
|
||||||
|
Data.old_down = FileHandler.read_strip_minimal(self.args.current_non_up_patches)
|
||||||
|
|
||||||
|
# Read the new kcfg
|
||||||
|
new_cfg = FileHandler.read_kconfig_inclusion(self.args.config_inclusion, None)
|
||||||
|
Data.updated_kcfg = KCFG.parse_opts_strs(new_cfg)
|
||||||
|
|
||||||
|
# entire current config, [common] + [amd64]
|
||||||
|
all_kcfg = FileHandler.read_kconfig_parser(os.path.join(self.args.build_root, SLK_KCONFIG))
|
||||||
|
Data.current_kcfg = []
|
||||||
|
for hdr in HDRS:
|
||||||
|
Data.current_kcfg.extend(all_kcfg.get(hdr, []))
|
||||||
|
Data.current_kcfg = KCFG.parse_opts_strs(Data.current_kcfg)
|
||||||
|
|
||||||
|
new_up = set(FileHandler.read_dir(self.args.patches, "*.patch"))
|
||||||
|
new_down = set(FileHandler.read_dir(self.args.non_up_patches, "*.patch"))
|
||||||
|
|
||||||
|
for patch in Data.new_series:
|
||||||
|
if patch in new_up:
|
||||||
|
Data.new_up.append(patch)
|
||||||
|
elif patch in new_down:
|
||||||
|
Data.new_down.append(patch)
|
||||||
|
else:
|
||||||
|
print("-> ERR: Patch {} not found either in upstream or non-upstream list".format(patch))
|
||||||
|
|
||||||
|
def find_mlnx_hw_mgmt_markers(self):
|
||||||
|
""" Find the indexes where the current mlnx patches sits in SLK_SERIES file """
|
||||||
|
(Data.i_mlnx_start, Data.i_mlnx_end) = FileHandler.find_marker_indices(Data.old_series, marker=HW_MGMT_MARKER)
|
||||||
|
if Data.i_mlnx_start < 0 or Data.i_mlnx_end > len(Data.old_series):
|
||||||
|
print("-> FATAL mellanox_hw_mgmt markers not found. Couldn't continue.. exiting")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
def rm_old_up_mlnx(self):
|
||||||
|
""" Delete the old mlnx upstream patches """
|
||||||
|
print("\n -> POST: Removed the following upstream patches:")
|
||||||
|
index = Data.i_mlnx_start
|
||||||
|
while index <= Data.i_mlnx_end:
|
||||||
|
file_n = os.path.join(self.args.build_root, os.path.join(SLK_PATCH_LOC, Data.old_series[index].strip()))
|
||||||
|
if os.path.isfile(file_n):
|
||||||
|
print(Data.old_series[index].strip())
|
||||||
|
os.remove(file_n)
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
def mv_new_up_mlnx(self):
|
||||||
|
for patch in Data.new_up:
|
||||||
|
src_path = os.path.join(self.args.patches, patch)
|
||||||
|
shutil.copy(src_path, os.path.join(self.args.build_root, SLK_PATCH_LOC))
|
||||||
|
|
||||||
|
def write_final_slk_series(self):
|
||||||
|
tmp_new_up = [d+"\n" for d in Data.new_up]
|
||||||
|
Data.final_slk_series = Data.old_series[0:Data.i_mlnx_start+1] + tmp_new_up + Data.old_series[Data.i_mlnx_end:]
|
||||||
|
print("\n -> POST: Updated sonic-linux-kernel/series file: \n{}".format("".join(Data.final_slk_series)))
|
||||||
|
FileHandler.write_lines(os.path.join(self.args.build_root, SLK_SERIES), Data.final_slk_series, True)
|
||||||
|
|
||||||
|
def rm_old_non_up_mlnx(self):
|
||||||
|
""" Remove the old non-upstream patches
|
||||||
|
"""
|
||||||
|
print("\n -> POST: Removed the following supposedly non-upstream patches:")
|
||||||
|
# Remove all the old patches and any patches that got accepted with this kernel version
|
||||||
|
for patch in Data.old_down + Data.new_up:
|
||||||
|
file_n = os.path.join(self.args.build_root, os.path.join(NON_UP_PATCH_LOC, patch))
|
||||||
|
if os.path.isfile(file_n):
|
||||||
|
print(patch)
|
||||||
|
os.remove(file_n)
|
||||||
|
|
||||||
|
# Make sure the dir is now empty as all these patches are of hw-mgmt
|
||||||
|
files = FileHandler.read_dir(os.path.join(self.args.build_root, NON_UP_PATCH_LOC), "*.patch")
|
||||||
|
if files:
|
||||||
|
print("\n -> POST: Patches Remaining in {}, likely SDK non-upstream patches \n{}".format(NON_UP_PATCH_LOC, files))
|
||||||
|
|
||||||
|
def mv_new_non_up_mlnx(self):
|
||||||
|
for patch in Data.new_down:
|
||||||
|
src_path = os.path.join(self.args.non_up_patches, patch)
|
||||||
|
shutil.copy(src_path, os.path.join(self.args.build_root, NON_UP_PATCH_LOC))
|
||||||
|
|
||||||
|
def construct_series_with_non_up(self):
|
||||||
|
Data.non_up_slk_series = copy.deepcopy(Data.final_slk_series)
|
||||||
|
lines = ["# Current non-upstream patch list, should be updated by integrate_kernel_patches.py script"]
|
||||||
|
for index, patch in enumerate(Data.new_series):
|
||||||
|
patch = patch + "\n"
|
||||||
|
if patch not in Data.non_up_slk_series:
|
||||||
|
prev_patch = Data.new_series[index-1] + "\n"
|
||||||
|
if prev_patch not in Data.non_up_slk_series:
|
||||||
|
print("\n -> POST: ERR: patch {} is not found in non_up_slk_series list: {}".format(prev_patch, "".join(Data.non_up_slk_series)))
|
||||||
|
continue
|
||||||
|
index_prev_patch = Data.non_up_slk_series.index(prev_patch)
|
||||||
|
if index_prev_patch < len(Data.non_up_slk_series) - 1:
|
||||||
|
Data.non_up_slk_series = Data.non_up_slk_series[0:index_prev_patch+1] + [patch] + Data.non_up_slk_series[index_prev_patch + 1:]
|
||||||
|
else:
|
||||||
|
Data.non_up_slk_series = Data.non_up_slk_series + [patch]
|
||||||
|
lines.append(patch.strip())
|
||||||
|
|
||||||
|
# Update the non_up_current_patch_list file
|
||||||
|
FileHandler.write_lines(self.args.current_non_up_patches, lines)
|
||||||
|
print("\n -> POST: series file updated with non-upstream patches \n{}".format("".join(Data.non_up_slk_series)))
|
||||||
|
|
||||||
|
def write_series_diff(self):
|
||||||
|
diff = difflib.unified_diff(Data.final_slk_series, Data.non_up_slk_series, fromfile='a/patch/series', tofile="b/patch/series", lineterm="\n")
|
||||||
|
lines = []
|
||||||
|
for line in diff:
|
||||||
|
lines.append(line)
|
||||||
|
print("\n -> POST: final series.diff \n{}".format("".join(lines)))
|
||||||
|
FileHandler.write_lines(os.path.join(self.args.build_root, NON_UP_PATCH_DIFF), lines, True)
|
||||||
|
|
||||||
|
def find_conflicts(self):
|
||||||
|
# current config under mellanox marker
|
||||||
|
old_mlnx_kcfg = FileHandler.read_kconfig_inclusion(os.path.join(self.args.build_root, SLK_KCONFIG))
|
||||||
|
old_mlnx_kcfg = KCFG.parse_opts_strs(old_mlnx_kcfg)
|
||||||
|
|
||||||
|
print("-> INFO: [common] + [amd64] Kconfig: \n{}".format("\n".join(KCFG.get_writable_opts(Data.current_kcfg))))
|
||||||
|
print("-> INFO: current mellanox marker Kconfig: \n{}".format("\n".join(KCFG.get_writable_opts(old_mlnx_kcfg))))
|
||||||
|
|
||||||
|
# Filter the mellanox config from current config
|
||||||
|
conflict_prone = set(Data.current_kcfg)
|
||||||
|
for kcfg in old_mlnx_kcfg:
|
||||||
|
if kcfg in conflict_prone:
|
||||||
|
conflict_prone.remove(kcfg)
|
||||||
|
|
||||||
|
print("-> INFO: conflict prone Kconfig: \n{}".format("\n".join(KCFG.get_writable_opts(list(conflict_prone)))))
|
||||||
|
print("-> INFO: updated kconfig for mellanox marker: \n{}".format("\n".join(KCFG.get_writable_opts(Data.updated_kcfg))))
|
||||||
|
|
||||||
|
# check for conflicts
|
||||||
|
has_conflict = False
|
||||||
|
for (cfg, val) in Data.updated_kcfg:
|
||||||
|
for (cfg_o, val_o) in conflict_prone:
|
||||||
|
if cfg == cfg_o and val != val_o:
|
||||||
|
print("-> ERR Conflict seen on the following kconfig: {}, old_opt: {}, new_opt: {}".format(cfg, val_o, val))
|
||||||
|
has_conflict = True
|
||||||
|
return has_conflict
|
||||||
|
|
||||||
|
def perform(self):
|
||||||
|
""" Read the data output from the deploy_kernel_patches.py script
|
||||||
|
and move to appropriate locations """
|
||||||
|
self.read_data()
|
||||||
|
self.find_mlnx_hw_mgmt_markers()
|
||||||
|
# Find and report conflicts in new kconfig
|
||||||
|
if self.find_conflicts():
|
||||||
|
print("-> FATAL Conflicts in kconfig-inclusion detected, exiting...")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
# Write the new kcfg to the new file
|
||||||
|
path = os.path.join(self.args.build_root, SLK_KCONFIG)
|
||||||
|
FileHandler.write_lines_marker(path, KCFG.get_writable_opts(Data.updated_kcfg), MLNX_KFG_MARKER)
|
||||||
|
# Handle Upstream patches
|
||||||
|
self.rm_old_up_mlnx()
|
||||||
|
self.mv_new_up_mlnx()
|
||||||
|
self.write_final_slk_series()
|
||||||
|
# Handle Non Upstream patches
|
||||||
|
self.rm_old_non_up_mlnx()
|
||||||
|
self.mv_new_non_up_mlnx()
|
||||||
|
self.construct_series_with_non_up()
|
||||||
|
self.write_series_diff()
|
||||||
|
|
||||||
|
|
||||||
|
def create_parser():
|
||||||
|
# Create argument parser
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
# Positional mandatory arguments
|
||||||
|
parser.add_argument("action", type=str, choices=["pre", "post"])
|
||||||
|
|
||||||
|
# Optional arguments
|
||||||
|
parser.add_argument("--patches", type=str)
|
||||||
|
parser.add_argument("--non_up_patches", type=str)
|
||||||
|
parser.add_argument("--config_inclusion", type=str)
|
||||||
|
parser.add_argument("--series", type=str)
|
||||||
|
parser.add_argument("--current_non_up_patches", type=str)
|
||||||
|
parser.add_argument("--build_root", type=str)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = create_parser()
|
||||||
|
action = HwMgmtAction.get(parser.parse_args())
|
||||||
|
action.perform()
|
@ -0,0 +1,40 @@
|
|||||||
|
# Description: Add kconfig options that has to be included in the kernel
|
||||||
|
# Note: Markers should start with "###->"
|
||||||
|
# Header should end with .*-start eg: any_description-start
|
||||||
|
# Footer must end with .*-end eg: any_description-end
|
||||||
|
# Markers should not be nested
|
||||||
|
|
||||||
|
[common]
|
||||||
|
CONFIG_LOG_BUF_SHIFT=20
|
||||||
|
|
||||||
|
[amd64]
|
||||||
|
# For Inventec d7032
|
||||||
|
CONFIG_GPIO_ICH=m
|
||||||
|
# For mitac ly1200
|
||||||
|
CONFIG_SENSORS_MAX31790=m
|
||||||
|
# For optoe
|
||||||
|
CONFIG_EEPROM_OPTOE=m
|
||||||
|
|
||||||
|
###-> mellanox-start
|
||||||
|
CONFIG_SPI_PXA2XX=m
|
||||||
|
CONFIG_THERMAL_NETLINK=y
|
||||||
|
CONFIG_SENSORS_XDPE152=m
|
||||||
|
CONFIG_SENSORS_DRIVETEMP=m
|
||||||
|
CONFIG_SENSORS_IIO_HWMON=m
|
||||||
|
CONFIG_SENSORS_LM25066=m
|
||||||
|
CONFIG_SENSORS_UCD9000=m
|
||||||
|
CONFIG_SENSORS_UCD9200=m
|
||||||
|
CONFIG_THERMAL_OF=y
|
||||||
|
###-> mellanox-end
|
||||||
|
|
||||||
|
# For Cisco 8000
|
||||||
|
CONFIG_PHYLIB=m
|
||||||
|
CONFIG_GPIOLIB=y
|
||||||
|
CONFIG_OF_GPIO=y
|
||||||
|
CONFIG_OF=y
|
||||||
|
CONFIG_OF_MDIO=m
|
||||||
|
|
||||||
|
[armhf]
|
||||||
|
CONFIG_EEPROM_SFF_8436=m
|
||||||
|
CONFIG_EEPROM_OPTOE=m
|
||||||
|
CONFIG_I2C_MUX_GPIO=m
|
@ -0,0 +1,76 @@
|
|||||||
|
# This series applies on GIT commit 18c5597832fcf6988111b05a9a1607ae148723c
|
||||||
|
# Note: Markers should start with "###->".
|
||||||
|
# Header should end with .*-start eg: any_description-start
|
||||||
|
# Footer must end with .*-end eg: any_description-end
|
||||||
|
# Markers should not be nested
|
||||||
|
|
||||||
|
# Backport from 5.15
|
||||||
|
0001-x86-platform-Increase-maximum-GPIO-number-for-X86_64.patch
|
||||||
|
|
||||||
|
# Backport from 5.16
|
||||||
|
0001-net-arp-introduce-arp_evict_nocarrier-sysctl-paramet.patch
|
||||||
|
|
||||||
|
# Backport from 5.19
|
||||||
|
0001-net-ipv6-Introduce-accept_unsolicited_na-knob-to-imp.patch
|
||||||
|
0002-net-ipv6-Expand-and-rename-accept_unsolicited_na-to-.patch
|
||||||
|
|
||||||
|
#
|
||||||
|
# This series applies on GIT commit 1451b36b2b0d62178e42f648d8a18131af18f7d8
|
||||||
|
# Tkernel-sched-core-fix-cgroup-fork-race.patch
|
||||||
|
# Tconfig-mlnx-sn2700.patch
|
||||||
|
# Tdriver-at24-fix-odd-length-two-byte-access.patch
|
||||||
|
# Tdriver-hwmon-lm75b-update.patch
|
||||||
|
# Tdriver-hwmon-pmbus-add-dps460-support.patch
|
||||||
|
# Tdriver-hwmon-pmbus-ucd9200-mlnx.patch
|
||||||
|
# Trtnetlink-catch-EOPNOTSUPP-errors.patch
|
||||||
|
# Tbridge-per-port-multicast-broadcast-flood-flags.patch
|
||||||
|
#
|
||||||
|
|
||||||
|
# Mellanox patches for 5.10
|
||||||
|
###-> mellanox_sdk-start
|
||||||
|
###-> mellanox_sdk-end
|
||||||
|
|
||||||
|
###-> mellanox_hw_mgmt-start
|
||||||
|
0001-i2c-mlxcpld-Update-module-license.patch
|
||||||
|
0002-i2c-mlxcpld-Decrease-polling-time-for-performance-im.patch
|
||||||
|
0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-settin.patch
|
||||||
|
0004-i2c-mux-mlxcpld-Update-module-license.patch
|
||||||
|
0005-i2c-mux-mlxcpld-Move-header-file-out-of-x86-realm.patch
|
||||||
|
0006-i2c-mux-mlxcpld-Convert-driver-to-platform-driver.patch
|
||||||
|
0007-i2c-mux-mlxcpld-Prepare-mux-selection-infrastructure.patch
|
||||||
|
0008-i2c-mux-mlxcpld-Get-rid-of-adapter-numbers-enforceme.patch
|
||||||
|
0009-i2c-mux-mlxcpld-Extend-driver-to-support-word-addres.patch
|
||||||
|
0010-i2c-mux-mlxcpld-Extend-supported-mux-number.patch
|
||||||
|
0011-i2c-mux-mlxcpld-Add-callback-to-notify-mux-creation-.patch
|
||||||
|
0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch
|
||||||
|
0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch
|
||||||
|
0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch
|
||||||
|
0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch
|
||||||
|
0103-mlxsw-core-Remove-unnecessary-asserts.patch
|
||||||
|
0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch
|
||||||
|
0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch
|
||||||
|
0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch
|
||||||
|
0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch
|
||||||
|
###-> mellanox_hw_mgmt-end
|
||||||
|
|
||||||
|
# Cisco patches for 5.10 kernel
|
||||||
|
cisco-mtd-part.patch
|
||||||
|
cisco-mdio-mux-support-acpi.patch
|
||||||
|
cisco-x86-gpio-config.patch
|
||||||
|
|
||||||
|
# sFlow + dropmon support
|
||||||
|
0001-psample-Encapsulate-packet-metadata-in-a-struct.patch
|
||||||
|
0002-psample-Add-additional-metadata-attributes.patch
|
||||||
|
0003-psample-define-the-macro-PSAMPLE_MD_EXTENDED_ATTR.patch
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marvell platform patches for 4.19
|
||||||
|
armhf_secondary_boot_online.patch
|
||||||
|
#
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Internal patches will be added below (placeholder)
|
||||||
|
# Do not add any public patch below this marker
|
||||||
|
#
|
||||||
|
############################################################
|
@ -0,0 +1,10 @@
|
|||||||
|
# Current non-upstream patch list, should be updated by integrate_kernel_patches.py script
|
||||||
|
0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch
|
||||||
|
0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch
|
||||||
|
0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch
|
||||||
|
0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch
|
||||||
|
0103-mlxsw-core-Remove-unnecessary-asserts.patch
|
||||||
|
0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch
|
||||||
|
0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch
|
||||||
|
0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch
|
||||||
|
0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch
|
@ -0,0 +1,36 @@
|
|||||||
|
# Description: Add kconfig options that has to be included in the kernel
|
||||||
|
# Note: Markers should start with "###->"
|
||||||
|
# Header should end with .*-start eg: any_description-start
|
||||||
|
# Footer must end with .*-end eg: any_description-end
|
||||||
|
# Markers should not be nested
|
||||||
|
|
||||||
|
[common]
|
||||||
|
CONFIG_LOG_BUF_SHIFT=20
|
||||||
|
|
||||||
|
[amd64]
|
||||||
|
# For Inventec d7032
|
||||||
|
CONFIG_GPIO_ICH=m
|
||||||
|
# For mitac ly1200
|
||||||
|
CONFIG_SENSORS_MAX31790=m
|
||||||
|
# For optoe
|
||||||
|
CONFIG_EEPROM_OPTOE=m
|
||||||
|
|
||||||
|
###-> mellanox-start
|
||||||
|
CONFIG_OF=y
|
||||||
|
CONFIG_THERMAL_OF=y
|
||||||
|
CONFIG_CPU_THERMAL=y
|
||||||
|
CONFIG_PINCTRL_CANNONLAKE=m
|
||||||
|
CONFIG_PINCTRL_DENVERTON=m
|
||||||
|
###-> mellanox-end
|
||||||
|
|
||||||
|
# For Cisco 8000
|
||||||
|
CONFIG_PHYLIB=m
|
||||||
|
CONFIG_GPIOLIB=y
|
||||||
|
CONFIG_OF_GPIO=y
|
||||||
|
CONFIG_OF=y
|
||||||
|
CONFIG_OF_MDIO=m
|
||||||
|
|
||||||
|
[armhf]
|
||||||
|
CONFIG_EEPROM_SFF_8436=m
|
||||||
|
CONFIG_EEPROM_OPTOE=m
|
||||||
|
CONFIG_I2C_MUX_GPIO=m
|
12
platform/mellanox/integration-scripts/tests/data/new_kconfig
Normal file
12
platform/mellanox/integration-scripts/tests/data/new_kconfig
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
# New hw-mgmt 7.0020.5048 kernel config flags
|
||||||
|
|
||||||
|
CONFIG_SPI_PXA2XX=m
|
||||||
|
CONFIG_THERMAL_NETLINK=y
|
||||||
|
CONFIG_SENSORS_XDPE152=m
|
||||||
|
CONFIG_SENSORS_DRIVETEMP=m
|
||||||
|
CONFIG_SENSORS_IIO_HWMON=m
|
||||||
|
CONFIG_SENSORS_LM25066=m
|
||||||
|
CONFIG_SENSORS_UCD9000=m
|
||||||
|
CONFIG_SENSORS_UCD9200=m
|
||||||
|
CONFIG_THERMAL_OF=y
|
27
platform/mellanox/integration-scripts/tests/data/new_series
Normal file
27
platform/mellanox/integration-scripts/tests/data/new_series
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
# Patches updated from hw-mgmt 7.0020.5048
|
||||||
|
|
||||||
|
0001-i2c-mlxcpld-Update-module-license.patch
|
||||||
|
0002-i2c-mlxcpld-Decrease-polling-time-for-performance-im.patch
|
||||||
|
0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-settin.patch
|
||||||
|
0004-i2c-mux-mlxcpld-Update-module-license.patch
|
||||||
|
0005-i2c-mux-mlxcpld-Move-header-file-out-of-x86-realm.patch
|
||||||
|
0006-i2c-mux-mlxcpld-Convert-driver-to-platform-driver.patch
|
||||||
|
0007-i2c-mux-mlxcpld-Prepare-mux-selection-infrastructure.patch
|
||||||
|
0008-i2c-mux-mlxcpld-Get-rid-of-adapter-numbers-enforceme.patch
|
||||||
|
0009-i2c-mux-mlxcpld-Extend-driver-to-support-word-addres.patch
|
||||||
|
0010-i2c-mux-mlxcpld-Extend-supported-mux-number.patch
|
||||||
|
0011-i2c-mux-mlxcpld-Add-callback-to-notify-mux-creation-.patch
|
||||||
|
0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch
|
||||||
|
0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch
|
||||||
|
0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch
|
||||||
|
0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch
|
||||||
|
0103-mlxsw-core-Remove-unnecessary-asserts.patch
|
||||||
|
0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch
|
||||||
|
0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch
|
||||||
|
0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch
|
||||||
|
0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch
|
||||||
|
0168-TMP-mlxsw-minimal-Ignore-error-reading-SPAD-register.patch
|
||||||
|
0169-TMP-mlxsw-i2c-Prevent-transaction-execution-for-spec.patch
|
||||||
|
0172-DS-platform-mlx-platform-Add-SPI-path-for-rack-switc.patch
|
||||||
|
0174-DS-mlxsw-core_linecards-Skip-devlink-and-provisionin.patch
|
64
platform/mellanox/integration-scripts/tests/data/series
Executable file
64
platform/mellanox/integration-scripts/tests/data/series
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
# This series applies on GIT commit 18c5597832fcf6988111b05a9a1607ae148723c
|
||||||
|
# Note: Markers should start with "###->".
|
||||||
|
# Header should end with .*-start eg: any_description-start
|
||||||
|
# Footer must end with .*-end eg: any_description-end
|
||||||
|
# Markers should not be nested
|
||||||
|
|
||||||
|
# Backport from 5.15
|
||||||
|
0001-x86-platform-Increase-maximum-GPIO-number-for-X86_64.patch
|
||||||
|
|
||||||
|
# Backport from 5.16
|
||||||
|
0001-net-arp-introduce-arp_evict_nocarrier-sysctl-paramet.patch
|
||||||
|
|
||||||
|
# Backport from 5.19
|
||||||
|
0001-net-ipv6-Introduce-accept_unsolicited_na-knob-to-imp.patch
|
||||||
|
0002-net-ipv6-Expand-and-rename-accept_unsolicited_na-to-.patch
|
||||||
|
|
||||||
|
#
|
||||||
|
# This series applies on GIT commit 1451b36b2b0d62178e42f648d8a18131af18f7d8
|
||||||
|
# Tkernel-sched-core-fix-cgroup-fork-race.patch
|
||||||
|
# Tconfig-mlnx-sn2700.patch
|
||||||
|
# Tdriver-at24-fix-odd-length-two-byte-access.patch
|
||||||
|
# Tdriver-hwmon-lm75b-update.patch
|
||||||
|
# Tdriver-hwmon-pmbus-add-dps460-support.patch
|
||||||
|
# Tdriver-hwmon-pmbus-ucd9200-mlnx.patch
|
||||||
|
# Trtnetlink-catch-EOPNOTSUPP-errors.patch
|
||||||
|
# Tbridge-per-port-multicast-broadcast-flood-flags.patch
|
||||||
|
#
|
||||||
|
|
||||||
|
# Mellanox patches for 5.10
|
||||||
|
###-> mellanox_sdk-start
|
||||||
|
###-> mellanox_sdk-end
|
||||||
|
|
||||||
|
###-> mellanox_hw_mgmt-start
|
||||||
|
0001-i2c-mlxcpld-Update-module-license.patch
|
||||||
|
0002-i2c-mlxcpld-Decrease-polling-time-for-performan.patch
|
||||||
|
0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-s.patch
|
||||||
|
0004-i2c-mux-mlxcpld-Update-module-license.patch
|
||||||
|
0005-i2c-mux-mlxcpld-Move-header-file-out-of-x86-rea.patch
|
||||||
|
0006-i2c-mux-mlxcpld-Convert-driver-to-platform-driv.patch
|
||||||
|
0007-i2c-mux-mlxcpld-Prepare-mux-selection-infrastru.patch
|
||||||
|
0008-i2c-mux-mlxcpld-Get-rid-of-adapter-numbers-enfo.patch
|
||||||
|
###-> mellanox_hw_mgmt-end
|
||||||
|
|
||||||
|
# Cisco patches for 5.10 kernel
|
||||||
|
cisco-mtd-part.patch
|
||||||
|
cisco-mdio-mux-support-acpi.patch
|
||||||
|
cisco-x86-gpio-config.patch
|
||||||
|
|
||||||
|
# sFlow + dropmon support
|
||||||
|
0001-psample-Encapsulate-packet-metadata-in-a-struct.patch
|
||||||
|
0002-psample-Add-additional-metadata-attributes.patch
|
||||||
|
0003-psample-define-the-macro-PSAMPLE_MD_EXTENDED_ATTR.patch
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marvell platform patches for 4.19
|
||||||
|
armhf_secondary_boot_online.patch
|
||||||
|
#
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Internal patches will be added below (placeholder)
|
||||||
|
# Do not add any public patch below this marker
|
||||||
|
#
|
||||||
|
############################################################
|
@ -0,0 +1,96 @@
|
|||||||
|
# This series applies on GIT commit 18c5597832fcf6988111b05a9a1607ae148723c
|
||||||
|
# Note: Markers should start with "###->".
|
||||||
|
# Header should end with .*-start eg: any_description-start
|
||||||
|
# Footer must end with .*-end eg: any_description-end
|
||||||
|
# Markers should not be nested
|
||||||
|
|
||||||
|
# Backport from 5.15
|
||||||
|
0001-x86-platform-Increase-maximum-GPIO-number-for-X86_64.patch
|
||||||
|
|
||||||
|
# Backport from 5.16
|
||||||
|
0001-net-arp-introduce-arp_evict_nocarrier-sysctl-paramet.patch
|
||||||
|
|
||||||
|
# Backport from 5.19
|
||||||
|
0001-net-ipv6-Introduce-accept_unsolicited_na-knob-to-imp.patch
|
||||||
|
0002-net-ipv6-Expand-and-rename-accept_unsolicited_na-to-.patch
|
||||||
|
|
||||||
|
#
|
||||||
|
# This series applies on GIT commit 1451b36b2b0d62178e42f648d8a18131af18f7d8
|
||||||
|
# Tkernel-sched-core-fix-cgroup-fork-race.patch
|
||||||
|
# Tconfig-mlnx-sn2700.patch
|
||||||
|
# Tdriver-at24-fix-odd-length-two-byte-access.patch
|
||||||
|
# Tdriver-hwmon-lm75b-update.patch
|
||||||
|
# Tdriver-hwmon-pmbus-add-dps460-support.patch
|
||||||
|
# Tdriver-hwmon-pmbus-ucd9200-mlnx.patch
|
||||||
|
# Trtnetlink-catch-EOPNOTSUPP-errors.patch
|
||||||
|
# Tbridge-per-port-multicast-broadcast-flood-flags.patch
|
||||||
|
#
|
||||||
|
|
||||||
|
# Mellanox patches for 5.10
|
||||||
|
###-> mellanox_sdk-start
|
||||||
|
###-> mellanox_sdk-end
|
||||||
|
|
||||||
|
###-> mellanox_hw_mgmt-start
|
||||||
|
0001-i2c-mlxcpld-Update-module-license.patch
|
||||||
|
0002-i2c-mlxcpld-Decrease-polling-time-for-performance-im.patch
|
||||||
|
0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-settin.patch
|
||||||
|
0004-i2c-mux-mlxcpld-Update-module-license.patch
|
||||||
|
0005-i2c-mux-mlxcpld-Move-header-file-out-of-x86-realm.patch
|
||||||
|
0006-i2c-mux-mlxcpld-Convert-driver-to-platform-driver.patch
|
||||||
|
0007-i2c-mux-mlxcpld-Prepare-mux-selection-infrastructure.patch
|
||||||
|
0008-i2c-mux-mlxcpld-Get-rid-of-adapter-numbers-enforceme.patch
|
||||||
|
0009-i2c-mux-mlxcpld-Extend-driver-to-support-word-addres.patch
|
||||||
|
0010-i2c-mux-mlxcpld-Extend-supported-mux-number.patch
|
||||||
|
0011-i2c-mux-mlxcpld-Add-callback-to-notify-mux-creation-.patch
|
||||||
|
0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch
|
||||||
|
0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch
|
||||||
|
0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch
|
||||||
|
0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch
|
||||||
|
0103-mlxsw-core-Remove-unnecessary-asserts.patch
|
||||||
|
0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch
|
||||||
|
0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch
|
||||||
|
0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch
|
||||||
|
0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch
|
||||||
|
###-> mellanox_hw_mgmt-end
|
||||||
|
|
||||||
|
# Cisco patches for 5.10 kernel
|
||||||
|
cisco-mtd-part.patch
|
||||||
|
cisco-mdio-mux-support-acpi.patch
|
||||||
|
cisco-x86-gpio-config.patch
|
||||||
|
|
||||||
|
# sFlow + dropmon support
|
||||||
|
0001-psample-Encapsulate-packet-metadata-in-a-struct.patch
|
||||||
|
0002-psample-Add-additional-metadata-attributes.patch
|
||||||
|
0003-psample-define-the-macro-PSAMPLE_MD_EXTENDED_ATTR.patch
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marvell platform patches for 4.19
|
||||||
|
armhf_secondary_boot_online.patch
|
||||||
|
#
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Internal patches will be added below (placeholder)
|
||||||
|
# Do not add any public patch below this marker
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
CONFIG_SPI_PXA2XX=m
|
||||||
|
CONFIG_THERMAL_NETLINK=y
|
||||||
|
CONFIG_SENSORS_XDPE152=m
|
||||||
|
CONFIG_SENSORS_DRIVETEMP=m
|
||||||
|
CONFIG_SENSORS_IIO_HWMON=m
|
||||||
|
CONFIG_SENSORS_LM25066=m
|
||||||
|
CONFIG_SENSORS_UCD9000=m
|
||||||
|
CONFIG_SENSORS_UCD9200=m
|
||||||
|
CONFIG_THERMAL_OF=y
|
||||||
|
|
||||||
|
CONFIG_SPI_PXA2XX=m
|
||||||
|
CONFIG_THERMAL_NETLINK=y
|
||||||
|
CONFIG_SENSORS_XDPE152=m
|
||||||
|
CONFIG_SENSORS_DRIVETEMP=m
|
||||||
|
CONFIG_SENSORS_IIO_HWMON=m
|
||||||
|
CONFIG_SENSORS_LM25066=m
|
||||||
|
CONFIG_SENSORS_UCD9000=m
|
||||||
|
CONFIG_SENSORS_UCD9200=m
|
||||||
|
CONFIG_THERMAL_OF=y
|
159
platform/mellanox/integration-scripts/tests/test_filehandler.py
Normal file
159
platform/mellanox/integration-scripts/tests/test_filehandler.py
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
import sys
|
||||||
|
from unittest import mock
|
||||||
|
sys.path.append('../')
|
||||||
|
from helper import *
|
||||||
|
|
||||||
|
MOCK_SLK_SERIES = """\
|
||||||
|
# Trtnetlink-catch-EOPNOTSUPP-errors.patch
|
||||||
|
# Tbridge-per-port-multicast-broadcast-flood-flags.patch
|
||||||
|
#
|
||||||
|
|
||||||
|
# Mellanox patches for 5.10
|
||||||
|
###-> mellanox_sdk-start
|
||||||
|
###-> mellanox_sdk-end
|
||||||
|
|
||||||
|
###-> mellanox_hw_mgmt-start
|
||||||
|
0001-i2c-mlxcpld-Update-module-license.patch
|
||||||
|
0002-i2c-mlxcpld-Decrease-polling-time-for-performan.patch
|
||||||
|
0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-s.patch
|
||||||
|
0004-i2c-mux-mlxcpld-Update-module-license.patch
|
||||||
|
###-> mellanox_hw_mgmt-end
|
||||||
|
"""
|
||||||
|
|
||||||
|
MOCK_SLK_KCFG = """\
|
||||||
|
CONFIG_RANDOM=rrr
|
||||||
|
|
||||||
|
[common]
|
||||||
|
CONFIG_LOG_BUF_SHIFT=20
|
||||||
|
|
||||||
|
[amd64]
|
||||||
|
CONFIG_SENSORS_DPS1900=m
|
||||||
|
|
||||||
|
###-> mellanox-start
|
||||||
|
CONFIG_OF=y
|
||||||
|
CONFIG_THERMAL_OF=y
|
||||||
|
CONFIG_DW_DMAC_PCI=y
|
||||||
|
###-> mellanox-end
|
||||||
|
|
||||||
|
[armhf]
|
||||||
|
CONFIG_EEPROM_SFF_8436=m
|
||||||
|
CONFIG_EEPROM_OPTOE=m
|
||||||
|
CONFIG_I2C_MUX_GPIO=y
|
||||||
|
"""
|
||||||
|
|
||||||
|
UPDATED_MLNX_KCFG = """\
|
||||||
|
CONFIG_OF=y
|
||||||
|
CONFIG_THERMAL_OF=y
|
||||||
|
CONFIG_DW_DMAC_PCI=y
|
||||||
|
CONFIG_I2C_I801=m
|
||||||
|
CONFIG_PINCTRL=y
|
||||||
|
CONFIG_PINCTRL_INTEL=m
|
||||||
|
CONFIG_I2C_MUX_PCA954X=m
|
||||||
|
CONFIG_SPI_PXA2XX=m
|
||||||
|
"""
|
||||||
|
|
||||||
|
FINAL_MOCK_SLK_KCFG = """\
|
||||||
|
CONFIG_RANDOM=rrr
|
||||||
|
|
||||||
|
[common]
|
||||||
|
CONFIG_LOG_BUF_SHIFT=20
|
||||||
|
|
||||||
|
[amd64]
|
||||||
|
CONFIG_SENSORS_DPS1900=m
|
||||||
|
|
||||||
|
###-> mellanox-start
|
||||||
|
CONFIG_OF=y
|
||||||
|
CONFIG_THERMAL_OF=y
|
||||||
|
CONFIG_DW_DMAC_PCI=y
|
||||||
|
CONFIG_I2C_I801=m
|
||||||
|
CONFIG_PINCTRL=y
|
||||||
|
CONFIG_PINCTRL_INTEL=m
|
||||||
|
CONFIG_I2C_MUX_PCA954X=m
|
||||||
|
CONFIG_SPI_PXA2XX=m
|
||||||
|
###-> mellanox-end
|
||||||
|
|
||||||
|
[armhf]
|
||||||
|
CONFIG_EEPROM_SFF_8436=m
|
||||||
|
CONFIG_EEPROM_OPTOE=m
|
||||||
|
CONFIG_I2C_MUX_GPIO=y
|
||||||
|
"""
|
||||||
|
|
||||||
|
LINES_WRITE = []
|
||||||
|
LINES_READ = []
|
||||||
|
|
||||||
|
def writer_mock(path, lines, raw=False):
|
||||||
|
global LINES_WRITE
|
||||||
|
if raw:
|
||||||
|
join_with = ""
|
||||||
|
else:
|
||||||
|
join_with = "\n"
|
||||||
|
print("Expected: ")
|
||||||
|
print(join_with.join(LINES_WRITE))
|
||||||
|
print("Recieved:")
|
||||||
|
print(join_with.join(lines))
|
||||||
|
assert LINES_WRITE == lines
|
||||||
|
|
||||||
|
def read_raw_mock(path):
|
||||||
|
global LINES_READ
|
||||||
|
return LINES_READ
|
||||||
|
|
||||||
|
class TestFilehandler:
|
||||||
|
def test_find_markers(self):
|
||||||
|
lines = MOCK_SLK_SERIES.split("\n")
|
||||||
|
print(lines)
|
||||||
|
i_start, i_end = FileHandler.find_marker_indices(lines, "mellanox_hw_mgmt")
|
||||||
|
print(i_start, i_end)
|
||||||
|
assert lines[i_start] == "###-> mellanox_hw_mgmt-start"
|
||||||
|
assert lines[i_end] == "###-> mellanox_hw_mgmt-end"
|
||||||
|
|
||||||
|
i_start, i_end = FileHandler.find_marker_indices(lines, "mellanox_sdk")
|
||||||
|
print(i_start, i_end)
|
||||||
|
assert lines[i_start] == "###-> mellanox_sdk-start"
|
||||||
|
assert lines[i_end] == "###-> mellanox_sdk-end"
|
||||||
|
|
||||||
|
i_start, i_end = FileHandler.find_marker_indices(lines, "whatevrr")
|
||||||
|
print(i_start, i_end)
|
||||||
|
assert i_start == -1
|
||||||
|
assert i_end == len(lines)
|
||||||
|
|
||||||
|
i_start, i_end = FileHandler.find_marker_indices(lines)
|
||||||
|
print(i_start, i_end)
|
||||||
|
assert i_start == -1
|
||||||
|
assert i_end == len(lines)
|
||||||
|
|
||||||
|
@mock.patch('helper.FileHandler.read_raw', side_effect=read_raw_mock)
|
||||||
|
def test_read_kconfig_parser(self, mock_read_raw):
|
||||||
|
global LINES_READ
|
||||||
|
LINES_READ = MOCK_SLK_KCFG.split("\n")
|
||||||
|
all_cfg = FileHandler.read_kconfig_parser("")
|
||||||
|
print(all_cfg)
|
||||||
|
assert all_cfg['no_parent'] == ['CONFIG_RANDOM=rrr']
|
||||||
|
assert all_cfg['common'] == ['CONFIG_LOG_BUF_SHIFT=20']
|
||||||
|
assert all_cfg['amd64'] == ['CONFIG_SENSORS_DPS1900=m', 'CONFIG_OF=y', 'CONFIG_THERMAL_OF=y', 'CONFIG_DW_DMAC_PCI=y']
|
||||||
|
assert all_cfg['armhf'] == ['CONFIG_EEPROM_SFF_8436=m', 'CONFIG_EEPROM_OPTOE=m', 'CONFIG_I2C_MUX_GPIO=y']
|
||||||
|
|
||||||
|
@mock.patch('helper.FileHandler.write_lines', side_effect=writer_mock)
|
||||||
|
@mock.patch('helper.FileHandler.read_raw', side_effect=read_raw_mock)
|
||||||
|
def test_write_lines_marker(self, mock_read_raw, mock_write_lines_marker):
|
||||||
|
global LINES_READ
|
||||||
|
global LINES_WRITE
|
||||||
|
LINES_READ = MOCK_SLK_KCFG.splitlines(True)
|
||||||
|
LINES_WRITE = FINAL_MOCK_SLK_KCFG.splitlines(True)
|
||||||
|
|
||||||
|
list_opts = KCFG.parse_opts_strs(UPDATED_MLNX_KCFG.split("\n"))
|
||||||
|
writable_opts = KCFG.get_writable_opts(list_opts)
|
||||||
|
|
||||||
|
FileHandler.write_lines_marker("", writable_opts, marker="mellanox")
|
||||||
|
|
||||||
|
@mock.patch('helper.FileHandler.write_lines', side_effect=writer_mock)
|
||||||
|
@mock.patch('helper.FileHandler.read_raw', side_effect=read_raw_mock)
|
||||||
|
def test_read_kconfig_inclusion(self, mock_read_raw, mock_write_lines_marker):
|
||||||
|
global LINES_READ
|
||||||
|
LINES_READ = FINAL_MOCK_SLK_KCFG.splitlines(True)
|
||||||
|
opts = FileHandler.read_kconfig_inclusion("")
|
||||||
|
|
||||||
|
global LINES_WRITE
|
||||||
|
LINES_WRITE = UPDATED_MLNX_KCFG.splitlines()
|
||||||
|
writable_opts = KCFG.get_writable_opts(KCFG.parse_opts_strs(opts))
|
||||||
|
print(writable_opts)
|
||||||
|
FileHandler.write_lines("", writable_opts)
|
122
platform/mellanox/integration-scripts/tests/test_hwmgmtaction.py
Normal file
122
platform/mellanox/integration-scripts/tests/test_hwmgmtaction.py
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
import sys
|
||||||
|
import filecmp
|
||||||
|
from unittest import mock, TestCase
|
||||||
|
sys.path.append('../')
|
||||||
|
from hwmgmt_kernel_patches import *
|
||||||
|
|
||||||
|
NEW_NONUP_LIST = """ \
|
||||||
|
0168-TMP-mlxsw-minimal-Ignore-error-reading-SPAD-register.patch
|
||||||
|
0169-TMP-mlxsw-i2c-Prevent-transaction-execution-for-spec.patch
|
||||||
|
0172-DS-platform-mlx-platform-Add-SPI-path-for-rack-switc.patch
|
||||||
|
0174-DS-mlxsw-core_linecards-Skip-devlink-and-provisionin.patch
|
||||||
|
"""
|
||||||
|
|
||||||
|
NEW_UP_LIST = """\
|
||||||
|
0001-i2c-mlxcpld-Update-module-license.patch
|
||||||
|
0002-i2c-mlxcpld-Decrease-polling-time-for-performance-im.patch
|
||||||
|
0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-settin.patch
|
||||||
|
0004-i2c-mux-mlxcpld-Update-module-license.patch
|
||||||
|
0005-i2c-mux-mlxcpld-Move-header-file-out-of-x86-realm.patch
|
||||||
|
0006-i2c-mux-mlxcpld-Convert-driver-to-platform-driver.patch
|
||||||
|
0007-i2c-mux-mlxcpld-Prepare-mux-selection-infrastructure.patch
|
||||||
|
0008-i2c-mux-mlxcpld-Get-rid-of-adapter-numbers-enforceme.patch
|
||||||
|
0009-i2c-mux-mlxcpld-Extend-driver-to-support-word-addres.patch
|
||||||
|
0010-i2c-mux-mlxcpld-Extend-supported-mux-number.patch
|
||||||
|
0011-i2c-mux-mlxcpld-Add-callback-to-notify-mux-creation-.patch
|
||||||
|
0099-mlxsw-core_hwmon-Fix-variable-names-for-hwmon-attrib.patch
|
||||||
|
0100-mlxsw-core_thermal-Rename-labels-according-to-naming.patch
|
||||||
|
0101-mlxsw-core_thermal-Remove-obsolete-API-for-query-res.patch
|
||||||
|
0102-mlxsw-reg-Add-mgpir_-prefix-to-MGPIR-fields-comments.patch
|
||||||
|
0103-mlxsw-core-Remove-unnecessary-asserts.patch
|
||||||
|
0104-mlxsw-reg-Extend-MTMP-register-with-new-slot-number-.patch
|
||||||
|
0105-mlxsw-reg-Extend-MTBR-register-with-new-slot-number-.patch
|
||||||
|
0106-mlxsw-reg-Extend-MCIA-register-with-new-slot-number-.patch
|
||||||
|
0107-mlxsw-reg-Extend-MCION-register-with-new-slot-number.patch
|
||||||
|
"""
|
||||||
|
|
||||||
|
REL_INPUTS_DIR = "platform/mellanox/integration-scripts/tests/data/"
|
||||||
|
MOCK_INPUTS_DIR = "/sonic/" + REL_INPUTS_DIR
|
||||||
|
MOCK_WRITE_FILE = MOCK_INPUTS_DIR + "test_writer_file.out"
|
||||||
|
|
||||||
|
def write_lines_mock(path, lines, raw=False):
|
||||||
|
# Create the dir if it doesn't exist already
|
||||||
|
with open(MOCK_WRITE_FILE, 'w') as f:
|
||||||
|
for line in lines:
|
||||||
|
if raw:
|
||||||
|
f.write(f"{line}")
|
||||||
|
else:
|
||||||
|
f.write(f"{line}\n")
|
||||||
|
|
||||||
|
def mock_hwmgmt_args():
|
||||||
|
with mock.patch("sys.argv", ["hwmgmt_kernel_patches.py", "post",
|
||||||
|
"--patches", "/tmp",
|
||||||
|
"--non_up_patches", "/tmp",
|
||||||
|
"--config_inclusion", MOCK_INPUTS_DIR+"/new_kconfig",
|
||||||
|
"--series", MOCK_INPUTS_DIR+"/new_series",
|
||||||
|
"--current_non_up_patches", MOCK_INPUTS_DIR+"/hwmgmt_nonup_patches",
|
||||||
|
"--build_root", "/sonic"]):
|
||||||
|
parser = create_parser()
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
def check_file_content(path):
|
||||||
|
list1 = FileHandler.read_raw(MOCK_WRITE_FILE)
|
||||||
|
list2 = FileHandler.read_raw(path)
|
||||||
|
for i in range(0, len(list1)):
|
||||||
|
if list1[i] != list2[i]:
|
||||||
|
print("--- {}\n--- {}".format(list1[i], list2[i]))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
@mock.patch('helper.SLK_PATCH_LOC', REL_INPUTS_DIR)
|
||||||
|
@mock.patch('helper.SLK_SERIES', REL_INPUTS_DIR+"series")
|
||||||
|
@mock.patch('helper.SLK_KCONFIG', REL_INPUTS_DIR+"kconfig-inclusion")
|
||||||
|
class TestHwMgmtPostAction(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.action = HwMgmtAction.get(mock_hwmgmt_args())
|
||||||
|
self.action.read_data()
|
||||||
|
# Populate the new_up, new_down list
|
||||||
|
Data.new_up = NEW_UP_LIST.splitlines()
|
||||||
|
Data.new_down = NEW_NONUP_LIST.splitlines()
|
||||||
|
Data.old_series = FileHandler.read_raw(MOCK_INPUTS_DIR+"/series")
|
||||||
|
all_kcfg = FileHandler.read_kconfig_parser(MOCK_INPUTS_DIR+"/kconfig-inclusions")
|
||||||
|
Data.current_kcfg = []
|
||||||
|
for hdr in HDRS:
|
||||||
|
Data.current_kcfg.extend(all_kcfg.get(hdr, []))
|
||||||
|
Data.current_kcfg = KCFG.parse_opts_strs(Data.current_kcfg)
|
||||||
|
|
||||||
|
def test_find_mlnx_hw_mgmt_markers(self):
|
||||||
|
self.action.find_mlnx_hw_mgmt_markers()
|
||||||
|
print(Data.i_mlnx_start, Data.i_mlnx_end)
|
||||||
|
assert Data.old_series[Data.i_mlnx_start].strip() == "###-> mellanox_hw_mgmt-start"
|
||||||
|
assert Data.old_series[Data.i_mlnx_end].strip() == "###-> mellanox_hw_mgmt-end"
|
||||||
|
|
||||||
|
def test_find_conflicts(self):
|
||||||
|
# Add a line to create conflict
|
||||||
|
print(Data.current_kcfg)
|
||||||
|
Data.updated_kcfg.append(["CONFIG_EEPROM_OPTOE", "n"])
|
||||||
|
self.action.find_mlnx_hw_mgmt_markers()
|
||||||
|
assert self.action.find_conflicts() == True
|
||||||
|
|
||||||
|
# Add a duplicate option
|
||||||
|
Data.updated_kcfg.pop(-1)
|
||||||
|
Data.updated_kcfg.append(["CONFIG_EEPROM_OPTOE", "m"])
|
||||||
|
assert self.action.find_conflicts() == False
|
||||||
|
|
||||||
|
# Check with no conflicts or duplicates
|
||||||
|
Data.updated_kcfg.pop(-1)
|
||||||
|
assert self.action.find_conflicts() == False
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch('helper.FileHandler.write_lines', side_effect=write_lines_mock)
|
||||||
|
def test_write_final_slk_series(self, mock_write_lines):
|
||||||
|
self.action.find_mlnx_hw_mgmt_markers()
|
||||||
|
assert not self.action.find_conflicts()
|
||||||
|
self.action.write_final_slk_series()
|
||||||
|
assert check_file_content(MOCK_INPUTS_DIR+"expected_data/series")
|
||||||
|
|
||||||
|
def test_write_kconfig_inclusion(self):
|
||||||
|
self.action.find_mlnx_hw_mgmt_markers()
|
||||||
|
assert not self.action.find_conflicts()
|
||||||
|
print(Data.updated_kcfg)
|
||||||
|
FileHandler.write_lines_marker(MOCK_WRITE_FILE, KCFG.get_writable_opts(Data.updated_kcfg), MLNX_KFG_MARKER)
|
||||||
|
assert check_file_content(MOCK_INPUTS_DIR+"expected_data/kconfig-inclusions")
|
Reference in New Issue
Block a user