[Mellanox] Upgrade HW-MGMT to 7.0030.2008 and update platform-api (#17134)
Why I did it Add platform support for Debian 12 (Bookworm) on Mellanox Platform How I did it Update hw-management to v7.0030.2008 Deprecate the sfp_count == module_count approach in favour of asic init completion Ref: Mellanox/hw-mgmt@bf4f593 Add xxd package to base image which is required by hw-management scripts Add the non-upstream flag into linux kernel cache options Update the thermalctl logic based on new sysfs attributes Fix the integrate-mlnx-hw-mgmt script to not populate the arm64 Kconfig How to verify it Build kernel and run platform tests Signed-off-by: Vivek Reddy <vkarri@nvidia.com> Co-authored-by: Junchao-Mellanox <junchao@nvidia.com> Co-authored-by: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com>
This commit is contained in:
parent
98fc38ebec
commit
3fc48d51db
@ -398,6 +398,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
|
||||
resolvconf \
|
||||
lsof \
|
||||
sysstat \
|
||||
xxd \
|
||||
zstd
|
||||
|
||||
# Have systemd create the auditd log directory
|
||||
|
@ -8,8 +8,9 @@ declare -r SYSLOG_INFO="info"
|
||||
|
||||
declare -r HW_MGMT_CONFIG="/var/run/hw-management/config"
|
||||
|
||||
declare -r MODULE_COUNTER="${HW_MGMT_CONFIG}/module_counter"
|
||||
declare -r SFP_COUNTER="${HW_MGMT_CONFIG}/sfp_counter"
|
||||
declare -r ASIC_INIT_DONE="${HW_MGMT_CONFIG}/asics_init_done"
|
||||
declare -r NUM_ASICS="${HW_MGMT_CONFIG}/asic_num"
|
||||
declare -r ASIC_CHIPUP_COMPLETED="${HW_MGMT_CONFIG}/asic_chipup_completed"
|
||||
|
||||
declare -r EXIT_SUCCESS="0"
|
||||
declare -r EXIT_TIMEOUT="1"
|
||||
@ -26,12 +27,11 @@ function log_info() {
|
||||
eval "${SYSLOG_LOGGER} -t ${SYSLOG_IDENTIFIER} -p ${SYSLOG_INFO} $@"
|
||||
}
|
||||
|
||||
function wait_for_sfp() {
|
||||
local -r _NUM_MATCH="^[0-9]+$"
|
||||
local -r _NUM_ZERO="0"
|
||||
function wait_for_asic_chipup() {
|
||||
|
||||
local _MODULE_CNT="0"
|
||||
local _SFP_CNT="0"
|
||||
local _ASIC_INIT="0"
|
||||
local _ASIC_COUNT="0"
|
||||
local _ASICS_CHIPUP="0"
|
||||
|
||||
local -i _WDOG_CNT="1"
|
||||
local -ir _WDOG_MAX="300"
|
||||
@ -39,31 +39,30 @@ function wait_for_sfp() {
|
||||
local -r _TIMEOUT="1s"
|
||||
|
||||
while [[ "${_WDOG_CNT}" -le "${_WDOG_MAX}" ]]; do
|
||||
_MODULE_CNT="$(cat ${MODULE_COUNTER} 2>&1)"
|
||||
_SFP_CNT="$(cat ${SFP_COUNTER} 2>&1)"
|
||||
_ASIC_INIT="$(cat ${ASIC_INIT_DONE} 2>&1)"
|
||||
_ASIC_COUNT="$(cat ${NUM_ASICS} 2>&1)"
|
||||
_ASICS_CHIPUP="$(cat ${ASIC_CHIPUP_COMPLETED} 2>&1)"
|
||||
|
||||
if [[ "${_MODULE_CNT}" =~ ${_NUM_MATCH} && "${_SFP_CNT}" =~ ${_NUM_MATCH} ]]; then
|
||||
if [[ "${_SFP_CNT}" -gt "${_NUM_ZERO}" && "${_MODULE_CNT}" -eq "${_SFP_CNT}" ]]; then
|
||||
return "${EXIT_SUCCESS}"
|
||||
fi
|
||||
if [[ "${_ASIC_INIT}" -eq 1 && "${_ASIC_COUNT}" -eq "${_ASICS_CHIPUP}" ]]; then
|
||||
return "${EXIT_SUCCESS}"
|
||||
fi
|
||||
|
||||
let "_WDOG_CNT++"
|
||||
sleep "${_TIMEOUT}"
|
||||
done
|
||||
|
||||
log_error "Mellanox ASIC is not ready: INIT: ${_ASIC_INIT}, NUM_ASIC: ${_ASIC_COUNT}, CHIPUP: ${_ASICS_CHIPUP} timeout...."
|
||||
return "${EXIT_TIMEOUT}"
|
||||
}
|
||||
|
||||
log_info "Wait for SFP interfaces to be ready"
|
||||
log_info "Wait for Mellanox ASIC to be ready"
|
||||
|
||||
wait_for_sfp
|
||||
wait_for_asic_chipup
|
||||
EXIT_CODE="$?"
|
||||
if [[ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then
|
||||
log_error "SFP interfaces are not ready: timeout"
|
||||
exit "${EXIT_CODE}"
|
||||
fi
|
||||
|
||||
log_info "SFP interfaces are ready"
|
||||
log_notice "Mellanox ASIC is ready"
|
||||
|
||||
exit "${EXIT_SUCCESS}"
|
||||
|
@ -16,7 +16,7 @@
|
||||
#
|
||||
# Mellanox HW Management
|
||||
|
||||
MLNX_HW_MANAGEMENT_VERSION = 7.0030.1011
|
||||
MLNX_HW_MANAGEMENT_VERSION = 7.0030.2008
|
||||
|
||||
export MLNX_HW_MANAGEMENT_VERSION
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c7d4c31a212eec6a5543f554ffb2c63c5cb621e3
|
||||
Subproject commit f0cbd0e61f77ca0d8ca37612abc5fe8339e0f884
|
@ -1,169 +1,33 @@
|
||||
# Current non-upstream patch list, should be updated by hwmgmt_kernel_patches.py script
|
||||
0049-leds-mlxreg-Provide-conversion-for-hardware-LED-colo.patch
|
||||
0042-hwmon-mlxreg-fan-Add-support-for-new-flavour-of-capa.patch
|
||||
0044-leds-mlxreg-Add-support-for-new-flavour-of-capabilit.patch
|
||||
0045-leds-mlxreg-Remove-code-for-amber-LED-colour.patch
|
||||
0046-Extend-driver-to-support-Infineon-Digital-Multi-phas.patch
|
||||
0047-dt-bindings-trivial-devices-Add-infineon-xdpe1a2g7.patch
|
||||
0048-hwmon-pmbus-Add-support-for-MPS-Multi-phase-mp2891-c.patch
|
||||
0049-dt-bindings-trivial-devices-Add-mps-mp2891.patch
|
||||
0050-leds-mlxreg-Skip-setting-LED-color-during-initializa.patch
|
||||
0051-leds-mlxreg-Allow-multi-instantiation-of-same-name-L.patch
|
||||
0098-1-Revert-mlxsw-Use-u16-for-local_port-field.patch
|
||||
0098-2-Revert-mlxsw-i2c-Fix-chunk-size-setting.patch
|
||||
0098-3-Revert-mlxsw-core_hwmon-Adjust-module-label-names.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
|
||||
0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patch
|
||||
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
|
||||
0167-DS-lan743x-Add-support-for-fixed-phy.patch
|
||||
0168-TMP-mlxsw-minimal-Ignore-error-reading-SPAD-register.patch
|
||||
0171-platform-mellanox-mlxreg-lc-Fix-cleanup-on-failure-a.patch
|
||||
0172-DS-platform-mlx-platform-Add-SPI-path-for-rack-switc.patch
|
||||
0174-DS-mlxsw-core_linecards-Skip-devlink-and-provisionin.patch
|
||||
0181-Revert-Fix-out-of-bounds-memory-accesses-in-thermal.patch
|
||||
0182-platform-mellanox-Introduce-support-of-new-Nvidia-L1.patch
|
||||
0183-platform-mellanox-Split-initialization-procedure.patch
|
||||
0184-platform-mellanox-Split-logic-in-init-and-exit-flow.patch
|
||||
0185-platform-mellanox-Extend-all-systems-with-I2C-notifi.patch
|
||||
0187-platform_data-mlxreg-Add-field-with-mapped-resource-.patch
|
||||
0188-i2c-mux-Add-register-map-based-mux-driver.patch
|
||||
0189-i2c-mlxcpld-Allow-driver-to-run-on-ARM64-architectur.patch
|
||||
0190-i2c-mlxcpld-Modify-base-address-type.patch
|
||||
0191-i2c-mlxcpld-Allow-to-configure-base-address-of-regis.patch
|
||||
0192-i2c-mlxcpld-Add-support-for-extended-transaction-len.patch
|
||||
0193-platform-mellanox-mlx-platform-Add-mux-selection-reg.patch
|
||||
0194-platform-mellanox-mlx-platform-Move-bus-shift-assign.patch
|
||||
0195-platform-mellanox-Add-support-for-dynamic-I2C-channe.patch
|
||||
0196-platform-mellanox-Relocate-mlx-platform-driver.patch
|
||||
0197-platform-mellanox-Add-initial-support-for-PCIe-based.patch
|
||||
0198-platform-mellanox-Introduce-support-for-switches-bas.patch
|
||||
0199-platform-mellanox-mlx-platform-Add-reset-and-extend-.patch
|
||||
0200-dt-bindings-i2c-mellanox-i2c-mlxbf-convert-txt-to-YA.patch
|
||||
0203-i2c-mlxbf-remove-IRQF_ONESHOT.patch
|
||||
0206-i2c-mlxbf-add-multi-slave-functionality.patch
|
||||
0207-i2c-mlxbf-support-BlueField-3-SoC.patch
|
||||
0208-i2c-mlxbf-remove-device-tree-support.patch
|
||||
0209-UBUNTU-SAUCE-i2c-mlxbf.c-Add-driver-version.patch
|
||||
0210-platform-mellanox-Typo-fix-in-the-file-mlxbf-bootctl.patch
|
||||
0211-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch
|
||||
0212-platform-mellanox-mlxbf-pmc-Add-Mellanox-BlueField-P.patch
|
||||
0213-platform-mellanox-mlxbf-pmc-fix-kernel-doc-notation.patch
|
||||
0214-platform-mellanox-mlxbf-pmc-Fix-an-IS_ERR-vs-NULL-bu.patch
|
||||
0215-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-pmc.patch
|
||||
0216-UBUNTU-SAUCE-mlxbf_pmc-Fix-references-to-sprintf.patch
|
||||
0217-UBUNTU-SAUCE-mlxbf-pmc-Fix-error-when-reading-unprog.patch
|
||||
0218-UBUNTU-SAUCE-platform-mellanox-Add-mlx-trio-driver.patch
|
||||
0219-UBUNTU-SAUCE-platform-mellanox-mlxbf-tmfifo-Add-Blue.patch
|
||||
0220-UBUNTU-SAUCE-pka-Add-pka-driver.patch
|
||||
0221-UBUNTU-SAUCE-platform-mellanox-Add-mlxbf-livefish-dr.patch
|
||||
0222-workqueue-Add-resource-managed-version-of-delayed-wo.patch
|
||||
0223-devm-helpers-Fix-devm_delayed_work_autocancel-kernel.patch
|
||||
0224-devm-helpers-Add-resource-managed-version-of-work-in.patch
|
||||
0225-UBUNTU-SAUCE-Add-support-to-pwr-mlxbf.c-driver.patch
|
||||
0226-Add-Mellanox-BlueField-Gigabit-Ethernet-driver.patch
|
||||
0227-mlxbf_gige-clear-valid_polarity-upon-open.patch
|
||||
0228-net-mellanox-mlxbf_gige-Replace-non-standard-interru.patch
|
||||
0229-mlxbf_gige-increase-MDIO-polling-rate-to-5us.patch
|
||||
0230-mlxbf_gige-remove-driver-managed-interrupt-counts.patch
|
||||
0231-mlxbf_gige-remove-own-module-name-define-and-use-KBU.patch
|
||||
0232-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch
|
||||
0233-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch
|
||||
0234-UBUNTU-SAUCE-mlxbf_gige-add-validation-of-ACPI-table.patch
|
||||
0235-UBUNTU-SAUCE-mlxbf_gige-set-driver-version-to-1.27.patch
|
||||
0236-UBUNTU-SAUCE-mlxbf_gige-clear-MDIO-gateway-lock-afte.patch
|
||||
0237-mlxbf_gige-compute-MDIO-period-based-on-i1clk.patch
|
||||
0238-net-mlxbf_gige-Fix-an-IS_ERR-vs-NULL-bug-in-mlxbf_gi.patch
|
||||
0239-UBUNTU-SAUCE-mlxbf_gige-add-MDIO-support-for-BlueFie.patch
|
||||
0240-UBUNTU-SAUCE-mlxbf_gige-support-10M-100M-1G-speeds-o.patch
|
||||
0241-UBUNTU-SAUCE-mlxbf_gige-add-BlueField-3-Serdes-confi.patch
|
||||
0242-UBUNTU-SAUCE-mlxbf_gige-add-BlueField-3-ethtool_ops.patch
|
||||
0243-UBUNTU-SAUCE-bluefield_edac-Add-SMC-support.patch
|
||||
0244-UBUNTU-SAUCE-bluefield_edac-Update-license-and-copyr.patch
|
||||
0245-gpio-mlxbf2-Convert-to-device-PM-ops.patch
|
||||
0246-gpio-mlxbf2-Drop-wrong-use-of-ACPI_PTR.patch
|
||||
0247-gpio-mlxbf2-Use-devm_platform_ioremap_resource.patch
|
||||
0248-gpio-mlxbf2-Use-DEFINE_RES_MEM_NAMED-helper-macro.patch
|
||||
0249-gpio-mlxbf2-Introduce-IRQ-support.patch
|
||||
0250-UBUNTU-SAUCE-gpio-mlxbf2.c-support-driver-version.patch
|
||||
0251-mmc-sdhci-of-dwcmshc-add-rockchip-platform-support.patch
|
||||
0252-mmc-sdhci-of-dwcmshc-add-ACPI-support-for-BlueField-.patch
|
||||
0253-mmc-sdhci-of-dwcmshc-fix-error-return-code-in-dwcmsh.patch
|
||||
0254-mmc-sdhci-of-dwcmshc-set-MMC_CAP_WAIT_WHILE_BUSY.patch
|
||||
0255-mmc-sdhci-of-dwcmshc-Re-enable-support-for-the-BlueF.patch
|
||||
0256-UBUNTU-SAUCE-Support-BlueField-3-GPIO-driver.patch
|
||||
0257-regmap-debugfs-Enable-writing-to-the-regmap-debugfs-.patch
|
||||
0258-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch
|
||||
0259-mmc-sdhci-of-dwcmshc-Enable-host-V4-support-for-Blue.patch
|
||||
0260-UBUNTU-SAUCE-mlxbf-pka-Fix-kernel-crash-with-pka-TRN.patch
|
||||
0261-mlxbf-ptm-power-and-thermal-management-debugfs-drive.patch
|
||||
0262-UBUNTU-SAUCE-mlxbf-pmc-Fix-event-string-typo.patch
|
||||
0263-UBUNTU-SAUCE-mlxbf-pmc-Support-for-BlueField-3-perfo.patch
|
||||
0264-UBUNTU-SAUCE-platform-mellanox-Add-ctrl-message-and-.patch
|
||||
0266-UBUNTU-SAUCE-mlxbf-pmc-Bug-fix-for-BlueField-3-count.patch
|
||||
0267-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch
|
||||
0268-DS-mlxsw-core_linecards-Disable-firmware-bundling-ma.patch
|
||||
0269-platform-mellanox-Cosmetic-changes.patch
|
||||
0270-platform-mellanox-Fix-order-in-exit-flow.patch
|
||||
0271-platform-mellanox-Add-new-attributes.patch
|
||||
0272-platform-mellanox-Change-register-offset-addresses.patch
|
||||
0273-platform-mellanox-Add-field-upgrade-capability-regis.patch
|
||||
0274-platform-mellanox-Modify-reset-causes-description.patch
|
||||
0275-mlxsw-Use-u16-for-local_port-field-instead-of-u8.patch
|
||||
0276-mlxsw-minimal-Change-type-for-local-port.patch
|
||||
0277-mlxsw-i2c-Fix-chunk-size-setting-in-output-mailbox-b.patch
|
||||
0278-platform-mellanox-mlx-platform-Modify-graceful-shutd.patch
|
||||
0279-platform-mellanox-mlx-platform-Fix-signals-polarity-.patch
|
||||
0280-platform-mellanox-mlxreg-hotplug-Extend-condition-fo.patch
|
||||
0281-platform-mellanox-mlx-platform-Modify-health-and-pow.patch
|
||||
0282-platform-mellanox-mlx-platform-add-support-of-5th-CP.patch
|
||||
0283-mlxsw-core_hwmon-Align-modules-label-name-assignment.patch
|
||||
0284-platform-mellanox-mlx-platform-fix-CPLD4-PN-report.patch
|
||||
9002-TMP-fix-for-fan-minimum-speed.patch
|
||||
0053-platform-mellanox-Add-support-for-dynamic-I2C-channe.patch
|
||||
0054-platform-mellanox-Introduce-support-for-switches-equ.patch
|
||||
0055-mellanox-Relocate-mlx-platform-driver.patch
|
||||
0066-UBUNTU-SAUCE-sdhci-of-dwcmshc-Enable-host-V4-support.patch
|
||||
0067-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch
|
||||
0068-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-Add-runtime-PM-ope.patch
|
||||
0069-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch
|
||||
0070-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch
|
||||
0071-UBUNTU-SAUCE-mlxbf-gige-Fix-intermittent-no-ip-issue.patch
|
||||
0072-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch
|
||||
0073-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch
|
||||
0074-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch
|
||||
0075-UBUNTU-SAUCE-mlxbf-gige-Fix-kernel-panic-at-shutdown.patch
|
||||
0076-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch
|
||||
0077-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch
|
||||
0078-UBUNTU-SAUCE-mlxbf-bootctl-support-SMC-call-for-sett.patch
|
||||
0079-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch
|
||||
0080-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch
|
||||
0081-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch
|
||||
0082-UBUNTU-SAUCE-mlxbf-ptm-add-atx-debugfs-nodes.patch
|
||||
0083-UBUNTU-SAUCE-mlxbf-ptm-update-module-version.patch
|
||||
0084-UBUNTU-SAUCE-mlxbf-bootctl-Fix-kernel-panic-due-to-b.patch
|
||||
8000-mlxsw-Use-weak-reverse-dependencies-for-firmware-fla.patch
|
||||
8004-mlxsw-minimal-Downstream-Ignore-error-reading-SPAD-r.patch
|
||||
|
@ -98,15 +98,16 @@ endif
|
||||
--kernel_version $(KERNEL_VERSION) \
|
||||
--hw_mgmt_ver ${MLNX_HW_MANAGEMENT_VERSION} $(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_ARM) \
|
||||
--config_file_downstream $(KCFG_DOWN_LIST_ARM) \
|
||||
--kernel_version $(KERNEL_VERSION) \
|
||||
--arch arm64 \
|
||||
--os_type sonic $(LOG_SIMPLE)
|
||||
# Disable Writing KConfigs for arm64 platform
|
||||
# $(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_ARM) \
|
||||
# --config_file_downstream $(KCFG_DOWN_LIST_ARM) \
|
||||
# --kernel_version $(KERNEL_VERSION) \
|
||||
# --arch arm64 \
|
||||
# --os_type sonic $(LOG_SIMPLE)
|
||||
|
||||
$(BUILD_WORKDIR)/$($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hw-mgmt/recipes-kernel/linux/deploy_kernel_patches.py \
|
||||
--dst_accepted_folder $(PTCH_DIR) \
|
||||
|
@ -160,7 +160,7 @@ class DeviceDataManager:
|
||||
@classmethod
|
||||
@utils.read_only_cache()
|
||||
def get_sfp_count(cls):
|
||||
return utils.read_int_from_file('/run/hw-management/config/sfp_counter')
|
||||
return utils.read_int_from_file('/run/hw-management/config/module_counter')
|
||||
|
||||
@classmethod
|
||||
def get_linecard_sfp_count(cls, lc_index):
|
||||
|
@ -216,7 +216,10 @@ class PsuFan(MlnxFan):
|
||||
"""
|
||||
try:
|
||||
# Get PSU fan target speed according to current system cooling level
|
||||
cooling_level = utils.read_int_from_file('/run/hw-management/thermal/cooling_cur_state', log_func=None)
|
||||
pwm = utils.read_int_from_file('/run/hw-management/thermal/pwm1', log_func=None)
|
||||
if pwm >= PWM_MAX:
|
||||
pwm = PWM_MAX - 1
|
||||
cooling_level = int(pwm / PWM_MAX * 10)
|
||||
return int(self.PSU_FAN_SPEED[cooling_level], 16)
|
||||
except Exception:
|
||||
return self.get_speed()
|
||||
|
@ -242,8 +242,8 @@ class Psu(FixedPsu):
|
||||
|
||||
self.psu_power_max_capacity = os.path.join(PSU_PATH, "config/psu{}_power_capacity".format(self.index))
|
||||
|
||||
self.psu_temp = os.path.join(PSU_PATH, 'thermal/psu{}_temp'.format(self.index))
|
||||
self.psu_temp_threshold = os.path.join(PSU_PATH, 'thermal/psu{}_temp_max'.format(self.index))
|
||||
self.psu_temp = os.path.join(PSU_PATH, 'thermal/psu{}_temp1'.format(self.index))
|
||||
self.psu_temp_threshold = os.path.join(PSU_PATH, 'thermal/psu{}_temp1_max'.format(self.index))
|
||||
|
||||
self.psu_power_slope = os.path.join(PSU_PATH, self.PSU_POWER_SLOPE.format(self.index))
|
||||
|
||||
|
@ -65,16 +65,16 @@ THERMAL_NAMING_RULE = {
|
||||
"psu thermals":
|
||||
{
|
||||
"name": "PSU-{} Temp",
|
||||
"temperature": "psu{}_temp",
|
||||
"high_threshold": "psu{}_temp_max",
|
||||
"temperature": "psu{}_temp1",
|
||||
"high_threshold": "psu{}_temp1_max",
|
||||
"type": "indexable"
|
||||
},
|
||||
"chassis thermals": [
|
||||
{
|
||||
"name": "ASIC",
|
||||
"temperature": "asic",
|
||||
"high_threshold": "mlxsw/temp_trip_hot",
|
||||
"high_critical_threshold": "mlxsw/temp_trip_crit"
|
||||
"high_threshold": "asic_temp_emergency",
|
||||
"high_critical_threshold": "asic_temp_trip_crit"
|
||||
},
|
||||
{
|
||||
"name": "Ambient Port Side Temp",
|
||||
@ -105,8 +105,8 @@ THERMAL_NAMING_RULE = {
|
||||
{
|
||||
"name": "Gearbox {} Temp",
|
||||
"temperature": "gearbox{}_temp_input",
|
||||
"high_threshold": "mlxsw-gearbox{}/temp_trip_hot",
|
||||
"high_critical_threshold": "mlxsw-gearbox{}/temp_trip_crit",
|
||||
"high_threshold": "gearbox{}_temp_emergency",
|
||||
"high_critical_threshold": "gearbox{}_temp_trip_crit",
|
||||
"type": "indexable"
|
||||
},
|
||||
{
|
||||
@ -135,8 +135,8 @@ THERMAL_NAMING_RULE = {
|
||||
'linecard thermals': {
|
||||
"name": "Gearbox {} Temp",
|
||||
"temperature": "gearbox{}_temp_input",
|
||||
"high_threshold": "mlxsw-gearbox{}/temp_trip_hot",
|
||||
"high_critical_threshold": "mlxsw-gearbox{}/temp_trip_crit",
|
||||
"high_threshold": "gearbox{}_temp_emergency",
|
||||
"high_critical_threshold": "gearbox{}_temp_trip_crit",
|
||||
"type": "indexable"
|
||||
}
|
||||
}
|
||||
@ -268,16 +268,6 @@ def _check_thermal_sysfs_existence(file_path):
|
||||
|
||||
|
||||
class Thermal(ThermalBase):
|
||||
thermal_algorithm_status = False
|
||||
# Expect cooling level, used for caching the cooling level value before commiting to hardware
|
||||
expect_cooling_level = None
|
||||
# Expect cooling state
|
||||
expect_cooling_state = None
|
||||
# Last committed cooling level
|
||||
last_set_cooling_level = None
|
||||
last_set_cooling_state = None
|
||||
last_set_psu_cooling_level = None
|
||||
|
||||
def __init__(self, name, temp_file, high_th_file, high_crit_th_file, position):
|
||||
"""
|
||||
index should be a string for category ambient and int for other categories
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES.
|
||||
# Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES.
|
||||
# Apache-2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -42,14 +42,3 @@ def auto_recover_mock():
|
||||
utils.read_str_from_file = origin_read_str_from_file
|
||||
utils.write_file = origin_write_file
|
||||
utils.read_float_from_file = origin_read_float_from_file
|
||||
|
||||
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def auto_reset_cooling_level():
|
||||
from sonic_platform.thermal import Thermal
|
||||
yield
|
||||
Thermal.expect_cooling_level = None
|
||||
Thermal.expect_cooling_state = None
|
||||
Thermal.last_set_cooling_level = None
|
||||
Thermal.last_set_cooling_state = None
|
||||
Thermal.last_set_psu_cooling_level = None
|
||||
|
@ -124,8 +124,8 @@ class TestFan:
|
||||
assert fan.get_presence() is False
|
||||
mock_path_exists.return_value = True
|
||||
assert fan.get_presence() is True
|
||||
mock_read_int.return_value = 7
|
||||
assert fan.get_target_speed() == 70
|
||||
mock_read_int.return_value = int(255 / 10 * 7)
|
||||
assert fan.get_target_speed() == 60
|
||||
mock_read_int.return_value = FAN_DIR_VALUE_INTAKE
|
||||
assert fan.get_direction() == Fan.FAN_DIRECTION_INTAKE
|
||||
mock_read_int.return_value = FAN_DIR_VALUE_EXHAUST
|
||||
|
@ -1,201 +1,53 @@
|
||||
--- a/patch/series
|
||||
+++ b/patch/series
|
||||
@@ -111,6 +111,9 @@
|
||||
0045-i2c-mlxcpld-Fix-criteria-for-frequency-setting.patch
|
||||
0046-i2c-mlxcpld-Reduce-polling-time-for-performance-impr.patch
|
||||
0047-i2c-mlxcpld-Allow-flexible-polling-time-setting-for-.patch
|
||||
+0049-leds-mlxreg-Provide-conversion-for-hardware-LED-colo.patch
|
||||
@@ -113,17 +113,49 @@
|
||||
0039-mlxsw-reg-Limit-MTBR-register-payload-to-a-single-da.patch
|
||||
0040-mlxsw-core-Extend-allowed-list-of-external-cooling-d.patch
|
||||
0041-mlxsw-i2c-Utilize-standard-macros-for-dividing-buffe.patch
|
||||
+0042-hwmon-mlxreg-fan-Add-support-for-new-flavour-of-capa.patch
|
||||
0043-hwmon-mlxreg-fan-Extend-number-of-supporetd-fans.patch
|
||||
+0044-leds-mlxreg-Add-support-for-new-flavour-of-capabilit.patch
|
||||
+0045-leds-mlxreg-Remove-code-for-amber-LED-colour.patch
|
||||
+0046-Extend-driver-to-support-Infineon-Digital-Multi-phas.patch
|
||||
+0047-dt-bindings-trivial-devices-Add-infineon-xdpe1a2g7.patch
|
||||
+0048-hwmon-pmbus-Add-support-for-MPS-Multi-phase-mp2891-c.patch
|
||||
+0049-dt-bindings-trivial-devices-Add-mps-mp2891.patch
|
||||
+0050-leds-mlxreg-Skip-setting-LED-color-during-initializa.patch
|
||||
+0051-leds-mlxreg-Allow-multi-instantiation-of-same-name-L.patch
|
||||
0053-mlxsw-core-Avoid-creation-virtual-hwmon-objects-by-t.patch
|
||||
0054-mlxsw-minimal-Simplify-method-of-modules-number-dete.patch
|
||||
0055-platform_data-mlxreg-Add-new-type-to-support-modular.patch
|
||||
@@ -158,7 +161,68 @@
|
||||
0097-1-mlxsw-Use-u16-for-local_port-field.patch
|
||||
0097-2-mlxsw-i2c-Fix-chunk-size-setting.patch
|
||||
0097-3-mlxsw-core_hwmon-Adjust-module-label-names.patch
|
||||
+0098-1-Revert-mlxsw-Use-u16-for-local_port-field.patch
|
||||
+0098-2-Revert-mlxsw-i2c-Fix-chunk-size-setting.patch
|
||||
+0098-3-Revert-mlxsw-core_hwmon-Adjust-module-label-names.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
|
||||
+0108-mlxsw-reg-Extend-PMMP-register-with-new-slot-number-.patch
|
||||
+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
|
||||
0152-mlxsw-i2c-Prevent-transaction-execution-for-spec.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
|
||||
0157-platform-x86-mlx-platform-Make-activation-of-some-dr.patch
|
||||
0158-platform-x86-mlx-platform-Add-cosmetic-changes-for-a.patch
|
||||
0159-mlx-platform-Add-support-for-systems-equipped-with-t.patch
|
||||
@@ -169,15 +233,119 @@
|
||||
0164-hwmon-jc42-Add-support-for-Seiko-Instruments-S-34TS0.patch
|
||||
0165-platform-mellanox-mlxreg-io-Add-locking-for-io-opera.patch
|
||||
0166-DS-leds-leds-mlxreg-Send-udev-event-from-leds-mlxreg.patch
|
||||
+0167-DS-lan743x-Add-support-for-fixed-phy.patch
|
||||
+0168-TMP-mlxsw-minimal-Ignore-error-reading-SPAD-register.patch
|
||||
0170-i2c-mlxcpld-Fix-register-setting-for-400KHz-frequenc.patch
|
||||
+0171-platform-mellanox-mlxreg-lc-Fix-cleanup-on-failure-a.patch
|
||||
+0172-DS-platform-mlx-platform-Add-SPI-path-for-rack-switc.patch
|
||||
0173-mlxsw-core-Add-support-for-OSFP-transceiver-modules.patch
|
||||
+0174-DS-mlxsw-core_linecards-Skip-devlink-and-provisionin.patch
|
||||
0175-hwmon-pmbus-Add-support-for-Infineon-Digital-Multi-p.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
|
||||
0180-hwmon-pmbus-Fix-sensors-readouts-for-MPS-Multi-phase.patch
|
||||
+0181-Revert-Fix-out-of-bounds-memory-accesses-in-thermal.patch
|
||||
+0182-platform-mellanox-Introduce-support-of-new-Nvidia-L1.patch
|
||||
+0183-platform-mellanox-Split-initialization-procedure.patch
|
||||
+0184-platform-mellanox-Split-logic-in-init-and-exit-flow.patch
|
||||
+0185-platform-mellanox-Extend-all-systems-with-I2C-notifi.patch
|
||||
0186-platform-mellanox-mlxreg-hotplug-Allow-more-flexible.patch
|
||||
+0187-platform_data-mlxreg-Add-field-with-mapped-resource-.patch
|
||||
+0188-i2c-mux-Add-register-map-based-mux-driver.patch
|
||||
+0189-i2c-mlxcpld-Allow-driver-to-run-on-ARM64-architectur.patch
|
||||
+0190-i2c-mlxcpld-Modify-base-address-type.patch
|
||||
+0191-i2c-mlxcpld-Allow-to-configure-base-address-of-regis.patch
|
||||
+0192-i2c-mlxcpld-Add-support-for-extended-transaction-len.patch
|
||||
+0193-platform-mellanox-mlx-platform-Add-mux-selection-reg.patch
|
||||
+0194-platform-mellanox-mlx-platform-Move-bus-shift-assign.patch
|
||||
+0195-platform-mellanox-Add-support-for-dynamic-I2C-channe.patch
|
||||
+0196-platform-mellanox-Relocate-mlx-platform-driver.patch
|
||||
+0197-platform-mellanox-Add-initial-support-for-PCIe-based.patch
|
||||
+0198-platform-mellanox-Introduce-support-for-switches-bas.patch
|
||||
+0199-platform-mellanox-mlx-platform-Add-reset-and-extend-.patch
|
||||
+0200-dt-bindings-i2c-mellanox-i2c-mlxbf-convert-txt-to-YA.patch
|
||||
+0203-i2c-mlxbf-remove-IRQF_ONESHOT.patch
|
||||
+0206-i2c-mlxbf-add-multi-slave-functionality.patch
|
||||
+0207-i2c-mlxbf-support-BlueField-3-SoC.patch
|
||||
+0208-i2c-mlxbf-remove-device-tree-support.patch
|
||||
+0209-UBUNTU-SAUCE-i2c-mlxbf.c-Add-driver-version.patch
|
||||
+0210-platform-mellanox-Typo-fix-in-the-file-mlxbf-bootctl.patch
|
||||
+0211-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch
|
||||
+0212-platform-mellanox-mlxbf-pmc-Add-Mellanox-BlueField-P.patch
|
||||
+0213-platform-mellanox-mlxbf-pmc-fix-kernel-doc-notation.patch
|
||||
+0214-platform-mellanox-mlxbf-pmc-Fix-an-IS_ERR-vs-NULL-bu.patch
|
||||
+0215-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-pmc.patch
|
||||
+0216-UBUNTU-SAUCE-mlxbf_pmc-Fix-references-to-sprintf.patch
|
||||
+0217-UBUNTU-SAUCE-mlxbf-pmc-Fix-error-when-reading-unprog.patch
|
||||
+0218-UBUNTU-SAUCE-platform-mellanox-Add-mlx-trio-driver.patch
|
||||
+0219-UBUNTU-SAUCE-platform-mellanox-mlxbf-tmfifo-Add-Blue.patch
|
||||
+0220-UBUNTU-SAUCE-pka-Add-pka-driver.patch
|
||||
+0221-UBUNTU-SAUCE-platform-mellanox-Add-mlxbf-livefish-dr.patch
|
||||
+0222-workqueue-Add-resource-managed-version-of-delayed-wo.patch
|
||||
+0223-devm-helpers-Fix-devm_delayed_work_autocancel-kernel.patch
|
||||
+0224-devm-helpers-Add-resource-managed-version-of-work-in.patch
|
||||
+0225-UBUNTU-SAUCE-Add-support-to-pwr-mlxbf.c-driver.patch
|
||||
+0226-Add-Mellanox-BlueField-Gigabit-Ethernet-driver.patch
|
||||
+0227-mlxbf_gige-clear-valid_polarity-upon-open.patch
|
||||
+0228-net-mellanox-mlxbf_gige-Replace-non-standard-interru.patch
|
||||
+0229-mlxbf_gige-increase-MDIO-polling-rate-to-5us.patch
|
||||
+0230-mlxbf_gige-remove-driver-managed-interrupt-counts.patch
|
||||
+0231-mlxbf_gige-remove-own-module-name-define-and-use-KBU.patch
|
||||
+0232-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch
|
||||
+0233-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch
|
||||
+0234-UBUNTU-SAUCE-mlxbf_gige-add-validation-of-ACPI-table.patch
|
||||
+0235-UBUNTU-SAUCE-mlxbf_gige-set-driver-version-to-1.27.patch
|
||||
+0236-UBUNTU-SAUCE-mlxbf_gige-clear-MDIO-gateway-lock-afte.patch
|
||||
+0237-mlxbf_gige-compute-MDIO-period-based-on-i1clk.patch
|
||||
+0238-net-mlxbf_gige-Fix-an-IS_ERR-vs-NULL-bug-in-mlxbf_gi.patch
|
||||
+0239-UBUNTU-SAUCE-mlxbf_gige-add-MDIO-support-for-BlueFie.patch
|
||||
+0240-UBUNTU-SAUCE-mlxbf_gige-support-10M-100M-1G-speeds-o.patch
|
||||
+0241-UBUNTU-SAUCE-mlxbf_gige-add-BlueField-3-Serdes-confi.patch
|
||||
+0242-UBUNTU-SAUCE-mlxbf_gige-add-BlueField-3-ethtool_ops.patch
|
||||
+0243-UBUNTU-SAUCE-bluefield_edac-Add-SMC-support.patch
|
||||
+0244-UBUNTU-SAUCE-bluefield_edac-Update-license-and-copyr.patch
|
||||
+0245-gpio-mlxbf2-Convert-to-device-PM-ops.patch
|
||||
+0246-gpio-mlxbf2-Drop-wrong-use-of-ACPI_PTR.patch
|
||||
+0247-gpio-mlxbf2-Use-devm_platform_ioremap_resource.patch
|
||||
+0248-gpio-mlxbf2-Use-DEFINE_RES_MEM_NAMED-helper-macro.patch
|
||||
+0249-gpio-mlxbf2-Introduce-IRQ-support.patch
|
||||
+0250-UBUNTU-SAUCE-gpio-mlxbf2.c-support-driver-version.patch
|
||||
+0251-mmc-sdhci-of-dwcmshc-add-rockchip-platform-support.patch
|
||||
+0252-mmc-sdhci-of-dwcmshc-add-ACPI-support-for-BlueField-.patch
|
||||
+0253-mmc-sdhci-of-dwcmshc-fix-error-return-code-in-dwcmsh.patch
|
||||
+0254-mmc-sdhci-of-dwcmshc-set-MMC_CAP_WAIT_WHILE_BUSY.patch
|
||||
+0255-mmc-sdhci-of-dwcmshc-Re-enable-support-for-the-BlueF.patch
|
||||
+0256-UBUNTU-SAUCE-Support-BlueField-3-GPIO-driver.patch
|
||||
+0257-regmap-debugfs-Enable-writing-to-the-regmap-debugfs-.patch
|
||||
+0258-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch
|
||||
+0259-mmc-sdhci-of-dwcmshc-Enable-host-V4-support-for-Blue.patch
|
||||
+0260-UBUNTU-SAUCE-mlxbf-pka-Fix-kernel-crash-with-pka-TRN.patch
|
||||
+0261-mlxbf-ptm-power-and-thermal-management-debugfs-drive.patch
|
||||
+0262-UBUNTU-SAUCE-mlxbf-pmc-Fix-event-string-typo.patch
|
||||
+0263-UBUNTU-SAUCE-mlxbf-pmc-Support-for-BlueField-3-perfo.patch
|
||||
+0264-UBUNTU-SAUCE-platform-mellanox-Add-ctrl-message-and-.patch
|
||||
+0266-UBUNTU-SAUCE-mlxbf-pmc-Bug-fix-for-BlueField-3-count.patch
|
||||
+0267-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch
|
||||
+0268-DS-mlxsw-core_linecards-Disable-firmware-bundling-ma.patch
|
||||
+0269-platform-mellanox-Cosmetic-changes.patch
|
||||
+0270-platform-mellanox-Fix-order-in-exit-flow.patch
|
||||
+0271-platform-mellanox-Add-new-attributes.patch
|
||||
+0272-platform-mellanox-Change-register-offset-addresses.patch
|
||||
+0273-platform-mellanox-Add-field-upgrade-capability-regis.patch
|
||||
+0274-platform-mellanox-Modify-reset-causes-description.patch
|
||||
+0275-mlxsw-Use-u16-for-local_port-field-instead-of-u8.patch
|
||||
+0276-mlxsw-minimal-Change-type-for-local-port.patch
|
||||
+0277-mlxsw-i2c-Fix-chunk-size-setting-in-output-mailbox-b.patch
|
||||
+0278-platform-mellanox-mlx-platform-Modify-graceful-shutd.patch
|
||||
+0279-platform-mellanox-mlx-platform-Fix-signals-polarity-.patch
|
||||
+0280-platform-mellanox-mlxreg-hotplug-Extend-condition-fo.patch
|
||||
+0281-platform-mellanox-mlx-platform-Modify-health-and-pow.patch
|
||||
+0282-platform-mellanox-mlx-platform-add-support-of-5th-CP.patch
|
||||
+0283-mlxsw-core_hwmon-Align-modules-label-name-assignment.patch
|
||||
+0284-platform-mellanox-mlx-platform-fix-CPLD4-PN-report.patch
|
||||
0285-platform-mellanox-nvsw-sn2201-change-fans-i2c-busses.patch
|
||||
+9002-TMP-fix-for-fan-minimum-speed.patch
|
||||
###-> mellanox_hw_mgmt-end
|
||||
|
||||
# Cisco patches for 5.10 kernel
|
||||
0051-platform-mellanox-mlxreg-hotplug-Allow-more-flexible.patch
|
||||
0052-i2c-mux-Add-register-map-based-mux-driver.patch
|
||||
+0053-platform-mellanox-Add-support-for-dynamic-I2C-channe.patch
|
||||
+0054-platform-mellanox-Introduce-support-for-switches-equ.patch
|
||||
+0055-mellanox-Relocate-mlx-platform-driver.patch
|
||||
0056-Documentation-ABI-Add-new-attribute-for-mlxreg-io-sy.patch
|
||||
0057-Documentation-ABI-Add-new-attribute-for-mlxreg-io-sy.patch
|
||||
0061-pinctrl-Introduce-struct-pinfunction-and-PINCTRL_PIN.patch
|
||||
0062-pinctrl-mlxbf3-Add-pinctrl-driver-support.patch
|
||||
0063-gpio-mlxbf3-Add-gpio-driver-support.patch
|
||||
0064-pinctrl-mlxbf3-set-varaiable-mlxbf3_pmx_funcs-storag.patch
|
||||
+0066-UBUNTU-SAUCE-sdhci-of-dwcmshc-Enable-host-V4-support.patch
|
||||
+0067-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-add-the-missing-de.patch
|
||||
+0068-UBUNTU-SAUCE-mmc-sdhci-of-dwcmshc-Add-runtime-PM-ope.patch
|
||||
+0069-UBUNTU-SAUCE-mlxbf_gige-add-ethtool-mlxbf_gige_set_r.patch
|
||||
+0070-UBUNTU-SAUCE-Fix-OOB-handling-RX-packets-in-heavy-tr.patch
|
||||
+0071-UBUNTU-SAUCE-mlxbf-gige-Fix-intermittent-no-ip-issue.patch
|
||||
+0072-mlxbf_gige-add-MDIO-support-for-BlueField-3.patch
|
||||
+0073-mlxbf_gige-support-10M-100M-1G-speeds-on-BlueField-3.patch
|
||||
+0074-mlxbf_gige-add-set_link_ksettings-ethtool-callback.patch
|
||||
+0075-UBUNTU-SAUCE-mlxbf-gige-Fix-kernel-panic-at-shutdown.patch
|
||||
+0076-UBUNTU-SAUCE-platform-mellanox-Updates-to-mlxbf-boot.patch
|
||||
+0077-UBUNTU-SAUCE-mlx-bootctl-support-icm-carveout-eeprom.patch
|
||||
+0078-UBUNTU-SAUCE-mlxbf-bootctl-support-SMC-call-for-sett.patch
|
||||
+0079-UBUNTU-SAUCE-mlxbf-ptm-power-and-thermal-management-.patch
|
||||
+0080-UBUNTU-SAUCE-mlxbf-ptm-update-license.patch
|
||||
+0081-UBUNTU-SAUCE-mlxbf-ptm-use-0444-instead-of-S_IRUGO.patch
|
||||
+0082-UBUNTU-SAUCE-mlxbf-ptm-add-atx-debugfs-nodes.patch
|
||||
+0083-UBUNTU-SAUCE-mlxbf-ptm-update-module-version.patch
|
||||
+0084-UBUNTU-SAUCE-mlxbf-bootctl-Fix-kernel-panic-due-to-b.patch
|
||||
0085-hwmon-mlxreg-fan-Separate-methods-of-fan-setting-com.patch
|
||||
+8000-mlxsw-Use-weak-reverse-dependencies-for-firmware-fla.patch
|
||||
8003-mlxsw-i2c-SONIC-ISSU-Prevent-transaction-execution-f.patch
|
||||
+8004-mlxsw-minimal-Downstream-Ignore-error-reading-SPAD-r.patch
|
||||
8005-leds-leds-mlxreg-Downstream-Send-udev-event-from-led.patch
|
||||
8006-i2c-mlxcpld-Downstream-WA-to-avoid-error-for-SMBUS-r.patch
|
||||
8007-hwmon-mlxreg-fan-Downstream-Allow-fan-speed-setting-.patch
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
From bb46d45ce13c8faf9c2ab57b945c3a3adc587918 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Sun, 23 Jul 2023 06:26:09 +0000
|
||||
Subject: [PATCH backport 6.1.42 42/85] hwmon: (mlxreg-fan) Add support for new
|
||||
flavour of capability register
|
||||
|
||||
FAN platform data is common across the various systems, while fan
|
||||
driver should be able to apply only the fan instances relevant
|
||||
to specific system.
|
||||
|
||||
For example, platform data might contain descriptions for fan1,
|
||||
fan2, ..., fan{n}, while some systems equipped with all 'n' fans,
|
||||
others with less.
|
||||
Also, on some systems fan drawer can be equipped with several
|
||||
tachometers and on others only with one.
|
||||
|
||||
For detection of the real number of equipped drawers and tachometers
|
||||
special capability registers are used.
|
||||
These registers used to indicate presence of drawers and tachometers
|
||||
through the bitmap.
|
||||
|
||||
For some new big modular systems this register will provide presence
|
||||
data by counter.
|
||||
|
||||
Use slot parameter to distinct whether capability register contains
|
||||
bitmask or counter.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
drivers/hwmon/mlxreg-fan.c | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
|
||||
index 96017cc8da7e..dad94d2892b2 100644
|
||||
--- a/drivers/hwmon/mlxreg-fan.c
|
||||
+++ b/drivers/hwmon/mlxreg-fan.c
|
||||
@@ -390,7 +390,7 @@ static int mlxreg_fan_connect_verify(struct mlxreg_fan *fan,
|
||||
return err;
|
||||
}
|
||||
|
||||
- return !!(regval & data->bit);
|
||||
+ return data->slot ? (data->slot <= regval ? 1 : 0) : !!(regval & data->bit);
|
||||
}
|
||||
|
||||
static int mlxreg_pwm_connect_verify(struct mlxreg_fan *fan,
|
||||
@@ -527,7 +527,15 @@ static int mlxreg_fan_config(struct mlxreg_fan *fan,
|
||||
return err;
|
||||
}
|
||||
|
||||
- drwr_avail = hweight32(regval);
|
||||
+ /*
|
||||
+ * The number of drawers could be specified in registers by counters for newer
|
||||
+ * systems, or by bitmasks for older systems. In case the data is provided by
|
||||
+ * counter, it is indicated through 'version' field.
|
||||
+ */
|
||||
+ if (pdata->version)
|
||||
+ drwr_avail = regval;
|
||||
+ else
|
||||
+ drwr_avail = hweight32(regval);
|
||||
if (!tacho_avail || !drwr_avail || tacho_avail < drwr_avail) {
|
||||
dev_err(fan->dev, "Configuration is invalid: drawers num %d tachos num %d\n",
|
||||
drwr_avail, tacho_avail);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,62 @@
|
||||
From 46c4b0cdf2a3abe321e137bcb87e5639c39fd655 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Thu, 20 Jul 2023 11:01:56 +0000
|
||||
Subject: [PATCH backport 6.1.42 44/85] leds: mlxreg: Add support for new
|
||||
flavour of capability register
|
||||
|
||||
LED platform data is common across the various systems, while LED
|
||||
driver should be able to apply only the LED instances relevant
|
||||
to specific system.
|
||||
|
||||
For example, platform data might contain descriptions for fan1,
|
||||
fan2, ..., fan{n} LEDs, while some systems equipped with all 'n' fan
|
||||
LEDs, others with less.
|
||||
|
||||
For detection of the real number of equipped LEDs special capability
|
||||
register is used.
|
||||
This register used to indicate presence of LED through the bitmap.
|
||||
|
||||
For some new big modular systems this register will provide presence
|
||||
data by counter.
|
||||
|
||||
Use slot parameter to distinct whether capability register contains
|
||||
bitmask or counter.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
drivers/leds/leds-mlxreg.c | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
|
||||
index b7855c93bd72..063a9cb50a2b 100644
|
||||
--- a/drivers/leds/leds-mlxreg.c
|
||||
+++ b/drivers/leds/leds-mlxreg.c
|
||||
@@ -206,16 +206,22 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
|
||||
dev_err(&priv->pdev->dev, "Failed to query capability register\n");
|
||||
return err;
|
||||
}
|
||||
- if (!(regval & data->bit))
|
||||
+ /*
|
||||
+ * If slot is specified - validate if slot is equipped on system.
|
||||
+ * In case slot is specified in platform data, capability register
|
||||
+ * comtains the counter of untits.
|
||||
+ */
|
||||
+ if (data->slot && data->slot > regval)
|
||||
+ continue;
|
||||
+ else if (!(regval & data->bit))
|
||||
continue;
|
||||
/*
|
||||
* Field "bit" can contain one capability bit in 0 byte
|
||||
* and offset bit in 1-3 bytes. Clear capability bit and
|
||||
- * keep only offset bit.
|
||||
+ * contains the counter of units.
|
||||
*/
|
||||
data->bit &= MLXREG_LED_CAPABILITY_CLEAR;
|
||||
}
|
||||
-
|
||||
led_cdev = &led_data->led_cdev;
|
||||
led_data->data_parent = priv;
|
||||
if (strstr(data->label, "red") ||
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,47 @@
|
||||
From af93d2527b5af3f2e53507c7e35bcd9c9bd521cb Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Thu, 20 Jul 2023 11:17:31 +0000
|
||||
Subject: [PATCH backport 6.1.42 45/85] leds: mlxreg: Remove code for amber LED
|
||||
colour
|
||||
|
||||
Remove unused code for amber LED colour.
|
||||
|
||||
In case system LED color is "green", "orange" or "amber" same code is
|
||||
to be used for colour setting.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
drivers/leds/leds-mlxreg.c | 8 ++------
|
||||
1 file changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
|
||||
index 063a9cb50a2b..215132f67c07 100644
|
||||
--- a/drivers/leds/leds-mlxreg.c
|
||||
+++ b/drivers/leds/leds-mlxreg.c
|
||||
@@ -19,7 +19,6 @@
|
||||
#define MLXREG_LED_IS_OFF 0x00 /* Off */
|
||||
#define MLXREG_LED_RED_SOLID 0x05 /* Solid red */
|
||||
#define MLXREG_LED_GREEN_SOLID 0x0D /* Solid green */
|
||||
-#define MLXREG_LED_AMBER_SOLID 0x09 /* Solid amber */
|
||||
#define MLXREG_LED_BLINK_3HZ 167 /* ~167 msec off/on - HW support */
|
||||
#define MLXREG_LED_BLINK_6HZ 83 /* ~83 msec off/on - HW support */
|
||||
#define MLXREG_LED_CAPABILITY_CLEAR GENMASK(31, 8) /* Clear mask */
|
||||
@@ -224,13 +223,10 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
|
||||
}
|
||||
led_cdev = &led_data->led_cdev;
|
||||
led_data->data_parent = priv;
|
||||
- if (strstr(data->label, "red") ||
|
||||
- strstr(data->label, "orange")) {
|
||||
+ if (strstr(data->label, "red") || strstr(data->label, "orange") ||
|
||||
+ strstr(data->label, "amber")) {
|
||||
brightness = LED_OFF;
|
||||
led_data->base_color = MLXREG_LED_RED_SOLID;
|
||||
- } else if (strstr(data->label, "amber")) {
|
||||
- brightness = LED_OFF;
|
||||
- led_data->base_color = MLXREG_LED_AMBER_SOLID;
|
||||
} else {
|
||||
brightness = LED_OFF;
|
||||
led_data->base_color = MLXREG_LED_GREEN_SOLID;
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,37 @@
|
||||
From 276c9eae3cf83bb65c575b423c785d0ff37b6da0 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 17 Jul 2023 15:40:08 +0000
|
||||
Subject: [PATCH backport 6.1.42 46/85] Extend driver to support Infineon
|
||||
Digital Multi-phase XDPE1A2G7 device.
|
||||
|
||||
From telemetry perspective device is almost the same as XDPE15284, but
|
||||
does not support READ_EIN (86h) and READ_EOUT (87h) commands.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
drivers/hwmon/pmbus/xdpe152c4.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/drivers/hwmon/pmbus/xdpe152c4.c b/drivers/hwmon/pmbus/xdpe152c4.c
|
||||
index b8a36ef73e45..1ef1141ba537 100644
|
||||
--- a/drivers/hwmon/pmbus/xdpe152c4.c
|
||||
+++ b/drivers/hwmon/pmbus/xdpe152c4.c
|
||||
@@ -44,6 +44,7 @@ static int xdpe152_probe(struct i2c_client *client)
|
||||
}
|
||||
|
||||
static const struct i2c_device_id xdpe152_id[] = {
|
||||
+ {"xdpe1a2g7", 0},
|
||||
{"xdpe152c4", 0},
|
||||
{"xdpe15284", 0},
|
||||
{}
|
||||
@@ -52,6 +53,7 @@ static const struct i2c_device_id xdpe152_id[] = {
|
||||
MODULE_DEVICE_TABLE(i2c, xdpe152_id);
|
||||
|
||||
static const struct of_device_id __maybe_unused xdpe152_of_match[] = {
|
||||
+ {.compatible = "infineon,xdpe1a2g7"},
|
||||
{.compatible = "infineon,xdpe152c4"},
|
||||
{.compatible = "infineon,xdpe15284"},
|
||||
{}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,29 @@
|
||||
From 62520e9d0ab641b36fb770477792073e6aad4d54 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 17 Jul 2023 16:24:58 +0000
|
||||
Subject: [PATCH backport 6.1.42 47/85] dt-bindings: trivial-devices: Add
|
||||
infineon,xdpe1a2g7
|
||||
|
||||
Add new Infineon Multi-phase Digital VR Controller xdpe1a2g7
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
|
||||
index 61746755c107..7637390dfe09 100644
|
||||
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
|
||||
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
|
||||
@@ -145,6 +145,8 @@ properties:
|
||||
- infineon,tlv493d-a1b6
|
||||
# Infineon Multi-phase Digital VR Controller xdpe11280
|
||||
- infineon,xdpe11280
|
||||
+ # Infineon Multi-phase Digital VR Controller xdpe1a2g7
|
||||
+ - infineon,xdpe1a2g7
|
||||
# Infineon Multi-phase Digital VR Controller xdpe12254
|
||||
- infineon,xdpe12254
|
||||
# Infineon Multi-phase Digital VR Controller xdpe12284
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,563 @@
|
||||
From c8a04a4c79a9fb99215e93884ff76b89e9947275 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Thu, 13 Jul 2023 06:16:53 +0000
|
||||
Subject: [PATCH backport 6.1.42 48/85] hwmon: (pmbus) Add support for MPS
|
||||
Multi-phase mp2891 controller
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Introduce driver for dual-loop, digital, multi-phase controller MP2891 from
|
||||
Monolithic Power Systems, Inc. (MPS) vendor.
|
||||
|
||||
The MP2891 can work with MPS’s Intelli-PhaseTM products to complete the
|
||||
multi-phase voltage regulator (VR) solution with minimal external
|
||||
components.
|
||||
|
||||
This device supports:
|
||||
- Two power rails.
|
||||
- Programmable Multi-Phase up to 16 Phases on rail 1, and a maximum of 8
|
||||
phases on rail 2.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
Documentation/hwmon/mp2891.rst | 128 ++++++++++++
|
||||
drivers/hwmon/pmbus/Kconfig | 9 +
|
||||
drivers/hwmon/pmbus/Makefile | 1 +
|
||||
drivers/hwmon/pmbus/mp2891.c | 357 +++++++++++++++++++++++++++++++++
|
||||
4 files changed, 495 insertions(+)
|
||||
create mode 100644 Documentation/hwmon/mp2891.rst
|
||||
create mode 100644 drivers/hwmon/pmbus/mp2891.c
|
||||
|
||||
diff --git a/Documentation/hwmon/mp2891.rst b/Documentation/hwmon/mp2891.rst
|
||||
new file mode 100644
|
||||
index 000000000000..c4bda3d7ee8a
|
||||
--- /dev/null
|
||||
+++ b/Documentation/hwmon/mp2891.rst
|
||||
@@ -0,0 +1,128 @@
|
||||
+.. SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+Kernel driver mp2891
|
||||
+====================
|
||||
+
|
||||
+Supported chips:
|
||||
+
|
||||
+ * MPS MP2891
|
||||
+
|
||||
+ Prefix: 'mp2891'
|
||||
+
|
||||
+Author:
|
||||
+
|
||||
+ Vadim Pasternak <vadimp@nvidia.com>
|
||||
+
|
||||
+Description
|
||||
+-----------
|
||||
+
|
||||
+This driver implements support for Monolithic Power Systems, Inc. (MPS)
|
||||
+vendor dual-loop, digital, multi-phase controller MP2891.
|
||||
+The MP2891 can work with MPS’s Intelli-PhaseTM products to complete the
|
||||
+multi-phase voltage regulator (VR) solution with minimal external components.
|
||||
+
|
||||
+MP2891 is available in a QFN-56 (7mmx7mm) package.
|
||||
+
|
||||
+This device supports:
|
||||
+
|
||||
+- Two power rails.
|
||||
+- Programmable Multi-Phase up to 16 Phases on rail 1, and a maximum of 8 phases
|
||||
+ on rail 2.
|
||||
+- PWM-VID Interface.
|
||||
+- Two pages for telemetry.
|
||||
+- Programmable pins for PMBus Address.
|
||||
+- Ability to store and restore device configurations.
|
||||
+- 200kHz to 3MHz Switching Frequency.
|
||||
+- Automatic Loop Compensation.
|
||||
+- Couple Inductor Mode.
|
||||
+- Supports Multi-Configuration for 6 Different Applications.
|
||||
+- Flexible Pulse-Width Modulation (PWM) Assignment for 2 Rails.
|
||||
+- Automatic Phase-Shedding (APS) to Improve Overall Efficiency.
|
||||
+- Phase-to-Phase Active Current Balancing with Configurable Offsets for Thermal
|
||||
+ Balance.
|
||||
+- Digital Load-Line Regulation.
|
||||
+- Overclocking Mode by Adding Offset to VOUT.
|
||||
+
|
||||
+Device complaint with:
|
||||
+
|
||||
+- PMBus rev 1.3 interface.
|
||||
+
|
||||
+Device supports direct format for reading output current, output voltage,
|
||||
+input and output power and temperature.
|
||||
+Device supports linear format for reading input voltage and input power.
|
||||
+
|
||||
+The driver provides the next attributes for the current:
|
||||
+
|
||||
+- for current out input and maximum alarm;
|
||||
+- for phase current: input and label.
|
||||
+
|
||||
+The driver exports the following attributes via the 'sysfs' files, where:
|
||||
+
|
||||
+- 'n' is number of configured phases (from 1 to 10);
|
||||
+- index 1 for "iout";
|
||||
+- indexes 2 ... 1 + n for phases.
|
||||
+
|
||||
+**curr[1-{1+n}]_input**
|
||||
+
|
||||
+**curr[1-{1+n}]_label**
|
||||
+
|
||||
+**curr1_max**
|
||||
+
|
||||
+**curr1_max_alarm**
|
||||
+
|
||||
+The driver provides the next attributes for the voltage:
|
||||
+
|
||||
+- for voltage in: input, low and high critical thresholds, low and high
|
||||
+ critical alarms;
|
||||
+- for voltage out: input and high alarm;
|
||||
+
|
||||
+The driver exports the following attributes via the 'sysfs' files, where
|
||||
+
|
||||
+**in1_crit**
|
||||
+
|
||||
+**in1_crit_alarm**
|
||||
+
|
||||
+**in1_input**
|
||||
+
|
||||
+**in1_label**
|
||||
+
|
||||
+**in1_min**
|
||||
+
|
||||
+**in1_min_alarm**
|
||||
+
|
||||
+**in2_alarm**
|
||||
+
|
||||
+**in2_input**
|
||||
+
|
||||
+**in2_label**
|
||||
+
|
||||
+The driver provides the next attributes for the power:
|
||||
+
|
||||
+- for power in alarm and input.
|
||||
+- for power out: cap, cap alarm an input.
|
||||
+
|
||||
+The driver exports the following attributes via the 'sysfs' files, where
|
||||
+- indexes 1 for "pin";
|
||||
+- indexes 2 for "pout";
|
||||
+
|
||||
+**power1_alarm**
|
||||
+
|
||||
+**power1_input**
|
||||
+
|
||||
+**power1_label**
|
||||
+
|
||||
+**power2_input**
|
||||
+
|
||||
+**power2_label**
|
||||
+
|
||||
+**power2_max**
|
||||
+
|
||||
+**power2_max_alarm**
|
||||
+
|
||||
+The driver provides the next attributes for the temperature:
|
||||
+
|
||||
+**temp1_input**
|
||||
+
|
||||
+**temp1_max**
|
||||
+
|
||||
+**temp1_max_alarm**
|
||||
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
|
||||
index 89668af67206..77d67344cee4 100644
|
||||
--- a/drivers/hwmon/pmbus/Kconfig
|
||||
+++ b/drivers/hwmon/pmbus/Kconfig
|
||||
@@ -299,6 +299,15 @@ config SENSORS_MP2888
|
||||
This driver can also be built as a module. If so, the module will
|
||||
be called mp2888.
|
||||
|
||||
+config SENSORS_MP2891
|
||||
+ tristate "MPS MP2891"
|
||||
+ help
|
||||
+ If you say yes here you get hardware monitoring support for MPS
|
||||
+ MP2891 Dual Loop Digital Multi-Phase Controller.
|
||||
+
|
||||
+ This driver can also be built as a module. If so, the module will
|
||||
+ be called mp2891.
|
||||
+
|
||||
config SENSORS_MP2975
|
||||
tristate "MPS MP2975"
|
||||
help
|
||||
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
|
||||
index 0002dbe22d52..8e767d7b8c5b 100644
|
||||
--- a/drivers/hwmon/pmbus/Makefile
|
||||
+++ b/drivers/hwmon/pmbus/Makefile
|
||||
@@ -32,6 +32,7 @@ obj-$(CONFIG_SENSORS_MAX31785) += max31785.o
|
||||
obj-$(CONFIG_SENSORS_MAX34440) += max34440.o
|
||||
obj-$(CONFIG_SENSORS_MAX8688) += max8688.o
|
||||
obj-$(CONFIG_SENSORS_MP2888) += mp2888.o
|
||||
+obj-$(CONFIG_SENSORS_MP2891) += mp2891.o
|
||||
obj-$(CONFIG_SENSORS_MP2975) += mp2975.o
|
||||
obj-$(CONFIG_SENSORS_MP5023) += mp5023.o
|
||||
obj-$(CONFIG_SENSORS_PLI1209BC) += pli1209bc.o
|
||||
diff --git a/drivers/hwmon/pmbus/mp2891.c b/drivers/hwmon/pmbus/mp2891.c
|
||||
new file mode 100644
|
||||
index 000000000000..e9e82844ee2a
|
||||
--- /dev/null
|
||||
+++ b/drivers/hwmon/pmbus/mp2891.c
|
||||
@@ -0,0 +1,357 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+/*
|
||||
+ * Hardware monitoring driver for MPS Multi-phase Digital VR Controllers(MP2891)
|
||||
+ *
|
||||
+ * Copyright (C) 2023 Nvidia
|
||||
+ */
|
||||
+
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/i2c.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include "pmbus.h"
|
||||
+
|
||||
+/* Vendor specific registers. */
|
||||
+/*
|
||||
+ * MP2891_MFR_SVI3_IOUT_PRT:
|
||||
+ * bits 15:5 - reserved zeros;
|
||||
+ * bits 4:3 - set SVI3 Vout digital filter
|
||||
+ * b00: 5kHz
|
||||
+ * b01: 2kHz
|
||||
+ * b10: 1kHz
|
||||
+ * b11: no filter
|
||||
+ * bits 2:0 - define output current scaling selection of rail1.
|
||||
+ * b000: 1 A/LSB
|
||||
+ * b001: (1/32) A/LSB
|
||||
+ * b010: (1/16) A/LSB
|
||||
+ * b011: (1/8) A/LSB
|
||||
+ * b100: (1/4) A/LSB
|
||||
+ * b101: (1/2) A/LSB
|
||||
+ * b110: 1 A/LSB
|
||||
+ * b111: 2 A/LSB
|
||||
+ */
|
||||
+#define MP2891_MFR_SVI3_IOUT_PRT 0x65
|
||||
+/*
|
||||
+ * MP2891_MFR_VOUT_LOOP_CTRL:
|
||||
+ * bits 15:14 define the VID step.
|
||||
+ * b00: 6.25mV
|
||||
+ * b01: 5mV
|
||||
+ * b10: 2mV
|
||||
+ * b11: 1mV
|
||||
+ * bit 13 enable bit of 2.5mV resolution.
|
||||
+ * b0: disable
|
||||
+ * b1: enable
|
||||
+ * bits 12:11 reserved zeros
|
||||
+ * bit 10 defines rail remote sense amplifier gain:
|
||||
+ * b0: 1
|
||||
+ * b1: 0.5
|
||||
+ * bit 9 DC reference_select
|
||||
+ * b0: Comp EA uses Vfb and Vref
|
||||
+ * b1: Comp EA uses Vdiff and Vref
|
||||
+ * bit 8 enables DC loop calibration at DCM.
|
||||
+ * b0: disable
|
||||
+ * b1: enable
|
||||
+ * bit 7 enables DC loop calibration both at DCM and CCM operation.
|
||||
+ * b0: disable
|
||||
+ * b1: enable
|
||||
+ * bit 6 - holds DC loop when the PWM time interval meets PWM switching period condition
|
||||
+ * set with PMBus command MFR_VR_CONFIG1 (B7h), bit [3:2].
|
||||
+ * b0: disable hold DC loop when PWM switching period condition meets
|
||||
+ * b1: hold DC loop when PWM switching period condition meets
|
||||
+ * bit 5 hold DC loop when phase count is changed.
|
||||
+ * b0: disable hold DC loop when phase number change
|
||||
+ * b1: hold the DC loop when phase number change.
|
||||
+ * bit 4 hold DC loop regulation when a load transient event is detected.
|
||||
+ * b0: disable hold DC loop when meets VFB+/- window condition
|
||||
+ * b1: hold DC loop when meets VFB+/- window condition
|
||||
+ * bits 3:0 set the DC loop minimal holding time in direct format.
|
||||
+ */
|
||||
+#define MP2891_MFR_VOUT_LOOP_CTRL 0xbd
|
||||
+
|
||||
+#define MP2891_VID_STEP_POS 14
|
||||
+#define MP2891_VID_STEP_MASK GENMASK(MP2891_VID_STEP_POS + 1, MP2891_VID_STEP_POS)
|
||||
+#define MP2891_DAC_2P5MV_MASK BIT(13)
|
||||
+#define MP2891_IOUT_SCALE_MASK GENMASK(2, 0)
|
||||
+
|
||||
+#define MP2891_PAGE_NUM 2
|
||||
+#define MP2891_RAIL1_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | \
|
||||
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | \
|
||||
+ PMBUS_PHASE_VIRTUAL)
|
||||
+
|
||||
+#define MP2891_RAIL2_FUNC (PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_TEMP | \
|
||||
+ PMBUS_HAVE_POUT | PMBUS_PHASE_VIRTUAL)
|
||||
+
|
||||
+struct mp2891_data {
|
||||
+ struct pmbus_driver_info info;
|
||||
+ int vid_step[MP2891_PAGE_NUM];
|
||||
+ int iout_scale[MP2891_PAGE_NUM];
|
||||
+};
|
||||
+
|
||||
+#define to_mp2891_data(x) container_of(x, struct mp2891_data, info)
|
||||
+
|
||||
+static int mp2891_read_vout(struct i2c_client *client, int page, int phase, int reg)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
|
||||
+ struct mp2891_data *data = to_mp2891_data(info);
|
||||
+
|
||||
+ ret = pmbus_read_word_data(client, page, phase, reg);
|
||||
+
|
||||
+ return ret < 0 ? ret : ret * data->vid_step[page] / 100;
|
||||
+}
|
||||
+
|
||||
+static int mp2891_read_iout(struct i2c_client *client, int page, int phase, int reg)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
|
||||
+ struct mp2891_data *data = to_mp2891_data(info);
|
||||
+
|
||||
+ ret = pmbus_read_word_data(client, page, phase, reg);
|
||||
+
|
||||
+ return ret < 0 ? ret : ret * data->iout_scale[page];
|
||||
+}
|
||||
+
|
||||
+static int mp2891_read_byte_data(struct i2c_client *client, int page, int reg)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ switch (reg) {
|
||||
+ case PMBUS_VOUT_MODE:
|
||||
+ /*
|
||||
+ * Enforce VOUT direct format, since device allows to set the
|
||||
+ * different formats for the different rails. Conversion from
|
||||
+ * VID to direct provided by driver internally, in case it is
|
||||
+ * necessary.
|
||||
+ */
|
||||
+ ret = PB_VOUT_MODE_DIRECT;
|
||||
+ break;
|
||||
+ default:
|
||||
+ ret = -EINVAL;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int mp2891_read_word_data(struct i2c_client *client, int page, int phase, int reg)
|
||||
+{
|
||||
+ switch (reg) {
|
||||
+ case PMBUS_READ_VOUT:
|
||||
+ return mp2891_read_vout(client, page, phase, reg);
|
||||
+ case PMBUS_READ_IOUT:
|
||||
+ return mp2891_read_iout(client, page, phase, reg);
|
||||
+ case PMBUS_OT_WARN_LIMIT:
|
||||
+ case PMBUS_OT_FAULT_LIMIT:
|
||||
+ case PMBUS_UT_WARN_LIMIT:
|
||||
+ case PMBUS_UT_FAULT_LIMIT:
|
||||
+ case PMBUS_VOUT_OV_WARN_LIMIT:
|
||||
+ case PMBUS_VIN_OV_WARN_LIMIT:
|
||||
+ case PMBUS_POUT_MAX:
|
||||
+ case PMBUS_POUT_OP_FAULT_LIMIT:
|
||||
+ case PMBUS_MFR_VIN_MIN:
|
||||
+ case PMBUS_MFR_VOUT_MIN:
|
||||
+ case PMBUS_MFR_VIN_MAX:
|
||||
+ case PMBUS_MFR_VOUT_MAX:
|
||||
+ case PMBUS_MFR_IIN_MAX:
|
||||
+ case PMBUS_MFR_IOUT_MAX:
|
||||
+ case PMBUS_MFR_PIN_MAX:
|
||||
+ case PMBUS_MFR_POUT_MAX:
|
||||
+ case PMBUS_MFR_MAX_TEMP_1:
|
||||
+ return -ENXIO;
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int mp2891_identify_vid(struct i2c_client *client, struct mp2891_data *data, u32 reg,
|
||||
+ int page)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = i2c_smbus_read_word_data(client, reg);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /*
|
||||
+ * Obtain vid_step from MP2891_MFR_VOUT_LOOP_CTRL register:
|
||||
+ * bit 13 = 1, the vid_step is below 2.5mV/LSB;
|
||||
+ * bit 13 = 0, the vid_step is defined by bits 15:14:
|
||||
+ * 00b - 6.25mV/LSB, 01b - 5mV/LSB, 10b - 2mV/LSB, 11b - 1mV
|
||||
+ */
|
||||
+ if ((ret & MP2891_DAC_2P5MV_MASK) >> MP2891_VID_STEP_POS) {
|
||||
+ data->vid_step[page] = 250;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ switch ((ret & MP2891_VID_STEP_MASK) >> MP2891_VID_STEP_POS) {
|
||||
+ case 0:
|
||||
+ data->vid_step[page] = 625;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ data->vid_step[page] = 500;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ data->vid_step[page] = 200;
|
||||
+ break;
|
||||
+ default:
|
||||
+ data->vid_step[page] = 100;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mp2891_identify_rails_vid(struct i2c_client *client, struct mp2891_data *data)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Identify vid_step for rail 1. */
|
||||
+ ret = mp2891_identify_vid(client, data, MP2891_MFR_VOUT_LOOP_CTRL, 0);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Identify vid_step for rail 2. */
|
||||
+ return mp2891_identify_vid(client, data, MP2891_MFR_VOUT_LOOP_CTRL, 1);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mp2891_iout_scale_get(struct i2c_client *client, struct mp2891_data *data, u32 reg, int page)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = i2c_smbus_read_word_data(client, reg);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /*
|
||||
+ * Obtain iout_scale from the register MP2891_MFR_SVI3_IOUT_PRT, bits 2-0.
|
||||
+ * The value is selected as below:
|
||||
+ * 000b - 1A/LSB, 001b - (1/32)A/LSB, 010b - (1/16)A/LSB,
|
||||
+ * 011b - (1/8)A/LSB, 100b - (1/4)A/LSB, 101b - (1/2)A/LSB
|
||||
+ * 110b - 1A/LSB, 111b - 2A/LSB
|
||||
+ */
|
||||
+ switch (ret & MP2891_IOUT_SCALE_MASK) {
|
||||
+ case 0:
|
||||
+ case 6:
|
||||
+ data->iout_scale[page] = 32;
|
||||
+ return 0;
|
||||
+ case 1:
|
||||
+ data->iout_scale[page] = 1;
|
||||
+ return 0;
|
||||
+ case 2:
|
||||
+ data->iout_scale[page] = 2;
|
||||
+ return 0;
|
||||
+ case 3:
|
||||
+ data->iout_scale[page] = 4;
|
||||
+ return 0;
|
||||
+ case 4:
|
||||
+ data->iout_scale[page] = 8;
|
||||
+ return 0;
|
||||
+ case 5:
|
||||
+ data->iout_scale[page] = 16;
|
||||
+ return 0;
|
||||
+ default:
|
||||
+ data->iout_scale[page] = 64;
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int mp2891_rails_iout_scale_get(struct i2c_client *client, struct mp2891_data *data)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Get iout_scale for rail 1. */
|
||||
+ ret = mp2891_iout_scale_get(client, data, MP2891_MFR_SVI3_IOUT_PRT, 0);
|
||||
+ /* Get iout_scale for rail 2. */
|
||||
+ return ret < 0 ? ret : mp2891_iout_scale_get(client, data, MP2891_MFR_SVI3_IOUT_PRT, 1);
|
||||
+}
|
||||
+
|
||||
+static struct pmbus_driver_info mp2891_info = {
|
||||
+ .pages = MP2891_PAGE_NUM,
|
||||
+ .format[PSC_VOLTAGE_IN] = direct,
|
||||
+ .format[PSC_VOLTAGE_OUT] = direct,
|
||||
+ .format[PSC_CURRENT_OUT] = direct,
|
||||
+ .format[PSC_TEMPERATURE] = direct,
|
||||
+ .format[PSC_POWER] = linear,
|
||||
+ .m[PSC_VOLTAGE_IN] = 1,
|
||||
+ .m[PSC_VOLTAGE_OUT] = 1,
|
||||
+ .m[PSC_CURRENT_OUT] = 32,
|
||||
+ .m[PSC_TEMPERATURE] = 1,
|
||||
+ .R[PSC_VOLTAGE_IN] = 3,
|
||||
+ .R[PSC_VOLTAGE_OUT] = 3,
|
||||
+ .R[PSC_CURRENT_OUT] = 0,
|
||||
+ .R[PSC_TEMPERATURE] = 0,
|
||||
+ .b[PSC_VOLTAGE_IN] = 0,
|
||||
+ .b[PSC_VOLTAGE_OUT] = 0,
|
||||
+ .b[PSC_CURRENT_OUT] = 0,
|
||||
+ .b[PSC_TEMPERATURE] = 0,
|
||||
+ .func[0] = MP2891_RAIL1_FUNC,
|
||||
+ .func[1] = MP2891_RAIL2_FUNC,
|
||||
+ .read_word_data = mp2891_read_word_data,
|
||||
+ .read_byte_data = mp2891_read_byte_data,
|
||||
+};
|
||||
+
|
||||
+static int mp2891_probe(struct i2c_client *client)
|
||||
+{
|
||||
+ struct pmbus_driver_info *info;
|
||||
+ struct mp2891_data *data;
|
||||
+ int ret;
|
||||
+
|
||||
+ data = devm_kzalloc(&client->dev, sizeof(struct mp2891_data), GFP_KERNEL);
|
||||
+
|
||||
+ if (!data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ memcpy(&data->info, &mp2891_info, sizeof(*info));
|
||||
+ info = &data->info;
|
||||
+
|
||||
+ /* Identify VID setting per rail - obtain the vid_step of output voltage. */
|
||||
+ ret = mp2891_identify_rails_vid(client, data);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Get iout scale per rail - obtain current scale. */
|
||||
+ ret = mp2891_rails_iout_scale_get(client, data);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ return pmbus_do_probe(client, info);
|
||||
+}
|
||||
+
|
||||
+static const struct i2c_device_id mp2891_id[] = {
|
||||
+ {"mp2891", 0},
|
||||
+ {}
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(i2c, mp2891_id);
|
||||
+
|
||||
+static const struct of_device_id __maybe_unused mp2891_of_match[] = {
|
||||
+ {.compatible = "mps,mp2891"},
|
||||
+ {}
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, mp2891_of_match);
|
||||
+
|
||||
+static struct i2c_driver mp2891_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "mp2891",
|
||||
+ .of_match_table = mp2891_of_match,
|
||||
+ },
|
||||
+ .probe_new = mp2891_probe,
|
||||
+ .id_table = mp2891_id,
|
||||
+};
|
||||
+
|
||||
+module_i2c_driver(mp2891_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("PMBus driver for MPS MP2891 device");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_IMPORT_NS(PMBUS);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,30 @@
|
||||
From 98b6b44b7b190c664f41e482de4597571e700e7f Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Thu, 13 Jul 2023 06:20:05 +0000
|
||||
Subject: [PATCH backport 6.1.42 49/85] dt-bindings: trivial-devices: Add
|
||||
mps,mp2891
|
||||
|
||||
Add new dual-loop, digital, multi-phase controller MP2891 fro
|
||||
Monolithic Power Systems, Inc. (MPS) to trivial devices.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
|
||||
index 7637390dfe09..8e6c0bc60ee3 100644
|
||||
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
|
||||
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
|
||||
@@ -113,6 +113,8 @@ properties:
|
||||
- fsl,mpl3115
|
||||
# MPR121: Proximity Capacitive Touch Sensor Controller
|
||||
- fsl,mpr121
|
||||
+ # Monolithic Power Systems Inc. multi-phase controller mp2891
|
||||
+ - mps,mp2891
|
||||
# Monolithic Power Systems Inc. multi-phase controller mp2888
|
||||
- mps,mp2888
|
||||
# Monolithic Power Systems Inc. multi-phase controller mp2975
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,96 +0,0 @@
|
||||
From 4db801c656712234c840883b68429e6d45080ea3 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 6 Jul 2021 18:38:29 +0000
|
||||
Subject: [PATCH backport v5.10.43 49/67] leds: mlxreg: Provide conversion for
|
||||
hardware LED color code
|
||||
|
||||
In case register is set by hardware, convert hardware color code to
|
||||
expose correct color to "sysfs".
|
||||
For some LED color at initial state is set by hardware. Hardware
|
||||
controls LED color until the first software write access to any LED
|
||||
register - the first software access cancels hardware control.
|
||||
If LED is under hardware control - detect the color in brightness_get()
|
||||
function.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
drivers/leds/leds-mlxreg.c | 27 ++++++++++++++++++++++-----
|
||||
1 file changed, 22 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
|
||||
index 82aea1cd0c12..aa82f6a521f8 100644
|
||||
--- a/drivers/leds/leds-mlxreg.c
|
||||
+++ b/drivers/leds/leds-mlxreg.c
|
||||
@@ -17,7 +17,9 @@
|
||||
#define MLXREG_LED_OFFSET_BLINK_3HZ 0x01 /* Offset from solid: 3Hz blink */
|
||||
#define MLXREG_LED_OFFSET_BLINK_6HZ 0x02 /* Offset from solid: 6Hz blink */
|
||||
#define MLXREG_LED_IS_OFF 0x00 /* Off */
|
||||
-#define MLXREG_LED_RED_SOLID 0x05 /* Solid red */
|
||||
+#define MLXREG_LED_RED_SOLID_HW 0x01 /* Solid red or orange by hardware */
|
||||
+#define MLXREG_LED_RED_SOLID 0x05 /* Solid red or orange */
|
||||
+#define MLXREG_LED_GREEN_SOLID_HW 0x09 /* Solid green by hardware */
|
||||
#define MLXREG_LED_GREEN_SOLID 0x0D /* Solid green */
|
||||
#define MLXREG_LED_AMBER_SOLID 0x09 /* Solid amber */
|
||||
#define MLXREG_LED_BLINK_3HZ 167 /* ~167 msec off/on - HW support */
|
||||
@@ -30,6 +32,7 @@
|
||||
* @data: led configuration data;
|
||||
* @led_classdev: led class data;
|
||||
* @base_color: base led color (other colors have constant offset from base);
|
||||
+ * @base_color_hw: base led color set by hardware;
|
||||
* @led_data: led data;
|
||||
* @data_parent: pointer to private device control data of parent;
|
||||
*/
|
||||
@@ -37,6 +40,7 @@ struct mlxreg_led_data {
|
||||
struct mlxreg_core_data *data;
|
||||
struct led_classdev led_cdev;
|
||||
u8 base_color;
|
||||
+ u8 base_color_hw;
|
||||
void *data_parent;
|
||||
char led_cdev_name[MLXREG_CORE_LABEL_MAX_SIZE];
|
||||
};
|
||||
@@ -124,8 +128,17 @@ mlxreg_led_get_hw(struct mlxreg_led_data *led_data)
|
||||
regval = regval & ~data->mask;
|
||||
regval = (ror32(data->mask, data->bit) == 0xf0) ? ror32(regval,
|
||||
data->bit) : ror32(regval, data->bit + 4);
|
||||
- if (regval >= led_data->base_color &&
|
||||
- regval <= (led_data->base_color + MLXREG_LED_OFFSET_BLINK_6HZ))
|
||||
+
|
||||
+ /*
|
||||
+ * For some LED color at initial state is set by hardware. Hardware controls LED color
|
||||
+ * until the first write access to any LED register. If LED is under hardware control -
|
||||
+ * convert the value to the software mask to expose correct color. The first LED set by
|
||||
+ * software cancels hardware control.
|
||||
+ */
|
||||
+ if ((regval >= led_data->base_color &&
|
||||
+ regval <= (led_data->base_color + MLXREG_LED_OFFSET_BLINK_6HZ)) ||
|
||||
+ (led_data->base_color_hw && regval >= led_data->base_color_hw &&
|
||||
+ regval <= (led_data->base_color_hw + MLXREG_LED_OFFSET_BLINK_6HZ)))
|
||||
return LED_FULL;
|
||||
|
||||
return LED_OFF;
|
||||
@@ -217,16 +230,20 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
|
||||
|
||||
led_cdev = &led_data->led_cdev;
|
||||
led_data->data_parent = priv;
|
||||
- if (strstr(data->label, "red") ||
|
||||
- strstr(data->label, "orange")) {
|
||||
+ if (strstr(data->label, "red")) {
|
||||
+ brightness = LED_OFF;
|
||||
+ led_data->base_color = MLXREG_LED_RED_SOLID;
|
||||
+ } else if (strstr(data->label, "orange")) {
|
||||
brightness = LED_OFF;
|
||||
led_data->base_color = MLXREG_LED_RED_SOLID;
|
||||
+ led_data->base_color_hw = MLXREG_LED_RED_SOLID_HW;
|
||||
} else if (strstr(data->label, "amber")) {
|
||||
brightness = LED_OFF;
|
||||
led_data->base_color = MLXREG_LED_AMBER_SOLID;
|
||||
} else {
|
||||
brightness = LED_OFF;
|
||||
led_data->base_color = MLXREG_LED_GREEN_SOLID;
|
||||
+ led_data->base_color_hw = MLXREG_LED_GREEN_SOLID_HW;
|
||||
}
|
||||
snprintf(led_data->led_cdev_name, sizeof(led_data->led_cdev_name),
|
||||
"mlxreg:%s", data->label);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 3d0e396f29b5da17385c279946b70ee5cd373efe Mon Sep 17 00:00:00 2001
|
||||
From 519742b99a6a2d6b8d5797d70608fdc954d2871a Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 7 Jul 2021 10:18:14 +0000
|
||||
Subject: [PATCH backport 5.10 050/182] leds: mlxreg: Skip setting LED color
|
||||
Subject: [PATCH backport 6.1.42 55/85] leds: mlxreg: Skip setting LED color
|
||||
during initialization
|
||||
|
||||
Hardware controls LED through CPLD device and LED control ownership
|
||||
@ -15,15 +15,16 @@ keeping hardware settings visible for user, until user will not decide
|
||||
to set LEDs according to user OS specific requirements.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Michael Shych <michaelsh@nvidia.com>
|
||||
---
|
||||
drivers/leds/leds-mlxreg.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
|
||||
index 82aea1cd0c12..7df4653a80d7 100644
|
||||
index 215132f67c07..c0caf810b6d0 100644
|
||||
--- a/drivers/leds/leds-mlxreg.c
|
||||
+++ b/drivers/leds/leds-mlxreg.c
|
||||
@@ -243,9 +243,6 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
|
||||
@@ -246,9 +246,6 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -1,77 +0,0 @@
|
||||
From 6782d682cb0510d0fee33f456ed3492834bad97d Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 7 Jul 2021 10:29:27 +0000
|
||||
Subject: leds: mlxreg: Allow multi-instantiation of same name LED for modular
|
||||
systems
|
||||
|
||||
It could be more than one instance of LED with the same name in the
|
||||
modular systems. For example, "status" or "uid" LED can be located
|
||||
on chassis and on each line card of modular system.
|
||||
In order to avoid conflicts with duplicated names, append platform
|
||||
device Id, which is unique, to LED name after driver name.
|
||||
Thus, for example, "status" LED on chassis is to be called, like it is
|
||||
called now on non-modular systems, on which platform device Id is not
|
||||
specified: "mlxreg:status:green". While for the line cards LEDs it will
|
||||
be called like: "pcicard48:status:green", "ibcard66:status:green",
|
||||
etc. Where line card prefix is specified according to the type of bus
|
||||
connecting line card to the chassis.
|
||||
|
||||
LED driver works on top of register space of the programmable devices
|
||||
(CPLD or FPGA), providing the logic for LED control. The programmable
|
||||
devices on the line cards are connected through I2C bus and LED driver
|
||||
will work over I2C. On main board programmable device is connected
|
||||
through LPC, and LED driver works over LPC.
|
||||
|
||||
The motivation it to provide support for new modular systems which
|
||||
could be equipped with the different types of replaceable line cards
|
||||
and management board.
|
||||
|
||||
Line cards are connected to the chassis through I2C interface for the
|
||||
chassis management operations and through PCIe for the networking
|
||||
operations.
|
||||
|
||||
The first type of line card supports 16x100GbE QSFP28 Ethernet ports.
|
||||
Those line cards equipped with the programmable devices aimed for
|
||||
system control of Nvidia Ethernet switch ASIC control, Nvidia FPGA,
|
||||
Nvidia gearboxes (PHYs).
|
||||
The next coming card generations are supposed to support:
|
||||
- Line cards with 8x200Gbe QSFP28 Ethernet ports.
|
||||
- Line cards with 4x400Gbe QSFP-DD Ethernet ports.
|
||||
- Smart cards equipped with Nvidia ARM CPU for offloading and for fast
|
||||
access to the storage (EBoF).
|
||||
- Fabric cards for inter-connection.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
drivers/leds/leds-mlxreg.c | 15 +++++++++++++--
|
||||
1 file changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
|
||||
index 0f2608a34..099ff4be2 100644
|
||||
--- a/drivers/leds/leds-mlxreg.c
|
||||
+++ b/drivers/leds/leds-mlxreg.c
|
||||
@@ -245,8 +245,19 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
|
||||
led_data->base_color = MLXREG_LED_GREEN_SOLID;
|
||||
led_data->base_color_hw = MLXREG_LED_GREEN_SOLID_HW;
|
||||
}
|
||||
- snprintf(led_data->led_cdev_name, sizeof(led_data->led_cdev_name),
|
||||
- "mlxreg:%s", data->label);
|
||||
+
|
||||
+ /*
|
||||
+ * Id greater than zero is used for LEDs located on replaceable unit,
|
||||
+ * like line card or fabric card. In this case Id is set to I2C bus
|
||||
+ * number. Otherwise LEDs located on the main board. The field "identity"
|
||||
+ * specifies the type of bus connecting line card to the chassis.
|
||||
+ */
|
||||
+ if (priv->pdev->id > 0)
|
||||
+ sprintf(led_data->led_cdev_name, "%scard%d:%s", led_pdata->identity,
|
||||
+ priv->pdev->id, data->label);
|
||||
+ else
|
||||
+ sprintf(led_data->led_cdev_name, "%s:%s", "mlxreg",
|
||||
+ data->label);
|
||||
led_cdev->name = led_data->led_cdev_name;
|
||||
led_cdev->brightness = brightness;
|
||||
led_cdev->max_brightness = LED_ON;
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,8 +1,8 @@
|
||||
From d1fbdc9c5bd0939362ebdb4d76a701cb938f3837 Mon Sep 17 00:00:00 2001
|
||||
From 7831c5d10460c08cb5837827784677e0286d14e7 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 18 Jan 2023 19:12:12 +0200
|
||||
Subject: [PATCH backport 5.10 083/150] platform/mellanox: Add support for
|
||||
dynamic I2C channels infrastructure
|
||||
Date: Sun, 30 Jul 2023 21:31:54 +0000
|
||||
Subject: [PATH backport v6.1 53/54] platform/mellanox: Add support for dynamic
|
||||
I2C channels infrastructure
|
||||
|
||||
Allow to support platform configuration for dynamically allocated I2C
|
||||
channels.
|
||||
@ -17,49 +17,50 @@ Thus, hotplug mux channels will be aligned according to the dynamic
|
||||
adapters data.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Michael Shych <michaelsh@nvidia.com>
|
||||
---
|
||||
drivers/platform/x86/mlx-platform.c | 69 ++++++++++++++++++++++++-----
|
||||
1 file changed, 59 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
|
||||
index 9d4cab937..773d110c9 100644
|
||||
index 44f107965832..9021597b5446 100644
|
||||
--- a/drivers/platform/x86/mlx-platform.c
|
||||
+++ b/drivers/platform/x86/mlx-platform.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/module.h>
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/platform_data/i2c-mux-reg.h>
|
||||
+#include <linux/platform_data/i2c-mux-regmap.h>
|
||||
#include <linux/platform_data/mlxreg.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/regmap.h>
|
||||
@@ -336,6 +337,7 @@
|
||||
@@ -350,6 +351,7 @@
|
||||
* @hotplug_resources: system hotplug resources
|
||||
* @hotplug_resources_size: size of system hotplug resources
|
||||
* @hi2c_main_init_status: init status of I2C main bus
|
||||
+ * @mux_added: number of added mux segments
|
||||
* @irq_fpga: FPGA IRQ number
|
||||
*/
|
||||
struct mlxplat_priv {
|
||||
struct platform_device *pdev_i2c;
|
||||
@@ -349,6 +351,7 @@ struct mlxplat_priv {
|
||||
@@ -364,6 +366,7 @@ struct mlxplat_priv {
|
||||
struct resource *hotplug_resources;
|
||||
unsigned int hotplug_resources_size;
|
||||
u8 i2c_main_init_status;
|
||||
+ int mux_added;
|
||||
int irq_fpga;
|
||||
};
|
||||
|
||||
static struct platform_device *mlxplat_dev;
|
||||
@@ -436,7 +439,9 @@ static struct i2c_mux_reg_platform_data mlxplat_default_mux_data[] = {
|
||||
@@ -453,7 +456,9 @@ static struct i2c_mux_reg_platform_data mlxplat_default_mux_data[] = {
|
||||
/* Platform mux configuration variables */
|
||||
static int mlxplat_max_adap_num;
|
||||
static int mlxplat_mux_num;
|
||||
+static int mlxplat_mux_hotplug_num;
|
||||
static struct i2c_mux_reg_platform_data *mlxplat_mux_data;
|
||||
+static struct i2c_mux_regmap_platform_data *mlxplat_mux_regmap_data;
|
||||
static struct notifier_block *mlxplat_reboot_nb;
|
||||
|
||||
/* Platform extended mux data */
|
||||
static struct i2c_mux_reg_platform_data mlxplat_extended_mux_data[] = {
|
||||
@@ -6368,12 +6373,17 @@ static int mlxplat_mlxcpld_verify_bus_topology(int *nr)
|
||||
@@ -6126,12 +6131,17 @@ static int mlxplat_mlxcpld_verify_bus_topology(int *nr)
|
||||
/* Shift adapter ids, since expected parent adapter is not free. */
|
||||
*nr = i;
|
||||
for (i = 0; i < mlxplat_mux_num; i++) {
|
||||
@ -81,7 +82,7 @@ index 9d4cab937..773d110c9 100644
|
||||
mlxplat_hotplug->shift_nr = shift;
|
||||
|
||||
return 0;
|
||||
@@ -6563,8 +6573,31 @@ mlxplat_i2c_mux_complition_notify(void *handle, struct i2c_adapter *parent,
|
||||
@@ -6428,8 +6438,31 @@ mlxplat_i2c_mux_complition_notify(void *handle, struct i2c_adapter *parent,
|
||||
struct i2c_adapter *adapters[])
|
||||
{
|
||||
struct mlxplat_priv *priv = handle;
|
||||
@ -113,8 +114,8 @@ index 9d4cab937..773d110c9 100644
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int mlxplat_i2c_mux_topolgy_init(struct mlxplat_priv *priv)
|
||||
@@ -6578,17 +6611,33 @@ static int mlxplat_i2c_mux_topolgy_init(struct mlxplat_priv *priv)
|
||||
static int mlxplat_i2c_mux_topology_init(struct mlxplat_priv *priv)
|
||||
@@ -6443,17 +6476,33 @@ static int mlxplat_i2c_mux_topology_init(struct mlxplat_priv *priv)
|
||||
|
||||
priv->i2c_main_init_status = MLXPLAT_I2C_MAIN_BUS_HANDLE_CREATED;
|
||||
for (i = 0; i < mlxplat_mux_num; i++) {
|
@ -0,0 +1,312 @@
|
||||
From 3e4ff8f2195a3dc7b04bb5a1b9fd6b655f78a75e Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 24 Jul 2023 11:10:50 +0000
|
||||
Subject: [PATH backport v6.1 54/54] platform: mellanox: Introduce support for
|
||||
switches equipped with new FPGA device
|
||||
|
||||
Add support for Nvidia MQM97xx and MSN47xx family switches equipped with
|
||||
new FPGA device.
|
||||
|
||||
These switches are based on previous generation of MQM97xx and MSN47xx
|
||||
switches, but COMe module uses new FPGA device.
|
||||
|
||||
Platform configuration for new switches is based on the new VMOD0016
|
||||
class. Configuration is extended to support new register map with
|
||||
callbacks supporting indirect addressing for PCIe-to-LPC bridge.
|
||||
This bridge provides interface between FPGA at COMe board (directly
|
||||
connected to CPU PCIe root complex) to CPLDs on switch board (which
|
||||
cannot be connected directly to PCIe root complex).
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Michael Shych <michaelsh@nvidia.com>
|
||||
---
|
||||
drivers/platform/x86/mlx-platform.c | 196 ++++++++++++++++++++++++++++
|
||||
1 file changed, 196 insertions(+)
|
||||
|
||||
diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
|
||||
index 9021597b5446..46958810e972 100644
|
||||
--- a/drivers/platform/x86/mlx-platform.c
|
||||
+++ b/drivers/platform/x86/mlx-platform.c
|
||||
@@ -183,6 +183,9 @@
|
||||
#define MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET 0xfb
|
||||
#define MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET 0xfc
|
||||
#define MLXPLAT_CPLD_LPC_REG_CONFIG3_OFFSET 0xfd
|
||||
+#define MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET 0x100
|
||||
+#define MLXPLAT_CPLD_LPC_REG_EXT_MID_OFFSET 0x195
|
||||
+#define MLXPLAT_CPLD_LPC_REG_EXT_MAX_OFFSET 0x1ff
|
||||
#define MLXPLAT_CPLD_LPC_IO_RANGE 0x100
|
||||
|
||||
#define MLXPLAT_CPLD_LPC_PIO_OFFSET 0x10000UL
|
||||
@@ -277,6 +280,7 @@
|
||||
/* Maximum number of possible physical buses equipped on system */
|
||||
#define MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM 16
|
||||
#define MLXPLAT_CPLD_MAX_PHYS_EXT_ADAPTER_NUM 24
|
||||
+#define MLXPLAT_CPLD_DEFAULT_MUX_HOTPLUG_VECTOR 0
|
||||
|
||||
/* Number of channels in group */
|
||||
#define MLXPLAT_CPLD_GRP_CHNL_NUM 8
|
||||
@@ -338,6 +342,21 @@
|
||||
#define PCI_DEVICE_ID_LATTICE_I2C_BRIDGE 0x9c2f
|
||||
#define PCI_DEVICE_ID_LATTICE_JTAG_BRIDGE 0x9c30
|
||||
#define PCI_DEVICE_ID_LATTICE_LPC_BRIDGE 0x9c32
|
||||
+#define MLXPLAT_FPGA_PCI_BAR0_SIZE 0x4000
|
||||
+#define MLXPLAT_FPGA_PCI_BASE_OFFSET 0x00000000
|
||||
+#define MLXPLAT_FPGA_PCI_MSB_ADDR 0x25
|
||||
+#define MLXPLAT_FPGA_PCI_MSB_EXT_ADDR 0x20
|
||||
+#define MLXPLAT_FPGA_PCI_LSB_ADDR_OFFSET MLXPLAT_FPGA_PCI_BASE_OFFSET
|
||||
+#define MLXPLAT_FPGA_PCI_MSB_ADDR_OFFSET (MLXPLAT_FPGA_PCI_BASE_OFFSET + 0x01)
|
||||
+#define MLXPLAT_FPGA_PCI_DATA_OUT_OFFSET (MLXPLAT_FPGA_PCI_BASE_OFFSET + 0x02)
|
||||
+#define MLXPLAT_FPGA_PCI_DATA_IN_OFFSET (MLXPLAT_FPGA_PCI_BASE_OFFSET + 0x03)
|
||||
+#define MLXPLAT_FPGA_PCI_CTRL_OFFSET (MLXPLAT_FPGA_PCI_BASE_OFFSET + 0x04)
|
||||
+#define MLXPLAT_FPGA_PCI_STAT_OFFSET (MLXPLAT_FPGA_PCI_BASE_OFFSET + 0x05)
|
||||
+
|
||||
+#define MLXPLAT_FPGA_PCI_CTRL_READ BIT(0)
|
||||
+#define MLXPLAT_FPGA_PCI_CTRL_WRITE BIT(1)
|
||||
+#define MLXPLAT_FPGA_PCI_COMPLETED GENMASK(1, 0)
|
||||
+#define MLXPLAT_FPGA_PCI_TO 50 /* usec */
|
||||
|
||||
/* mlxplat_priv - platform private data
|
||||
* @pdev_i2c - i2c controller platform device
|
||||
@@ -453,6 +472,28 @@ static struct i2c_mux_reg_platform_data mlxplat_default_mux_data[] = {
|
||||
|
||||
};
|
||||
|
||||
+/* Default channels vector for regmap mux. */
|
||||
+static int mlxplat_default_regmap_mux_chan[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
+
|
||||
+/* Platform regmap mux data */
|
||||
+static struct i2c_mux_regmap_platform_data mlxplat_default_regmap_mux_data[] = {
|
||||
+ {
|
||||
+ .parent = 1,
|
||||
+ .chan_ids = mlxplat_default_regmap_mux_chan,
|
||||
+ .num_adaps = ARRAY_SIZE(mlxplat_default_regmap_mux_chan),
|
||||
+ .sel_reg_addr = MLXPLAT_CPLD_LPC_REG_I2C_CH1_OFFSET,
|
||||
+ .reg_size = 1,
|
||||
+ },
|
||||
+ {
|
||||
+ .parent = 1,
|
||||
+ .chan_ids = mlxplat_default_regmap_mux_chan,
|
||||
+ .num_adaps = ARRAY_SIZE(mlxplat_default_regmap_mux_chan),
|
||||
+ .sel_reg_addr = MLXPLAT_CPLD_LPC_REG_I2C_CH2_OFFSET,
|
||||
+ .reg_size = 1,
|
||||
+ },
|
||||
+
|
||||
+};
|
||||
+
|
||||
/* Platform mux configuration variables */
|
||||
static int mlxplat_max_adap_num;
|
||||
static int mlxplat_mux_num;
|
||||
@@ -3540,6 +3581,12 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = {
|
||||
.mask = GENMASK(7, 0) & ~BIT(2),
|
||||
.mode = 0200,
|
||||
},
|
||||
+ {
|
||||
+ .label = "kexec_activated",
|
||||
+ .reg = MLXPLAT_CPLD_LPC_REG_RESET_GP2_OFFSET,
|
||||
+ .mask = GENMASK(7, 0) & ~BIT(1),
|
||||
+ .mode = 0644,
|
||||
+ },
|
||||
{
|
||||
.label = "erot1_reset",
|
||||
.reg = MLXPLAT_CPLD_LPC_REG_RESET_GP2_OFFSET,
|
||||
@@ -5065,6 +5112,7 @@ static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg)
|
||||
case MLXPLAT_CPLD_LPC_REG_PWM3_OFFSET:
|
||||
case MLXPLAT_CPLD_LPC_REG_PWM4_OFFSET:
|
||||
case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET:
|
||||
+ case MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET ... MLXPLAT_CPLD_LPC_REG_EXT_MAX_OFFSET:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -5230,6 +5278,7 @@ static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg)
|
||||
case MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET:
|
||||
case MLXPLAT_CPLD_LPC_REG_CONFIG3_OFFSET:
|
||||
case MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET:
|
||||
+ case MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET ... MLXPLAT_CPLD_LPC_REG_EXT_MAX_OFFSET:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -5387,6 +5436,7 @@ static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg)
|
||||
case MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET:
|
||||
case MLXPLAT_CPLD_LPC_REG_CONFIG3_OFFSET:
|
||||
case MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET:
|
||||
+ case MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET ... MLXPLAT_CPLD_LPC_REG_EXT_MAX_OFFSET:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -5417,6 +5467,14 @@ static const struct reg_default mlxplat_mlxcpld_regmap_ng400[] = {
|
||||
{ MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 0x00 },
|
||||
};
|
||||
|
||||
+static const struct reg_default mlxplat_mlxcpld_regmap_bf3[] = {
|
||||
+ { MLXPLAT_CPLD_LPC_REG_GP2_OFFSET, 0xc1 },
|
||||
+ { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 },
|
||||
+ { MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET, 0x00 },
|
||||
+ { MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 0x00 },
|
||||
+ { MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 0x00 },
|
||||
+};
|
||||
+
|
||||
static const struct reg_default mlxplat_mlxcpld_regmap_rack_switch[] = {
|
||||
{ MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, MLXPLAT_REGMAP_NVSWITCH_PWM_DEFAULT },
|
||||
{ MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET, 0x00 },
|
||||
@@ -5545,6 +5603,114 @@ static const struct regmap_config mlxplat_mlxcpld_regmap_config_eth_modular = {
|
||||
.reg_write = mlxplat_mlxcpld_reg_write,
|
||||
};
|
||||
|
||||
+/* Wait completion routine for indirect access for register map */
|
||||
+static int mlxplat_fpga_completion_wait(struct mlxplat_mlxcpld_regmap_context *ctx)
|
||||
+{
|
||||
+ unsigned long end;
|
||||
+ u8 status;
|
||||
+
|
||||
+ end = jiffies + msecs_to_jiffies(MLXPLAT_FPGA_PCI_TO);
|
||||
+ do {
|
||||
+ status = ioread8(ctx->base + MLXPLAT_FPGA_PCI_STAT_OFFSET);
|
||||
+ if (!(status & MLXPLAT_FPGA_PCI_COMPLETED))
|
||||
+ return 0;
|
||||
+ cond_resched();
|
||||
+ } while (time_before(jiffies, end));
|
||||
+
|
||||
+ return -EIO;
|
||||
+}
|
||||
+
|
||||
+/* Read callback for indirect register map access */
|
||||
+static int mlxplat_fpga_reg_read(void *context, unsigned int reg, unsigned int *val)
|
||||
+{
|
||||
+ struct mlxplat_mlxcpld_regmap_context *ctx = context;
|
||||
+ unsigned int msb_off = MLXPLAT_FPGA_PCI_MSB_ADDR;
|
||||
+ int err;
|
||||
+
|
||||
+ if (reg >= MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET) {
|
||||
+ if (reg <= MLXPLAT_CPLD_LPC_REG_EXT_MID_OFFSET) {
|
||||
+ /* Access to 2-nd FPGA bank */
|
||||
+ *val = ioread8(i2c_bridge_addr + reg -
|
||||
+ MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ /* Access to 3-rd FPGA bank */
|
||||
+ reg -= MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET;
|
||||
+ msb_off = MLXPLAT_FPGA_PCI_MSB_EXT_ADDR;
|
||||
+ }
|
||||
+
|
||||
+ /* Verify there is no pending transactions */
|
||||
+ err = mlxplat_fpga_completion_wait(ctx);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Set address in register space */
|
||||
+ iowrite8(msb_off, ctx->base + MLXPLAT_FPGA_PCI_MSB_ADDR_OFFSET);
|
||||
+ iowrite8(reg, ctx->base + MLXPLAT_FPGA_PCI_LSB_ADDR_OFFSET);
|
||||
+ /* Activate read operation */
|
||||
+ iowrite8(MLXPLAT_FPGA_PCI_CTRL_READ, ctx->base + MLXPLAT_FPGA_PCI_CTRL_OFFSET);
|
||||
+ /* Verify transaction completion */
|
||||
+ err = mlxplat_fpga_completion_wait(ctx);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Read data */
|
||||
+ *val = ioread8(ctx->base + MLXPLAT_FPGA_PCI_DATA_IN_OFFSET);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* Write callback for indirect register map access */
|
||||
+static int mlxplat_fpga_reg_write(void *context, unsigned int reg, unsigned int val)
|
||||
+{
|
||||
+ struct mlxplat_mlxcpld_regmap_context *ctx = context;
|
||||
+ unsigned int msb_off = MLXPLAT_FPGA_PCI_MSB_ADDR;
|
||||
+ int err;
|
||||
+
|
||||
+ if (reg >= MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET) {
|
||||
+ if (reg <= MLXPLAT_CPLD_LPC_REG_EXT_MID_OFFSET) {
|
||||
+ /* Access to 2-nd FPGA bank */
|
||||
+ iowrite8(val, i2c_bridge_addr + reg - MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET);
|
||||
+ /* Flush modification */
|
||||
+ wmb();
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Access to 3-rd FPGA bank */
|
||||
+ reg -= MLXPLAT_CPLD_LPC_REG_EXT_MIN_OFFSET;
|
||||
+ msb_off = MLXPLAT_FPGA_PCI_MSB_EXT_ADDR;
|
||||
+ }
|
||||
+
|
||||
+ /* Verify there is no pending transactions */
|
||||
+ err = mlxplat_fpga_completion_wait(ctx);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Set address in register space */
|
||||
+ iowrite8(msb_off, ctx->base + MLXPLAT_FPGA_PCI_MSB_ADDR_OFFSET);
|
||||
+ iowrite8(reg, ctx->base + MLXPLAT_FPGA_PCI_LSB_ADDR_OFFSET);
|
||||
+ /* Set data to be written */
|
||||
+ iowrite8(val, ctx->base + MLXPLAT_FPGA_PCI_DATA_OUT_OFFSET);
|
||||
+ /* Activate write operation */
|
||||
+ iowrite8(MLXPLAT_FPGA_PCI_CTRL_WRITE, ctx->base + MLXPLAT_FPGA_PCI_CTRL_OFFSET);
|
||||
+
|
||||
+ return mlxplat_fpga_completion_wait(ctx);
|
||||
+}
|
||||
+
|
||||
+static const struct regmap_config mlxplat_fpga_regmap_config_bf3_comex_default = {
|
||||
+ .reg_bits = 9,
|
||||
+ .val_bits = 8,
|
||||
+ .max_register = 511,
|
||||
+ .cache_type = REGCACHE_FLAT,
|
||||
+ .writeable_reg = mlxplat_mlxcpld_writeable_reg,
|
||||
+ .readable_reg = mlxplat_mlxcpld_readable_reg,
|
||||
+ .volatile_reg = mlxplat_mlxcpld_volatile_reg,
|
||||
+ .reg_defaults = mlxplat_mlxcpld_regmap_bf3,
|
||||
+ .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_bf3),
|
||||
+ .reg_read = mlxplat_fpga_reg_read,
|
||||
+ .reg_write = mlxplat_fpga_reg_write,
|
||||
+};
|
||||
+
|
||||
static struct resource mlxplat_mlxcpld_resources[] = {
|
||||
[0] = DEFINE_RES_IRQ_NAMED(MLXPLAT_CPLD_LPC_SYSIRQ, "mlxreg-hotplug"),
|
||||
};
|
||||
@@ -5927,6 +6093,30 @@ static int __init mlxplat_dmi_l1_switch_matched(const struct dmi_system_id *dmi)
|
||||
return mlxplat_register_platform_device();
|
||||
}
|
||||
|
||||
+static int __init mlxplat_dmi_bf3_comex_default_matched(const struct dmi_system_id *dmi)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
|
||||
+ mlxplat_mux_hotplug_num = MLXPLAT_CPLD_DEFAULT_MUX_HOTPLUG_VECTOR;
|
||||
+ mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_regmap_mux_data);
|
||||
+ mlxplat_mux_regmap_data = mlxplat_default_regmap_mux_data;
|
||||
+ mlxplat_hotplug = &mlxplat_mlxcpld_ext_data;
|
||||
+ mlxplat_hotplug->deferred_nr =
|
||||
+ mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
|
||||
+ mlxplat_led = &mlxplat_default_ng_led_data;
|
||||
+ mlxplat_regs_io = &mlxplat_default_ng_regs_io_data;
|
||||
+ mlxplat_fan = &mlxplat_default_fan_data;
|
||||
+ for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++)
|
||||
+ mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i];
|
||||
+ mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data;
|
||||
+ mlxplat_regmap_config = &mlxplat_fpga_regmap_config_bf3_comex_default;
|
||||
+ mlxplat_reboot_nb = &mlxplat_reboot_default_nb;
|
||||
+ pm_power_off = mlxplat_poweroff;
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
static const struct dmi_system_id mlxplat_dmi_table[] __initconst = {
|
||||
{
|
||||
.callback = mlxplat_dmi_default_wc_matched,
|
||||
@@ -6015,6 +6205,12 @@ static const struct dmi_system_id mlxplat_dmi_table[] __initconst = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "VMOD0015"),
|
||||
},
|
||||
},
|
||||
+ {
|
||||
+ .callback = mlxplat_dmi_bf3_comex_default_matched,
|
||||
+ .matches = {
|
||||
+ DMI_MATCH(DMI_BOARD_NAME, "VMOD0016"),
|
||||
+ },
|
||||
+ },
|
||||
{
|
||||
.callback = mlxplat_dmi_l1_switch_matched,
|
||||
.matches = {
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,35 +1,34 @@
|
||||
From 723dacff3d93f270a52195c895e2ddf233b146d7 Mon Sep 17 00:00:00 2001
|
||||
From a4eca7c60f361575fb15bcab6fdcd39c795c8244 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 7 Nov 2022 11:52:34 +0200
|
||||
Subject: [PATCH backport 5.10 084/150] platform: mellanox: Relocate
|
||||
mlx-platform driver
|
||||
Date: Mon, 24 Jul 2023 11:52:56 +0000
|
||||
Subject: [PATCH backport 6.1.42 58/85] mellanox: Relocate mlx-platform driver
|
||||
|
||||
Move 'mlx-platform' driver 'x86' to 'mellanox' folder.
|
||||
|
||||
Motivation to allow running it on systems with ARM architecture.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Michael Shych <michaelsh@nvidia.com>
|
||||
---
|
||||
drivers/platform/mellanox/Kconfig | 12 ++++++++++++
|
||||
drivers/platform/mellanox/Makefile | 1 +
|
||||
drivers/platform/{x86 => mellanox}/mlx-platform.c | 0
|
||||
drivers/platform/x86/Kconfig | 12 ------------
|
||||
drivers/platform/x86/Kconfig | 13 -------------
|
||||
drivers/platform/x86/Makefile | 1 -
|
||||
5 files changed, 13 insertions(+), 13 deletions(-)
|
||||
5 files changed, 13 insertions(+), 14 deletions(-)
|
||||
rename drivers/platform/{x86 => mellanox}/mlx-platform.c (100%)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig
|
||||
index 75e2bee17..ff8267329 100644
|
||||
index 382793e73a60..70b628834b4f 100644
|
||||
--- a/drivers/platform/mellanox/Kconfig
|
||||
+++ b/drivers/platform/mellanox/Kconfig
|
||||
@@ -14,6 +14,19 @@ menuconfig MELLANOX_PLATFORM
|
||||
@@ -14,6 +14,18 @@ menuconfig MELLANOX_PLATFORM
|
||||
|
||||
if MELLANOX_PLATFORM
|
||||
|
||||
+config MLX_PLATFORM
|
||||
+ tristate "Mellanox Technologies platform support"
|
||||
+ depends on I2C
|
||||
+ select REGMAP
|
||||
+ depends on I2C && REGMAP
|
||||
+ help
|
||||
+ This option enables system support for the Mellanox Technologies
|
||||
+ platform. The Mellanox systems provide data center networking
|
||||
@ -41,9 +40,9 @@ index 75e2bee17..ff8267329 100644
|
||||
+
|
||||
config MLXREG_HOTPLUG
|
||||
tristate "Mellanox platform hotplug driver support"
|
||||
depends on REGMAP
|
||||
depends on HWMON
|
||||
diff --git a/drivers/platform/mellanox/Makefile b/drivers/platform/mellanox/Makefile
|
||||
index 6af37ee88..23919e56a 100644
|
||||
index 04703c0416b1..ba56485cbe8c 100644
|
||||
--- a/drivers/platform/mellanox/Makefile
|
||||
+++ b/drivers/platform/mellanox/Makefile
|
||||
@@ -3,6 +3,7 @@
|
||||
@ -52,19 +51,19 @@ index 6af37ee88..23919e56a 100644
|
||||
#
|
||||
+obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o
|
||||
obj-$(CONFIG_MLXBF_BOOTCTL) += mlxbf-bootctl.o
|
||||
obj-$(CONFIG_MLXBF_PMC) += mlxbf-pmc.o
|
||||
obj-$(CONFIG_MLXBF_TMFIFO) += mlxbf-tmfifo.o
|
||||
obj-$(CONFIG_MLXREG_HOTPLUG) += mlxreg-hotplug.o
|
||||
diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/mellanox/mlx-platform.c
|
||||
similarity index 100%
|
||||
rename from drivers/platform/x86/mlx-platform.c
|
||||
rename to drivers/platform/mellanox/mlx-platform.c
|
||||
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
|
||||
index a1858689d..4270d4c17 100644
|
||||
index 1396a839dd8a..f11136bbf88d 100644
|
||||
--- a/drivers/platform/x86/Kconfig
|
||||
+++ b/drivers/platform/x86/Kconfig
|
||||
@@ -1193,19 +1193,6 @@ config I2C_MULTI_INSTANTIATE
|
||||
@@ -954,19 +954,6 @@ config SERIAL_MULTI_INSTANTIATE
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called i2c-multi-instantiate.
|
||||
will be called serial-multi-instantiate.
|
||||
|
||||
-config MLX_PLATFORM
|
||||
- tristate "Mellanox Technologies platform support"
|
||||
@ -83,17 +82,17 @@ index a1858689d..4270d4c17 100644
|
||||
bool "DMI based touchscreen configuration info"
|
||||
depends on ACPI && DMI && I2C=y && TOUCHSCREEN_SILEAD
|
||||
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
|
||||
index 5f823f7ef..1db86675f 100644
|
||||
index 1d3d1b02541b..aee1bc4b0a80 100644
|
||||
--- a/drivers/platform/x86/Makefile
|
||||
+++ b/drivers/platform/x86/Makefile
|
||||
@@ -122,7 +122,6 @@ obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o
|
||||
|
||||
@@ -109,7 +109,6 @@ obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o
|
||||
# Platform drivers
|
||||
obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o
|
||||
obj-$(CONFIG_FW_ATTR_CLASS) += firmware_attributes_class.o
|
||||
obj-$(CONFIG_SERIAL_MULTI_INSTANTIATE) += serial-multi-instantiate.o
|
||||
-obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o
|
||||
|
||||
# Intel uncore drivers
|
||||
obj-$(CONFIG_WIRELESS_HOTKEY) += wireless-hotkey.o
|
||||
obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,40 @@
|
||||
From b7b422bbd95928b213444692d5b00ef081160c0b Mon Sep 17 00:00:00 2001
|
||||
From: Liming Sun <limings@nvidia.com>
|
||||
Date: Sat, 10 Dec 2022 13:55:54 -0500
|
||||
Subject: [PATCH backport 6.1.42 66/85] UBUNTU: SAUCE: sdhci-of-dwcmshc: Enable
|
||||
host V4 support for BlueField-3 SoC
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/1999309
|
||||
|
||||
This commit enables SDHCI Host V4 support on Bluefield-3 SoC to be
|
||||
consistent with UEFI setting.
|
||||
|
||||
Signed-off-by: Liming Sun <limings@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
[bzolnier: use a short URL version for BugLink]
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/mmc/host/sdhci-of-dwcmshc.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
index a7343d4bc50e..a1188508e75d 100644
|
||||
--- a/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
@@ -528,6 +528,12 @@ static int dwcmshc_probe(struct platform_device *pdev)
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_ACPI
|
||||
+ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) {
|
||||
+ sdhci_enable_v4_mode(host);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
|
||||
|
||||
err = sdhci_setup_host(host);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,9 +1,8 @@
|
||||
From 51ec31f1bfb39fd87dea8861b4642d03cbd6c887 Mon Sep 17 00:00:00 2001
|
||||
From 07163b7fab5b23c01195a456d92e3dc9e73b538c Mon Sep 17 00:00:00 2001
|
||||
From: Liming Sun <limings@nvidia.com>
|
||||
Date: Fri, 3 Feb 2023 07:52:18 -0500
|
||||
Subject: [PATCH 12/12] UBUNTU: SAUCE: mmc: sdhci-of-dwcmshc: add the missing
|
||||
device table IDs for acpi
|
||||
X-NVConfidentiality: public
|
||||
Subject: [PATCH backport 6.1.42 67/85] UBUNTU: SAUCE: mmc: sdhci-of-dwcmshc:
|
||||
add the missing device table IDs for acpi
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2004645
|
||||
|
||||
@ -20,10 +19,10 @@ Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.co
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
index ea972bd3c..565489ee7 100644
|
||||
index a1188508e75d..7d657d29af21 100644
|
||||
--- a/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
@@ -349,6 +349,7 @@ static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = {
|
||||
@@ -446,6 +446,7 @@ static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = {
|
||||
},
|
||||
{}
|
||||
};
|
||||
@ -32,5 +31,5 @@ index ea972bd3c..565489ee7 100644
|
||||
|
||||
static int dwcmshc_probe(struct platform_device *pdev)
|
||||
--
|
||||
2.14.1
|
||||
2.20.1
|
||||
|
@ -0,0 +1,158 @@
|
||||
From be8912e006b49c4f9febcd2556030876737e1b72 Mon Sep 17 00:00:00 2001
|
||||
From: Liming Sun <limings@nvidia.com>
|
||||
Date: Tue, 4 Apr 2023 19:30:00 -0400
|
||||
Subject: [PATCH backport 6.1.42 68/85] UBUNTU: SAUCE: mmc: sdhci-of-dwcmshc:
|
||||
Add runtime PM operations for BlueField-3
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2015307
|
||||
|
||||
This commit implements the runtime PM operations For BlueField-3 SoC
|
||||
to disable eMMC card clock when idle.
|
||||
|
||||
Reviewed-by: Khalil Blaiech <kblaiech@nvidia.com>
|
||||
Signed-off-by: Liming Sun <limings@nvidia.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Acked-by: Andrei Gherzan <andrei.gherzan@canonical.com>
|
||||
[bzolnier: use a short URL version for BugLink]
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/mmc/host/sdhci-of-dwcmshc.c | 102 +++++++++++++++++++++++++++-
|
||||
1 file changed, 101 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
index 7d657d29af21..32fd0668b427 100644
|
||||
--- a/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/reset.h>
|
||||
#include <linux/sizes.h>
|
||||
+#include <linux/pm_runtime.h>
|
||||
|
||||
#include "sdhci-pltfm.h"
|
||||
|
||||
@@ -91,6 +92,21 @@ struct dwcmshc_priv {
|
||||
void *priv; /* pointer to SoC private stuff */
|
||||
};
|
||||
|
||||
+/* Last jiffies when entering idle state */
|
||||
+static uint64_t idle_last_jiffies;
|
||||
+
|
||||
+/* Total jiffies in idle state */
|
||||
+static uint64_t idle_total_jiffies;
|
||||
+
|
||||
+/* Total idle time */
|
||||
+static int idle_time;
|
||||
+module_param(idle_time, int, 0444);
|
||||
+MODULE_PARM_DESC(idle_time, "idle time (seconds)");
|
||||
+
|
||||
+/* The current idle state */
|
||||
+static int idle_state;
|
||||
+module_param(idle_state, int, 0444);
|
||||
+MODULE_PARM_DESC(idle_state, "idle state (0: not idle, 1: idle)");
|
||||
/*
|
||||
* If DMA addr spans 128MB boundary, we split the DMA transfer into two
|
||||
* so that each DMA transfer doesn't exceed the boundary.
|
||||
@@ -532,6 +548,7 @@ static int dwcmshc_probe(struct platform_device *pdev)
|
||||
#ifdef CONFIG_ACPI
|
||||
if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) {
|
||||
sdhci_enable_v4_mode(host);
|
||||
+ pm_runtime_enable(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -635,7 +652,90 @@ static int dwcmshc_resume(struct device *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
-static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);
|
||||
+#ifdef CONFIG_PM
|
||||
+
|
||||
+#ifdef CONFIG_ACPI
|
||||
+static void dwcmshc_enable_card_clk(struct sdhci_host *host)
|
||||
+{
|
||||
+ u16 ctrl;
|
||||
+
|
||||
+ ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
|
||||
+ ctrl |= SDHCI_CLOCK_CARD_EN;
|
||||
+ sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL);
|
||||
+}
|
||||
+
|
||||
+static void dwcmshc_disable_card_clk(struct sdhci_host *host)
|
||||
+{
|
||||
+ u16 ctrl;
|
||||
+
|
||||
+ ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
|
||||
+ ctrl &= ~SDHCI_CLOCK_CARD_EN;
|
||||
+ sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static int dwcmshc_runtime_suspend(struct device *dev)
|
||||
+{
|
||||
+ struct sdhci_host *host = dev_get_drvdata(dev);
|
||||
+ const struct sdhci_pltfm_data *pltfm_data;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ pltfm_data = device_get_match_data(dev);
|
||||
+ if (!pltfm_data)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+#ifdef CONFIG_ACPI
|
||||
+ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) {
|
||||
+ ret = sdhci_runtime_suspend_host(host);
|
||||
+ if (!ret) {
|
||||
+ dwcmshc_disable_card_clk(host);
|
||||
+
|
||||
+ if (!idle_state) {
|
||||
+ idle_state = 1;
|
||||
+ idle_last_jiffies = jiffies;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int dwcmshc_runtime_resume(struct device *dev)
|
||||
+{
|
||||
+ struct sdhci_host *host = dev_get_drvdata(dev);
|
||||
+ const struct sdhci_pltfm_data *pltfm_data;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ pltfm_data = device_get_match_data(dev);
|
||||
+ if (!pltfm_data)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+#ifdef CONFIG_ACPI
|
||||
+ if (pltfm_data == &sdhci_dwcmshc_bf3_pdata) {
|
||||
+ dwcmshc_enable_card_clk(host);
|
||||
+
|
||||
+ if (idle_state) {
|
||||
+ idle_state = 0;
|
||||
+ idle_total_jiffies = jiffies - idle_last_jiffies;
|
||||
+ idle_time += jiffies_to_msecs(
|
||||
+ idle_total_jiffies) / 1000;
|
||||
+ }
|
||||
+
|
||||
+ ret = sdhci_runtime_resume_host(host, 0);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+static const struct dev_pm_ops dwcmshc_pmops = {
|
||||
+ SET_SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume)
|
||||
+ SET_RUNTIME_PM_OPS(dwcmshc_runtime_suspend,
|
||||
+ dwcmshc_runtime_resume, NULL)
|
||||
+};
|
||||
|
||||
static struct platform_driver sdhci_dwcmshc_driver = {
|
||||
.driver = {
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 422290c8c36a7a92a64fecea45f431794dc99be6 Mon Sep 17 00:00:00 2001
|
||||
From 8c4980bc00f7be2d1172f047e148ecb07c43d955 Mon Sep 17 00:00:00 2001
|
||||
From: David Thompson <davthompson@nvidia.com>
|
||||
Date: Thu, 14 Jul 2022 17:47:18 -0400
|
||||
Subject: [PATCH backport 5.10 33/63] UBUNTU: SAUCE: mlxbf_gige: add ethtool
|
||||
Subject: [PATCH backport 6.1.42 69/85] UBUNTU: SAUCE: mlxbf_gige: add ethtool
|
||||
mlxbf_gige_set_ringparam
|
||||
|
||||
This patch adds the "set_ringparam" callback, to be used by
|
||||
@ -14,19 +14,21 @@ Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
|
||||
---
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c | 38 +++++++++++++++++++
|
||||
1 file changed, 38 insertions(+)
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c | 40 +++++++++++++++++++
|
||||
1 file changed, 40 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
|
||||
index af46b0cd7..257724323 100644
|
||||
index 41ebef25a930..4becb39b5664 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
|
||||
@@ -42,6 +42,43 @@ static void mlxbf_gige_get_ringparam(struct net_device *netdev,
|
||||
@@ -45,6 +45,45 @@ mlxbf_gige_get_ringparam(struct net_device *netdev,
|
||||
ering->tx_pending = priv->tx_q_entries;
|
||||
}
|
||||
|
||||
+static int mlxbf_gige_set_ringparam(struct net_device *netdev,
|
||||
+ struct ethtool_ringparam *ering)
|
||||
+ struct ethtool_ringparam *ering,
|
||||
+ struct kernel_ethtool_ringparam *kernel_ring,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ const struct net_device_ops *ops = netdev->netdev_ops;
|
||||
+ struct mlxbf_gige *priv = netdev_priv(netdev);
|
||||
@ -65,7 +67,7 @@ index af46b0cd7..257724323 100644
|
||||
static const struct {
|
||||
const char string[ETH_GSTRING_LEN];
|
||||
} mlxbf_gige_ethtool_stats_keys[] = {
|
||||
@@ -124,6 +161,7 @@ static void mlxbf_gige_get_pauseparam(struct net_device *netdev,
|
||||
@@ -127,6 +166,7 @@ static void mlxbf_gige_get_pauseparam(struct net_device *netdev,
|
||||
const struct ethtool_ops mlxbf_gige_ethtool_ops = {
|
||||
.get_link = ethtool_op_get_link,
|
||||
.get_ringparam = mlxbf_gige_get_ringparam,
|
@ -1,7 +1,7 @@
|
||||
From 30e4a53201f1f1cd9ca90057cd8f191c93fdab15 Mon Sep 17 00:00:00 2001
|
||||
From 8864f5ec2e1c0e1271a202859325900bd6727139 Mon Sep 17 00:00:00 2001
|
||||
From: David Thompson <davthompson@nvidia.com>
|
||||
Date: Wed, 20 Jul 2022 17:50:36 -0400
|
||||
Subject: [PATCH backport 5.10 34/63] UBUNTU: SAUCE: Fix OOB handling RX
|
||||
Subject: [PATCH backport 6.1.42 70/85] UBUNTU: SAUCE: Fix OOB handling RX
|
||||
packets in heavy traffic
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/1982424
|
||||
@ -59,10 +59,10 @@ Signed-off-by: Ike Panhc <ike.pan@canonical.com>
|
||||
1 file changed, 11 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
|
||||
index afa3b92a6..96230763c 100644
|
||||
index 0d5a41a2ae01..dc05ab5b042a 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
|
||||
@@ -266,6 +266,9 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
|
||||
@@ -267,6 +267,9 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
|
||||
priv->stats.rx_truncate_errors++;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ index afa3b92a6..96230763c 100644
|
||||
/* Let hardware know we've replenished one buffer */
|
||||
rx_pi++;
|
||||
|
||||
@@ -278,8 +281,6 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
|
||||
@@ -279,8 +282,6 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
|
||||
rx_pi_rem = rx_pi % priv->rx_q_entries;
|
||||
if (rx_pi_rem == 0)
|
||||
priv->valid_polarity ^= 1;
|
||||
@ -81,7 +81,7 @@ index afa3b92a6..96230763c 100644
|
||||
|
||||
if (skb)
|
||||
netif_receive_skb(skb);
|
||||
@@ -299,6 +300,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget)
|
||||
@@ -300,6 +301,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget)
|
||||
|
||||
mlxbf_gige_handle_tx_complete(priv);
|
||||
|
||||
@ -92,7 +92,7 @@ index afa3b92a6..96230763c 100644
|
||||
do {
|
||||
remaining_pkts = mlxbf_gige_rx_packet(priv, &work_done);
|
||||
} while (remaining_pkts && work_done < budget);
|
||||
@@ -314,6 +319,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget)
|
||||
@@ -315,6 +320,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget)
|
||||
data = readq(priv->base + MLXBF_GIGE_INT_MASK);
|
||||
data &= ~MLXBF_GIGE_INT_MASK_RX_RECEIVE_PACKET;
|
||||
writeq(data, priv->base + MLXBF_GIGE_INT_MASK);
|
@ -0,0 +1,85 @@
|
||||
From 7a9c30f4e3f19eb533acce3d3c63de87d18bac1d Mon Sep 17 00:00:00 2001
|
||||
From: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Date: Tue, 28 Feb 2023 18:03:12 -0500
|
||||
Subject: [PATCH backport 6.1.42 71/85] UBUNTU: SAUCE: mlxbf-gige: Fix
|
||||
intermittent no ip issue
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2008833
|
||||
|
||||
During the reboot test, the OOB might not get an ip assigned.
|
||||
This is due to a race condition between phy_startcall and the
|
||||
RX DMA being enabled and depends on the amount of background
|
||||
traffic received by the OOB. Enable the RX DMA after teh phy
|
||||
is started.
|
||||
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 14 +++++++-------
|
||||
.../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 6 +++---
|
||||
2 files changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
index 2292d63a279c..eafc0d3313fd 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
@@ -147,14 +147,14 @@ static int mlxbf_gige_open(struct net_device *netdev)
|
||||
*/
|
||||
priv->valid_polarity = 0;
|
||||
|
||||
- err = mlxbf_gige_rx_init(priv);
|
||||
+ phy_start(phydev);
|
||||
+
|
||||
+ err = mlxbf_gige_tx_init(priv);
|
||||
if (err)
|
||||
goto free_irqs;
|
||||
- err = mlxbf_gige_tx_init(priv);
|
||||
+ err = mlxbf_gige_rx_init(priv);
|
||||
if (err)
|
||||
- goto rx_deinit;
|
||||
-
|
||||
- phy_start(phydev);
|
||||
+ goto tx_deinit;
|
||||
|
||||
netif_napi_add(netdev, &priv->napi, mlxbf_gige_poll);
|
||||
napi_enable(&priv->napi);
|
||||
@@ -176,8 +176,8 @@ static int mlxbf_gige_open(struct net_device *netdev)
|
||||
|
||||
return 0;
|
||||
|
||||
-rx_deinit:
|
||||
- mlxbf_gige_rx_deinit(priv);
|
||||
+tx_deinit:
|
||||
+ mlxbf_gige_tx_deinit(priv);
|
||||
|
||||
free_irqs:
|
||||
mlxbf_gige_free_irqs(priv);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
|
||||
index dc05ab5b042a..b9cf0a3c8b0f 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
|
||||
@@ -142,6 +142,9 @@ int mlxbf_gige_rx_init(struct mlxbf_gige *priv)
|
||||
writeq(MLXBF_GIGE_RX_MAC_FILTER_COUNT_PASS_EN,
|
||||
priv->base + MLXBF_GIGE_RX_MAC_FILTER_COUNT_PASS);
|
||||
|
||||
+ writeq(ilog2(priv->rx_q_entries),
|
||||
+ priv->base + MLXBF_GIGE_RX_WQE_SIZE_LOG2);
|
||||
+
|
||||
/* Clear MLXBF_GIGE_INT_MASK 'receive pkt' bit to
|
||||
* indicate readiness to receive interrupts
|
||||
*/
|
||||
@@ -154,9 +157,6 @@ int mlxbf_gige_rx_init(struct mlxbf_gige *priv)
|
||||
data |= MLXBF_GIGE_RX_DMA_EN;
|
||||
writeq(data, priv->base + MLXBF_GIGE_RX_DMA);
|
||||
|
||||
- writeq(ilog2(priv->rx_q_entries),
|
||||
- priv->base + MLXBF_GIGE_RX_WQE_SIZE_LOG2);
|
||||
-
|
||||
return 0;
|
||||
|
||||
free_wqe_and_skb:
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,10 +1,10 @@
|
||||
From 6073dbcdbce9c9f8e63790217b17913efb5174c5 Mon Sep 17 00:00:00 2001
|
||||
From 0d3a669288079d5a197b95d1a4615301e61fb039 Mon Sep 17 00:00:00 2001
|
||||
From: David Thompson <davthompson@nvidia.com>
|
||||
Date: Tue, 25 Oct 2022 16:25:19 -0400
|
||||
Subject: [PATCH backport 5.10 40/63] UBUNTU: SAUCE: mlxbf_gige: add MDIO
|
||||
support for BlueField-3
|
||||
Date: Thu, 12 Jan 2023 15:26:06 -0500
|
||||
Subject: [PATCH backport 6.1.42 72/85] mlxbf_gige: add MDIO support for
|
||||
BlueField-3
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/1995148
|
||||
BugLink: https://bugs.launchpad.net/bugs/2012649
|
||||
|
||||
This patch adds initial MDIO support for the BlueField-3
|
||||
SoC. Separate header files for the BlueField-2 and the
|
||||
@ -18,19 +18,25 @@ a mlxbf_gige_mdio_gw_t struct was created for this purpose.
|
||||
|
||||
Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
(cherry picked from commit 2321d69f92aa7e6aa2cc98e7a8e005566943922f)
|
||||
Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h | 19 ++
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_main.c | 2 +
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_mdio.c | 172 +++++++++++++-----
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_mdio.c | 178 +++++++++++++-----
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h | 53 ++++++
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h | 54 ++++++
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_regs.h | 1 +
|
||||
6 files changed, 251 insertions(+), 50 deletions(-)
|
||||
6 files changed, 256 insertions(+), 51 deletions(-)
|
||||
create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h
|
||||
create mode 100644 drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
|
||||
index 5a1027b07..421a0b1b7 100644
|
||||
index 5a1027b07215..421a0b1b766c 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
|
||||
@@ -67,6 +67,23 @@ struct mlxbf_gige_stats {
|
||||
@ -67,10 +73,10 @@ index 5a1027b07..421a0b1b7 100644
|
||||
|
||||
/* Rx Work Queue Element definitions */
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
index 66a50e35f..49695f3e9 100644
|
||||
index eafc0d3313fd..a3bd14d5dbff 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
@@ -351,6 +351,8 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
|
||||
@@ -315,6 +315,8 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
|
||||
@ -80,7 +86,7 @@ index 66a50e35f..49695f3e9 100644
|
||||
err = mlxbf_gige_mdio_probe(pdev, priv);
|
||||
if (err)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c
|
||||
index daa31ddb2..4ee3df30c 100644
|
||||
index aa780b1614a3..4ee3df30c402 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio.c
|
||||
@@ -23,9 +23,75 @@
|
||||
@ -321,17 +327,23 @@ index daa31ddb2..4ee3df30c 100644
|
||||
}
|
||||
|
||||
int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
|
||||
@@ -230,6 +297,9 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
|
||||
@@ -230,7 +297,14 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
|
||||
struct resource *res;
|
||||
int ret;
|
||||
|
||||
- priv->mdio_io = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MDIO9);
|
||||
+ if (priv->hw_version > MLXBF_GIGE_VERSION_BF3)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_MDIO9);
|
||||
if (!res)
|
||||
return -ENODEV;
|
||||
@@ -246,13 +316,15 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
|
||||
+ res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_MDIO9);
|
||||
+ if (!res)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ priv->mdio_io = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(priv->mdio_io))
|
||||
return PTR_ERR(priv->mdio_io);
|
||||
|
||||
@@ -242,13 +316,15 @@ int mlxbf_gige_mdio_probe(struct platform_device *pdev, struct mlxbf_gige *priv)
|
||||
/* For backward compatibility with older ACPI tables, also keep
|
||||
* CLK resource internal to the driver.
|
||||
*/
|
||||
@ -350,7 +362,7 @@ index daa31ddb2..4ee3df30c 100644
|
||||
priv->mdiobus = devm_mdiobus_alloc(dev);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h
|
||||
new file mode 100644
|
||||
index 000000000..7f1ff0ac7
|
||||
index 000000000000..7f1ff0ac7699
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf2.h
|
||||
@@ -0,0 +1,53 @@
|
||||
@ -409,7 +421,7 @@ index 000000000..7f1ff0ac7
|
||||
+#endif /* __MLXBF_GIGE_MDIO_BF2_H__ */
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h
|
||||
new file mode 100644
|
||||
index 000000000..9dd9144b9
|
||||
index 000000000000..9dd9144b9173
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_mdio_bf3.h
|
||||
@@ -0,0 +1,54 @@
|
||||
@ -468,7 +480,7 @@ index 000000000..9dd9144b9
|
||||
+
|
||||
+#endif /* __MLXBF_GIGE_MDIO_BF3_H__ */
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
|
||||
index 7be3a7939..8d52dbef4 100644
|
||||
index 7be3a793984d..8d52dbef4adf 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
|
||||
@@ -10,6 +10,7 @@
|
@ -1,10 +1,10 @@
|
||||
From b9f0d98629a7720d2b6e34aed529f943cf421c04 Mon Sep 17 00:00:00 2001
|
||||
From 4c1187581e9c7dc8cf354278c3257d8542209269 Mon Sep 17 00:00:00 2001
|
||||
From: David Thompson <davthompson@nvidia.com>
|
||||
Date: Tue, 25 Oct 2022 17:19:27 -0400
|
||||
Subject: [PATCH backport 5.10 41/63] UBUNTU: SAUCE: mlxbf_gige: support
|
||||
10M/100M/1G speeds on BlueField-3
|
||||
Date: Thu, 12 Jan 2023 15:26:07 -0500
|
||||
Subject: [PATCH backport 6.1.42 73/85] mlxbf_gige: support 10M/100M/1G speeds
|
||||
on BlueField-3
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/1995148
|
||||
BugLink: https://bugs.launchpad.net/bugs/2012649
|
||||
|
||||
The BlueField-3 OOB interface supports 10Mbps, 100Mbps, and 1Gbps speeds.
|
||||
The external PHY is responsible for autonegotiating the speed with the
|
||||
@ -18,14 +18,21 @@ This patch does two things:
|
||||
|
||||
Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
(cherry picked from commit 20d03d4d9437771a9b6d38d4a6027a70d78d9865)
|
||||
Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h | 8 ++
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_main.c | 109 +++++++++++++++---
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_main.c | 105 +++++++++++++++---
|
||||
.../mellanox/mlxbf_gige/mlxbf_gige_regs.h | 21 ++++
|
||||
3 files changed, 123 insertions(+), 15 deletions(-)
|
||||
3 files changed, 119 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
|
||||
index 421a0b1b7..a453b9cd9 100644
|
||||
index 421a0b1b766c..a453b9cd9033 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
|
||||
@@ -14,6 +14,7 @@
|
||||
@ -58,10 +65,10 @@ index 421a0b1b7..a453b9cd9 100644
|
||||
|
||||
/* Rx Work Queue Element definitions */
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
index 49695f3e9..106b83bd6 100644
|
||||
index a3bd14d5dbff..0af086703bcd 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
@@ -270,13 +270,103 @@ static const struct net_device_ops mlxbf_gige_netdev_ops = {
|
||||
@@ -263,13 +263,99 @@ static const struct net_device_ops mlxbf_gige_netdev_ops = {
|
||||
.ndo_get_stats64 = mlxbf_gige_get_stats64,
|
||||
};
|
||||
|
||||
@ -77,12 +84,10 @@ index 49695f3e9..106b83bd6 100644
|
||||
+{
|
||||
+ struct mlxbf_gige *priv = netdev_priv(netdev);
|
||||
+ struct phy_device *phydev = netdev->phydev;
|
||||
+ unsigned long flags;
|
||||
+ u8 sgmii_mode;
|
||||
+ u16 ipg_size;
|
||||
+ u32 val;
|
||||
+
|
||||
+ spin_lock_irqsave(&priv->lock, flags);
|
||||
+ if (phydev->link && phydev->speed != priv->prev_speed) {
|
||||
+ switch (phydev->speed) {
|
||||
+ case 1000:
|
||||
@ -98,7 +103,6 @@ index 49695f3e9..106b83bd6 100644
|
||||
+ sgmii_mode = MLXBF_GIGE_10M_SGMII_MODE;
|
||||
+ break;
|
||||
+ default:
|
||||
+ spin_unlock_irqrestore(&priv->lock, flags);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@ -115,7 +119,6 @@ index 49695f3e9..106b83bd6 100644
|
||||
+
|
||||
+ priv->prev_speed = phydev->speed;
|
||||
+ }
|
||||
+ spin_unlock_irqrestore(&priv->lock, flags);
|
||||
+
|
||||
+ phy_print_status(phydev);
|
||||
+}
|
||||
@ -166,7 +169,7 @@ index 49695f3e9..106b83bd6 100644
|
||||
static int mlxbf_gige_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct phy_device *phydev;
|
||||
@@ -395,25 +485,14 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
|
||||
@@ -359,25 +445,14 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
|
||||
phydev->irq = phy_irq;
|
||||
|
||||
err = phy_connect_direct(netdev, phydev,
|
||||
@ -196,7 +199,7 @@ index 49695f3e9..106b83bd6 100644
|
||||
/* Display information about attached PHY device */
|
||||
phy_attached_info(phydev);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
|
||||
index 8d52dbef4..cd0973229 100644
|
||||
index 8d52dbef4adf..cd0973229c9b 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_regs.h
|
||||
@@ -8,6 +8,8 @@
|
@ -0,0 +1,39 @@
|
||||
From 58d63cc90771fb493f5cf735a05eb95331041be3 Mon Sep 17 00:00:00 2001
|
||||
From: David Thompson <davthompson@nvidia.com>
|
||||
Date: Thu, 12 Jan 2023 15:26:08 -0500
|
||||
Subject: [PATCH backport 6.1.42 74/85] mlxbf_gige: add "set_link_ksettings"
|
||||
ethtool callback
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2012649
|
||||
|
||||
This patch extends the "ethtool_ops" data structure to
|
||||
include the "set_link_ksettings" callback. This change
|
||||
enables configuration of the various interface speeds
|
||||
that the BlueField-3 supports (10Mbps, 100Mbps, and 1Gbps).
|
||||
|
||||
Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
(cherry picked from commit cedd97737a1f302b3d0493d7054a35e0c5997b99)
|
||||
Signed-off-by: David Thompson <davthompson@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
|
||||
index 4becb39b5664..8c5c81981ce7 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
|
||||
@@ -175,4 +175,5 @@ const struct ethtool_ops mlxbf_gige_ethtool_ops = {
|
||||
.nway_reset = phy_ethtool_nway_reset,
|
||||
.get_pauseparam = mlxbf_gige_get_pauseparam,
|
||||
.get_link_ksettings = phy_ethtool_get_link_ksettings,
|
||||
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
|
||||
};
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,48 @@
|
||||
From 7124b7b040a0cda35c09be51ac40e8e52026ec2d Mon Sep 17 00:00:00 2001
|
||||
From: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Date: Fri, 2 Jun 2023 13:04:25 -0400
|
||||
Subject: [PATCH backport 6.1.42 75/85] UBUNTU: SAUCE: mlxbf-gige: Fix kernel
|
||||
panic at shutdown
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2022370
|
||||
|
||||
We occasionally see a race condition (once every 350 reboots) where napi is still
|
||||
running (mlxbf_gige_poll) while a shutdown has been initiated through "reboot".
|
||||
Since mlxbf_gige_poll is still running, it tries to access a NULL pointer and as
|
||||
a result causes a kernel panic.
|
||||
|
||||
The fix is to explicitly disable napi and dequeue it during shutdown.
|
||||
mlxbf_gige_remove already calls:
|
||||
unregister_netdev->unregister_netdevice->unregister_netdev_queue->
|
||||
rollback_registered->rollback_registered_many->dev_close_many->
|
||||
__dev_close_many->ndo_stop->mlxbf_gige_stop which stops napi
|
||||
|
||||
So use mlxbf_gige_remove in place of the existing shutdown logic.
|
||||
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 5 +----
|
||||
1 file changed, 1 insertion(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
index 0af086703bcd..fe35b5a24219 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
|
||||
@@ -485,10 +485,7 @@ static int mlxbf_gige_remove(struct platform_device *pdev)
|
||||
|
||||
static void mlxbf_gige_shutdown(struct platform_device *pdev)
|
||||
{
|
||||
- struct mlxbf_gige *priv = platform_get_drvdata(pdev);
|
||||
-
|
||||
- writeq(0, priv->base + MLXBF_GIGE_INT_EN);
|
||||
- mlxbf_gige_clean_port(priv);
|
||||
+ mlxbf_gige_remove(pdev);
|
||||
}
|
||||
|
||||
static const struct acpi_device_id __maybe_unused mlxbf_gige_acpi_match[] = {
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,8 +1,8 @@
|
||||
From 988b360c98ef157e37818f5f7db322c129d3dfb9 Mon Sep 17 00:00:00 2001
|
||||
From 4651b1520abcc8744493d41e1ebc1dbee3035904 Mon Sep 17 00:00:00 2001
|
||||
From: Shravan Kumar Ramani <shravankr@nvidia.com>
|
||||
Date: Wed, 6 Jul 2022 07:37:22 -0400
|
||||
Subject: [PATCH backport 5.10 12/63] UBUNTU: SAUCE: platform/mellanox: Updates
|
||||
to mlxbf-bootctl
|
||||
Subject: [PATCH backport 6.1.42 76/85] UBUNTU: SAUCE: platform/mellanox:
|
||||
Updates to mlxbf-bootctl
|
||||
|
||||
BugLink: https://launchpad.net/bugs/1980832
|
||||
|
||||
@ -18,7 +18,7 @@ Signed-off-by: Ike Panhc <ike.pan@canonical.com>
|
||||
2 files changed, 1268 insertions(+), 230 deletions(-)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
index 1c7a288b5..2302e1e09 100644
|
||||
index 1c7a288b59a5..2302e1e09c7e 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
@@ -1,51 +1,129 @@
|
||||
@ -1559,7 +1559,7 @@ index 1c7a288b5..2302e1e09 100644
|
||||
+MODULE_AUTHOR("Shravan Kumar Ramani <shravankr@nvidia.com>");
|
||||
+MODULE_LICENSE("Dual BSD/GPL");
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
index 148fdb43b..3e9dda829 100644
|
||||
index 148fdb43b435..3e9dda829d6d 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
@@ -1,11 +1,22 @@
|
@ -1,7 +1,7 @@
|
||||
From 02aa895d298c83e5e6e0f6e64f04895e50235a33 Mon Sep 17 00:00:00 2001
|
||||
From 61618188dadb1cc9b6708916e0e7a1c2e31d469d Mon Sep 17 00:00:00 2001
|
||||
From: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Date: Mon, 31 Oct 2022 12:18:52 -0400
|
||||
Subject: [PATCH backport 5.10 60/63] UBUNTU: SAUCE: mlx-bootctl: support icm
|
||||
Subject: [PATCH backport 6.1.42 77/85] UBUNTU: SAUCE: mlx-bootctl: support icm
|
||||
carveout eeprom region read/write
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/1995296
|
||||
@ -22,7 +22,7 @@ Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.co
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
index 2302e1e09..e8877a19d 100644
|
||||
index 2302e1e09c7e..e8877a19dda9 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
@@ -104,6 +104,7 @@ enum {
|
||||
@ -94,7 +94,7 @@ index 2302e1e09..e8877a19d 100644
|
||||
};
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
index 3e9dda829..c70204770 100644
|
||||
index 3e9dda829d6d..c70204770af3 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
@@ -95,6 +95,15 @@
|
@ -0,0 +1,93 @@
|
||||
From 63f46d5beb56293f64ebb39f94a005acbe381f25 Mon Sep 17 00:00:00 2001
|
||||
From: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Date: Thu, 30 Mar 2023 14:42:33 -0400
|
||||
Subject: [PATCH backport 6.1.42 78/85] UBUNTU: SAUCE: mlxbf-bootctl: support
|
||||
SMC call for setting ARM boot state
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2013383
|
||||
|
||||
Add a new SMC call which allows setting the ARM boot progress state to "OS is up".
|
||||
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/mlxbf-bootctl.c | 23 +++++++++++++++++++++++
|
||||
drivers/platform/mellanox/mlxbf-bootctl.h | 5 +++++
|
||||
2 files changed, 28 insertions(+)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
index e8877a19dda9..a68bf5b27013 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
@@ -105,6 +105,7 @@ enum {
|
||||
/* This mutex is used to serialize MFG write and lock operations. */
|
||||
static DEFINE_MUTEX(mfg_ops_lock);
|
||||
static DEFINE_MUTEX(icm_ops_lock);
|
||||
+static DEFINE_MUTEX(os_up_lock);
|
||||
|
||||
#define MLNX_MFG_OOB_MAC_LEN ETH_ALEN
|
||||
#define MLNX_MFG_OPN_VAL_LEN 24
|
||||
@@ -747,6 +748,26 @@ static ssize_t mfg_lock_store(struct device_driver *drv, const char *buf,
|
||||
return count;
|
||||
}
|
||||
|
||||
+static ssize_t os_up_store(struct device_driver *drv, const char *buf,
|
||||
+ size_t count)
|
||||
+{
|
||||
+ unsigned long val;
|
||||
+ int err;
|
||||
+
|
||||
+ err = kstrtoul(buf, 10, &val);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ if (val != 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ mutex_lock(&os_up_lock);
|
||||
+ smc_call0(MLNX_HANDLE_OS_UP);
|
||||
+ mutex_unlock(&os_up_lock);
|
||||
+
|
||||
+ return count;
|
||||
+}
|
||||
+
|
||||
/* Log header format. */
|
||||
#define RSH_LOG_TYPE_SHIFT 56
|
||||
#define RSH_LOG_LEN_SHIFT 48
|
||||
@@ -1209,6 +1230,7 @@ static DRIVER_ATTR_RW(rev);
|
||||
static DRIVER_ATTR_WO(mfg_lock);
|
||||
static DRIVER_ATTR_RW(rsh_log);
|
||||
static DRIVER_ATTR_RW(large_icm);
|
||||
+static DRIVER_ATTR_WO(os_up);
|
||||
|
||||
static struct attribute *mbc_dev_attrs[] = {
|
||||
&driver_attr_post_reset_wdog.attr,
|
||||
@@ -1227,6 +1249,7 @@ static struct attribute *mbc_dev_attrs[] = {
|
||||
&driver_attr_mfg_lock.attr,
|
||||
&driver_attr_rsh_log.attr,
|
||||
&driver_attr_large_icm.attr,
|
||||
+ &driver_attr_os_up.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
index c70204770af3..dc73f7e88914 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.h
|
||||
@@ -102,6 +102,11 @@
|
||||
#define MLNX_HANDLE_SET_ICM_INFO 0x82000012
|
||||
#define MLNX_HANDLE_GET_ICM_INFO 0x82000013
|
||||
|
||||
+/*
|
||||
+ * SMC function ID to set the ARM boot state to up
|
||||
+ */
|
||||
+#define MLNX_HANDLE_OS_UP 0x82000014
|
||||
+
|
||||
#define MAX_ICM_BUFFER_SIZE 10
|
||||
|
||||
/* SMC function IDs for SiP Service queries */
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,69 +1,94 @@
|
||||
From 1193879b92e665c100056085385ffdb4ab2715cb Mon Sep 17 00:00:00 2001
|
||||
From 2734b1f7ca9acafd126706be280844d962e1b368 Mon Sep 17 00:00:00 2001
|
||||
From: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Date: Fri, 13 Jan 2023 15:21:02 -0500
|
||||
Subject: [PATCH backport 5.10 2/6] mlxbf-ptm: power and thermal management
|
||||
debugfs driver
|
||||
Date: Mon, 16 Jan 2023 11:39:34 -0500
|
||||
Subject: [PATCH backport 6.1.42 79/85] UBUNTU: SAUCE: mlxbf-ptm: power and
|
||||
thermal management debugfs driver
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2002852
|
||||
|
||||
mlxbf-ptm driver implements debugfs interface for Bluefield
|
||||
devices power and thermal management. It provides some parameters
|
||||
that can be monitored by system software.
|
||||
|
||||
Change-Id: I241e1406962548cef9b33c4b3dea925e675c3c88
|
||||
Signed-off-by: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/Kconfig | 10 ++
|
||||
drivers/platform/mellanox/Makefile | 1 +
|
||||
drivers/platform/mellanox/mlxbf-ptm.c | 195 ++++++++++++++++++++++++++
|
||||
3 files changed, 206 insertions(+)
|
||||
drivers/platform/mellanox/mlxbf-ptm.c | 216 ++++++++++++++++++++++++++
|
||||
3 files changed, 227 insertions(+)
|
||||
create mode 100644 drivers/platform/mellanox/mlxbf-ptm.c
|
||||
|
||||
diff --git a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig
|
||||
index a5231c23a..48bd61f61 100644
|
||||
index 70b628834b4f..75efd345b22e 100644
|
||||
--- a/drivers/platform/mellanox/Kconfig
|
||||
+++ b/drivers/platform/mellanox/Kconfig
|
||||
@@ -106,6 +106,16 @@ config MLXBF_TRIO
|
||||
This driver supports the TRIO PCIe root complex interface on
|
||||
Mellanox BlueField SoCs.
|
||||
@@ -90,6 +90,16 @@ config MLXBF_PMC
|
||||
to performance monitoring counters within various blocks in the
|
||||
Mellanox BlueField SoC via a sysfs interface.
|
||||
|
||||
+config MLXBF_PTM
|
||||
+ tristate "BlueField Power and Thermal Management debugfs interface"
|
||||
+ depends on ARM64
|
||||
+ depends on DEBUG_FS
|
||||
+ help
|
||||
+ If you say yes to this option, support will be added for the
|
||||
+ If you say yes to this option, support will added for the
|
||||
+ mlxbf-ptm driver. This driver provides debugfs interface
|
||||
+ to userspace with information related to power and thermal
|
||||
+ management of the Bluefield device.
|
||||
+
|
||||
source "drivers/platform/mellanox/mlxbf_pka/Kconfig"
|
||||
|
||||
config NVSW_SN2201
|
||||
tristate "Nvidia SN2201 platform driver support"
|
||||
depends on HWMON
|
||||
diff --git a/drivers/platform/mellanox/Makefile b/drivers/platform/mellanox/Makefile
|
||||
index 7c6393ebe..6aa0ab157 100644
|
||||
index ba56485cbe8c..d7f4d940c505 100644
|
||||
--- a/drivers/platform/mellanox/Makefile
|
||||
+++ b/drivers/platform/mellanox/Makefile
|
||||
@@ -9,6 +9,7 @@ obj-$(CONFIG_MLXBF_PMC) += mlxbf-pmc.o
|
||||
@@ -7,6 +7,7 @@ obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o
|
||||
obj-$(CONFIG_MLXBF_BOOTCTL) += mlxbf-bootctl.o
|
||||
obj-$(CONFIG_MLXBF_PMC) += mlxbf-pmc.o
|
||||
obj-$(CONFIG_MLXBF_TMFIFO) += mlxbf-tmfifo.o
|
||||
obj-$(CONFIG_MLXBF_TRIO) += mlx-trio.o
|
||||
obj-$(CONFIG_MLXBF_LIVEFISH) += mlxbf-livefish.o
|
||||
+obj-$(CONFIG_MLXBF_PTM) += mlxbf-ptm.o
|
||||
obj-$(CONFIG_MLXREG_HOTPLUG) += mlxreg-hotplug.o
|
||||
obj-$(CONFIG_MLXREG_IO) += mlxreg-io.o
|
||||
obj-$(CONFIG_MLXREG_LC) += mlxreg-lc.o
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
new file mode 100644
|
||||
index 000000000..307ba1f33
|
||||
index 000000000000..3692018b9d60
|
||||
--- /dev/null
|
||||
+++ b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
@@ -0,0 +1,195 @@
|
||||
@@ -0,0 +1,216 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
|
||||
+/*
|
||||
+ * Copyright (C) 2023 NVIDIA Corporation & Affiliates.
|
||||
+ *
|
||||
+ * Nvidia Bluefield power and thermal debugfs driver
|
||||
+ * This driver provides a debugfs interface for systems management
|
||||
+ * software to monitor power and thermal actions.
|
||||
+ *
|
||||
+ * Copyright (C) 2023 NVIDIA Corporation. All rights reserved.
|
||||
+ * This Software is licensed under one of the following licenses:
|
||||
+ *
|
||||
+ * 1) under the terms of the "Common Public License 1.0" a copy of which is
|
||||
+ * available from the Open Source Initiative, see
|
||||
+ * http://www.opensource.org/licenses/cpl.php.
|
||||
+ *
|
||||
+ * 2) under the terms of the "The BSD License" a copy of which is
|
||||
+ * available from the Open Source Initiative, see
|
||||
+ * http://www.opensource.org/licenses/bsd-license.php.
|
||||
+ *
|
||||
+ * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
|
||||
+ * copy of which is available from the Open Source Initiative, see
|
||||
+ * http://www.opensource.org/licenses/gpl-license.php.
|
||||
+ *
|
||||
+ * Licensee has the right to choose one of the above licenses.
|
||||
+ *
|
||||
+ * Redistributions of source code must retain the above copyright
|
||||
+ * notice and one of the license notices.
|
||||
+ *
|
||||
+ * Redistributions in binary form must reproduce both the above copyright
|
||||
+ * notice, one of the license notices in the documentation
|
||||
+ * and/or other materials provided with the distribution.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
@ -0,0 +1,60 @@
|
||||
From d6703416953dd1c3fe6e84a76c6d85a73fcbdc4b Mon Sep 17 00:00:00 2001
|
||||
From: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Date: Wed, 22 Mar 2023 11:39:54 -0400
|
||||
Subject: [PATCH backport 6.1.42 80/85] UBUNTU: SAUCE: mlxbf-ptm: update
|
||||
license
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2011738
|
||||
|
||||
Update license
|
||||
|
||||
Signed-off-by: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/mlxbf-ptm.c | 26 ++------------------------
|
||||
1 file changed, 2 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
index 3692018b9d60..79c3e2902070 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
@@ -1,32 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
|
||||
/*
|
||||
+ * Copyright (C) 2023 NVIDIA Corporation & Affiliates.
|
||||
+ *
|
||||
* Nvidia Bluefield power and thermal debugfs driver
|
||||
* This driver provides a debugfs interface for systems management
|
||||
* software to monitor power and thermal actions.
|
||||
- *
|
||||
- * Copyright (C) 2023 NVIDIA Corporation. All rights reserved.
|
||||
- * This Software is licensed under one of the following licenses:
|
||||
- *
|
||||
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
|
||||
- * available from the Open Source Initiative, see
|
||||
- * http://www.opensource.org/licenses/cpl.php.
|
||||
- *
|
||||
- * 2) under the terms of the "The BSD License" a copy of which is
|
||||
- * available from the Open Source Initiative, see
|
||||
- * http://www.opensource.org/licenses/bsd-license.php.
|
||||
- *
|
||||
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
|
||||
- * copy of which is available from the Open Source Initiative, see
|
||||
- * http://www.opensource.org/licenses/gpl-license.php.
|
||||
- *
|
||||
- * Licensee has the right to choose one of the above licenses.
|
||||
- *
|
||||
- * Redistributions of source code must retain the above copyright
|
||||
- * notice and one of the license notices.
|
||||
- *
|
||||
- * Redistributions in binary form must reproduce both the above copyright
|
||||
- * notice, one of the license notices in the documentation
|
||||
- * and/or other materials provided with the distribution.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,64 @@
|
||||
From c3c93684288a230ebf63ca8e07cc420db07d5f89 Mon Sep 17 00:00:00 2001
|
||||
From: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Date: Wed, 22 Mar 2023 11:39:55 -0400
|
||||
Subject: [PATCH backport 6.1.42 81/85] UBUNTU: SAUCE: mlxbf-ptm: use 0444
|
||||
instead of S_IRUGO
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2011738
|
||||
|
||||
As recommended by checkscript, change S_IRUGO to 0444
|
||||
|
||||
Signed-off-by: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/mlxbf-ptm.c | 22 +++++++++++-----------
|
||||
1 file changed, 11 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
index 79c3e2902070..aeb68dc42e32 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
@@ -154,27 +154,27 @@ static int __init mlxbf_ptm_init(void)
|
||||
monitors = debugfs_create_dir("monitors", ptm_root);
|
||||
status = debugfs_create_dir("status", monitors);
|
||||
|
||||
- debugfs_create_file("vr0_power", S_IRUGO, status, NULL,
|
||||
+ debugfs_create_file("vr0_power", 0444, status, NULL,
|
||||
&vr0_power_fops);
|
||||
- debugfs_create_file("vr1_power", S_IRUGO, status, NULL,
|
||||
+ debugfs_create_file("vr1_power", 0444, status, NULL,
|
||||
&vr1_power_fops);
|
||||
- debugfs_create_file("total_power", S_IRUGO, status, NULL,
|
||||
+ debugfs_create_file("total_power", 0444, status, NULL,
|
||||
&total_power_fops);
|
||||
- debugfs_create_file("ddr_temp", S_IRUGO, status,
|
||||
+ debugfs_create_file("ddr_temp", 0444, status,
|
||||
NULL, &ddr_thld_fops);
|
||||
- debugfs_create_file("core_temp", S_IRUGO, status,
|
||||
+ debugfs_create_file("core_temp", 0444, status,
|
||||
NULL, &core_temp_fops);
|
||||
- debugfs_create_file("power_throttling_event_count", S_IRUGO, status,
|
||||
+ debugfs_create_file("power_throttling_event_count", 0444, status,
|
||||
NULL, &pwr_evt_counter_fops);
|
||||
- debugfs_create_file("thermal_throttling_event_count", S_IRUGO, status,
|
||||
+ debugfs_create_file("thermal_throttling_event_count", 0444, status,
|
||||
NULL, &temp_evt_counter_fops);
|
||||
- debugfs_create_file("throttling_state", S_IRUGO, status,
|
||||
+ debugfs_create_file("throttling_state", 0444, status,
|
||||
NULL, &throttling_state_fops);
|
||||
- debugfs_create_file("power_throttling_state", S_IRUGO, status,
|
||||
+ debugfs_create_file("power_throttling_state", 0444, status,
|
||||
NULL, &pthrottling_state_fops);
|
||||
- debugfs_create_file("thermal_throttling_state", S_IRUGO, status,
|
||||
+ debugfs_create_file("thermal_throttling_state", 0444, status,
|
||||
NULL, &tthrottling_state_fops);
|
||||
- debugfs_create_file("error_state", S_IRUGO, status,
|
||||
+ debugfs_create_file("error_state", 0444, status,
|
||||
NULL, &error_status_fops);
|
||||
|
||||
return 0;
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,83 @@
|
||||
From 82305cf0e95a8c711cbcb9f74193c5a2fe62f6fa Mon Sep 17 00:00:00 2001
|
||||
From: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Date: Wed, 22 Mar 2023 11:39:56 -0400
|
||||
Subject: [PATCH backport 6.1.42 82/85] UBUNTU: SAUCE: mlxbf-ptm: add atx
|
||||
debugfs nodes
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2011738
|
||||
|
||||
Add additional debugfs nodes that provide ATX status and
|
||||
power profile data.
|
||||
|
||||
Signed-off-by: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/mlxbf-ptm.c | 36 +++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
index aeb68dc42e32..a2845aa57c5b 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
@@ -23,6 +23,9 @@
|
||||
#define MLNX_PTM_GET_MAX_TEMP 0x82000108
|
||||
#define MLNX_PTM_GET_PWR_EVT_CNT 0x82000109
|
||||
#define MLNX_PTM_GET_TEMP_EVT_CNT 0x8200010A
|
||||
+#define MLNX_PTM_GET_POWER_ENVELOPE 0x8200010B
|
||||
+#define MLNX_PTM_GET_ATX_PWR_STATE 0x8200010C
|
||||
+#define MLNX_PTM_GET_CUR_PPROFILE 0x8200010D
|
||||
|
||||
#define MLNX_POWER_ERROR 300
|
||||
|
||||
@@ -142,6 +145,33 @@ static int error_status_show(void *data, u64 *val)
|
||||
DEFINE_SIMPLE_ATTRIBUTE(error_status_fops,
|
||||
error_status_show, NULL, "%llu\n");
|
||||
|
||||
+static int power_envelope_show(void *data, u64 *val)
|
||||
+{
|
||||
+ *val = smc_call0(MLNX_PTM_GET_POWER_ENVELOPE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+DEFINE_SIMPLE_ATTRIBUTE(power_envelope_fops,
|
||||
+ power_envelope_show, NULL, "%llu\n");
|
||||
+
|
||||
+static int atx_status_show(void *data, u64 *val)
|
||||
+{
|
||||
+ *val = smc_call0(MLNX_PTM_GET_ATX_PWR_STATE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+DEFINE_SIMPLE_ATTRIBUTE(atx_status_fops,
|
||||
+ atx_status_show, NULL, "%lld\n");
|
||||
+
|
||||
+static int current_pprofile_show(void *data, u64 *val)
|
||||
+{
|
||||
+ *val = smc_call0(MLNX_PTM_GET_CUR_PPROFILE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+DEFINE_SIMPLE_ATTRIBUTE(current_pprofile_fops,
|
||||
+ current_pprofile_show, NULL, "%llu\n");
|
||||
+
|
||||
|
||||
static int __init mlxbf_ptm_init(void)
|
||||
{
|
||||
@@ -176,6 +206,12 @@ static int __init mlxbf_ptm_init(void)
|
||||
NULL, &tthrottling_state_fops);
|
||||
debugfs_create_file("error_state", 0444, status,
|
||||
NULL, &error_status_fops);
|
||||
+ debugfs_create_file("power_envelope", 0444, status,
|
||||
+ NULL, &power_envelope_fops);
|
||||
+ debugfs_create_file("atx_power_available", 0444, status,
|
||||
+ NULL, &atx_status_fops);
|
||||
+ debugfs_create_file("active_power_profile", 0444, status,
|
||||
+ NULL, ¤t_pprofile_fops);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,31 @@
|
||||
From efaf25dc1e11de91140b9010e743182bc763124c Mon Sep 17 00:00:00 2001
|
||||
From: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Date: Wed, 22 Mar 2023 11:39:57 -0400
|
||||
Subject: [PATCH backport 6.1.42 83/85] UBUNTU: SAUCE: mlxbf-ptm: update module
|
||||
version
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2011738
|
||||
|
||||
update module version
|
||||
|
||||
Signed-off-by: Jitendra Lanka <jlanka@nvidia.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/mlxbf-ptm.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
index a2845aa57c5b..eb4460cb058b 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-ptm.c
|
||||
@@ -227,4 +227,4 @@ module_exit(mlxbf_ptm_exit);
|
||||
MODULE_AUTHOR("Jitendra Lanka <jlanka@nvidia.com>");
|
||||
MODULE_DESCRIPTION("Nvidia Bluefield power and thermal debugfs driver");
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
-MODULE_VERSION("1.0");
|
||||
+MODULE_VERSION("1.1");
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,56 @@
|
||||
From 9c9944b7c98fc61161c204b7ef397a3ac05977ba Mon Sep 17 00:00:00 2001
|
||||
From: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Date: Thu, 20 Jul 2023 16:37:37 -0400
|
||||
Subject: [PATCH backport 6.1.42 13/20] UBUNTU: SAUCE: mlxbf-bootctl: Fix
|
||||
kernel panic due to buffer overflow
|
||||
|
||||
BugLink: https://bugs.launchpad.net/bugs/2028309
|
||||
|
||||
Running the following LTP (linux-test-project) script, causes
|
||||
a kernel panic and a reboot of the DPU:
|
||||
ltp/testcases/bin/read_all -d /sys -q -r 10
|
||||
|
||||
The above test reads all directory and files under /sys.
|
||||
Reading the sysfs entry "large_icm" causes the kernel panic
|
||||
due to a garbage value returned via i2c read. That garbage
|
||||
value causes a buffer overflow in sprintf.
|
||||
|
||||
Replace sprintf with snprintf. And also add missing lock and
|
||||
increase the buffer size to PAGE_SIZE.
|
||||
|
||||
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
|
||||
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
Acked-by: Tim Gardner <tim.gardner@canonical.com>
|
||||
Signed-off-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com>
|
||||
---
|
||||
drivers/platform/mellanox/mlxbf-bootctl.c | 7 +++----
|
||||
1 file changed, 3 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
index a68bf5b27013..52666ee360b2 100644
|
||||
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
|
||||
@@ -387,17 +387,16 @@ static ssize_t oob_mac_store(struct device_driver *drv, const char *buf,
|
||||
|
||||
static ssize_t large_icm_show(struct device_driver *drv, char *buf)
|
||||
{
|
||||
- char icm_str[MAX_ICM_BUFFER_SIZE] = { 0 };
|
||||
struct arm_smccc_res res;
|
||||
|
||||
+ mutex_lock(&icm_ops_lock);
|
||||
arm_smccc_smc(MLNX_HANDLE_GET_ICM_INFO, 0, 0, 0, 0,
|
||||
0, 0, 0, &res);
|
||||
+ mutex_unlock(&icm_ops_lock);
|
||||
if (res.a0)
|
||||
return -EPERM;
|
||||
|
||||
- sprintf(icm_str, "0x%lx", res.a1);
|
||||
-
|
||||
- return snprintf(buf, sizeof(icm_str), "%s", icm_str);
|
||||
+ return snprintf(buf, PAGE_SIZE, "0x%lx", res.a1);
|
||||
}
|
||||
|
||||
static ssize_t large_icm_store(struct device_driver *drv, const char *buf,
|
||||
--
|
||||
2.25.1
|
||||
|
@ -1,771 +0,0 @@
|
||||
From 3a6322534307154e067d0596f52f287ecd0f599e Mon Sep 17 00:00:00 2001
|
||||
From: Ciju Rajan K <crajank@nvidia.com>
|
||||
Date: Thu, 17 Aug 2023 10:00:25 +0000
|
||||
Subject: Revert "mlxsw: Use u16 for local_port field instead of u8"
|
||||
|
||||
This reverts commit 0639995c2017338c563db36f631e94d19ae45c74.
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.c | 32 ++++----
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 34 ++++-----
|
||||
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 6 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 106 +++++++++++++-------------
|
||||
4 files changed, 89 insertions(+), 89 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
index 631c19222fc4..7938bad70e37 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
@@ -47,7 +47,7 @@ static struct workqueue_struct *mlxsw_owq;
|
||||
struct mlxsw_core_port {
|
||||
struct devlink_port devlink_port;
|
||||
void *port_driver_priv;
|
||||
- u16 local_port;
|
||||
+ u8 local_port;
|
||||
};
|
||||
|
||||
void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port)
|
||||
@@ -669,7 +669,7 @@ static void mlxsw_emad_process_response(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
/* called with rcu read lock held */
|
||||
-static void mlxsw_emad_rx_listener_func(struct sk_buff *skb, u16 local_port,
|
||||
+static void mlxsw_emad_rx_listener_func(struct sk_buff *skb, u8 local_port,
|
||||
void *priv)
|
||||
{
|
||||
struct mlxsw_core *mlxsw_core = priv;
|
||||
@@ -2094,7 +2094,7 @@ int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
|
||||
EXPORT_SYMBOL(mlxsw_core_skb_transmit);
|
||||
|
||||
void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
|
||||
- struct sk_buff *skb, u16 local_port)
|
||||
+ struct sk_buff *skb, u8 local_port)
|
||||
{
|
||||
if (mlxsw_core->driver->ptp_transmitted)
|
||||
mlxsw_core->driver->ptp_transmitted(mlxsw_core, skb,
|
||||
@@ -2172,7 +2172,7 @@ mlxsw_core_rx_listener_state_set(struct mlxsw_core *mlxsw_core,
|
||||
rxl_item->enabled = enabled;
|
||||
}
|
||||
|
||||
-static void mlxsw_core_event_listener_func(struct sk_buff *skb, u16 local_port,
|
||||
+static void mlxsw_core_event_listener_func(struct sk_buff *skb, u8 local_port,
|
||||
void *priv)
|
||||
{
|
||||
struct mlxsw_event_listener_item *event_listener_item = priv;
|
||||
@@ -2599,7 +2599,7 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
|
||||
{
|
||||
struct mlxsw_rx_listener_item *rxl_item;
|
||||
const struct mlxsw_rx_listener *rxl;
|
||||
- u16 local_port;
|
||||
+ u8 local_port;
|
||||
bool found = false;
|
||||
|
||||
if (rx_info->is_lag) {
|
||||
@@ -2657,7 +2657,7 @@ static int mlxsw_core_lag_mapping_index(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
void mlxsw_core_lag_mapping_set(struct mlxsw_core *mlxsw_core,
|
||||
- u16 lag_id, u8 port_index, u16 local_port)
|
||||
+ u16 lag_id, u8 port_index, u8 local_port)
|
||||
{
|
||||
int index = mlxsw_core_lag_mapping_index(mlxsw_core,
|
||||
lag_id, port_index);
|
||||
@@ -2677,7 +2677,7 @@ u8 mlxsw_core_lag_mapping_get(struct mlxsw_core *mlxsw_core,
|
||||
EXPORT_SYMBOL(mlxsw_core_lag_mapping_get);
|
||||
|
||||
void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core,
|
||||
- u16 lag_id, u16 local_port)
|
||||
+ u16 lag_id, u8 local_port)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -2705,7 +2705,7 @@ u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_res_get);
|
||||
|
||||
-static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
enum devlink_port_flavour flavour,
|
||||
u32 port_number, bool split,
|
||||
u32 split_port_subnumber,
|
||||
@@ -2736,7 +2736,7 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
return err;
|
||||
}
|
||||
|
||||
-static void __mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u16 local_port)
|
||||
+static void __mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port)
|
||||
{
|
||||
struct mlxsw_core_port *mlxsw_core_port =
|
||||
&mlxsw_core->ports[local_port];
|
||||
@@ -2746,7 +2746,7 @@ static void __mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u16 local_port
|
||||
memset(mlxsw_core_port, 0, sizeof(*mlxsw_core_port));
|
||||
}
|
||||
|
||||
-int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
u32 port_number, bool split,
|
||||
u32 split_port_subnumber,
|
||||
bool splittable, u32 lanes,
|
||||
@@ -2761,7 +2761,7 @@ int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_port_init);
|
||||
|
||||
-void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u16 local_port)
|
||||
+void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port)
|
||||
{
|
||||
__mlxsw_core_port_fini(mlxsw_core, local_port);
|
||||
}
|
||||
@@ -2794,7 +2794,7 @@ void mlxsw_core_cpu_port_fini(struct mlxsw_core *mlxsw_core)
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_cpu_port_fini);
|
||||
|
||||
-void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
void *port_driver_priv, struct net_device *dev)
|
||||
{
|
||||
struct mlxsw_core_port *mlxsw_core_port =
|
||||
@@ -2806,7 +2806,7 @@ void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_port_eth_set);
|
||||
|
||||
-void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
void *port_driver_priv)
|
||||
{
|
||||
struct mlxsw_core_port *mlxsw_core_port =
|
||||
@@ -2818,7 +2818,7 @@ void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_port_ib_set);
|
||||
|
||||
-void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
void *port_driver_priv)
|
||||
{
|
||||
struct mlxsw_core_port *mlxsw_core_port =
|
||||
@@ -2831,7 +2831,7 @@ void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
EXPORT_SYMBOL(mlxsw_core_port_clear);
|
||||
|
||||
enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
|
||||
- u16 local_port)
|
||||
+ u8 local_port)
|
||||
{
|
||||
struct mlxsw_core_port *mlxsw_core_port =
|
||||
&mlxsw_core->ports[local_port];
|
||||
@@ -2844,7 +2844,7 @@ EXPORT_SYMBOL(mlxsw_core_port_type_get);
|
||||
|
||||
struct devlink_port *
|
||||
mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
|
||||
- u16 local_port)
|
||||
+ u8 local_port)
|
||||
{
|
||||
struct mlxsw_core_port *mlxsw_core_port =
|
||||
&mlxsw_core->ports[local_port];
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index 1fc783174292..56efb8e48022 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -49,7 +49,7 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
|
||||
void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, bool reload);
|
||||
|
||||
struct mlxsw_tx_info {
|
||||
- u16 local_port;
|
||||
+ u8 local_port;
|
||||
bool is_emad;
|
||||
};
|
||||
|
||||
@@ -58,11 +58,11 @@ bool mlxsw_core_skb_transmit_busy(struct mlxsw_core *mlxsw_core,
|
||||
int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
|
||||
const struct mlxsw_tx_info *tx_info);
|
||||
void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
|
||||
- struct sk_buff *skb, u16 local_port);
|
||||
+ struct sk_buff *skb, u8 local_port);
|
||||
|
||||
struct mlxsw_rx_listener {
|
||||
- void (*func)(struct sk_buff *skb, u16 local_port, void *priv);
|
||||
- u16 local_port;
|
||||
+ void (*func)(struct sk_buff *skb, u8 local_port, void *priv);
|
||||
+ u8 local_port;
|
||||
u8 mirror_reason;
|
||||
u16 trap_id;
|
||||
};
|
||||
@@ -194,35 +194,35 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
|
||||
struct mlxsw_rx_info *rx_info);
|
||||
|
||||
void mlxsw_core_lag_mapping_set(struct mlxsw_core *mlxsw_core,
|
||||
- u16 lag_id, u8 port_index, u16 local_port);
|
||||
+ u16 lag_id, u8 port_index, u8 local_port);
|
||||
u8 mlxsw_core_lag_mapping_get(struct mlxsw_core *mlxsw_core,
|
||||
u16 lag_id, u8 port_index);
|
||||
void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core,
|
||||
- u16 lag_id, u16 local_port);
|
||||
+ u16 lag_id, u8 local_port);
|
||||
|
||||
void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port);
|
||||
-int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
u32 port_number, bool split, u32 split_port_subnumber,
|
||||
bool splittable, u32 lanes,
|
||||
const unsigned char *switch_id,
|
||||
unsigned char switch_id_len);
|
||||
-void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u16 local_port);
|
||||
+void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port);
|
||||
int mlxsw_core_cpu_port_init(struct mlxsw_core *mlxsw_core,
|
||||
void *port_driver_priv,
|
||||
const unsigned char *switch_id,
|
||||
unsigned char switch_id_len);
|
||||
void mlxsw_core_cpu_port_fini(struct mlxsw_core *mlxsw_core);
|
||||
-void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
void *port_driver_priv, struct net_device *dev);
|
||||
-void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
void *port_driver_priv);
|
||||
-void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
void *port_driver_priv);
|
||||
enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
|
||||
- u16 local_port);
|
||||
+ u8 local_port);
|
||||
struct devlink_port *
|
||||
mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
|
||||
- u16 local_port);
|
||||
+ u8 local_port);
|
||||
struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core);
|
||||
int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module);
|
||||
|
||||
@@ -290,11 +290,11 @@ struct mlxsw_driver {
|
||||
struct netlink_ext_ack *extack);
|
||||
void (*fini)(struct mlxsw_core *mlxsw_core);
|
||||
int (*basic_trap_groups_set)(struct mlxsw_core *mlxsw_core);
|
||||
- int (*port_type_set)(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+ int (*port_type_set)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
enum devlink_port_type new_type);
|
||||
- int (*port_split)(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+ int (*port_split)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
unsigned int count, struct netlink_ext_ack *extack);
|
||||
- int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u16 local_port,
|
||||
+ int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
struct netlink_ext_ack *extack);
|
||||
int (*sb_pool_get)(struct mlxsw_core *mlxsw_core,
|
||||
unsigned int sb_index, u16 pool_index,
|
||||
@@ -368,7 +368,7 @@ struct mlxsw_driver {
|
||||
* is responsible for freeing the passed-in SKB.
|
||||
*/
|
||||
void (*ptp_transmitted)(struct mlxsw_core *mlxsw_core,
|
||||
- struct sk_buff *skb, u16 local_port);
|
||||
+ struct sk_buff *skb, u8 local_port);
|
||||
|
||||
u8 txhdr_len;
|
||||
const struct mlxsw_config_profile *profile;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
index 1ddd11320b99..3d07c2dcf08d 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
@@ -38,7 +38,7 @@ struct mlxsw_m {
|
||||
struct mlxsw_m_port {
|
||||
struct net_device *dev;
|
||||
struct mlxsw_m *mlxsw_m;
|
||||
- u16 local_port;
|
||||
+ u8 local_port;
|
||||
u8 module;
|
||||
};
|
||||
|
||||
@@ -201,7 +201,7 @@ mlxsw_m_port_dev_addr_get(struct mlxsw_m_port *mlxsw_m_port)
|
||||
}
|
||||
|
||||
static int
|
||||
-mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module)
|
||||
+mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module)
|
||||
{
|
||||
struct mlxsw_m_port *mlxsw_m_port;
|
||||
struct net_device *dev;
|
||||
@@ -264,7 +264,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module)
|
||||
return err;
|
||||
}
|
||||
|
||||
-static void mlxsw_m_port_remove(struct mlxsw_m *mlxsw_m, u16 local_port)
|
||||
+static void mlxsw_m_port_remove(struct mlxsw_m *mlxsw_m, u8 local_port)
|
||||
{
|
||||
struct mlxsw_m_port *mlxsw_m_port = mlxsw_m->ports[local_port];
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 2ec9ec6078e2..a9119451d999 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -161,7 +161,7 @@ MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
|
||||
|
||||
-static inline void mlxsw_reg_sspr_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(sspr, payload);
|
||||
mlxsw_reg_sspr_m_set(payload, 1);
|
||||
@@ -407,7 +407,7 @@ static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
|
||||
enum mlxsw_reg_sfd_rec_policy policy,
|
||||
const char *mac, u16 fid_vid,
|
||||
enum mlxsw_reg_sfd_rec_action action,
|
||||
- u16 local_port)
|
||||
+ u8 local_port)
|
||||
{
|
||||
mlxsw_reg_sfd_rec_pack(payload, rec_index,
|
||||
MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
|
||||
@@ -419,7 +419,7 @@ static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
|
||||
|
||||
static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
|
||||
char *mac, u16 *p_fid_vid,
|
||||
- u16 *p_local_port)
|
||||
+ u8 *p_local_port)
|
||||
{
|
||||
mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
|
||||
*p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
|
||||
@@ -685,7 +685,7 @@ MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
|
||||
|
||||
static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
|
||||
char *mac, u16 *p_vid,
|
||||
- u16 *p_local_port)
|
||||
+ u8 *p_local_port)
|
||||
{
|
||||
mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
|
||||
*p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
|
||||
@@ -800,7 +800,7 @@ enum mlxsw_reg_spms_state {
|
||||
*/
|
||||
MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
|
||||
|
||||
-static inline void mlxsw_reg_spms_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(spms, payload);
|
||||
mlxsw_reg_spms_local_port_set(payload, local_port);
|
||||
@@ -840,7 +840,7 @@ MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
|
||||
|
||||
-static inline void mlxsw_reg_spvid_pack(char *payload, u16 local_port, u16 pvid)
|
||||
+static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
|
||||
{
|
||||
MLXSW_REG_ZERO(spvid, payload);
|
||||
mlxsw_reg_spvid_local_port_set(payload, local_port);
|
||||
@@ -929,7 +929,7 @@ MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
|
||||
MLXSW_REG_SPVM_BASE_LEN, 0, 12,
|
||||
MLXSW_REG_SPVM_REC_LEN, 0, false);
|
||||
|
||||
-static inline void mlxsw_reg_spvm_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
|
||||
u16 vid_begin, u16 vid_end,
|
||||
bool is_member, bool untagged)
|
||||
{
|
||||
@@ -991,7 +991,7 @@ MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
|
||||
|
||||
-static inline void mlxsw_reg_spaft_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
|
||||
bool allow_untagged)
|
||||
{
|
||||
MLXSW_REG_ZERO(spaft, payload);
|
||||
@@ -1317,7 +1317,7 @@ MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
|
||||
MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
|
||||
|
||||
static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
|
||||
- u16 local_port)
|
||||
+ u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(sldr, payload);
|
||||
mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
|
||||
@@ -1327,7 +1327,7 @@ static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
|
||||
}
|
||||
|
||||
static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
|
||||
- u16 local_port)
|
||||
+ u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(sldr, payload);
|
||||
mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
|
||||
@@ -1501,7 +1501,7 @@ MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
|
||||
MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
|
||||
|
||||
static inline void mlxsw_reg_slcor_pack(char *payload,
|
||||
- u16 local_port, u16 lag_id,
|
||||
+ u8 local_port, u16 lag_id,
|
||||
enum mlxsw_reg_slcor_col col)
|
||||
{
|
||||
MLXSW_REG_ZERO(slcor, payload);
|
||||
@@ -1511,7 +1511,7 @@ static inline void mlxsw_reg_slcor_pack(char *payload,
|
||||
}
|
||||
|
||||
static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
|
||||
- u16 local_port, u16 lag_id,
|
||||
+ u8 local_port, u16 lag_id,
|
||||
u8 port_index)
|
||||
{
|
||||
mlxsw_reg_slcor_pack(payload, local_port, lag_id,
|
||||
@@ -1520,21 +1520,21 @@ static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
|
||||
}
|
||||
|
||||
static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
|
||||
- u16 local_port, u16 lag_id)
|
||||
+ u8 local_port, u16 lag_id)
|
||||
{
|
||||
mlxsw_reg_slcor_pack(payload, local_port, lag_id,
|
||||
MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
|
||||
}
|
||||
|
||||
static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
|
||||
- u16 local_port, u16 lag_id)
|
||||
+ u8 local_port, u16 lag_id)
|
||||
{
|
||||
mlxsw_reg_slcor_pack(payload, local_port, lag_id,
|
||||
MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
|
||||
}
|
||||
|
||||
static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
|
||||
- u16 local_port, u16 lag_id)
|
||||
+ u8 local_port, u16 lag_id)
|
||||
{
|
||||
mlxsw_reg_slcor_pack(payload, local_port, lag_id,
|
||||
MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
|
||||
@@ -1581,7 +1581,7 @@ enum mlxsw_reg_spmlr_learn_mode {
|
||||
*/
|
||||
MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
|
||||
|
||||
-static inline void mlxsw_reg_spmlr_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_spmlr_learn_mode mode)
|
||||
{
|
||||
MLXSW_REG_ZERO(spmlr, payload);
|
||||
@@ -1666,7 +1666,7 @@ MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
|
||||
|
||||
-static inline void mlxsw_reg_svfa_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_svfa_mt mt, bool valid,
|
||||
u16 fid, u16 vid)
|
||||
{
|
||||
@@ -1705,7 +1705,7 @@ MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
|
||||
|
||||
-static inline void mlxsw_reg_svpe_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
|
||||
bool enable)
|
||||
{
|
||||
MLXSW_REG_ZERO(svpe, payload);
|
||||
@@ -1838,7 +1838,7 @@ MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
|
||||
MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
|
||||
MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
|
||||
|
||||
-static inline void mlxsw_reg_spvmlr_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
|
||||
u16 vid_begin, u16 vid_end,
|
||||
bool learn_enable)
|
||||
{
|
||||
@@ -1907,7 +1907,7 @@ MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
|
||||
#define MLXSW_REG_CWTP_MAX_PROFILE 2
|
||||
#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
|
||||
|
||||
-static inline void mlxsw_reg_cwtp_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
|
||||
u8 traffic_class)
|
||||
{
|
||||
int i;
|
||||
@@ -2025,7 +2025,7 @@ MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
|
||||
|
||||
#define MLXSW_REG_CWTPM_RESET_PROFILE 0
|
||||
|
||||
-static inline void mlxsw_reg_cwtpm_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
|
||||
u8 traffic_class, u8 profile,
|
||||
bool wred, bool ecn)
|
||||
{
|
||||
@@ -2116,7 +2116,7 @@ MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
|
||||
|
||||
static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
|
||||
enum mlxsw_reg_pxbt_op op,
|
||||
- u16 local_port, u16 acl_info)
|
||||
+ u8 local_port, u16 acl_info)
|
||||
{
|
||||
MLXSW_REG_ZERO(ppbt, payload);
|
||||
mlxsw_reg_ppbt_e_set(payload, e);
|
||||
@@ -3260,7 +3260,7 @@ enum mlxsw_reg_qpts_trust_state {
|
||||
*/
|
||||
MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
|
||||
|
||||
-static inline void mlxsw_reg_qpts_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_qpts_trust_state ts)
|
||||
{
|
||||
MLXSW_REG_ZERO(qpts, payload);
|
||||
@@ -3476,7 +3476,7 @@ MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
|
||||
|
||||
-static inline void mlxsw_reg_qtct_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
|
||||
u8 switch_prio, u8 tclass)
|
||||
{
|
||||
MLXSW_REG_ZERO(qtct, payload);
|
||||
@@ -3643,7 +3643,7 @@ MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
|
||||
#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
|
||||
#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11
|
||||
|
||||
-static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_qeec_hr hr, u8 index,
|
||||
u8 next_index)
|
||||
{
|
||||
@@ -3654,7 +3654,7 @@ static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
|
||||
mlxsw_reg_qeec_next_element_index_set(payload, next_index);
|
||||
}
|
||||
|
||||
-static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u8 local_port,
|
||||
bool ptps)
|
||||
{
|
||||
MLXSW_REG_ZERO(qeec, payload);
|
||||
@@ -3692,7 +3692,7 @@ MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
|
||||
|
||||
-static inline void mlxsw_reg_qrwe_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
|
||||
bool rewrite_pcp, bool rewrite_dscp)
|
||||
{
|
||||
MLXSW_REG_ZERO(qrwe, payload);
|
||||
@@ -3772,7 +3772,7 @@ MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
|
||||
MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
|
||||
MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
|
||||
|
||||
-static inline void mlxsw_reg_qpdsm_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(qpdsm, payload);
|
||||
mlxsw_reg_qpdsm_local_port_set(payload, local_port);
|
||||
@@ -3813,7 +3813,7 @@ MLXSW_ITEM32(reg, qpdp, local_port, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
|
||||
|
||||
-static inline void mlxsw_reg_qpdp_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_qpdp_pack(char *payload, u8 local_port,
|
||||
u8 switch_prio)
|
||||
{
|
||||
MLXSW_REG_ZERO(qpdp, payload);
|
||||
@@ -3859,7 +3859,7 @@ MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
|
||||
MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
|
||||
MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
|
||||
|
||||
-static inline void mlxsw_reg_qpdpm_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(qpdpm, payload);
|
||||
mlxsw_reg_qpdpm_local_port_set(payload, local_port);
|
||||
@@ -3901,7 +3901,7 @@ MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
|
||||
MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
|
||||
|
||||
static inline void
|
||||
-mlxsw_reg_qtctm_pack(char *payload, u16 local_port, bool mc)
|
||||
+mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
|
||||
{
|
||||
MLXSW_REG_ZERO(qtctm, payload);
|
||||
mlxsw_reg_qtctm_local_port_set(payload, local_port);
|
||||
@@ -4065,7 +4065,7 @@ MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
|
||||
*/
|
||||
MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
|
||||
|
||||
-static inline void mlxsw_reg_pmlp_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(pmlp, payload);
|
||||
mlxsw_reg_pmlp_local_port_set(payload, local_port);
|
||||
@@ -4112,7 +4112,7 @@ MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
|
||||
|
||||
-static inline void mlxsw_reg_pmtu_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
|
||||
u16 new_mtu)
|
||||
{
|
||||
MLXSW_REG_ZERO(pmtu, payload);
|
||||
@@ -4306,7 +4306,7 @@ enum mlxsw_reg_ptys_connector_type {
|
||||
*/
|
||||
MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
|
||||
|
||||
-static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
|
||||
u32 proto_admin, bool autoneg)
|
||||
{
|
||||
MLXSW_REG_ZERO(ptys, payload);
|
||||
@@ -4316,7 +4316,7 @@ static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port,
|
||||
mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
|
||||
}
|
||||
|
||||
-static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u8 local_port,
|
||||
u32 proto_admin, bool autoneg)
|
||||
{
|
||||
MLXSW_REG_ZERO(ptys, payload);
|
||||
@@ -4358,7 +4358,7 @@ static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
|
||||
mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
|
||||
}
|
||||
|
||||
-static inline void mlxsw_reg_ptys_ib_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
|
||||
u16 proto_admin, u16 link_width)
|
||||
{
|
||||
MLXSW_REG_ZERO(ptys, payload);
|
||||
@@ -4416,7 +4416,7 @@ MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
|
||||
MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
|
||||
|
||||
static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
|
||||
- u16 local_port)
|
||||
+ u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(ppad, payload);
|
||||
mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
|
||||
@@ -4490,7 +4490,7 @@ MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
|
||||
|
||||
-static inline void mlxsw_reg_paos_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_port_admin_status status)
|
||||
{
|
||||
MLXSW_REG_ZERO(paos, payload);
|
||||
@@ -4633,7 +4633,7 @@ static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
|
||||
mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
|
||||
}
|
||||
|
||||
-static inline void mlxsw_reg_pfcc_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(pfcc, payload);
|
||||
mlxsw_reg_pfcc_local_port_set(payload, local_port);
|
||||
@@ -5132,7 +5132,7 @@ MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
|
||||
MLXSW_ITEM64(reg, ppcnt, wred_discard,
|
||||
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
|
||||
|
||||
-static inline void mlxsw_reg_ppcnt_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_ppcnt_grp grp,
|
||||
u8 prio_tc)
|
||||
{
|
||||
@@ -5243,7 +5243,7 @@ MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
|
||||
|
||||
#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
|
||||
|
||||
-static inline void mlxsw_reg_pptb_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(pptb, payload);
|
||||
mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
|
||||
@@ -5340,7 +5340,7 @@ MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
|
||||
MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
|
||||
0x08, 0x04, false);
|
||||
|
||||
-static inline void mlxsw_reg_pbmc_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
|
||||
u16 xoff_timer_value, u16 xoff_refresh)
|
||||
{
|
||||
MLXSW_REG_ZERO(pbmc, payload);
|
||||
@@ -5398,7 +5398,7 @@ MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
|
||||
|
||||
-static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u16 local_port)
|
||||
+static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(pspa, payload);
|
||||
mlxsw_reg_pspa_swid_set(payload, swid);
|
||||
@@ -5513,7 +5513,7 @@ MLXSW_ITEM32(reg, pplr, local_port, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
|
||||
|
||||
-static inline void mlxsw_reg_pplr_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port,
|
||||
bool phy_local)
|
||||
{
|
||||
MLXSW_REG_ZERO(pplr, payload);
|
||||
@@ -5609,7 +5609,7 @@ MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
|
||||
|
||||
-static inline void mlxsw_reg_pddr_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_pddr_pack(char *payload, u8 local_port,
|
||||
u8 page_select)
|
||||
{
|
||||
MLXSW_REG_ZERO(pddr, payload);
|
||||
@@ -9160,7 +9160,7 @@ MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
|
||||
|
||||
-static inline void mlxsw_reg_mpar_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_mpar_i_e i_e,
|
||||
bool enable, u8 pa_id)
|
||||
{
|
||||
@@ -9281,7 +9281,7 @@ MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
|
||||
|
||||
-static inline void mlxsw_reg_mlcr_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
|
||||
bool active)
|
||||
{
|
||||
MLXSW_REG_ZERO(mlcr, payload);
|
||||
@@ -9671,7 +9671,7 @@ MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
|
||||
|
||||
-static inline void mlxsw_reg_mpsc_pack(char *payload, u16 local_port, bool e,
|
||||
+static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
|
||||
u32 rate)
|
||||
{
|
||||
MLXSW_REG_ZERO(mpsc, payload);
|
||||
@@ -9904,7 +9904,7 @@ MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
|
||||
*/
|
||||
MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
|
||||
|
||||
-static inline void mlxsw_reg_momte_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_momte_pack(char *payload, u8 local_port,
|
||||
enum mlxsw_reg_momte_type type)
|
||||
{
|
||||
MLXSW_REG_ZERO(momte, payload);
|
||||
@@ -10574,7 +10574,7 @@ MLXSW_ITEM32(reg, tnqdr, local_port, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
|
||||
|
||||
-static inline void mlxsw_reg_tnqdr_pack(char *payload, u16 local_port)
|
||||
+static inline void mlxsw_reg_tnqdr_pack(char *payload, u8 local_port)
|
||||
{
|
||||
MLXSW_REG_ZERO(tnqdr, payload);
|
||||
mlxsw_reg_tnqdr_local_port_set(payload, local_port);
|
||||
@@ -10963,7 +10963,7 @@ MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
|
||||
|
||||
-static inline void mlxsw_reg_sbcm_pack(char *payload, u16 local_port, u8 pg_buff,
|
||||
+static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
|
||||
enum mlxsw_reg_sbxx_dir dir,
|
||||
u32 min_buff, u32 max_buff,
|
||||
bool infi_max, u8 pool)
|
||||
@@ -11049,7 +11049,7 @@ MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
|
||||
|
||||
-static inline void mlxsw_reg_sbpm_pack(char *payload, u16 local_port, u8 pool,
|
||||
+static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
|
||||
enum mlxsw_reg_sbxx_dir dir, bool clr,
|
||||
u32 min_buff, u32 max_buff)
|
||||
{
|
||||
@@ -11244,7 +11244,7 @@ MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
|
||||
|
||||
-static inline void mlxsw_reg_sbib_pack(char *payload, u16 local_port,
|
||||
+static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
|
||||
u32 buff_size)
|
||||
{
|
||||
MLXSW_REG_ZERO(sbib, payload);
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,26 +0,0 @@
|
||||
From 0dda3bcede5f26c2bd44edbd90c7e9f0aab9ccf0 Mon Sep 17 00:00:00 2001
|
||||
From: Ciju Rajan K <crajank@nvidia.com>
|
||||
Date: Thu, 17 Aug 2023 10:00:59 +0000
|
||||
Subject: Revert "mlxsw: i2c: Fix chunk size setting in output mailbox buffer"
|
||||
|
||||
This reverts commit ac91378962238d34030bb4035308f88ba173165f.
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/i2c.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c
|
||||
index cc99ec3f4e96..b8a5c0cbb6b5 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c
|
||||
@@ -447,7 +447,7 @@ mlxsw_i2c_cmd(struct device *dev, u16 opcode, u32 in_mod, size_t in_mbox_size,
|
||||
} else {
|
||||
/* No input mailbox is case of initialization query command. */
|
||||
reg_size = MLXSW_I2C_MAX_DATA_SIZE;
|
||||
- num = DIV_ROUND_UP(reg_size, mlxsw_i2c->block_size);
|
||||
+ num = reg_size / mlxsw_i2c->block_size;
|
||||
|
||||
if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) {
|
||||
dev_err(&client->dev, "Could not acquire lock");
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,28 +0,0 @@
|
||||
From e0f5c6c6572fd70ad8fa0d268ee95fb8aba1bd98 Mon Sep 17 00:00:00 2001
|
||||
From: Ciju Rajan K <crajank@nvidia.com>
|
||||
Date: Thu, 17 Aug 2023 10:01:22 +0000
|
||||
Subject: Revert "mlxsw: core_hwmon: Adjust module label names based on MTCAP
|
||||
sensor counter"
|
||||
|
||||
This reverts commit 33aa62a331425d5828d417eeac7fab697eb45286.
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 464787b10b73..d41afdfbd085 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -377,8 +377,7 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev,
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
|
||||
return sprintf(buf, "front panel %03u\n",
|
||||
- mlwsw_hwmon_attr->type_index + 1 -
|
||||
- mlwsw_hwmon_attr->hwmon->sensor_count);
|
||||
+ mlwsw_hwmon_attr->type_index);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,256 +0,0 @@
|
||||
From 320a964b80a8f9245da0515a26c2d41e035b3d10 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:41 +0200
|
||||
Subject: [PATCH backport 5.10 099/182] mlxsw: core_hwmon: Fix variable names
|
||||
for hwmon attributes
|
||||
|
||||
Replace all local variables 'mlwsw_hwmon_attr' by 'mlxsw_hwmon_attr'.
|
||||
All variable prefixes should start with 'mlxsw' according to the naming
|
||||
convention, so 'mlwsw' is changed to 'mlxsw'.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 76 +++++++++----------
|
||||
1 file changed, 38 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index d41afdfbd085..3788d02b5244 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -57,14 +57,14 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
int temp, index;
|
||||
int err;
|
||||
|
||||
- index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index,
|
||||
+ index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon->module_sensor_max);
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -80,14 +80,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
int temp_max, index;
|
||||
int err;
|
||||
|
||||
- index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index,
|
||||
+ index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon->module_sensor_max);
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -103,9 +103,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
|
||||
unsigned long val;
|
||||
int index;
|
||||
@@ -117,7 +117,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
|
||||
if (val != 1)
|
||||
return -EINVAL;
|
||||
|
||||
- index = mlxsw_hwmon_get_attr_index(mlwsw_hwmon_attr->type_index,
|
||||
+ index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon->module_sensor_max);
|
||||
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index);
|
||||
@@ -138,13 +138,13 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mfsm_pl[MLXSW_REG_MFSM_LEN];
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mfsm_pack(mfsm_pl, mlwsw_hwmon_attr->type_index);
|
||||
+ mlxsw_reg_mfsm_pack(mfsm_pl, mlxsw_hwmon_attr->type_index);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsm), mfsm_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n");
|
||||
@@ -157,9 +157,9 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char fore_pl[MLXSW_REG_FORE_LEN];
|
||||
bool fault;
|
||||
int err;
|
||||
@@ -169,7 +169,7 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev,
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query fan\n");
|
||||
return err;
|
||||
}
|
||||
- mlxsw_reg_fore_unpack(fore_pl, mlwsw_hwmon_attr->type_index, &fault);
|
||||
+ mlxsw_reg_fore_unpack(fore_pl, mlxsw_hwmon_attr->type_index, &fault);
|
||||
|
||||
return sprintf(buf, "%u\n", fault);
|
||||
}
|
||||
@@ -178,13 +178,13 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mfsc_pl[MLXSW_REG_MFSC_LEN];
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mfsc_pack(mfsc_pl, mlwsw_hwmon_attr->type_index, 0);
|
||||
+ mlxsw_reg_mfsc_pack(mfsc_pl, mlxsw_hwmon_attr->type_index, 0);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query PWM\n");
|
||||
@@ -198,9 +198,9 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mfsc_pl[MLXSW_REG_MFSC_LEN];
|
||||
unsigned long val;
|
||||
int err;
|
||||
@@ -211,7 +211,7 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev,
|
||||
if (val > 255)
|
||||
return -EINVAL;
|
||||
|
||||
- mlxsw_reg_mfsc_pack(mfsc_pl, mlwsw_hwmon_attr->type_index, val);
|
||||
+ mlxsw_reg_mfsc_pack(mfsc_pl, mlxsw_hwmon_attr->type_index, val);
|
||||
err = mlxsw_reg_write(mlxsw_hwmon->core, MLXSW_REG(mfsc), mfsc_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to write PWM\n");
|
||||
@@ -224,14 +224,14 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
int *p_temp)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
u8 module;
|
||||
int err;
|
||||
|
||||
- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
|
||||
false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -261,15 +261,15 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
|
||||
u8 module, fault;
|
||||
u16 temp;
|
||||
int err;
|
||||
|
||||
- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
|
||||
1);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
|
||||
@@ -303,13 +303,13 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
int *p_temp)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
u8 module;
|
||||
int err;
|
||||
|
||||
- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module,
|
||||
SFP_TEMP_HIGH_WARN, p_temp);
|
||||
if (err) {
|
||||
@@ -337,13 +337,13 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
int *p_temp)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
u8 module;
|
||||
int err;
|
||||
|
||||
- module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module,
|
||||
SFP_TEMP_HIGH_ALARM, p_temp);
|
||||
if (err) {
|
||||
@@ -373,11 +373,11 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
|
||||
return sprintf(buf, "front panel %03u\n",
|
||||
- mlwsw_hwmon_attr->type_index);
|
||||
+ mlxsw_hwmon_attr->type_index);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
@@ -385,10 +385,10 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
- struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
|
||||
+ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
|
||||
- int index = mlwsw_hwmon_attr->type_index -
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ int index = mlxsw_hwmon_attr->type_index -
|
||||
mlxsw_hwmon->module_sensor_max + 1;
|
||||
|
||||
return sprintf(buf, "gearbox %03u\n", index);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,162 +0,0 @@
|
||||
From 2f12c9f7cd1d91732ee64d11611cc4cb6baf69a6 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:42 +0200
|
||||
Subject: [PATCH backport 5.10 100/182] mlxsw: core_thermal: Rename labels
|
||||
according to naming convention
|
||||
|
||||
Rename labels for error flow handling in order to align with naming
|
||||
convention used in rest of 'mlxsw' code.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 43 ++++++++++---------
|
||||
1 file changed, 23 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 91abc7a3f7ea..f471f03e0094 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -393,11 +393,11 @@ static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
|
||||
trip->min_state,
|
||||
THERMAL_WEIGHT_DEFAULT);
|
||||
if (err < 0)
|
||||
- goto err_bind_cooling_device;
|
||||
+ goto err_thermal_zone_bind_cooling_device;
|
||||
}
|
||||
return 0;
|
||||
|
||||
-err_bind_cooling_device:
|
||||
+err_thermal_zone_bind_cooling_device:
|
||||
for (j = i - 1; j >= 0; j--)
|
||||
thermal_zone_unbind_cooling_device(tzdev, j, cdev);
|
||||
return err;
|
||||
@@ -766,7 +766,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
|
||||
for (i = 0; i < thermal->tz_module_num; i++) {
|
||||
err = mlxsw_thermal_module_init(dev, core, thermal, i);
|
||||
if (err)
|
||||
- goto err_unreg_tz_module_arr;
|
||||
+ goto err_thermal_module_init;
|
||||
}
|
||||
|
||||
for (i = 0; i < thermal->tz_module_num; i++) {
|
||||
@@ -775,12 +775,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
|
||||
continue;
|
||||
err = mlxsw_thermal_module_tz_init(module_tz);
|
||||
if (err)
|
||||
- goto err_unreg_tz_module_arr;
|
||||
+ goto err_thermal_module_tz_init;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
-err_unreg_tz_module_arr:
|
||||
+err_thermal_module_tz_init:
|
||||
+err_thermal_module_init:
|
||||
for (i = thermal->tz_module_num - 1; i >= 0; i--)
|
||||
mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
|
||||
kfree(thermal->tz_module_arr);
|
||||
@@ -871,12 +872,12 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
gearbox_tz->parent = thermal;
|
||||
err = mlxsw_thermal_gearbox_tz_init(gearbox_tz);
|
||||
if (err)
|
||||
- goto err_unreg_tz_gearbox;
|
||||
+ goto err_thermal_gearbox_tz_init;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
-err_unreg_tz_gearbox:
|
||||
+err_thermal_gearbox_tz_init:
|
||||
for (i--; i >= 0; i--)
|
||||
mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]);
|
||||
kfree(thermal->tz_gearbox_arr);
|
||||
@@ -920,7 +921,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to probe PWMs\n");
|
||||
- goto err_free_thermal;
|
||||
+ goto err_reg_query;
|
||||
}
|
||||
mlxsw_reg_mfcr_unpack(mfcr_pl, &freq, &tacho_active, &pwm_active);
|
||||
|
||||
@@ -934,14 +935,14 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsl),
|
||||
mfsl_pl);
|
||||
if (err)
|
||||
- goto err_free_thermal;
|
||||
+ goto err_reg_query;
|
||||
|
||||
/* set the minimal RPMs to 0 */
|
||||
mlxsw_reg_mfsl_tach_min_set(mfsl_pl, 0);
|
||||
err = mlxsw_reg_write(thermal->core, MLXSW_REG(mfsl),
|
||||
mfsl_pl);
|
||||
if (err)
|
||||
- goto err_free_thermal;
|
||||
+ goto err_reg_write;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) {
|
||||
@@ -954,7 +955,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
if (IS_ERR(cdev)) {
|
||||
err = PTR_ERR(cdev);
|
||||
dev_err(dev, "Failed to register cooling device\n");
|
||||
- goto err_unreg_cdevs;
|
||||
+ goto err_thermal_cooling_device_register;
|
||||
}
|
||||
thermal->cdevs[i] = cdev;
|
||||
}
|
||||
@@ -978,38 +979,40 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
if (IS_ERR(thermal->tzdev)) {
|
||||
err = PTR_ERR(thermal->tzdev);
|
||||
dev_err(dev, "Failed to register thermal zone\n");
|
||||
- goto err_unreg_cdevs;
|
||||
+ goto err_thermal_zone_device_register;
|
||||
}
|
||||
|
||||
err = mlxsw_thermal_modules_init(dev, core, thermal);
|
||||
if (err)
|
||||
- goto err_unreg_tzdev;
|
||||
+ goto err_thermal_modules_init;
|
||||
|
||||
err = mlxsw_thermal_gearboxes_init(dev, core, thermal);
|
||||
if (err)
|
||||
- goto err_unreg_modules_tzdev;
|
||||
+ goto err_thermal_gearboxes_init;
|
||||
|
||||
err = thermal_zone_device_enable(thermal->tzdev);
|
||||
if (err)
|
||||
- goto err_unreg_gearboxes;
|
||||
+ goto err_thermal_zone_device_enable;
|
||||
|
||||
*p_thermal = thermal;
|
||||
return 0;
|
||||
|
||||
-err_unreg_gearboxes:
|
||||
+err_thermal_zone_device_enable:
|
||||
mlxsw_thermal_gearboxes_fini(thermal);
|
||||
-err_unreg_modules_tzdev:
|
||||
+err_thermal_gearboxes_init:
|
||||
mlxsw_thermal_modules_fini(thermal);
|
||||
-err_unreg_tzdev:
|
||||
+err_thermal_modules_init:
|
||||
if (thermal->tzdev) {
|
||||
thermal_zone_device_unregister(thermal->tzdev);
|
||||
thermal->tzdev = NULL;
|
||||
}
|
||||
-err_unreg_cdevs:
|
||||
+err_thermal_zone_device_register:
|
||||
+err_thermal_cooling_device_register:
|
||||
for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
|
||||
if (thermal->cdevs[i])
|
||||
thermal_cooling_device_unregister(thermal->cdevs[i]);
|
||||
-err_free_thermal:
|
||||
+err_reg_write:
|
||||
+err_reg_query:
|
||||
devm_kfree(dev, thermal);
|
||||
return err;
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,111 +0,0 @@
|
||||
From d0a94e237cb6d2020a0a1c27f357a9c3bfc0b1d5 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:43 +0200
|
||||
Subject: [PATCH backport 5.10 101/182] mlxsw: core_thermal: Remove obsolete
|
||||
API for query resource
|
||||
|
||||
Remove obsolete API mlxsw_core_res_query_enabled(), which is only
|
||||
relevant for end-of-life SwitchX-2 ASICs. Support for these ASICs was
|
||||
removed in commit b0d80c013b04 ("mlxsw: Remove Mellanox SwitchX-2 ASIC
|
||||
support").
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ------
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 2 --
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 ---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 12 ------------
|
||||
4 files changed, 23 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
index 7938bad70e37..0b1888318ef1 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
@@ -129,12 +129,6 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_driver_priv);
|
||||
|
||||
-bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
|
||||
-{
|
||||
- return mlxsw_core->driver->res_query_enabled;
|
||||
-}
|
||||
-EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
|
||||
-
|
||||
bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core)
|
||||
{
|
||||
return mlxsw_core->driver->temp_warn_enabled;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index 56efb8e48022..0ceb7dae95f6 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -30,8 +30,6 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
|
||||
|
||||
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
|
||||
|
||||
-bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
|
||||
-
|
||||
bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core);
|
||||
|
||||
bool
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 3788d02b5244..8b170ad92302 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -655,9 +655,6 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
u8 module_sensor_max;
|
||||
int i, err;
|
||||
|
||||
- if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
|
||||
- return 0;
|
||||
-
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index f471f03e0094..80942c78d9e5 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -746,9 +746,6 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
int i, err;
|
||||
|
||||
- if (!mlxsw_core_res_query_enabled(core))
|
||||
- return 0;
|
||||
-
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
@@ -793,9 +790,6 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
|
||||
{
|
||||
int i;
|
||||
|
||||
- if (!mlxsw_core_res_query_enabled(thermal->core))
|
||||
- return;
|
||||
-
|
||||
for (i = thermal->tz_module_num - 1; i >= 0; i--)
|
||||
mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
|
||||
kfree(thermal->tz_module_arr);
|
||||
@@ -843,9 +837,6 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
int i;
|
||||
int err;
|
||||
|
||||
- if (!mlxsw_core_res_query_enabled(core))
|
||||
- return 0;
|
||||
-
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
@@ -889,9 +880,6 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal)
|
||||
{
|
||||
int i;
|
||||
|
||||
- if (!mlxsw_core_res_query_enabled(thermal->core))
|
||||
- return;
|
||||
-
|
||||
for (i = thermal->tz_gearbox_num - 1; i >= 0; i--)
|
||||
mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]);
|
||||
kfree(thermal->tz_gearbox_arr);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,52 +0,0 @@
|
||||
From 2e6cd3d593c0bf1cc38093a73ec7777a5b806bfe Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:44 +0200
|
||||
Subject: [PATCH backport 5.10 102/182] mlxsw: reg: Add "mgpir_" prefix to
|
||||
MGPIR fields comments
|
||||
|
||||
Do the same as for other registers and have "mgpir_" prefix for the
|
||||
MGPIR fields.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 7f9b902049db..c3fb2e4d4458 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10130,24 +10130,24 @@ enum mlxsw_reg_mgpir_device_type {
|
||||
MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
|
||||
};
|
||||
|
||||
-/* device_type
|
||||
+/* mgpir_device_type
|
||||
* Access: RO
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
|
||||
|
||||
-/* devices_per_flash
|
||||
+/* mgpir_devices_per_flash
|
||||
* Number of devices of device_type per flash (can be shared by few devices).
|
||||
* Access: RO
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
|
||||
|
||||
-/* num_of_devices
|
||||
+/* mgpir_num_of_devices
|
||||
* Number of devices of device_type.
|
||||
* Access: RO
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
|
||||
|
||||
-/* num_of_modules
|
||||
+/* mgpir_num_of_modules
|
||||
* Number of modules.
|
||||
* Access: RO
|
||||
*/
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,102 +0,0 @@
|
||||
From 7b7f5f88374c3377fc28e48a0bc77ae4aa783fda Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 7 Dec 2021 16:07:31 +0200
|
||||
Subject: [PATCH backport 5.10 103/182] mlxsw: core: Remove unnecessary asserts
|
||||
|
||||
Remove unnecessary asserts for module index validation. Leave only one
|
||||
that is actually necessary in mlxsw_env_pmpe_listener_func() where the
|
||||
module index is directly read from the firmware event.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 24 -------------------
|
||||
1 file changed, 24 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 6dd4ae2f45f4..c1d51b4b6b36 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -414,9 +414,6 @@ int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
!(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT)))
|
||||
return 0;
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return -EINVAL;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
|
||||
if (mlxsw_env->module_info[module].num_ports_up) {
|
||||
@@ -456,9 +453,6 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
u32 status_bits;
|
||||
int err;
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return -EINVAL;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
|
||||
params->policy = mlxsw_env->module_info[module].power_mode_policy;
|
||||
@@ -560,9 +554,6 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
bool low_power;
|
||||
int err = 0;
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return -EINVAL;
|
||||
-
|
||||
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
|
||||
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
|
||||
@@ -901,9 +892,6 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return -EINVAL;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
*p_counter = mlxsw_env->module_info[module].module_overheat_counter;
|
||||
mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
@@ -916,9 +904,6 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
mlxsw_env->module_info[module].num_ports_mapped++;
|
||||
mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
@@ -929,9 +914,6 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
mlxsw_env->module_info[module].num_ports_mapped--;
|
||||
mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
@@ -943,9 +925,6 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
int err = 0;
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return -EINVAL;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
|
||||
if (mlxsw_env->module_info[module].power_mode_policy !=
|
||||
@@ -975,9 +954,6 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
- return;
|
||||
-
|
||||
mutex_lock(&mlxsw_env->module_info_lock);
|
||||
|
||||
mlxsw_env->module_info[module].num_ports_up--;
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,147 +0,0 @@
|
||||
From 58426cf3ccba63cbc0b9ddc2abfc1173ca8ba368 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:45 +0200
|
||||
Subject: [PATCH backport 5.10 104/182] mlxsw: reg: Extend MTMP register with
|
||||
new slot number field
|
||||
|
||||
Extend MTMP (Management Temperature Register) with new field specifying
|
||||
the slot index. The purpose of this field is to support access to MTMP
|
||||
register for reading temperature sensors on modular systems.
|
||||
For non-modular systems the 'sensor_index' uniquely identifies the cage
|
||||
sensors, while 'slot_index' is always 0. For modular systems the
|
||||
sensors are identified by:
|
||||
- 'slot_index', specifying the slot index, where line card is located;
|
||||
- 'sensor_index', specifying cage sensor within the line card.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 11 ++++++-----
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 6 +++---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 11 +++++++++--
|
||||
4 files changed, 19 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index c1d51b4b6b36..32faedfd2ea8 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -142,7 +142,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
int page;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
|
||||
false, false);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 8b170ad92302..71ca3b561e62 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -66,7 +66,7 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon->module_sensor_max);
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
|
||||
@@ -89,7 +89,7 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon->module_sensor_max);
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
|
||||
@@ -232,8 +232,9 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
|
||||
- false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0,
|
||||
+ MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false,
|
||||
+ false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to query module temperature\n");
|
||||
@@ -721,7 +722,7 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
while (index < max_index) {
|
||||
sensor_index = index % mlxsw_hwmon->module_sensor_max +
|
||||
MLXSW_REG_MTMP_GBOX_INDEX_MIN;
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, sensor_index, true, true);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true);
|
||||
err = mlxsw_reg_write(mlxsw_hwmon->core,
|
||||
MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 80942c78d9e5..f4f0f8ce8597 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -272,7 +272,7 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
|
||||
int temp;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, 0, false, false);
|
||||
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
@@ -432,7 +432,7 @@ mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core,
|
||||
int err;
|
||||
|
||||
/* Read module temperature and thresholds. */
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, sensor_index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, false, false);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
/* Set temperature and thresholds to zero to avoid passing
|
||||
@@ -577,7 +577,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
|
||||
int err;
|
||||
|
||||
index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module;
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index c3fb2e4d4458..0428904b99d2 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -8541,6 +8541,12 @@ MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
|
||||
|
||||
MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
|
||||
|
||||
+/* reg_mtmp_slot_index
|
||||
+ * Slot index (0: Main board).
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4);
|
||||
+
|
||||
#define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
|
||||
#define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
|
||||
/* reg_mtmp_sensor_index
|
||||
@@ -8630,11 +8636,12 @@ MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
|
||||
*/
|
||||
MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
|
||||
|
||||
-static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index,
|
||||
- bool max_temp_enable,
|
||||
+static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index,
|
||||
+ u16 sensor_index, bool max_temp_enable,
|
||||
bool max_temp_reset)
|
||||
{
|
||||
MLXSW_REG_ZERO(mtmp, payload);
|
||||
+ mlxsw_reg_mtmp_slot_index_set(payload, slot_index);
|
||||
mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
|
||||
mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
|
||||
mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,88 +0,0 @@
|
||||
From c9c07da3e3dadf102a25e27f49d0ce4f414c096c Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:46 +0200
|
||||
Subject: [PATCH backport 5.10 105/182] mlxsw: reg: Extend MTBR register with
|
||||
new slot number field
|
||||
|
||||
Extend MTBR (Management Temperature Bulk Register) with new field
|
||||
specifying the slot number. The purpose of this field is to support
|
||||
access to MTBR register for reading temperature sensors on modular
|
||||
system. For non-modular systems the 'sensor_index' uniquely identifies
|
||||
the cage sensors. For modular systems the sensors are identified by two
|
||||
indexes:
|
||||
- 'slot_index', specifying the slot number, where line card is located;
|
||||
- 'sensor_index', specifying cage sensor within the line card.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 4 ++--
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 4 ++--
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 11 +++++++++--
|
||||
3 files changed, 13 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 32faedfd2ea8..c2aa05be5bcc 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -591,8 +591,8 @@ static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core,
|
||||
u16 temp;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
|
||||
- 1);
|
||||
+ mlxsw_reg_mtbr_pack(mtbr_pl, 0,
|
||||
+ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtbr), mtbr_pl);
|
||||
if (err)
|
||||
return err;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 71ca3b561e62..f4bc711a16cf 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -271,8 +271,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
- mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
|
||||
- 1);
|
||||
+ mlxsw_reg_mtbr_pack(mtbr_pl, 0,
|
||||
+ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to query module temperature sensor\n");
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 0428904b99d2..df210bd9a29c 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -8707,6 +8707,12 @@ MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
|
||||
|
||||
MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
|
||||
|
||||
+/* reg_mtbr_slot_index
|
||||
+ * Slot index (0: Main board).
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4);
|
||||
+
|
||||
/* reg_mtbr_base_sensor_index
|
||||
* Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
|
||||
* 64-127 are mapped to the SFP+/QSFP modules sequentially).
|
||||
@@ -8739,10 +8745,11 @@ MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
|
||||
MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
|
||||
MLXSW_REG_MTBR_REC_LEN, 0x00, false);
|
||||
|
||||
-static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index,
|
||||
- u8 num_rec)
|
||||
+static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index,
|
||||
+ u16 base_sensor_index, u8 num_rec)
|
||||
{
|
||||
MLXSW_REG_ZERO(mtbr, payload);
|
||||
+ mlxsw_reg_mtbr_slot_index_set(payload, slot_index);
|
||||
mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
|
||||
mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,109 +0,0 @@
|
||||
From 4f10b61f33bdaee774b31b7fe37a76058b755561 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:47 +0200
|
||||
Subject: [PATCH backport 5.10 106/182] mlxsw: reg: Extend MCIA register with
|
||||
new slot number field
|
||||
|
||||
Extend MCIA (Management Cable Info Access Register) with new field
|
||||
specifying the slot number. The purpose of this field is to support
|
||||
access to MCIA register for reading cage cable information on modular
|
||||
system. For non-modular systems the 'module' number uniquely identifies
|
||||
the transceiver location. For modular systems the transceivers are
|
||||
identified by two indexes:
|
||||
- 'slot_index', specifying the slot number, where line card is located;
|
||||
- 'module', specifying cage transceiver within the line card.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 13 +++++++------
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 14 +++++++++++---
|
||||
2 files changed, 18 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index c2aa05be5bcc..a516c04ad19b 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -35,8 +35,8 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
|
||||
u8 ident;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, 1,
|
||||
- MLXSW_REG_MCIA_I2C_ADDR_LOW);
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, 0, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0,
|
||||
+ 1, MLXSW_REG_MCIA_I2C_ADDR_LOW);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -110,7 +110,8 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
|
||||
}
|
||||
}
|
||||
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, module, 0, page, offset, size, i2c_addr);
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, offset, size,
|
||||
+ i2c_addr);
|
||||
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcia), mcia_pl);
|
||||
if (err)
|
||||
@@ -184,12 +185,12 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM;
|
||||
else
|
||||
page = MLXSW_REG_MCIA_TH_PAGE_NUM;
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, module, 0, page,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page,
|
||||
MLXSW_REG_MCIA_TH_PAGE_OFF + off,
|
||||
MLXSW_REG_MCIA_TH_ITEM_SIZE,
|
||||
MLXSW_REG_MCIA_I2C_ADDR_LOW);
|
||||
} else {
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, module, 0,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0,
|
||||
MLXSW_REG_MCIA_PAGE0_LO,
|
||||
off, MLXSW_REG_MCIA_TH_ITEM_SIZE,
|
||||
MLXSW_REG_MCIA_I2C_ADDR_HIGH);
|
||||
@@ -369,7 +370,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
size = min_t(u8, page->length - bytes_read,
|
||||
MLXSW_REG_MCIA_EEPROM_SIZE);
|
||||
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, module, 0, page->page,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page->page,
|
||||
device_addr + bytes_read, size,
|
||||
page->i2c_address);
|
||||
mlxsw_reg_mcia_bank_number_set(mcia_pl, page->bank);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index df210bd9a29c..bdbe198a9053 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -8798,6 +8798,12 @@ MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
|
||||
|
||||
+/* reg_mcia_slot_index
|
||||
+ * Slot index (0: Main board)
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mcia, slot, 0x00, 12, 4);
|
||||
+
|
||||
enum {
|
||||
MLXSW_REG_MCIA_STATUS_GOOD = 0,
|
||||
/* No response from module's EEPROM. */
|
||||
@@ -8896,11 +8902,13 @@ MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
|
||||
MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
|
||||
MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
|
||||
|
||||
-static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
|
||||
- u8 page_number, u16 device_addr,
|
||||
- u8 size, u8 i2c_device_addr)
|
||||
+static inline void mlxsw_reg_mcia_pack(char *payload, u8 slot_index, u8 module,
|
||||
+ u8 lock, u8 page_number,
|
||||
+ u16 device_addr, u8 size,
|
||||
+ u8 i2c_device_addr)
|
||||
{
|
||||
MLXSW_REG_ZERO(mcia, payload);
|
||||
+ mlxsw_reg_mcia_slot_set(payload, slot_index);
|
||||
mlxsw_reg_mcia_module_set(payload, module);
|
||||
mlxsw_reg_mcia_l_set(payload, lock);
|
||||
mlxsw_reg_mcia_page_number_set(payload, page_number);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,69 +0,0 @@
|
||||
From aba06998f55ba715e6161a427356fccc17b466fc Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:50 +0200
|
||||
Subject: [PATCH backport 5.10 107/182] mlxsw: reg: Extend MCION register with
|
||||
new slot number field
|
||||
|
||||
Extend MCION (Management Cable IO and Notifications Register) with new
|
||||
field specifying the slot number. The purpose of this field is to
|
||||
support access to MCION register for query cage transceiver on modular
|
||||
system.
|
||||
|
||||
For non-modular systems the 'module' number uniquely identifies the
|
||||
transceiver location. For modular systems the transceivers are
|
||||
identified by two indexes:
|
||||
- 'slot_index', specifying the slot number, where line card is located;
|
||||
- 'module', specifying cage transceiver within the line card.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 9 ++++++++-
|
||||
2 files changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index a516c04ad19b..2ac8444aa8b2 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -458,7 +458,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
|
||||
params->policy = mlxsw_env->module_info[module].power_mode_policy;
|
||||
|
||||
- mlxsw_reg_mcion_pack(mcion_pl, module);
|
||||
+ mlxsw_reg_mcion_pack(mcion_pl, 0, module);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to retrieve module's power mode");
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index bdbe198a9053..acde0cd00944 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -9327,6 +9327,12 @@ MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8);
|
||||
|
||||
+/* reg_mcion_slot_index
|
||||
+ * Slot index.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mcion, slot_index, 0x00, 12, 4);
|
||||
+
|
||||
enum {
|
||||
MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0),
|
||||
MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8),
|
||||
@@ -9338,9 +9344,10 @@ enum {
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16);
|
||||
|
||||
-static inline void mlxsw_reg_mcion_pack(char *payload, u8 module)
|
||||
+static inline void mlxsw_reg_mcion_pack(char *payload, u8 slot_index, u8 module)
|
||||
{
|
||||
MLXSW_REG_ZERO(mcion, payload);
|
||||
+ mlxsw_reg_mcion_slot_index_set(payload, slot_index);
|
||||
mlxsw_reg_mcion_module_set(payload, module);
|
||||
}
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,68 +0,0 @@
|
||||
From 0aebe300b70a084161c12e813396025b255d91d7 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:51 +0200
|
||||
Subject: [PATCH backport 5.10 108/182] mlxsw: reg: Extend PMMP register with
|
||||
new slot number field
|
||||
|
||||
Extend PMMP (Port Module Memory Map Properties Register) with new
|
||||
field specifying the slot number. The purpose of this field is to
|
||||
enable overriding the cable/module memory map advertisement.
|
||||
|
||||
For non-modular systems the 'module' number uniquely identifies the
|
||||
transceiver location. For modular systems the transceivers are
|
||||
identified by two indexes:
|
||||
- 'slot_index', specifying the slot number, where line card is located;
|
||||
- 'module', specifying cage transceiver within the line card.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 2 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 9 ++++++++-
|
||||
2 files changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 2ac8444aa8b2..ad27a1c90f92 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -501,7 +501,7 @@ static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core,
|
||||
u16 eeprom_override_mask, eeprom_override;
|
||||
char pmmp_pl[MLXSW_REG_PMMP_LEN];
|
||||
|
||||
- mlxsw_reg_pmmp_pack(pmmp_pl, module);
|
||||
+ mlxsw_reg_pmmp_pack(pmmp_pl, 0, module);
|
||||
mlxsw_reg_pmmp_sticky_set(pmmp_pl, true);
|
||||
/* Mask all the bits except low power mode. */
|
||||
eeprom_override_mask = ~MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index acde0cd00944..aad0cb1497aa 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -5633,6 +5633,12 @@ MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8);
|
||||
|
||||
+/* reg_pmmp_slot_index
|
||||
+ * Slot index.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, pmmp, slot_index, 0x00, 24, 4);
|
||||
+
|
||||
/* reg_pmmp_sticky
|
||||
* When set, will keep eeprom_override values after plug-out event.
|
||||
* Access: OP
|
||||
@@ -5660,9 +5666,10 @@ enum {
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16);
|
||||
|
||||
-static inline void mlxsw_reg_pmmp_pack(char *payload, u8 module)
|
||||
+static inline void mlxsw_reg_pmmp_pack(char *payload, u8 slot_index, u8 module)
|
||||
{
|
||||
MLXSW_REG_ZERO(pmmp, payload);
|
||||
+ mlxsw_reg_pmmp_slot_index_set(payload, slot_index);
|
||||
mlxsw_reg_pmmp_module_set(payload, module);
|
||||
}
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,199 +0,0 @@
|
||||
From 441a7861ef61f4d0d55dee542d4704487694f68c Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 22 Dec 2021 06:11:50 +0000
|
||||
Subject: [PATCH backport 5.10 109/182] mlxsw: reg: Extend MGPIR register with
|
||||
new slot fields
|
||||
|
||||
Extend MGPIR (Management General Peripheral Information Register) with
|
||||
new fields specifying the slot number and number of the slots available
|
||||
on system. The purpose of these fields is:
|
||||
- to support access to MPGIR register on modular system for getting the
|
||||
number of cages, equipped on the line card, inserted at specified
|
||||
slot. In case slot number is set zero, MGPIR will provide the
|
||||
information for the main board. For Top of the Rack (non-modular)
|
||||
system it will provide the same as before.
|
||||
- to provide the number of slots supported by system. This data is
|
||||
relevant only in case slot number is set zero.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 4 ++--
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 9 +++++----
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 8 ++++----
|
||||
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 4 ++--
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 20 +++++++++++++++++--
|
||||
5 files changed, 31 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index ad27a1c90f92..8ab15d5bd7f5 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -983,12 +983,12 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
u8 module_count;
|
||||
int i, err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count);
|
||||
+ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL);
|
||||
|
||||
env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL);
|
||||
if (!env)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index f4bc711a16cf..2bc4c4556895 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -656,13 +656,13 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
u8 module_sensor_max;
|
||||
int i, err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
|
||||
- &module_sensor_max);
|
||||
+ &module_sensor_max, NULL);
|
||||
|
||||
/* Add extra attributes for module temperature. Sensor index is
|
||||
* assigned to sensor_count value, while all indexed before
|
||||
@@ -707,12 +707,13 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
u8 gbox_num;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL);
|
||||
+ mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL,
|
||||
+ NULL);
|
||||
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
|
||||
!gbox_num)
|
||||
return 0;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index f4f0f8ce8597..21a7415c8ef5 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -746,13 +746,13 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
int i, err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
|
||||
- &thermal->tz_module_num);
|
||||
+ &thermal->tz_module_num, NULL);
|
||||
|
||||
thermal->tz_module_arr = kcalloc(thermal->tz_module_num,
|
||||
sizeof(*thermal->tz_module_arr),
|
||||
@@ -837,13 +837,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
int i;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
|
||||
- NULL);
|
||||
+ NULL, NULL);
|
||||
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
|
||||
!gbox_num)
|
||||
return 0;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
index 3d07c2dcf08d..b2ffcfda8374 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
@@ -280,13 +280,13 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m)
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
int i, err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
|
||||
- &mlxsw_m->max_ports);
|
||||
+ &mlxsw_m->max_ports, NULL);
|
||||
if (!mlxsw_m->max_ports)
|
||||
return 0;
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index aad0cb1497aa..a5fa25d4bd8f 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10166,6 +10166,12 @@ enum mlxsw_reg_mgpir_device_type {
|
||||
MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
|
||||
};
|
||||
|
||||
+/* mgpir_slot_index
|
||||
+ * Slot index (0: Main board).
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
|
||||
+
|
||||
/* mgpir_device_type
|
||||
* Access: RO
|
||||
*/
|
||||
@@ -10183,21 +10189,29 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
|
||||
|
||||
+/* mgpir_num_of_slots
|
||||
+ * Number of slots in the system.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
|
||||
+
|
||||
/* mgpir_num_of_modules
|
||||
* Number of modules.
|
||||
* Access: RO
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
|
||||
|
||||
-static inline void mlxsw_reg_mgpir_pack(char *payload)
|
||||
+static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
|
||||
{
|
||||
MLXSW_REG_ZERO(mgpir, payload);
|
||||
+ mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
|
||||
}
|
||||
|
||||
static inline void
|
||||
mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
|
||||
enum mlxsw_reg_mgpir_device_type *device_type,
|
||||
- u8 *devices_per_flash, u8 *num_of_modules)
|
||||
+ u8 *devices_per_flash, u8 *num_of_modules,
|
||||
+ u8 *num_of_slots)
|
||||
{
|
||||
if (num_of_devices)
|
||||
*num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
|
||||
@@ -10208,6 +10222,8 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
|
||||
mlxsw_reg_mgpir_devices_per_flash_get(payload);
|
||||
if (num_of_modules)
|
||||
*num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
|
||||
+ if (num_of_slots)
|
||||
+ *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
|
||||
}
|
||||
|
||||
/* MFDE - Monitoring FW Debug Register
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,66 +0,0 @@
|
||||
From 7c2049bccef11b265fd4a4458b92277ea8ea97fc Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:52 +0200
|
||||
Subject: [PATCH backport 5.10 110/182] mlxsw: core_env: Pass slot index during
|
||||
PMAOS register write call
|
||||
|
||||
Pass the slot index down to PMAOS pack helper alongside with the module.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 6 +++---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 3 ++-
|
||||
2 files changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 8ab15d5bd7f5..b7c1fd3dbf45 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -398,7 +398,7 @@ static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
{
|
||||
char pmaos_pl[MLXSW_REG_PMAOS_LEN];
|
||||
|
||||
- mlxsw_reg_pmaos_pack(pmaos_pl, module);
|
||||
+ mlxsw_reg_pmaos_pack(pmaos_pl, 0, module);
|
||||
mlxsw_reg_pmaos_rst_set(pmaos_pl, true);
|
||||
|
||||
return mlxsw_reg_write(mlxsw_core, MLXSW_REG(pmaos), pmaos_pl);
|
||||
@@ -486,7 +486,7 @@ static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core,
|
||||
enum mlxsw_reg_pmaos_admin_status admin_status;
|
||||
char pmaos_pl[MLXSW_REG_PMAOS_LEN];
|
||||
|
||||
- mlxsw_reg_pmaos_pack(pmaos_pl, module);
|
||||
+ mlxsw_reg_pmaos_pack(pmaos_pl, 0, module);
|
||||
admin_status = enable ? MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED :
|
||||
MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED;
|
||||
mlxsw_reg_pmaos_admin_status_set(pmaos_pl, admin_status);
|
||||
@@ -876,7 +876,7 @@ mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core,
|
||||
for (i = 0; i < module_count; i++) {
|
||||
char pmaos_pl[MLXSW_REG_PMAOS_LEN];
|
||||
|
||||
- mlxsw_reg_pmaos_pack(pmaos_pl, i);
|
||||
+ mlxsw_reg_pmaos_pack(pmaos_pl, 0, i);
|
||||
mlxsw_reg_pmaos_e_set(pmaos_pl,
|
||||
MLXSW_REG_PMAOS_E_GENERATE_EVENT);
|
||||
mlxsw_reg_pmaos_ee_set(pmaos_pl, true);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index a5fa25d4bd8f..07f68fd1a4e5 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -5481,9 +5481,10 @@ enum mlxsw_reg_pmaos_e {
|
||||
*/
|
||||
MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2);
|
||||
|
||||
-static inline void mlxsw_reg_pmaos_pack(char *payload, u8 module)
|
||||
+static inline void mlxsw_reg_pmaos_pack(char *payload, u8 slot_index, u8 module)
|
||||
{
|
||||
MLXSW_REG_ZERO(pmaos, payload);
|
||||
+ mlxsw_reg_pmaos_slot_index_set(payload, slot_index);
|
||||
mlxsw_reg_pmaos_module_set(payload, module);
|
||||
}
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,38 +0,0 @@
|
||||
From 4b630e780a6fa8b387e79e252169d5743faf5321 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:49 +0200
|
||||
Subject: [PATCH backport 5.10 111/182] mlxsw: reg: Add new field to Management
|
||||
General Peripheral Information Register
|
||||
|
||||
Add new field 'max_modules_per_slot' to provide maximum number of
|
||||
modules that can be connected per slot. This field will always be zero,
|
||||
if 'slot_index' in query request is set to non-zero value, otherwise
|
||||
value in this field will provide maximum modules number, which can be
|
||||
equipped on device inserted at any slot.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 07f68fd1a4e5..98c627ffe039 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10190,6 +10190,12 @@ MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
|
||||
*/
|
||||
MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
|
||||
|
||||
+/* max_modules_per_slot
|
||||
+ * Maximum number of modules that can be connected per slot.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mgpir, max_modules_per_slot, 0x04, 16, 8);
|
||||
+
|
||||
/* mgpir_num_of_slots
|
||||
* Number of slots in the system.
|
||||
* Access: RO
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,828 +0,0 @@
|
||||
From 0b0f4813bdd0b4ed70074d616f68bb6c774662bc Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Fri, 3 Dec 2021 11:48:53 +0200
|
||||
Subject: [PATCH backport 5.10 112/182] mlxsw: core: Extend interfaces for
|
||||
cable info access with slot argument
|
||||
|
||||
Extend all cable info APIs with 'slot_index' argument.
|
||||
|
||||
For main board, slot will always be set to zero and these APIs will work
|
||||
as before. If reading cable information is required from cages located
|
||||
on line cards, slot should be set to the physical slot number, where
|
||||
line card is located in modular systems.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 172 +++++++++++-------
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.h | 43 +++--
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 10 +-
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 4 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 21 ++-
|
||||
.../net/ethernet/mellanox/mlxsw/spectrum.c | 2 +-
|
||||
.../mellanox/mlxsw/spectrum_ethtool.c | 10 +-
|
||||
7 files changed, 155 insertions(+), 107 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index b7c1fd3dbf45..fc4468a6b0f6 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -27,16 +27,18 @@ struct mlxsw_env {
|
||||
struct mlxsw_env_module_info module_info[];
|
||||
};
|
||||
|
||||
-static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
|
||||
- bool *qsfp, bool *cmis)
|
||||
+static int
|
||||
+mlxsw_env_validate_cable_ident(struct mlxsw_core *core, u8 slot_index, int id,
|
||||
+ bool *qsfp, bool *cmis)
|
||||
{
|
||||
char mcia_pl[MLXSW_REG_MCIA_LEN];
|
||||
char *eeprom_tmp;
|
||||
u8 ident;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, 0, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0,
|
||||
- 1, MLXSW_REG_MCIA_I2C_ADDR_LOW);
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, slot_index, id, 0,
|
||||
+ MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, 1,
|
||||
+ MLXSW_REG_MCIA_I2C_ADDR_LOW);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -64,8 +66,8 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
|
||||
}
|
||||
|
||||
static int
|
||||
-mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
|
||||
- u16 offset, u16 size, void *data,
|
||||
+mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ int module, u16 offset, u16 size, void *data,
|
||||
bool qsfp, unsigned int *p_read_size)
|
||||
{
|
||||
char mcia_pl[MLXSW_REG_MCIA_LEN];
|
||||
@@ -110,7 +112,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
|
||||
}
|
||||
}
|
||||
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, offset, size,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page, offset, size,
|
||||
i2c_addr);
|
||||
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcia), mcia_pl);
|
||||
@@ -128,8 +130,9 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
- int off, int *temp)
|
||||
+int
|
||||
+mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, u8 slot_index,
|
||||
+ int module, int off, int *temp)
|
||||
{
|
||||
unsigned int module_temp, module_crit, module_emerg;
|
||||
union {
|
||||
@@ -143,8 +146,9 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
int page;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
|
||||
- false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, slot_index,
|
||||
+ MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false,
|
||||
+ false);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -173,7 +177,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
*/
|
||||
|
||||
/* Validate module identifier value. */
|
||||
- err = mlxsw_env_validate_cable_ident(core, module, &qsfp, &cmis);
|
||||
+ err = mlxsw_env_validate_cable_ident(core, slot_index, module, &qsfp,
|
||||
+ &cmis);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -185,12 +190,12 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM;
|
||||
else
|
||||
page = MLXSW_REG_MCIA_TH_PAGE_NUM;
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page,
|
||||
MLXSW_REG_MCIA_TH_PAGE_OFF + off,
|
||||
MLXSW_REG_MCIA_TH_ITEM_SIZE,
|
||||
MLXSW_REG_MCIA_I2C_ADDR_LOW);
|
||||
} else {
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0,
|
||||
MLXSW_REG_MCIA_PAGE0_LO,
|
||||
off, MLXSW_REG_MCIA_TH_ITEM_SIZE,
|
||||
MLXSW_REG_MCIA_I2C_ADDR_HIGH);
|
||||
@@ -207,8 +212,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
|
||||
- struct ethtool_modinfo *modinfo)
|
||||
+int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ int module, struct ethtool_modinfo *modinfo)
|
||||
{
|
||||
u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE];
|
||||
u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE;
|
||||
@@ -216,8 +221,9 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
|
||||
unsigned int read_size;
|
||||
int err;
|
||||
|
||||
- err = mlxsw_env_query_module_eeprom(mlxsw_core, module, 0, offset,
|
||||
- module_info, false, &read_size);
|
||||
+ err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, module, 0,
|
||||
+ offset, module_info, false,
|
||||
+ &read_size);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -246,9 +252,10 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
|
||||
break;
|
||||
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
|
||||
/* Verify if transceiver provides diagnostic monitoring page */
|
||||
- err = mlxsw_env_query_module_eeprom(mlxsw_core, module,
|
||||
- SFP_DIAGMON, 1, &diag_mon,
|
||||
- false, &read_size);
|
||||
+ err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index,
|
||||
+ module, SFP_DIAGMON, 1,
|
||||
+ &diag_mon, false,
|
||||
+ &read_size);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -286,8 +293,9 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
|
||||
EXPORT_SYMBOL(mlxsw_env_get_module_info);
|
||||
|
||||
int mlxsw_env_get_module_eeprom(struct net_device *netdev,
|
||||
- struct mlxsw_core *mlxsw_core, int module,
|
||||
- struct ethtool_eeprom *ee, u8 *data)
|
||||
+ struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ int module, struct ethtool_eeprom *ee,
|
||||
+ u8 *data)
|
||||
{
|
||||
int offset = ee->offset;
|
||||
unsigned int read_size;
|
||||
@@ -300,12 +308,14 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev,
|
||||
|
||||
memset(data, 0, ee->len);
|
||||
/* Validate module identifier value. */
|
||||
- err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp, &cmis);
|
||||
+ err = mlxsw_env_validate_cable_ident(mlxsw_core, slot_index, module,
|
||||
+ &qsfp, &cmis);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
while (i < ee->len) {
|
||||
- err = mlxsw_env_query_module_eeprom(mlxsw_core, module, offset,
|
||||
+ err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index,
|
||||
+ module, offset,
|
||||
ee->len - i, data + i,
|
||||
qsfp, &read_size);
|
||||
if (err) {
|
||||
@@ -351,7 +361,8 @@ static int mlxsw_env_mcia_status_process(const char *mcia_pl,
|
||||
}
|
||||
|
||||
int
|
||||
-mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
+mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core,
|
||||
+ u8 slot_index, u8 module,
|
||||
const struct ethtool_module_eeprom *page,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
@@ -370,7 +381,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
size = min_t(u8, page->length - bytes_read,
|
||||
MLXSW_REG_MCIA_EEPROM_SIZE);
|
||||
|
||||
- mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page->page,
|
||||
+ mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page->page,
|
||||
device_addr + bytes_read, size,
|
||||
page->i2c_address);
|
||||
mlxsw_reg_mcia_bank_number_set(mcia_pl, page->bank);
|
||||
@@ -394,18 +405,20 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_get_module_eeprom_by_page);
|
||||
|
||||
-static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
+static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module)
|
||||
{
|
||||
char pmaos_pl[MLXSW_REG_PMAOS_LEN];
|
||||
|
||||
- mlxsw_reg_pmaos_pack(pmaos_pl, 0, module);
|
||||
+ mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, module);
|
||||
mlxsw_reg_pmaos_rst_set(pmaos_pl, true);
|
||||
|
||||
return mlxsw_reg_write(mlxsw_core, MLXSW_REG(pmaos), pmaos_pl);
|
||||
}
|
||||
|
||||
int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
- struct mlxsw_core *mlxsw_core, u8 module, u32 *flags)
|
||||
+ struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module, u32 *flags)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
u32 req = *flags;
|
||||
@@ -430,7 +443,7 @@ int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
goto out;
|
||||
}
|
||||
|
||||
- err = mlxsw_env_module_reset(mlxsw_core, module);
|
||||
+ err = mlxsw_env_module_reset(mlxsw_core, slot_index, module);
|
||||
if (err) {
|
||||
netdev_err(netdev, "Failed to reset module\n");
|
||||
goto out;
|
||||
@@ -445,7 +458,8 @@ int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
EXPORT_SYMBOL(mlxsw_env_reset_module);
|
||||
|
||||
int
|
||||
-mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
+mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module,
|
||||
struct ethtool_module_power_mode_params *params,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
@@ -458,7 +472,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
|
||||
params->policy = mlxsw_env->module_info[module].power_mode_policy;
|
||||
|
||||
- mlxsw_reg_mcion_pack(mcion_pl, 0, module);
|
||||
+ mlxsw_reg_mcion_pack(mcion_pl, slot_index, module);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to retrieve module's power mode");
|
||||
@@ -481,12 +495,12 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
EXPORT_SYMBOL(mlxsw_env_get_module_power_mode);
|
||||
|
||||
static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core,
|
||||
- u8 module, bool enable)
|
||||
+ u8 slot_index, u8 module, bool enable)
|
||||
{
|
||||
enum mlxsw_reg_pmaos_admin_status admin_status;
|
||||
char pmaos_pl[MLXSW_REG_PMAOS_LEN];
|
||||
|
||||
- mlxsw_reg_pmaos_pack(pmaos_pl, 0, module);
|
||||
+ mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, module);
|
||||
admin_status = enable ? MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED :
|
||||
MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED;
|
||||
mlxsw_reg_pmaos_admin_status_set(pmaos_pl, admin_status);
|
||||
@@ -496,12 +510,13 @@ static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core,
|
||||
- u8 module, bool low_power)
|
||||
+ u8 slot_index, u8 module,
|
||||
+ bool low_power)
|
||||
{
|
||||
u16 eeprom_override_mask, eeprom_override;
|
||||
char pmmp_pl[MLXSW_REG_PMMP_LEN];
|
||||
|
||||
- mlxsw_reg_pmmp_pack(pmmp_pl, 0, module);
|
||||
+ mlxsw_reg_pmmp_pack(pmmp_pl, slot_index, module);
|
||||
mlxsw_reg_pmmp_sticky_set(pmmp_pl, true);
|
||||
/* Mask all the bits except low power mode. */
|
||||
eeprom_override_mask = ~MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK;
|
||||
@@ -514,24 +529,26 @@ static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core,
|
||||
- u8 module, bool low_power,
|
||||
+ u8 slot_index, u8 module,
|
||||
+ bool low_power,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
int err;
|
||||
|
||||
- err = mlxsw_env_module_enable_set(mlxsw_core, module, false);
|
||||
+ err = mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, false);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to disable module");
|
||||
return err;
|
||||
}
|
||||
|
||||
- err = mlxsw_env_module_low_power_set(mlxsw_core, module, low_power);
|
||||
+ err = mlxsw_env_module_low_power_set(mlxsw_core, slot_index, module,
|
||||
+ low_power);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to set module's power mode");
|
||||
goto err_module_low_power_set;
|
||||
}
|
||||
|
||||
- err = mlxsw_env_module_enable_set(mlxsw_core, module, true);
|
||||
+ err = mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, true);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to enable module");
|
||||
goto err_module_enable_set;
|
||||
@@ -540,14 +557,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core,
|
||||
return 0;
|
||||
|
||||
err_module_enable_set:
|
||||
- mlxsw_env_module_low_power_set(mlxsw_core, module, !low_power);
|
||||
+ mlxsw_env_module_low_power_set(mlxsw_core, slot_index, module,
|
||||
+ !low_power);
|
||||
err_module_low_power_set:
|
||||
- mlxsw_env_module_enable_set(mlxsw_core, module, true);
|
||||
+ mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, true);
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
-mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
+mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module,
|
||||
enum ethtool_module_power_mode_policy policy,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
@@ -571,8 +590,8 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
goto out_set_policy;
|
||||
|
||||
low_power = policy == ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO;
|
||||
- err = __mlxsw_env_set_module_power_mode(mlxsw_core, module, low_power,
|
||||
- extack);
|
||||
+ err = __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module,
|
||||
+ low_power, extack);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
@@ -585,14 +604,14 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);
|
||||
|
||||
static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core,
|
||||
- u8 module,
|
||||
+ u8 slot_index, u8 module,
|
||||
bool *p_has_temp_sensor)
|
||||
{
|
||||
char mtbr_pl[MLXSW_REG_MTBR_LEN];
|
||||
u16 temp;
|
||||
int err;
|
||||
|
||||
- mlxsw_reg_mtbr_pack(mtbr_pl, 0,
|
||||
+ mlxsw_reg_mtbr_pack(mtbr_pl, slot_index,
|
||||
MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtbr), mtbr_pl);
|
||||
if (err)
|
||||
@@ -613,13 +632,15 @@ static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core,
|
||||
- u16 sensor_index, bool enable)
|
||||
+static int
|
||||
+mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u16 sensor_index, bool enable)
|
||||
{
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
|
||||
enum mlxsw_reg_mtmp_tee tee;
|
||||
int err, threshold_hi;
|
||||
|
||||
+ mlxsw_reg_mtmp_slot_index_set(mtmp_pl, slot_index);
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, sensor_index);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err)
|
||||
@@ -627,6 +648,7 @@ static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
if (enable) {
|
||||
err = mlxsw_env_module_temp_thresholds_get(mlxsw_core,
|
||||
+ slot_index,
|
||||
sensor_index -
|
||||
MLXSW_REG_MTMP_MODULE_INDEX_MIN,
|
||||
SFP_TEMP_HIGH_WARN,
|
||||
@@ -654,14 +676,14 @@ static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core,
|
||||
- u8 module_count)
|
||||
+ u8 slot_index, u8 module_count)
|
||||
{
|
||||
int i, err, sensor_index;
|
||||
bool has_temp_sensor;
|
||||
|
||||
for (i = 0; i < module_count; i++) {
|
||||
- err = mlxsw_env_module_has_temp_sensor(mlxsw_core, i,
|
||||
- &has_temp_sensor);
|
||||
+ err = mlxsw_env_module_has_temp_sensor(mlxsw_core, slot_index,
|
||||
+ i, &has_temp_sensor);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -669,7 +691,8 @@ static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core,
|
||||
continue;
|
||||
|
||||
sensor_index = i + MLXSW_REG_MTMP_MODULE_INDEX_MIN;
|
||||
- err = mlxsw_env_temp_event_set(mlxsw_core, sensor_index, true);
|
||||
+ err = mlxsw_env_temp_event_set(mlxsw_core, slot_index,
|
||||
+ sensor_index, true);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
@@ -776,6 +799,7 @@ static void mlxsw_env_temp_warn_event_unregister(struct mlxsw_env *mlxsw_env)
|
||||
|
||||
struct mlxsw_env_module_plug_unplug_event {
|
||||
struct mlxsw_env *mlxsw_env;
|
||||
+ u8 slot_index;
|
||||
u8 module;
|
||||
struct work_struct work;
|
||||
};
|
||||
@@ -796,7 +820,9 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work)
|
||||
mlxsw_env->module_info[event->module].is_overheat = false;
|
||||
mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
|
||||
- err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, event->module,
|
||||
+ err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core,
|
||||
+ event->slot_index,
|
||||
+ event->module,
|
||||
&has_temp_sensor);
|
||||
/* Do not disable events on modules without sensors or faulty sensors
|
||||
* because FW returns errors.
|
||||
@@ -808,7 +834,8 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work)
|
||||
goto out;
|
||||
|
||||
sensor_index = event->module + MLXSW_REG_MTMP_MODULE_INDEX_MIN;
|
||||
- mlxsw_env_temp_event_set(mlxsw_env->core, sensor_index, true);
|
||||
+ mlxsw_env_temp_event_set(mlxsw_env->core, event->slot_index,
|
||||
+ sensor_index, true);
|
||||
|
||||
out:
|
||||
kfree(event);
|
||||
@@ -835,6 +862,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl,
|
||||
return;
|
||||
|
||||
event->mlxsw_env = mlxsw_env;
|
||||
+ event->slot_index = 0;
|
||||
event->module = module;
|
||||
INIT_WORK(&event->work, mlxsw_env_pmpe_event_work);
|
||||
mlxsw_core_schedule_work(&event->work);
|
||||
@@ -869,14 +897,14 @@ mlxsw_env_module_plug_event_unregister(struct mlxsw_env *mlxsw_env)
|
||||
|
||||
static int
|
||||
mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core,
|
||||
- u8 module_count)
|
||||
+ u8 slot_index, u8 module_count)
|
||||
{
|
||||
int i, err;
|
||||
|
||||
for (i = 0; i < module_count; i++) {
|
||||
char pmaos_pl[MLXSW_REG_PMAOS_LEN];
|
||||
|
||||
- mlxsw_reg_pmaos_pack(pmaos_pl, 0, i);
|
||||
+ mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, i);
|
||||
mlxsw_reg_pmaos_e_set(pmaos_pl,
|
||||
MLXSW_REG_PMAOS_E_GENERATE_EVENT);
|
||||
mlxsw_reg_pmaos_ee_set(pmaos_pl, true);
|
||||
@@ -888,8 +916,8 @@ mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
int
|
||||
-mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
- u64 *p_counter)
|
||||
+mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module, u64 *p_counter)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
@@ -901,7 +929,8 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_overheat_counter_get);
|
||||
|
||||
-void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
+void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
@@ -911,7 +940,8 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_map);
|
||||
|
||||
-void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
+void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
@@ -921,7 +951,8 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_unmap);
|
||||
|
||||
-int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
+int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
int err = 0;
|
||||
@@ -938,8 +969,8 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
/* Transition to high power mode following first port using the module
|
||||
* being put administratively up.
|
||||
*/
|
||||
- err = __mlxsw_env_set_module_power_mode(mlxsw_core, module, false,
|
||||
- NULL);
|
||||
+ err = __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module,
|
||||
+ false, NULL);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
@@ -951,7 +982,8 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_up);
|
||||
|
||||
-void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
+void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
|
||||
@@ -969,7 +1001,8 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module)
|
||||
/* Transition to low power mode following last port using the module
|
||||
* being put administratively down.
|
||||
*/
|
||||
- __mlxsw_env_set_module_power_mode(mlxsw_core, module, true, NULL);
|
||||
+ __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, true,
|
||||
+ NULL);
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
@@ -1014,12 +1047,13 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
if (err)
|
||||
goto err_module_plug_event_register;
|
||||
|
||||
- err = mlxsw_env_module_oper_state_event_enable(mlxsw_core,
|
||||
+ err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0,
|
||||
env->module_count);
|
||||
if (err)
|
||||
goto err_oper_state_event_enable;
|
||||
|
||||
- err = mlxsw_env_module_temp_event_enable(mlxsw_core, env->module_count);
|
||||
+ err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0,
|
||||
+ env->module_count);
|
||||
if (err)
|
||||
goto err_temp_event_enable;
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.h b/drivers/net/ethernet/mellanox/mlxsw/core_env.h
|
||||
index da121b1a84b4..03d027870d65 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.h
|
||||
@@ -9,46 +9,55 @@
|
||||
struct ethtool_modinfo;
|
||||
struct ethtool_eeprom;
|
||||
|
||||
-int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
|
||||
- int off, int *temp);
|
||||
+int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core,
|
||||
+ u8 slot_index, int module, int off,
|
||||
+ int *temp);
|
||||
|
||||
-int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
|
||||
- struct ethtool_modinfo *modinfo);
|
||||
+int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ int module, struct ethtool_modinfo *modinfo);
|
||||
|
||||
int mlxsw_env_get_module_eeprom(struct net_device *netdev,
|
||||
- struct mlxsw_core *mlxsw_core, int module,
|
||||
- struct ethtool_eeprom *ee, u8 *data);
|
||||
+ struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ int module, struct ethtool_eeprom *ee,
|
||||
+ u8 *data);
|
||||
|
||||
int
|
||||
-mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
+mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core,
|
||||
+ u8 slot_index, u8 module,
|
||||
const struct ethtool_module_eeprom *page,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
- struct mlxsw_core *mlxsw_core, u8 module,
|
||||
- u32 *flags);
|
||||
+ struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module, u32 *flags);
|
||||
|
||||
int
|
||||
-mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
+mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module,
|
||||
struct ethtool_module_power_mode_params *params,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
int
|
||||
-mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
+mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module,
|
||||
enum ethtool_module_power_mode_policy policy,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
int
|
||||
-mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module,
|
||||
- u64 *p_counter);
|
||||
+mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module, u64 *p_counter);
|
||||
|
||||
-void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module);
|
||||
+void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module);
|
||||
|
||||
-void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module);
|
||||
+void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module);
|
||||
|
||||
-int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module);
|
||||
+int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module);
|
||||
|
||||
-void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module);
|
||||
+void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ u8 module);
|
||||
|
||||
int mlxsw_env_init(struct mlxsw_core *core, struct mlxsw_env **p_env);
|
||||
void mlxsw_env_fini(struct mlxsw_env *env);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 2bc4c4556895..5df54a5bf292 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -311,8 +311,9 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module,
|
||||
- SFP_TEMP_HIGH_WARN, p_temp);
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
|
||||
+ module, SFP_TEMP_HIGH_WARN,
|
||||
+ p_temp);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to query module temperature thresholds\n");
|
||||
return err;
|
||||
@@ -345,8 +346,9 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module,
|
||||
- SFP_TEMP_HIGH_ALARM, p_temp);
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
|
||||
+ module, SFP_TEMP_HIGH_ALARM,
|
||||
+ p_temp);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to query module temperature thresholds\n");
|
||||
return err;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 21a7415c8ef5..4f84c4bb66af 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -151,13 +151,13 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
|
||||
* EEPROM if we got valid thresholds from MTMP.
|
||||
*/
|
||||
if (!emerg_temp || !crit_temp) {
|
||||
- err = mlxsw_env_module_temp_thresholds_get(core, tz->module,
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module,
|
||||
SFP_TEMP_HIGH_WARN,
|
||||
&crit_temp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- err = mlxsw_env_module_temp_thresholds_get(core, tz->module,
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module,
|
||||
SFP_TEMP_HIGH_ALARM,
|
||||
&emerg_temp);
|
||||
if (err)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
index b2ffcfda8374..104f1ba0242f 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
@@ -59,7 +59,8 @@ static int mlxsw_m_port_open(struct net_device *dev)
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
|
||||
struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
|
||||
|
||||
- return mlxsw_env_module_port_up(mlxsw_m->core, mlxsw_m_port->module);
|
||||
+ return mlxsw_env_module_port_up(mlxsw_m->core, 0,
|
||||
+ mlxsw_m_port->module);
|
||||
}
|
||||
|
||||
static int mlxsw_m_port_stop(struct net_device *dev)
|
||||
@@ -67,7 +68,7 @@ static int mlxsw_m_port_stop(struct net_device *dev)
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
|
||||
struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
|
||||
|
||||
- mlxsw_env_module_port_down(mlxsw_m->core, mlxsw_m_port->module);
|
||||
+ mlxsw_env_module_port_down(mlxsw_m->core, 0, mlxsw_m_port->module);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -110,7 +111,8 @@ static int mlxsw_m_get_module_info(struct net_device *netdev,
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
|
||||
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
|
||||
|
||||
- return mlxsw_env_get_module_info(core, mlxsw_m_port->module, modinfo);
|
||||
+ return mlxsw_env_get_module_info(core, 0, mlxsw_m_port->module,
|
||||
+ modinfo);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -120,8 +122,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee,
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
|
||||
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
|
||||
|
||||
- return mlxsw_env_get_module_eeprom(netdev, core, mlxsw_m_port->module,
|
||||
- ee, data);
|
||||
+ return mlxsw_env_get_module_eeprom(netdev, core, 0,
|
||||
+ mlxsw_m_port->module, ee, data);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -132,7 +134,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev,
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
|
||||
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
|
||||
|
||||
- return mlxsw_env_get_module_eeprom_by_page(core, mlxsw_m_port->module,
|
||||
+ return mlxsw_env_get_module_eeprom_by_page(core, 0,
|
||||
+ mlxsw_m_port->module,
|
||||
page, extack);
|
||||
}
|
||||
|
||||
@@ -141,7 +144,7 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags)
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
|
||||
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
|
||||
|
||||
- return mlxsw_env_reset_module(netdev, core, mlxsw_m_port->module,
|
||||
+ return mlxsw_env_reset_module(netdev, core, 0, mlxsw_m_port->module,
|
||||
flags);
|
||||
}
|
||||
|
||||
@@ -153,7 +156,7 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev,
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
|
||||
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
|
||||
|
||||
- return mlxsw_env_get_module_power_mode(core, mlxsw_m_port->module,
|
||||
+ return mlxsw_env_get_module_power_mode(core, 0, mlxsw_m_port->module,
|
||||
params, extack);
|
||||
}
|
||||
|
||||
@@ -165,7 +168,7 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev,
|
||||
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
|
||||
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
|
||||
|
||||
- return mlxsw_env_set_module_power_mode(core, mlxsw_m_port->module,
|
||||
+ return mlxsw_env_set_module_power_mode(core, 0, mlxsw_m_port->module,
|
||||
params->policy, extack);
|
||||
}
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
index 4110e15c22c7..e0424f490c6f 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
@@ -1377,7 +1377,7 @@ static int mlxsw_sp_port_overheat_init_val_set(struct mlxsw_sp_port *mlxsw_sp_po
|
||||
u64 overheat_counter;
|
||||
int err;
|
||||
|
||||
- err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, module,
|
||||
+ err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, 0, module,
|
||||
&overheat_counter);
|
||||
if (err)
|
||||
return err;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
|
||||
index 369b9d0dc5d4..c9298b236182 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
|
||||
@@ -566,7 +566,7 @@ mlxsw_sp_port_get_transceiver_overheat_stats(struct mlxsw_sp_port *mlxsw_sp_port
|
||||
u64 stats;
|
||||
int err;
|
||||
|
||||
- err = mlxsw_env_module_overheat_counter_get(mlxsw_core,
|
||||
+ err = mlxsw_env_module_overheat_counter_get(mlxsw_core, 0,
|
||||
port_mapping.module,
|
||||
&stats);
|
||||
if (err)
|
||||
@@ -1032,7 +1032,7 @@ static int mlxsw_sp_get_module_info(struct net_device *netdev,
|
||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||
int err;
|
||||
|
||||
- err = mlxsw_env_get_module_info(mlxsw_sp->core,
|
||||
+ err = mlxsw_env_get_module_info(mlxsw_sp->core, 0,
|
||||
mlxsw_sp_port->mapping.module,
|
||||
modinfo);
|
||||
|
||||
@@ -1046,7 +1046,7 @@ static int mlxsw_sp_get_module_eeprom(struct net_device *netdev,
|
||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||
int err;
|
||||
|
||||
- err = mlxsw_env_get_module_eeprom(netdev, mlxsw_sp->core,
|
||||
+ err = mlxsw_env_get_module_eeprom(netdev, mlxsw_sp->core, 0,
|
||||
mlxsw_sp_port->mapping.module, ee,
|
||||
data);
|
||||
|
||||
@@ -1062,8 +1062,8 @@ mlxsw_sp_get_module_eeprom_by_page(struct net_device *dev,
|
||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||
u8 module = mlxsw_sp_port->mapping.module;
|
||||
|
||||
- return mlxsw_env_get_module_eeprom_by_page(mlxsw_sp->core, module, page,
|
||||
- extack);
|
||||
+ return mlxsw_env_get_module_eeprom_by_page(mlxsw_sp->core, 0, module,
|
||||
+ page, extack);
|
||||
}
|
||||
|
||||
static int
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,520 +0,0 @@
|
||||
From fe0bf4454c709fa1ddb5fa105e88f2d57cb5ef5a Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:27 +0200
|
||||
Subject: [PATCH backport 5.10 113/182] mlxsw: core: Extend port module data
|
||||
structures for line cards
|
||||
|
||||
The port module core is tasked with module operations such as setting
|
||||
power mode policy and reset. The per-module information is currently
|
||||
stored in one large array suited for non-modular systems where only the
|
||||
main board is present (i.e., slot index 0).
|
||||
|
||||
As a preparation for line cards support, allocate a per line card array
|
||||
according to the queried number of slots in the system. For each line
|
||||
card, allocate a module array according to the queried maximum number of
|
||||
modules per-slot.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 223 ++++++++++++------
|
||||
1 file changed, 157 insertions(+), 66 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index fc4468a6b0f6..606d89b6f50f 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -20,13 +20,19 @@ struct mlxsw_env_module_info {
|
||||
enum ethtool_module_power_mode_policy power_mode_policy;
|
||||
};
|
||||
|
||||
-struct mlxsw_env {
|
||||
- struct mlxsw_core *core;
|
||||
+struct mlxsw_env_module_line_cards {
|
||||
u8 module_count;
|
||||
- struct mutex module_info_lock; /* Protects 'module_info'. */
|
||||
struct mlxsw_env_module_info module_info[];
|
||||
};
|
||||
|
||||
+struct mlxsw_env {
|
||||
+ struct mlxsw_core *core;
|
||||
+ u8 max_module_count; /* Maximum number of modules per-slot. */
|
||||
+ u8 num_of_slots; /* Including the main board. */
|
||||
+ struct mutex line_cards_lock; /* Protects line cards. */
|
||||
+ struct mlxsw_env_module_line_cards *line_cards[];
|
||||
+};
|
||||
+
|
||||
static int
|
||||
mlxsw_env_validate_cable_ident(struct mlxsw_core *core, u8 slot_index, int id,
|
||||
bool *qsfp, bool *cmis)
|
||||
@@ -405,6 +411,15 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_get_module_eeprom_by_page);
|
||||
|
||||
+static struct
|
||||
+mlxsw_env_module_info *mlxsw_env_module_info_get(struct mlxsw_core *mlxsw_core,
|
||||
+ u8 slot_index, u8 module)
|
||||
+{
|
||||
+ struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+
|
||||
+ return &mlxsw_env->line_cards[slot_index]->module_info[module];
|
||||
+}
|
||||
+
|
||||
static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module)
|
||||
{
|
||||
@@ -421,6 +436,7 @@ int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
u8 module, u32 *flags)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
u32 req = *flags;
|
||||
int err;
|
||||
|
||||
@@ -428,15 +444,16 @@ int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
!(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT)))
|
||||
return 0;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
- if (mlxsw_env->module_info[module].num_ports_up) {
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ if (module_info->num_ports_up) {
|
||||
netdev_err(netdev, "Cannot reset module when ports using it are administratively up\n");
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (mlxsw_env->module_info[module].num_ports_mapped > 1 &&
|
||||
+ if (module_info->num_ports_mapped > 1 &&
|
||||
!(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) {
|
||||
netdev_err(netdev, "Cannot reset module without \"phy-shared\" flag when shared by multiple ports\n");
|
||||
err = -EINVAL;
|
||||
@@ -452,7 +469,7 @@ int mlxsw_env_reset_module(struct net_device *netdev,
|
||||
*flags &= ~(ETH_RESET_PHY | (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT));
|
||||
|
||||
out:
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_reset_module);
|
||||
@@ -464,13 +481,15 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
char mcion_pl[MLXSW_REG_MCION_LEN];
|
||||
u32 status_bits;
|
||||
int err;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
- params->policy = mlxsw_env->module_info[module].power_mode_policy;
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ params->policy = module_info->power_mode_policy;
|
||||
|
||||
mlxsw_reg_mcion_pack(mcion_pl, slot_index, module);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl);
|
||||
@@ -489,7 +508,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
params->mode = ETHTOOL_MODULE_POWER_MODE_HIGH;
|
||||
|
||||
out:
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_get_module_power_mode);
|
||||
@@ -571,6 +590,7 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
bool low_power;
|
||||
int err = 0;
|
||||
|
||||
@@ -580,13 +600,14 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
- if (mlxsw_env->module_info[module].power_mode_policy == policy)
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ if (module_info->power_mode_policy == policy)
|
||||
goto out;
|
||||
|
||||
/* If any ports are up, we are already in high power mode. */
|
||||
- if (mlxsw_env->module_info[module].num_ports_up)
|
||||
+ if (module_info->num_ports_up)
|
||||
goto out_set_policy;
|
||||
|
||||
low_power = policy == ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO;
|
||||
@@ -596,9 +617,9 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
goto out;
|
||||
|
||||
out_set_policy:
|
||||
- mlxsw_env->module_info[module].power_mode_policy = policy;
|
||||
+ module_info->power_mode_policy = policy;
|
||||
out:
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);
|
||||
@@ -709,6 +730,7 @@ struct mlxsw_env_module_temp_warn_event {
|
||||
static void mlxsw_env_mtwe_event_work(struct work_struct *work)
|
||||
{
|
||||
struct mlxsw_env_module_temp_warn_event *event;
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
struct mlxsw_env *mlxsw_env;
|
||||
int i, sensor_warning;
|
||||
bool is_overheat;
|
||||
@@ -717,7 +739,7 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work)
|
||||
work);
|
||||
mlxsw_env = event->mlxsw_env;
|
||||
|
||||
- for (i = 0; i < mlxsw_env->module_count; i++) {
|
||||
+ for (i = 0; i < mlxsw_env->max_module_count; i++) {
|
||||
/* 64-127 of sensor_index are mapped to the port modules
|
||||
* sequentially (module 0 is mapped to sensor_index 64,
|
||||
* module 1 to sensor_index 65 and so on)
|
||||
@@ -725,9 +747,10 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work)
|
||||
sensor_warning =
|
||||
mlxsw_reg_mtwe_sensor_warning_get(event->mtwe_pl,
|
||||
i + MLXSW_REG_MTMP_MODULE_INDEX_MIN);
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
- is_overheat =
|
||||
- mlxsw_env->module_info[i].is_overheat;
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
+ /* MTWE only supports main board. */
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_env->core, 0, i);
|
||||
+ is_overheat = module_info->is_overheat;
|
||||
|
||||
if ((is_overheat && sensor_warning) ||
|
||||
(!is_overheat && !sensor_warning)) {
|
||||
@@ -735,21 +758,21 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work)
|
||||
* warning OR current state in "no warning" and MTWE
|
||||
* does not report warning.
|
||||
*/
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
continue;
|
||||
} else if (is_overheat && !sensor_warning) {
|
||||
/* MTWE reports "no warning", turn is_overheat off.
|
||||
*/
|
||||
- mlxsw_env->module_info[i].is_overheat = false;
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ module_info->is_overheat = false;
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
} else {
|
||||
/* Current state is "no warning" and MTWE reports
|
||||
* "warning", increase the counter and turn is_overheat
|
||||
* on.
|
||||
*/
|
||||
- mlxsw_env->module_info[i].is_overheat = true;
|
||||
- mlxsw_env->module_info[i].module_overheat_counter++;
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ module_info->is_overheat = true;
|
||||
+ module_info->module_overheat_counter++;
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,6 +830,7 @@ struct mlxsw_env_module_plug_unplug_event {
|
||||
static void mlxsw_env_pmpe_event_work(struct work_struct *work)
|
||||
{
|
||||
struct mlxsw_env_module_plug_unplug_event *event;
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
struct mlxsw_env *mlxsw_env;
|
||||
bool has_temp_sensor;
|
||||
u16 sensor_index;
|
||||
@@ -816,9 +840,12 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work)
|
||||
work);
|
||||
mlxsw_env = event->mlxsw_env;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
- mlxsw_env->module_info[event->module].is_overheat = false;
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_env->core,
|
||||
+ event->slot_index,
|
||||
+ event->module);
|
||||
+ module_info->is_overheat = false;
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core,
|
||||
event->slot_index,
|
||||
@@ -845,12 +872,14 @@ static void
|
||||
mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl,
|
||||
void *priv)
|
||||
{
|
||||
+ u8 slot_index = mlxsw_reg_pmpe_slot_index_get(pmpe_pl);
|
||||
struct mlxsw_env_module_plug_unplug_event *event;
|
||||
enum mlxsw_reg_pmpe_module_status module_status;
|
||||
u8 module = mlxsw_reg_pmpe_module_get(pmpe_pl);
|
||||
struct mlxsw_env *mlxsw_env = priv;
|
||||
|
||||
- if (WARN_ON_ONCE(module >= mlxsw_env->module_count))
|
||||
+ if (WARN_ON_ONCE(module >= mlxsw_env->max_module_count ||
|
||||
+ slot_index >= mlxsw_env->num_of_slots))
|
||||
return;
|
||||
|
||||
module_status = mlxsw_reg_pmpe_module_status_get(pmpe_pl);
|
||||
@@ -862,7 +891,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl,
|
||||
return;
|
||||
|
||||
event->mlxsw_env = mlxsw_env;
|
||||
- event->slot_index = 0;
|
||||
+ event->slot_index = slot_index;
|
||||
event->module = module;
|
||||
INIT_WORK(&event->work, mlxsw_env_pmpe_event_work);
|
||||
mlxsw_core_schedule_work(&event->work);
|
||||
@@ -920,10 +949,12 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_ind
|
||||
u8 module, u64 *p_counter)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
- *p_counter = mlxsw_env->module_info[module].module_overheat_counter;
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ *p_counter = module_info->module_overheat_counter;
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -933,10 +964,12 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
- mlxsw_env->module_info[module].num_ports_mapped++;
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ module_info->num_ports_mapped++;
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_map);
|
||||
|
||||
@@ -944,10 +977,12 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
- mlxsw_env->module_info[module].num_ports_mapped--;
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ module_info->num_ports_mapped--;
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_unmap);
|
||||
|
||||
@@ -955,15 +990,17 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
int err = 0;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
- if (mlxsw_env->module_info[module].power_mode_policy !=
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ if (module_info->power_mode_policy !=
|
||||
ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO)
|
||||
goto out_inc;
|
||||
|
||||
- if (mlxsw_env->module_info[module].num_ports_up != 0)
|
||||
+ if (module_info->num_ports_up != 0)
|
||||
goto out_inc;
|
||||
|
||||
/* Transition to high power mode following first port using the module
|
||||
@@ -975,9 +1012,9 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
goto out_unlock;
|
||||
|
||||
out_inc:
|
||||
- mlxsw_env->module_info[module].num_ports_up++;
|
||||
+ module_info->num_ports_up++;
|
||||
out_unlock:
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_up);
|
||||
@@ -986,16 +1023,18 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
|
||||
- mutex_lock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
- mlxsw_env->module_info[module].num_ports_up--;
|
||||
+ module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module);
|
||||
+ module_info->num_ports_up--;
|
||||
|
||||
- if (mlxsw_env->module_info[module].power_mode_policy !=
|
||||
+ if (module_info->power_mode_policy !=
|
||||
ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO)
|
||||
goto out_unlock;
|
||||
|
||||
- if (mlxsw_env->module_info[module].num_ports_up != 0)
|
||||
+ if (module_info->num_ports_up != 0)
|
||||
goto out_unlock;
|
||||
|
||||
/* Transition to low power mode following last port using the module
|
||||
@@ -1005,38 +1044,83 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
NULL);
|
||||
|
||||
out_unlock:
|
||||
- mutex_unlock(&mlxsw_env->module_info_lock);
|
||||
+ mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_module_port_down);
|
||||
|
||||
+static int mlxsw_env_line_cards_alloc(struct mlxsw_env *env)
|
||||
+{
|
||||
+ struct mlxsw_env_module_info *module_info;
|
||||
+ int i, j;
|
||||
+
|
||||
+ for (i = 0; i < env->num_of_slots; i++) {
|
||||
+ env->line_cards[i] = kzalloc(struct_size(env->line_cards[i],
|
||||
+ module_info,
|
||||
+ env->max_module_count),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!env->line_cards[i])
|
||||
+ goto kzalloc_err;
|
||||
+
|
||||
+ /* Firmware defaults to high power mode policy where modules
|
||||
+ * are transitioned to high power mode following plug-in.
|
||||
+ */
|
||||
+ for (j = 0; j < env->max_module_count; j++) {
|
||||
+ module_info = &env->line_cards[i]->module_info[j];
|
||||
+ module_info->power_mode_policy =
|
||||
+ ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+kzalloc_err:
|
||||
+ for (i--; i >= 0; i--)
|
||||
+ kfree(env->line_cards[i]);
|
||||
+ return -ENOMEM;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_env_line_cards_free(struct mlxsw_env *env)
|
||||
+{
|
||||
+ int i = env->num_of_slots;
|
||||
+
|
||||
+ for (i--; i >= 0; i--)
|
||||
+ kfree(env->line_cards[i]);
|
||||
+}
|
||||
+
|
||||
int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
{
|
||||
+ u8 module_count, num_of_slots, max_module_count;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
struct mlxsw_env *env;
|
||||
- u8 module_count;
|
||||
- int i, err;
|
||||
+ int err;
|
||||
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL);
|
||||
+ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count,
|
||||
+ &num_of_slots);
|
||||
+ /* If the system is modular, get the maximum number of modules per-slot.
|
||||
+ * Otherwise, get the maximum number of modules on the main board.
|
||||
+ */
|
||||
+ max_module_count = num_of_slots ?
|
||||
+ mlxsw_reg_mgpir_max_modules_per_slot_get(mgpir_pl) :
|
||||
+ module_count;
|
||||
|
||||
- env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL);
|
||||
+ env = kzalloc(struct_size(env, line_cards, num_of_slots + 1),
|
||||
+ GFP_KERNEL);
|
||||
if (!env)
|
||||
return -ENOMEM;
|
||||
|
||||
- /* Firmware defaults to high power mode policy where modules are
|
||||
- * transitioned to high power mode following plug-in.
|
||||
- */
|
||||
- for (i = 0; i < module_count; i++)
|
||||
- env->module_info[i].power_mode_policy =
|
||||
- ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH;
|
||||
-
|
||||
- mutex_init(&env->module_info_lock);
|
||||
env->core = mlxsw_core;
|
||||
- env->module_count = module_count;
|
||||
+ env->num_of_slots = num_of_slots + 1;
|
||||
+ env->max_module_count = max_module_count;
|
||||
+ err = mlxsw_env_line_cards_alloc(env);
|
||||
+ if (err)
|
||||
+ goto err_mlxsw_env_line_cards_alloc;
|
||||
+
|
||||
+ mutex_init(&env->line_cards_lock);
|
||||
*p_env = env;
|
||||
|
||||
err = mlxsw_env_temp_warn_event_register(mlxsw_core);
|
||||
@@ -1047,13 +1131,17 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
if (err)
|
||||
goto err_module_plug_event_register;
|
||||
|
||||
+ /* Set 'module_count' only for main board. Actual count for line card
|
||||
+ * is to be set after line card is activated.
|
||||
+ */
|
||||
+ env->line_cards[0]->module_count = num_of_slots ? 0 : module_count;
|
||||
err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0,
|
||||
- env->module_count);
|
||||
+ module_count);
|
||||
if (err)
|
||||
goto err_oper_state_event_enable;
|
||||
|
||||
err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0,
|
||||
- env->module_count);
|
||||
+ module_count);
|
||||
if (err)
|
||||
goto err_temp_event_enable;
|
||||
|
||||
@@ -1065,7 +1153,9 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
err_module_plug_event_register:
|
||||
mlxsw_env_temp_warn_event_unregister(env);
|
||||
err_temp_warn_event_register:
|
||||
- mutex_destroy(&env->module_info_lock);
|
||||
+ mutex_destroy(&env->line_cards_lock);
|
||||
+ mlxsw_env_line_cards_free(env);
|
||||
+err_mlxsw_env_line_cards_alloc:
|
||||
kfree(env);
|
||||
return err;
|
||||
}
|
||||
@@ -1076,6 +1166,7 @@ void mlxsw_env_fini(struct mlxsw_env *env)
|
||||
/* Make sure there is no more event work scheduled. */
|
||||
mlxsw_core_flush_owq();
|
||||
mlxsw_env_temp_warn_event_unregister(env);
|
||||
- mutex_destroy(&env->module_info_lock);
|
||||
+ mutex_destroy(&env->line_cards_lock);
|
||||
+ mlxsw_env_line_cards_free(env);
|
||||
kfree(env);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,92 +0,0 @@
|
||||
From 3c3be37747cb938fff1178f88d611eb00159297b Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:28 +0200
|
||||
Subject: [PATCH backport 5.10 114/182] mlxsw: core: Move port module events
|
||||
enablement to a separate function
|
||||
|
||||
Use a separate function for enablement of port module events such
|
||||
plug/unplug and temperature threshold crossing. The motivation is to
|
||||
reuse the function for line cards.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 44 ++++++++++++++-----
|
||||
1 file changed, 34 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 606d89b6f50f..4553dfa68f96 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -1087,6 +1087,32 @@ static void mlxsw_env_line_cards_free(struct mlxsw_env *env)
|
||||
kfree(env->line_cards[i]);
|
||||
}
|
||||
|
||||
+static int
|
||||
+mlxsw_env_module_event_enable(struct mlxsw_env *mlxsw_env, u8 slot_index)
|
||||
+{
|
||||
+ u8 module_count;
|
||||
+ int err;
|
||||
+
|
||||
+ module_count = mlxsw_env->line_cards[slot_index]->module_count;
|
||||
+ err = mlxsw_env_module_oper_state_event_enable(mlxsw_env->core,
|
||||
+ slot_index,
|
||||
+ module_count);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = mlxsw_env_module_temp_event_enable(mlxsw_env->core, slot_index,
|
||||
+ module_count);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mlxsw_env_module_event_disable(struct mlxsw_env *mlxsw_env, u8 slot_index)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
{
|
||||
u8 module_count, num_of_slots, max_module_count;
|
||||
@@ -1135,20 +1161,17 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
* is to be set after line card is activated.
|
||||
*/
|
||||
env->line_cards[0]->module_count = num_of_slots ? 0 : module_count;
|
||||
- err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0,
|
||||
- module_count);
|
||||
- if (err)
|
||||
- goto err_oper_state_event_enable;
|
||||
-
|
||||
- err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0,
|
||||
- module_count);
|
||||
+ /* Enable events only for main board. Line card events are to be
|
||||
+ * configured only after line card is activated. Before that, access to
|
||||
+ * modules on line cards is not allowed.
|
||||
+ */
|
||||
+ err = mlxsw_env_module_event_enable(env, 0);
|
||||
if (err)
|
||||
- goto err_temp_event_enable;
|
||||
+ goto err_mlxsw_env_module_event_enable;
|
||||
|
||||
return 0;
|
||||
|
||||
-err_temp_event_enable:
|
||||
-err_oper_state_event_enable:
|
||||
+err_mlxsw_env_module_event_enable:
|
||||
mlxsw_env_module_plug_event_unregister(env);
|
||||
err_module_plug_event_register:
|
||||
mlxsw_env_temp_warn_event_unregister(env);
|
||||
@@ -1162,6 +1185,7 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
|
||||
void mlxsw_env_fini(struct mlxsw_env *env)
|
||||
{
|
||||
+ mlxsw_env_module_event_disable(env, 0);
|
||||
mlxsw_env_module_plug_event_unregister(env);
|
||||
/* Make sure there is no more event work scheduled. */
|
||||
mlxsw_core_flush_owq();
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,122 +0,0 @@
|
||||
From 1a451b46c16494cfa38bb47495ad632626502681 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:29 +0200
|
||||
Subject: [PATCH backport 5.10 115/182] mlxsw: core_hwmon: Split gearbox
|
||||
initialization
|
||||
|
||||
Split gearbox initialization in two functions - the first one is to be
|
||||
used for gearbox configuration validation, the second for creation of
|
||||
gearbox related hwmon attributes, if any.
|
||||
|
||||
Currently, mlxsw supports gearbox hwmon attributes corresponding to the
|
||||
objects discovered on the main board. Same hwmon attributes could be
|
||||
also discovered on line cards. While the initialization flow for main
|
||||
board and for line cards is the same, the configuration flow is
|
||||
different.
|
||||
|
||||
The purpose of this patch is to allow reusing of initialization flow by
|
||||
main board and line cards.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 43 ++++++++++++++-----
|
||||
1 file changed, 33 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 5df54a5bf292..7061c18b7edc 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -700,13 +700,11 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
+static int
|
||||
+mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 *gbox_num)
|
||||
{
|
||||
enum mlxsw_reg_mgpir_device_type device_type;
|
||||
- int index, max_index, sensor_index;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
- char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
- u8 gbox_num;
|
||||
int err;
|
||||
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
@@ -714,10 +712,27 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL, NULL,
|
||||
+ mlxsw_reg_mgpir_unpack(mgpir_pl, gbox_num, &device_type, NULL, NULL,
|
||||
NULL);
|
||||
- if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
|
||||
- !gbox_num)
|
||||
+ if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE)
|
||||
+ *gbox_num = 0;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num)
|
||||
+{
|
||||
+ int index, max_index, sensor_index;
|
||||
+ char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
+ int err;
|
||||
+
|
||||
+ if (!gbox_num)
|
||||
return 0;
|
||||
|
||||
index = mlxsw_hwmon->module_sensor_max;
|
||||
@@ -756,6 +771,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
{
|
||||
struct mlxsw_hwmon *mlxsw_hwmon;
|
||||
struct device *hwmon_dev;
|
||||
+ u8 gbox_num;
|
||||
int err;
|
||||
|
||||
mlxsw_hwmon = kzalloc(sizeof(*mlxsw_hwmon), GFP_KERNEL);
|
||||
@@ -776,9 +792,13 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
if (err)
|
||||
goto err_temp_module_init;
|
||||
|
||||
- err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon);
|
||||
+ err = mlxsw_hwmon_gearbox_main_init(mlxsw_hwmon, &gbox_num);
|
||||
+ if (err)
|
||||
+ goto err_gearbox_main_init;
|
||||
+
|
||||
+ err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon, gbox_num);
|
||||
if (err)
|
||||
- goto err_temp_gearbox_init;
|
||||
+ goto err_gearbox_init;
|
||||
|
||||
mlxsw_hwmon->groups[0] = &mlxsw_hwmon->group;
|
||||
mlxsw_hwmon->group.attrs = mlxsw_hwmon->attrs;
|
||||
@@ -796,7 +816,9 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
return 0;
|
||||
|
||||
err_hwmon_register:
|
||||
-err_temp_gearbox_init:
|
||||
+err_gearbox_init:
|
||||
+ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon);
|
||||
+err_gearbox_main_init:
|
||||
err_temp_module_init:
|
||||
err_fans_init:
|
||||
err_temp_init:
|
||||
@@ -807,5 +829,6 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
{
|
||||
hwmon_device_unregister(mlxsw_hwmon->hwmon_dev);
|
||||
+ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon);
|
||||
kfree(mlxsw_hwmon);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,541 +0,0 @@
|
||||
From a18e5112ed12150e245e275e187ecd6d87d66b0e Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:30 +0200
|
||||
Subject: [PATCH backport 5.10 116/182] mlxsw: core_hwmon: Extend internal
|
||||
structures to support multi hwmon objects
|
||||
|
||||
Currently, mlxsw supports a single hwmon device and registers it with
|
||||
attributes corresponding to the various objects found on the main
|
||||
board such as fans and gearboxes.
|
||||
|
||||
Line cards can have the same objects, but unlike the main board they
|
||||
can be added and removed while the system is running. The various
|
||||
hwmon objects found on these line cards should be created when the
|
||||
line card becomes available and destroyed when the line card becomes
|
||||
unavailable.
|
||||
|
||||
The above can be achieved by representing each line card as a
|
||||
different hwmon device and registering / unregistering it when the
|
||||
line card becomes available / unavailable.
|
||||
|
||||
Prepare for multi hwmon device support by splitting
|
||||
'struct mlxsw_hwmon' into 'struct mlxsw_hwmon' and
|
||||
'struct mlxsw_hwmon_dev'. The first will hold information relevant to
|
||||
all hwmon devices, whereas the second will hold per-hwmon device
|
||||
information.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 192 ++++++++++--------
|
||||
1 file changed, 112 insertions(+), 80 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 7061c18b7edc..31b370862131 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
struct mlxsw_hwmon_attr {
|
||||
struct device_attribute dev_attr;
|
||||
- struct mlxsw_hwmon *hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev;
|
||||
unsigned int type_index;
|
||||
char name[32];
|
||||
};
|
||||
@@ -40,9 +40,8 @@ static int mlxsw_hwmon_get_attr_index(int index, int count)
|
||||
return index;
|
||||
}
|
||||
|
||||
-struct mlxsw_hwmon {
|
||||
- struct mlxsw_core *core;
|
||||
- const struct mlxsw_bus_info *bus_info;
|
||||
+struct mlxsw_hwmon_dev {
|
||||
+ struct mlxsw_hwmon *hwmon;
|
||||
struct device *hwmon_dev;
|
||||
struct attribute_group group;
|
||||
const struct attribute_group *groups[2];
|
||||
@@ -53,19 +52,26 @@ struct mlxsw_hwmon {
|
||||
u8 module_sensor_max;
|
||||
};
|
||||
|
||||
+struct mlxsw_hwmon {
|
||||
+ struct mlxsw_core *core;
|
||||
+ const struct mlxsw_bus_info *bus_info;
|
||||
+ struct mlxsw_hwmon_dev *main;
|
||||
+};
|
||||
+
|
||||
static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
int temp, index;
|
||||
int err;
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
- mlxsw_hwmon->module_sensor_max);
|
||||
+ mlxsw_hwmon_dev->module_sensor_max);
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
@@ -82,13 +88,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
int temp_max, index;
|
||||
int err;
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
- mlxsw_hwmon->module_sensor_max);
|
||||
+ mlxsw_hwmon_dev->module_sensor_max);
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
@@ -105,8 +112,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
- char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
+ char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
unsigned long val;
|
||||
int index;
|
||||
int err;
|
||||
@@ -118,7 +126,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
|
||||
return -EINVAL;
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
- mlxsw_hwmon->module_sensor_max);
|
||||
+ mlxsw_hwmon_dev->module_sensor_max);
|
||||
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -140,7 +148,8 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mfsm_pl[MLXSW_REG_MFSM_LEN];
|
||||
int err;
|
||||
|
||||
@@ -159,7 +168,8 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char fore_pl[MLXSW_REG_FORE_LEN];
|
||||
bool fault;
|
||||
int err;
|
||||
@@ -180,7 +190,8 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mfsc_pl[MLXSW_REG_MFSC_LEN];
|
||||
int err;
|
||||
|
||||
@@ -200,7 +211,8 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mfsc_pl[MLXSW_REG_MFSC_LEN];
|
||||
unsigned long val;
|
||||
int err;
|
||||
@@ -226,12 +238,13 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
u8 module;
|
||||
int err;
|
||||
|
||||
- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, 0,
|
||||
MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false,
|
||||
false);
|
||||
@@ -264,15 +277,16 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
|
||||
u8 module, fault;
|
||||
u16 temp;
|
||||
int err;
|
||||
|
||||
- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
- mlxsw_reg_mtbr_pack(mtbr_pl, 0,
|
||||
- MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
+ mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
|
||||
+ 1);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to query module temperature sensor\n");
|
||||
@@ -306,11 +320,12 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
u8 module;
|
||||
int err;
|
||||
|
||||
- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
|
||||
module, SFP_TEMP_HIGH_WARN,
|
||||
p_temp);
|
||||
@@ -341,11 +356,12 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
u8 module;
|
||||
int err;
|
||||
|
||||
- module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
|
||||
+ module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
|
||||
module, SFP_TEMP_HIGH_ALARM,
|
||||
p_temp);
|
||||
@@ -390,9 +406,9 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
- struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon;
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
int index = mlxsw_hwmon_attr->type_index -
|
||||
- mlxsw_hwmon->module_sensor_max + 1;
|
||||
+ mlxsw_hwmon_dev->module_sensor_max + 1;
|
||||
|
||||
return sprintf(buf, "gearbox %03u\n", index);
|
||||
}
|
||||
@@ -461,14 +477,15 @@ enum mlxsw_hwmon_attr_type {
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_EMERGENCY_ALARM,
|
||||
};
|
||||
|
||||
-static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon,
|
||||
+static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev,
|
||||
enum mlxsw_hwmon_attr_type attr_type,
|
||||
- unsigned int type_index, unsigned int num) {
|
||||
+ unsigned int type_index, unsigned int num)
|
||||
+{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr;
|
||||
unsigned int attr_index;
|
||||
|
||||
- attr_index = mlxsw_hwmon->attrs_count;
|
||||
- mlxsw_hwmon_attr = &mlxsw_hwmon->hwmon_attrs[attr_index];
|
||||
+ attr_index = mlxsw_hwmon_dev->attrs_count;
|
||||
+ mlxsw_hwmon_attr = &mlxsw_hwmon_dev->hwmon_attrs[attr_index];
|
||||
|
||||
switch (attr_type) {
|
||||
case MLXSW_HWMON_ATTR_TYPE_TEMP:
|
||||
@@ -568,16 +585,17 @@ static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon,
|
||||
}
|
||||
|
||||
mlxsw_hwmon_attr->type_index = type_index;
|
||||
- mlxsw_hwmon_attr->hwmon = mlxsw_hwmon;
|
||||
+ mlxsw_hwmon_attr->mlxsw_hwmon_dev = mlxsw_hwmon_dev;
|
||||
mlxsw_hwmon_attr->dev_attr.attr.name = mlxsw_hwmon_attr->name;
|
||||
sysfs_attr_init(&mlxsw_hwmon_attr->dev_attr.attr);
|
||||
|
||||
- mlxsw_hwmon->attrs[attr_index] = &mlxsw_hwmon_attr->dev_attr.attr;
|
||||
- mlxsw_hwmon->attrs_count++;
|
||||
+ mlxsw_hwmon_dev->attrs[attr_index] = &mlxsw_hwmon_attr->dev_attr.attr;
|
||||
+ mlxsw_hwmon_dev->attrs_count++;
|
||||
}
|
||||
|
||||
-static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
+static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
{
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mtcap_pl[MLXSW_REG_MTCAP_LEN] = {0};
|
||||
int i;
|
||||
int err;
|
||||
@@ -587,8 +605,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to get number of temp sensors\n");
|
||||
return err;
|
||||
}
|
||||
- mlxsw_hwmon->sensor_count = mlxsw_reg_mtcap_sensor_count_get(mtcap_pl);
|
||||
- for (i = 0; i < mlxsw_hwmon->sensor_count; i++) {
|
||||
+ mlxsw_hwmon_dev->sensor_count = mlxsw_reg_mtcap_sensor_count_get(mtcap_pl);
|
||||
+ for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) {
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
|
||||
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i);
|
||||
@@ -605,18 +623,19 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
i);
|
||||
return err;
|
||||
}
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP, i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_RST, i, i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
+static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
{
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mfcr_pl[MLXSW_REG_MFCR_LEN] = {0};
|
||||
enum mlxsw_reg_mfcr_pwm_frequency freq;
|
||||
unsigned int type_index;
|
||||
@@ -634,10 +653,10 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
num = 0;
|
||||
for (type_index = 0; type_index < MLXSW_MFCR_TACHOS_MAX; type_index++) {
|
||||
if (tacho_active & BIT(type_index)) {
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_FAN_RPM,
|
||||
type_index, num);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_FAN_FAULT,
|
||||
type_index, num++);
|
||||
}
|
||||
@@ -645,15 +664,16 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
num = 0;
|
||||
for (type_index = 0; type_index < MLXSW_MFCR_PWMS_MAX; type_index++) {
|
||||
if (pwm_active & BIT(type_index))
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_PWM,
|
||||
type_index, num++);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
+static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
{
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
u8 module_sensor_max;
|
||||
int i, err;
|
||||
@@ -671,28 +691,28 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
* sensor_count are already utilized by the sensors connected through
|
||||
* mtmp register by mlxsw_hwmon_temp_init().
|
||||
*/
|
||||
- mlxsw_hwmon->module_sensor_max = mlxsw_hwmon->sensor_count +
|
||||
- module_sensor_max;
|
||||
- for (i = mlxsw_hwmon->sensor_count;
|
||||
- i < mlxsw_hwmon->module_sensor_max; i++) {
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_dev->module_sensor_max = mlxsw_hwmon_dev->sensor_count +
|
||||
+ module_sensor_max;
|
||||
+ for (i = mlxsw_hwmon_dev->sensor_count;
|
||||
+ i < mlxsw_hwmon_dev->module_sensor_max; i++) {
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE, i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_FAULT,
|
||||
i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_CRIT, i,
|
||||
i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_EMERG,
|
||||
i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_LABEL,
|
||||
i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_CRIT_ALARM,
|
||||
i, i);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_EMERGENCY_ALARM,
|
||||
i, i);
|
||||
}
|
||||
@@ -701,8 +721,10 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
}
|
||||
|
||||
static int
|
||||
-mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 *gbox_num)
|
||||
+mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev,
|
||||
+ u8 *gbox_num)
|
||||
{
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
enum mlxsw_reg_mgpir_device_type device_type;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
int err;
|
||||
@@ -721,13 +743,14 @@ mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 *gbox_num)
|
||||
}
|
||||
|
||||
static void
|
||||
-mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
+mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
-mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num)
|
||||
+mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num)
|
||||
{
|
||||
+ struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
int index, max_index, sensor_index;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
int err;
|
||||
@@ -735,10 +758,10 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num)
|
||||
if (!gbox_num)
|
||||
return 0;
|
||||
|
||||
- index = mlxsw_hwmon->module_sensor_max;
|
||||
- max_index = mlxsw_hwmon->module_sensor_max + gbox_num;
|
||||
+ index = mlxsw_hwmon_dev->module_sensor_max;
|
||||
+ max_index = mlxsw_hwmon_dev->module_sensor_max + gbox_num;
|
||||
while (index < max_index) {
|
||||
- sensor_index = index % mlxsw_hwmon->module_sensor_max +
|
||||
+ sensor_index = index % mlxsw_hwmon_dev->module_sensor_max +
|
||||
MLXSW_REG_MTMP_GBOX_INDEX_MIN;
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true);
|
||||
err = mlxsw_reg_write(mlxsw_hwmon->core,
|
||||
@@ -748,15 +771,15 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon, u8 gbox_num)
|
||||
sensor_index);
|
||||
return err;
|
||||
}
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon, MLXSW_HWMON_ATTR_TYPE_TEMP,
|
||||
- index, index);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
+ MLXSW_HWMON_ATTR_TYPE_TEMP, index, index);
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, index,
|
||||
index);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_RST, index,
|
||||
index);
|
||||
- mlxsw_hwmon_attr_add(mlxsw_hwmon,
|
||||
+ mlxsw_hwmon_attr_add(mlxsw_hwmon_dev,
|
||||
MLXSW_HWMON_ATTR_TYPE_TEMP_GBOX_LABEL,
|
||||
index, index);
|
||||
index++;
|
||||
@@ -777,58 +800,67 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
mlxsw_hwmon = kzalloc(sizeof(*mlxsw_hwmon), GFP_KERNEL);
|
||||
if (!mlxsw_hwmon)
|
||||
return -ENOMEM;
|
||||
+ mlxsw_hwmon->main = kzalloc(sizeof(*mlxsw_hwmon->main), GFP_KERNEL);
|
||||
+ if (!mlxsw_hwmon->main) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto err_hwmon_main_init;
|
||||
+ }
|
||||
mlxsw_hwmon->core = mlxsw_core;
|
||||
mlxsw_hwmon->bus_info = mlxsw_bus_info;
|
||||
+ mlxsw_hwmon->main->hwmon = mlxsw_hwmon;
|
||||
|
||||
- err = mlxsw_hwmon_temp_init(mlxsw_hwmon);
|
||||
+ err = mlxsw_hwmon_temp_init(mlxsw_hwmon->main);
|
||||
if (err)
|
||||
goto err_temp_init;
|
||||
|
||||
- err = mlxsw_hwmon_fans_init(mlxsw_hwmon);
|
||||
+ err = mlxsw_hwmon_fans_init(mlxsw_hwmon->main);
|
||||
if (err)
|
||||
goto err_fans_init;
|
||||
|
||||
- err = mlxsw_hwmon_module_init(mlxsw_hwmon);
|
||||
+ err = mlxsw_hwmon_module_init(mlxsw_hwmon->main);
|
||||
if (err)
|
||||
goto err_temp_module_init;
|
||||
|
||||
- err = mlxsw_hwmon_gearbox_main_init(mlxsw_hwmon, &gbox_num);
|
||||
+ err = mlxsw_hwmon_gearbox_main_init(mlxsw_hwmon->main, &gbox_num);
|
||||
if (err)
|
||||
goto err_gearbox_main_init;
|
||||
|
||||
- err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon, gbox_num);
|
||||
+ err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon->main, gbox_num);
|
||||
if (err)
|
||||
goto err_gearbox_init;
|
||||
|
||||
- mlxsw_hwmon->groups[0] = &mlxsw_hwmon->group;
|
||||
- mlxsw_hwmon->group.attrs = mlxsw_hwmon->attrs;
|
||||
+ mlxsw_hwmon->main->groups[0] = &mlxsw_hwmon->main->group;
|
||||
+ mlxsw_hwmon->main->group.attrs = mlxsw_hwmon->main->attrs;
|
||||
|
||||
hwmon_dev = hwmon_device_register_with_groups(mlxsw_bus_info->dev,
|
||||
- "mlxsw", mlxsw_hwmon,
|
||||
- mlxsw_hwmon->groups);
|
||||
+ "mlxsw", mlxsw_hwmon->main,
|
||||
+ mlxsw_hwmon->main->groups);
|
||||
if (IS_ERR(hwmon_dev)) {
|
||||
err = PTR_ERR(hwmon_dev);
|
||||
goto err_hwmon_register;
|
||||
}
|
||||
|
||||
- mlxsw_hwmon->hwmon_dev = hwmon_dev;
|
||||
+ mlxsw_hwmon->main->hwmon_dev = hwmon_dev;
|
||||
*p_hwmon = mlxsw_hwmon;
|
||||
return 0;
|
||||
|
||||
err_hwmon_register:
|
||||
err_gearbox_init:
|
||||
- mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon);
|
||||
+ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main);
|
||||
err_gearbox_main_init:
|
||||
err_temp_module_init:
|
||||
err_fans_init:
|
||||
err_temp_init:
|
||||
+ kfree(mlxsw_hwmon->main);
|
||||
+err_hwmon_main_init:
|
||||
kfree(mlxsw_hwmon);
|
||||
return err;
|
||||
}
|
||||
|
||||
void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
{
|
||||
- hwmon_device_unregister(mlxsw_hwmon->hwmon_dev);
|
||||
- mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon);
|
||||
+ hwmon_device_unregister(mlxsw_hwmon->main->hwmon_dev);
|
||||
+ mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main);
|
||||
+ kfree(mlxsw_hwmon->main);
|
||||
kfree(mlxsw_hwmon);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,129 +0,0 @@
|
||||
From 15f2f79bffb77324a389b7e174f32406924d3a3a Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:31 +0200
|
||||
Subject: [PATCH backport 5.10 117/182] mlxsw: core_hwmon: Introduce slot
|
||||
parameter in hwmon interfaces
|
||||
|
||||
Add 'slot' parameter to 'mlxsw_hwmon_dev' structure. Use this parameter
|
||||
in mlxsw_reg_mtmp_pack(), mlxsw_reg_mtbr_pack() and
|
||||
Use mlxsw_reg_mtmp_slot_index_set() routines.
|
||||
For main board it'll always be zero, for line cards it'll be set to
|
||||
the physical slot number in modular systems.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 26 +++++++++++++------
|
||||
1 file changed, 18 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 31b370862131..0d7edabf19a4 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -50,6 +50,7 @@ struct mlxsw_hwmon_dev {
|
||||
unsigned int attrs_count;
|
||||
u8 sensor_count;
|
||||
u8 module_sensor_max;
|
||||
+ u8 slot_index;
|
||||
};
|
||||
|
||||
struct mlxsw_hwmon {
|
||||
@@ -72,7 +73,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon_dev->module_sensor_max);
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false,
|
||||
+ false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
|
||||
@@ -96,7 +98,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon_dev->module_sensor_max);
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false,
|
||||
+ false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n");
|
||||
@@ -128,6 +131,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
mlxsw_hwmon_dev->module_sensor_max);
|
||||
|
||||
+ mlxsw_reg_mtmp_slot_index_set(mtmp_pl, mlxsw_hwmon_dev->slot_index);
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err)
|
||||
@@ -245,7 +249,7 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0,
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index,
|
||||
MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false,
|
||||
false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -285,8 +289,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
- mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
|
||||
- 1);
|
||||
+ mlxsw_reg_mtbr_pack(mtbr_pl, mlxsw_hwmon_dev->slot_index,
|
||||
+ MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to query module temperature sensor\n");
|
||||
@@ -326,7 +330,8 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core,
|
||||
+ mlxsw_hwmon_dev->slot_index,
|
||||
module, SFP_TEMP_HIGH_WARN,
|
||||
p_temp);
|
||||
if (err) {
|
||||
@@ -362,7 +367,8 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev,
|
||||
int err;
|
||||
|
||||
module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count;
|
||||
- err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0,
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core,
|
||||
+ mlxsw_hwmon_dev->slot_index,
|
||||
module, SFP_TEMP_HIGH_ALARM,
|
||||
p_temp);
|
||||
if (err) {
|
||||
@@ -609,6 +615,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) {
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0};
|
||||
|
||||
+ mlxsw_reg_mtmp_slot_index_set(mtmp_pl,
|
||||
+ mlxsw_hwmon_dev->slot_index);
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp),
|
||||
mtmp_pl);
|
||||
@@ -763,7 +771,8 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num)
|
||||
while (index < max_index) {
|
||||
sensor_index = index % mlxsw_hwmon_dev->module_sensor_max +
|
||||
MLXSW_REG_MTMP_GBOX_INDEX_MIN;
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index,
|
||||
+ sensor_index, true, true);
|
||||
err = mlxsw_reg_write(mlxsw_hwmon->core,
|
||||
MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
@@ -808,6 +817,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
mlxsw_hwmon->core = mlxsw_core;
|
||||
mlxsw_hwmon->bus_info = mlxsw_bus_info;
|
||||
mlxsw_hwmon->main->hwmon = mlxsw_hwmon;
|
||||
+ mlxsw_hwmon->main->slot_index = 0;
|
||||
|
||||
err = mlxsw_hwmon_temp_init(mlxsw_hwmon->main);
|
||||
if (err)
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,136 +0,0 @@
|
||||
From c627292817e68e29abdf5fd9be93340251d71f7a Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:32 +0200
|
||||
Subject: [PATCH backport 5.10 118/182] mlxsw: core_hwmon: Extend hwmon device
|
||||
with gearbox mapping field
|
||||
|
||||
Add gearbox mapping field to 'mlxsw_hwmon_dev' structure. It should
|
||||
provide the mapping for gearbox sensor indexes, given gearbox number.
|
||||
For main board mapping is supposed to be always sequential, while for
|
||||
line cards on modular system it could be non-sequential.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 40 ++++++++++++++-----
|
||||
1 file changed, 31 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 0d7edabf19a4..6af23f4724e4 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -32,10 +32,11 @@ struct mlxsw_hwmon_attr {
|
||||
char name[32];
|
||||
};
|
||||
|
||||
-static int mlxsw_hwmon_get_attr_index(int index, int count)
|
||||
+static int
|
||||
+mlxsw_hwmon_get_attr_index(int index, int count, u16 *gearbox_sensor_map)
|
||||
{
|
||||
if (index >= count)
|
||||
- return index % count + MLXSW_REG_MTMP_GBOX_INDEX_MIN;
|
||||
+ return gearbox_sensor_map[index % count];
|
||||
|
||||
return index;
|
||||
}
|
||||
@@ -50,6 +51,7 @@ struct mlxsw_hwmon_dev {
|
||||
unsigned int attrs_count;
|
||||
u8 sensor_count;
|
||||
u8 module_sensor_max;
|
||||
+ u16 *gearbox_sensor_map;
|
||||
u8 slot_index;
|
||||
};
|
||||
|
||||
@@ -72,7 +74,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
|
||||
int err;
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
- mlxsw_hwmon_dev->module_sensor_max);
|
||||
+ mlxsw_hwmon_dev->module_sensor_max,
|
||||
+ mlxsw_hwmon_dev->gearbox_sensor_map);
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false,
|
||||
false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -97,7 +100,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev,
|
||||
int err;
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
- mlxsw_hwmon_dev->module_sensor_max);
|
||||
+ mlxsw_hwmon_dev->module_sensor_max,
|
||||
+ mlxsw_hwmon_dev->gearbox_sensor_map);
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false,
|
||||
false);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -129,7 +133,8 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev,
|
||||
return -EINVAL;
|
||||
|
||||
index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index,
|
||||
- mlxsw_hwmon_dev->module_sensor_max);
|
||||
+ mlxsw_hwmon_dev->module_sensor_max,
|
||||
+ mlxsw_hwmon_dev->gearbox_sensor_map);
|
||||
|
||||
mlxsw_reg_mtmp_slot_index_set(mtmp_pl, mlxsw_hwmon_dev->slot_index);
|
||||
mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index);
|
||||
@@ -735,7 +740,7 @@ mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev,
|
||||
struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
enum mlxsw_reg_mgpir_device_type device_type;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
- int err;
|
||||
+ int i, err;
|
||||
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
@@ -747,12 +752,30 @@ mlxsw_hwmon_gearbox_main_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev,
|
||||
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE)
|
||||
*gbox_num = 0;
|
||||
|
||||
+ /* Skip gearbox sensor mapping array allocation, if no gearboxes are
|
||||
+ * available.
|
||||
+ */
|
||||
+ if (!*gbox_num)
|
||||
+ return 0;
|
||||
+
|
||||
+ mlxsw_hwmon_dev->gearbox_sensor_map = kmalloc_array(*gbox_num,
|
||||
+ sizeof(u16),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!mlxsw_hwmon_dev->gearbox_sensor_map)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Fill out gearbox sensor mapping array. */
|
||||
+ for (i = 0; i < *gbox_num; i++)
|
||||
+ mlxsw_hwmon_dev->gearbox_sensor_map[i] =
|
||||
+ MLXSW_REG_MTMP_GBOX_INDEX_MIN + i;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
mlxsw_hwmon_gearbox_main_fini(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
{
|
||||
+ kfree(mlxsw_hwmon_dev->gearbox_sensor_map);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -761,7 +784,7 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num)
|
||||
struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon;
|
||||
int index, max_index, sensor_index;
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
- int err;
|
||||
+ int i = 0, err;
|
||||
|
||||
if (!gbox_num)
|
||||
return 0;
|
||||
@@ -769,8 +792,7 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num)
|
||||
index = mlxsw_hwmon_dev->module_sensor_max;
|
||||
max_index = mlxsw_hwmon_dev->module_sensor_max + gbox_num;
|
||||
while (index < max_index) {
|
||||
- sensor_index = index % mlxsw_hwmon_dev->module_sensor_max +
|
||||
- MLXSW_REG_MTMP_GBOX_INDEX_MIN;
|
||||
+ sensor_index = mlxsw_hwmon_dev->gearbox_sensor_map[i++];
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index,
|
||||
sensor_index, true, true);
|
||||
err = mlxsw_reg_write(mlxsw_hwmon->core,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,367 +0,0 @@
|
||||
From 8851888004e82e73629f031e8af592c36b12c469 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:33 +0200
|
||||
Subject: [PATCH backport 5.10 119/182] mlxsw: core_thermal: Extend internal
|
||||
structures to support multi thermal areas
|
||||
|
||||
Introduce intermediate level for thermal zones areas.
|
||||
Currently all thermal zones are associated with thermal objects located
|
||||
within the main board. Such objects are created during driver
|
||||
initialization and removed during driver de-initialization.
|
||||
|
||||
For line cards in modular system the thermal zones are to be associated
|
||||
with the specific line card. They should be created whenever new line
|
||||
card is available (inserted, validated, powered and enabled) and
|
||||
removed, when line card is getting unavailable.
|
||||
The thermal objects found on the line card #n are accessed by setting
|
||||
slot index to #n, while for access to objects found on the main board
|
||||
slot index should be set to default value zero.
|
||||
|
||||
Each thermal area contains the set of thermal zones associated with
|
||||
particular slot index.
|
||||
Thus introduction of thermal zone areas allows to use the same APIs for
|
||||
the main board and line cards, by adding slot index argument.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 134 +++++++++++-------
|
||||
1 file changed, 83 insertions(+), 51 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 4f84c4bb66af..5f8b1e92475b 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -83,6 +83,15 @@ struct mlxsw_thermal_module {
|
||||
struct thermal_zone_device *tzdev;
|
||||
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
|
||||
int module; /* Module or gearbox number */
|
||||
+ u8 slot_index;
|
||||
+};
|
||||
+
|
||||
+struct mlxsw_thermal_area {
|
||||
+ struct mlxsw_thermal_module *tz_module_arr;
|
||||
+ u8 tz_module_num;
|
||||
+ struct mlxsw_thermal_module *tz_gearbox_arr;
|
||||
+ u8 tz_gearbox_num;
|
||||
+ u8 slot_index;
|
||||
};
|
||||
|
||||
struct mlxsw_thermal {
|
||||
@@ -93,10 +102,7 @@ struct mlxsw_thermal {
|
||||
struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];
|
||||
u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1];
|
||||
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
|
||||
- struct mlxsw_thermal_module *tz_module_arr;
|
||||
- u8 tz_module_num;
|
||||
- struct mlxsw_thermal_module *tz_gearbox_arr;
|
||||
- u8 tz_gearbox_num;
|
||||
+ struct mlxsw_thermal_area *main;
|
||||
unsigned int tz_highest_score;
|
||||
struct thermal_zone_device *tz_highest_dev;
|
||||
};
|
||||
@@ -151,13 +157,15 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
|
||||
* EEPROM if we got valid thresholds from MTMP.
|
||||
*/
|
||||
if (!emerg_temp || !crit_temp) {
|
||||
- err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module,
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(core, tz->slot_index,
|
||||
+ tz->module,
|
||||
SFP_TEMP_HIGH_WARN,
|
||||
&crit_temp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module,
|
||||
+ err = mlxsw_env_module_temp_thresholds_get(core, tz->slot_index,
|
||||
+ tz->module,
|
||||
SFP_TEMP_HIGH_ALARM,
|
||||
&emerg_temp);
|
||||
if (err)
|
||||
@@ -424,15 +432,16 @@ static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev,
|
||||
|
||||
static void
|
||||
mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core,
|
||||
- u16 sensor_index, int *p_temp,
|
||||
- int *p_crit_temp,
|
||||
+ u8 slot_index, u16 sensor_index,
|
||||
+ int *p_temp, int *p_crit_temp,
|
||||
int *p_emerg_temp)
|
||||
{
|
||||
char mtmp_pl[MLXSW_REG_MTMP_LEN];
|
||||
int err;
|
||||
|
||||
/* Read module temperature and thresholds. */
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, slot_index, sensor_index,
|
||||
+ false, false);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err) {
|
||||
/* Set temperature and thresholds to zero to avoid passing
|
||||
@@ -463,6 +472,7 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
|
||||
|
||||
/* Read module temperature and thresholds. */
|
||||
mlxsw_thermal_module_temp_and_thresholds_get(thermal->core,
|
||||
+ tz->slot_index,
|
||||
sensor_index, &temp,
|
||||
&crit_temp, &emerg_temp);
|
||||
*p_temp = temp;
|
||||
@@ -577,7 +587,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
|
||||
int err;
|
||||
|
||||
index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module;
|
||||
- mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false);
|
||||
+ mlxsw_reg_mtmp_pack(mtmp_pl, tz->slot_index, index, false, false);
|
||||
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
if (err)
|
||||
@@ -704,25 +714,28 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev)
|
||||
|
||||
static int
|
||||
mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
|
||||
- struct mlxsw_thermal *thermal, u8 module)
|
||||
+ struct mlxsw_thermal *thermal,
|
||||
+ struct mlxsw_thermal_area *area, u8 module)
|
||||
{
|
||||
struct mlxsw_thermal_module *module_tz;
|
||||
int dummy_temp, crit_temp, emerg_temp;
|
||||
u16 sensor_index;
|
||||
|
||||
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + module;
|
||||
- module_tz = &thermal->tz_module_arr[module];
|
||||
+ module_tz = &area->tz_module_arr[module];
|
||||
/* Skip if parent is already set (case of port split). */
|
||||
if (module_tz->parent)
|
||||
return 0;
|
||||
module_tz->module = module;
|
||||
+ module_tz->slot_index = area->slot_index;
|
||||
module_tz->parent = thermal;
|
||||
memcpy(module_tz->trips, default_thermal_trips,
|
||||
sizeof(thermal->trips));
|
||||
/* Initialize all trip point. */
|
||||
mlxsw_thermal_module_trips_reset(module_tz);
|
||||
/* Read module temperature and thresholds. */
|
||||
- mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, &dummy_temp,
|
||||
+ mlxsw_thermal_module_temp_and_thresholds_get(core, area->slot_index,
|
||||
+ sensor_index, &dummy_temp,
|
||||
&crit_temp, &emerg_temp);
|
||||
/* Update trip point according to the module data. */
|
||||
return mlxsw_thermal_module_trips_update(dev, core, module_tz,
|
||||
@@ -740,34 +753,39 @@ static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
|
||||
|
||||
static int
|
||||
mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
|
||||
- struct mlxsw_thermal *thermal)
|
||||
+ struct mlxsw_thermal *thermal,
|
||||
+ struct mlxsw_thermal_area *area)
|
||||
{
|
||||
struct mlxsw_thermal_module *module_tz;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
int i, err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, area->slot_index);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
|
||||
- &thermal->tz_module_num, NULL);
|
||||
+ &area->tz_module_num, NULL);
|
||||
|
||||
- thermal->tz_module_arr = kcalloc(thermal->tz_module_num,
|
||||
- sizeof(*thermal->tz_module_arr),
|
||||
- GFP_KERNEL);
|
||||
- if (!thermal->tz_module_arr)
|
||||
+ /* For modular system module counter could be zero. */
|
||||
+ if (!area->tz_module_num)
|
||||
+ return 0;
|
||||
+
|
||||
+ area->tz_module_arr = kcalloc(area->tz_module_num,
|
||||
+ sizeof(*area->tz_module_arr),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!area->tz_module_arr)
|
||||
return -ENOMEM;
|
||||
|
||||
- for (i = 0; i < thermal->tz_module_num; i++) {
|
||||
- err = mlxsw_thermal_module_init(dev, core, thermal, i);
|
||||
+ for (i = 0; i < area->tz_module_num; i++) {
|
||||
+ err = mlxsw_thermal_module_init(dev, core, thermal, area, i);
|
||||
if (err)
|
||||
goto err_thermal_module_init;
|
||||
}
|
||||
|
||||
- for (i = 0; i < thermal->tz_module_num; i++) {
|
||||
- module_tz = &thermal->tz_module_arr[i];
|
||||
+ for (i = 0; i < area->tz_module_num; i++) {
|
||||
+ module_tz = &area->tz_module_arr[i];
|
||||
if (!module_tz->parent)
|
||||
continue;
|
||||
err = mlxsw_thermal_module_tz_init(module_tz);
|
||||
@@ -779,20 +797,21 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
|
||||
|
||||
err_thermal_module_tz_init:
|
||||
err_thermal_module_init:
|
||||
- for (i = thermal->tz_module_num - 1; i >= 0; i--)
|
||||
- mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
|
||||
- kfree(thermal->tz_module_arr);
|
||||
+ for (i = area->tz_module_num - 1; i >= 0; i--)
|
||||
+ mlxsw_thermal_module_fini(&area->tz_module_arr[i]);
|
||||
+ kfree(area->tz_module_arr);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
-mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
|
||||
+mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal,
|
||||
+ struct mlxsw_thermal_area *area)
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = thermal->tz_module_num - 1; i >= 0; i--)
|
||||
- mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
|
||||
- kfree(thermal->tz_module_arr);
|
||||
+ for (i = area->tz_module_num - 1; i >= 0; i--)
|
||||
+ mlxsw_thermal_module_fini(&area->tz_module_arr[i]);
|
||||
+ kfree(area->tz_module_arr);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -828,7 +847,8 @@ mlxsw_thermal_gearbox_tz_fini(struct mlxsw_thermal_module *gearbox_tz)
|
||||
|
||||
static int
|
||||
mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
- struct mlxsw_thermal *thermal)
|
||||
+ struct mlxsw_thermal *thermal,
|
||||
+ struct mlxsw_thermal_area *area)
|
||||
{
|
||||
enum mlxsw_reg_mgpir_device_type device_type;
|
||||
struct mlxsw_thermal_module *gearbox_tz;
|
||||
@@ -848,19 +868,20 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
!gbox_num)
|
||||
return 0;
|
||||
|
||||
- thermal->tz_gearbox_num = gbox_num;
|
||||
- thermal->tz_gearbox_arr = kcalloc(thermal->tz_gearbox_num,
|
||||
- sizeof(*thermal->tz_gearbox_arr),
|
||||
- GFP_KERNEL);
|
||||
- if (!thermal->tz_gearbox_arr)
|
||||
+ area->tz_gearbox_num = gbox_num;
|
||||
+ area->tz_gearbox_arr = kcalloc(area->tz_gearbox_num,
|
||||
+ sizeof(*area->tz_gearbox_arr),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!area->tz_gearbox_arr)
|
||||
return -ENOMEM;
|
||||
|
||||
- for (i = 0; i < thermal->tz_gearbox_num; i++) {
|
||||
- gearbox_tz = &thermal->tz_gearbox_arr[i];
|
||||
+ for (i = 0; i < area->tz_gearbox_num; i++) {
|
||||
+ gearbox_tz = &area->tz_gearbox_arr[i];
|
||||
memcpy(gearbox_tz->trips, default_thermal_trips,
|
||||
sizeof(thermal->trips));
|
||||
gearbox_tz->module = i;
|
||||
gearbox_tz->parent = thermal;
|
||||
+ gearbox_tz->slot_index = area->slot_index;
|
||||
err = mlxsw_thermal_gearbox_tz_init(gearbox_tz);
|
||||
if (err)
|
||||
goto err_thermal_gearbox_tz_init;
|
||||
@@ -870,19 +891,20 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
|
||||
err_thermal_gearbox_tz_init:
|
||||
for (i--; i >= 0; i--)
|
||||
- mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]);
|
||||
- kfree(thermal->tz_gearbox_arr);
|
||||
+ mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]);
|
||||
+ kfree(area->tz_gearbox_arr);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
-mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal)
|
||||
+mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal,
|
||||
+ struct mlxsw_thermal_area *area)
|
||||
{
|
||||
int i;
|
||||
|
||||
- for (i = thermal->tz_gearbox_num - 1; i >= 0; i--)
|
||||
- mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]);
|
||||
- kfree(thermal->tz_gearbox_arr);
|
||||
+ for (i = area->tz_gearbox_num - 1; i >= 0; i--)
|
||||
+ mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]);
|
||||
+ kfree(area->tz_gearbox_arr);
|
||||
}
|
||||
|
||||
int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
@@ -902,9 +924,16 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
if (!thermal)
|
||||
return -ENOMEM;
|
||||
|
||||
+ thermal->main = devm_kzalloc(dev, sizeof(*thermal->main), GFP_KERNEL);
|
||||
+ if (!thermal->main) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto err_devm_kzalloc;
|
||||
+ }
|
||||
+
|
||||
thermal->core = core;
|
||||
thermal->bus_info = bus_info;
|
||||
memcpy(thermal->trips, default_thermal_trips, sizeof(thermal->trips));
|
||||
+ thermal->main->slot_index = 0;
|
||||
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl);
|
||||
if (err) {
|
||||
@@ -970,11 +999,11 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
goto err_thermal_zone_device_register;
|
||||
}
|
||||
|
||||
- err = mlxsw_thermal_modules_init(dev, core, thermal);
|
||||
+ err = mlxsw_thermal_modules_init(dev, core, thermal, thermal->main);
|
||||
if (err)
|
||||
goto err_thermal_modules_init;
|
||||
|
||||
- err = mlxsw_thermal_gearboxes_init(dev, core, thermal);
|
||||
+ err = mlxsw_thermal_gearboxes_init(dev, core, thermal, thermal->main);
|
||||
if (err)
|
||||
goto err_thermal_gearboxes_init;
|
||||
|
||||
@@ -986,9 +1015,9 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
return 0;
|
||||
|
||||
err_thermal_zone_device_enable:
|
||||
- mlxsw_thermal_gearboxes_fini(thermal);
|
||||
+ mlxsw_thermal_gearboxes_fini(thermal, thermal->main);
|
||||
err_thermal_gearboxes_init:
|
||||
- mlxsw_thermal_modules_fini(thermal);
|
||||
+ mlxsw_thermal_modules_fini(thermal, thermal->main);
|
||||
err_thermal_modules_init:
|
||||
if (thermal->tzdev) {
|
||||
thermal_zone_device_unregister(thermal->tzdev);
|
||||
@@ -1001,6 +1030,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
thermal_cooling_device_unregister(thermal->cdevs[i]);
|
||||
err_reg_write:
|
||||
err_reg_query:
|
||||
+ devm_kfree(dev, thermal->main);
|
||||
+err_devm_kzalloc:
|
||||
devm_kfree(dev, thermal);
|
||||
return err;
|
||||
}
|
||||
@@ -1009,8 +1040,8 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
|
||||
{
|
||||
int i;
|
||||
|
||||
- mlxsw_thermal_gearboxes_fini(thermal);
|
||||
- mlxsw_thermal_modules_fini(thermal);
|
||||
+ mlxsw_thermal_gearboxes_fini(thermal, thermal->main);
|
||||
+ mlxsw_thermal_modules_fini(thermal, thermal->main);
|
||||
if (thermal->tzdev) {
|
||||
thermal_zone_device_unregister(thermal->tzdev);
|
||||
thermal->tzdev = NULL;
|
||||
@@ -1023,5 +1054,6 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
|
||||
}
|
||||
}
|
||||
|
||||
+ devm_kfree(thermal->bus_info->dev, thermal->main);
|
||||
devm_kfree(thermal->bus_info->dev, thermal);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,138 +0,0 @@
|
||||
From ed83386ce79974230c5fa59245efe760046d944c Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:34 +0200
|
||||
Subject: [PATCH backport 5.10 120/182] mlxsw: core_thermal: Split gearbox
|
||||
initialization
|
||||
|
||||
Split gearbox initialization in two routines - the first one is to be
|
||||
used for gearbox configuration validation, the second for creation of
|
||||
gearbox related thermal zones if any.
|
||||
|
||||
Currently, mlxsw supports gearbox thermal zones corresponding to the
|
||||
main board. For system equipped with the line cards assembled with the
|
||||
gearboxes, thermal zones will be associated with the gearboxes found on
|
||||
those line cards.
|
||||
|
||||
While the initialization flow for main board and for line cards is the
|
||||
same, the configuration flow is different.
|
||||
|
||||
The purpose of this patch is to allow reusing of initialization flow by
|
||||
main board and line cards.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 43 +++++++++++++++----
|
||||
1 file changed, 34 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 5f8b1e92475b..313856b88f6c 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -846,15 +846,12 @@ mlxsw_thermal_gearbox_tz_fini(struct mlxsw_thermal_module *gearbox_tz)
|
||||
}
|
||||
|
||||
static int
|
||||
-mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
- struct mlxsw_thermal *thermal,
|
||||
- struct mlxsw_thermal_area *area)
|
||||
+mlxsw_thermal_gearboxes_main_init(struct device *dev, struct mlxsw_core *core,
|
||||
+ struct mlxsw_thermal_area *area)
|
||||
{
|
||||
enum mlxsw_reg_mgpir_device_type device_type;
|
||||
- struct mlxsw_thermal_module *gearbox_tz;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
u8 gbox_num;
|
||||
- int i;
|
||||
int err;
|
||||
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
@@ -864,8 +861,11 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
|
||||
mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
|
||||
NULL, NULL);
|
||||
- if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE ||
|
||||
- !gbox_num)
|
||||
+ if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE)
|
||||
+ gbox_num = 0;
|
||||
+
|
||||
+ /* Skip gearbox sensor array allocation, if no gearboxes are available. */
|
||||
+ if (!gbox_num)
|
||||
return 0;
|
||||
|
||||
area->tz_gearbox_num = gbox_num;
|
||||
@@ -875,6 +875,26 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
if (!area->tz_gearbox_arr)
|
||||
return -ENOMEM;
|
||||
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mlxsw_thermal_gearboxes_main_fini(struct mlxsw_thermal_area *area)
|
||||
+{
|
||||
+ kfree(area->tz_gearbox_arr);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
+ struct mlxsw_thermal *thermal,
|
||||
+ struct mlxsw_thermal_area *area)
|
||||
+{
|
||||
+ struct mlxsw_thermal_module *gearbox_tz;
|
||||
+ int i, err;
|
||||
+
|
||||
+ if (!area->tz_gearbox_num)
|
||||
+ return 0;
|
||||
+
|
||||
for (i = 0; i < area->tz_gearbox_num; i++) {
|
||||
gearbox_tz = &area->tz_gearbox_arr[i];
|
||||
memcpy(gearbox_tz->trips, default_thermal_trips,
|
||||
@@ -892,7 +912,6 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
err_thermal_gearbox_tz_init:
|
||||
for (i--; i >= 0; i--)
|
||||
mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]);
|
||||
- kfree(area->tz_gearbox_arr);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -904,7 +923,6 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal,
|
||||
|
||||
for (i = area->tz_gearbox_num - 1; i >= 0; i--)
|
||||
mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]);
|
||||
- kfree(area->tz_gearbox_arr);
|
||||
}
|
||||
|
||||
int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
@@ -1003,6 +1021,10 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
if (err)
|
||||
goto err_thermal_modules_init;
|
||||
|
||||
+ err = mlxsw_thermal_gearboxes_main_init(dev, core, thermal->main);
|
||||
+ if (err)
|
||||
+ goto err_thermal_gearboxes_main_init;
|
||||
+
|
||||
err = mlxsw_thermal_gearboxes_init(dev, core, thermal, thermal->main);
|
||||
if (err)
|
||||
goto err_thermal_gearboxes_init;
|
||||
@@ -1017,6 +1039,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
err_thermal_zone_device_enable:
|
||||
mlxsw_thermal_gearboxes_fini(thermal, thermal->main);
|
||||
err_thermal_gearboxes_init:
|
||||
+ mlxsw_thermal_gearboxes_main_fini(thermal->main);
|
||||
+err_thermal_gearboxes_main_init:
|
||||
mlxsw_thermal_modules_fini(thermal, thermal->main);
|
||||
err_thermal_modules_init:
|
||||
if (thermal->tzdev) {
|
||||
@@ -1041,6 +1065,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
|
||||
int i;
|
||||
|
||||
mlxsw_thermal_gearboxes_fini(thermal, thermal->main);
|
||||
+ mlxsw_thermal_gearboxes_main_fini(thermal->main);
|
||||
mlxsw_thermal_modules_fini(thermal, thermal->main);
|
||||
if (thermal->tzdev) {
|
||||
thermal_zone_device_unregister(thermal->tzdev);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,127 +0,0 @@
|
||||
From 13a7ef7fcdc09def9d9756510f49da82283d78df Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:35 +0200
|
||||
Subject: [PATCH backport 5.10 121/182] mlxsw: core_thermal: Extend thermal
|
||||
area with gearbox mapping field
|
||||
|
||||
Add gearbox mapping field 'gearbox_sensor_map' to
|
||||
'mlxsw_thermal_module' structure. It should provide the mapping for
|
||||
gearbox sensor indexes, given gearbox number. For main board mapping is
|
||||
supposed to be always sequential, while for line cards on modular
|
||||
system it could be non-sequential.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 33 ++++++++++++++-----
|
||||
1 file changed, 25 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 313856b88f6c..bde5489d9240 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -77,9 +77,11 @@ static const struct mlxsw_thermal_trip default_thermal_trips[] = {
|
||||
#define MLXSW_THERMAL_TRIP_MASK (BIT(MLXSW_THERMAL_NUM_TRIPS) - 1)
|
||||
|
||||
struct mlxsw_thermal;
|
||||
+struct mlxsw_thermal_area;
|
||||
|
||||
struct mlxsw_thermal_module {
|
||||
struct mlxsw_thermal *parent;
|
||||
+ struct mlxsw_thermal_area *area;
|
||||
struct thermal_zone_device *tzdev;
|
||||
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
|
||||
int module; /* Module or gearbox number */
|
||||
@@ -92,6 +94,7 @@ struct mlxsw_thermal_area {
|
||||
struct mlxsw_thermal_module *tz_gearbox_arr;
|
||||
u8 tz_gearbox_num;
|
||||
u8 slot_index;
|
||||
+ u16 *gearbox_sensor_map;
|
||||
};
|
||||
|
||||
struct mlxsw_thermal {
|
||||
@@ -586,7 +589,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
|
||||
int temp;
|
||||
int err;
|
||||
|
||||
- index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module;
|
||||
+ index = tz->area->gearbox_sensor_map[tz->module];
|
||||
mlxsw_reg_mtmp_pack(mtmp_pl, tz->slot_index, index, false, false);
|
||||
|
||||
err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
|
||||
@@ -727,6 +730,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
|
||||
if (module_tz->parent)
|
||||
return 0;
|
||||
module_tz->module = module;
|
||||
+ module_tz->area = area;
|
||||
module_tz->slot_index = area->slot_index;
|
||||
module_tz->parent = thermal;
|
||||
memcpy(module_tz->trips, default_thermal_trips,
|
||||
@@ -851,36 +855,48 @@ mlxsw_thermal_gearboxes_main_init(struct device *dev, struct mlxsw_core *core,
|
||||
{
|
||||
enum mlxsw_reg_mgpir_device_type device_type;
|
||||
char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
- u8 gbox_num;
|
||||
- int err;
|
||||
+ int i = 0, err;
|
||||
|
||||
mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- mlxsw_reg_mgpir_unpack(mgpir_pl, &gbox_num, &device_type, NULL,
|
||||
- NULL, NULL);
|
||||
+ mlxsw_reg_mgpir_unpack(mgpir_pl, &area->tz_gearbox_num, &device_type,
|
||||
+ NULL, NULL, NULL);
|
||||
if (device_type != MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE)
|
||||
- gbox_num = 0;
|
||||
+ area->tz_gearbox_num = 0;
|
||||
|
||||
/* Skip gearbox sensor array allocation, if no gearboxes are available. */
|
||||
- if (!gbox_num)
|
||||
+ if (!area->tz_gearbox_num)
|
||||
return 0;
|
||||
|
||||
- area->tz_gearbox_num = gbox_num;
|
||||
area->tz_gearbox_arr = kcalloc(area->tz_gearbox_num,
|
||||
sizeof(*area->tz_gearbox_arr),
|
||||
GFP_KERNEL);
|
||||
if (!area->tz_gearbox_arr)
|
||||
return -ENOMEM;
|
||||
|
||||
+ area->gearbox_sensor_map = kmalloc_array(area->tz_gearbox_num,
|
||||
+ sizeof(u16), GFP_KERNEL);
|
||||
+ if (!area->gearbox_sensor_map)
|
||||
+ goto mlxsw_thermal_gearbox_sensor_map;
|
||||
+
|
||||
+ /* Fill out gearbox sensor mapping array. */
|
||||
+ for (i = 0; i < area->tz_gearbox_num; i++)
|
||||
+ area->gearbox_sensor_map[i] = MLXSW_REG_MTMP_GBOX_INDEX_MIN + i;
|
||||
+
|
||||
return 0;
|
||||
+
|
||||
+mlxsw_thermal_gearbox_sensor_map:
|
||||
+ kfree(area->tz_gearbox_arr);
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static void
|
||||
mlxsw_thermal_gearboxes_main_fini(struct mlxsw_thermal_area *area)
|
||||
{
|
||||
+ kfree(area->gearbox_sensor_map);
|
||||
kfree(area->tz_gearbox_arr);
|
||||
}
|
||||
|
||||
@@ -901,6 +917,7 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,
|
||||
sizeof(thermal->trips));
|
||||
gearbox_tz->module = i;
|
||||
gearbox_tz->parent = thermal;
|
||||
+ gearbox_tz->area = area;
|
||||
gearbox_tz->slot_index = area->slot_index;
|
||||
err = mlxsw_thermal_gearbox_tz_init(gearbox_tz);
|
||||
if (err)
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,59 +0,0 @@
|
||||
From 901e0ed6354f716b23854ad2f8e4eeb9a74414ab Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:36 +0200
|
||||
Subject: [PATCH backport 5.10 122/182] mlxsw: core_thermal: Add line card id
|
||||
prefix to line card thermal zone name
|
||||
|
||||
Add prefix "lc#n" to thermal zones associated with the thermal objects
|
||||
found on line cards.
|
||||
|
||||
For example thermal zone for module #9 located at line card #7 will
|
||||
have type:
|
||||
mlxsw-lc7-module9.
|
||||
And thermal zone for gearbox #3 located at line card #5 will have type:
|
||||
mlxsw-lc5-gearbox3.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_thermal.c | 16 ++++++++++++----
|
||||
1 file changed, 12 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index bde5489d9240..4964c9164c2d 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -689,8 +689,12 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
|
||||
char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME];
|
||||
int err;
|
||||
|
||||
- snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d",
|
||||
- module_tz->module + 1);
|
||||
+ if (module_tz->slot_index)
|
||||
+ snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-module%d",
|
||||
+ module_tz->slot_index, module_tz->module + 1);
|
||||
+ else
|
||||
+ snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d",
|
||||
+ module_tz->module + 1);
|
||||
module_tz->tzdev = thermal_zone_device_register(tz_name,
|
||||
MLXSW_THERMAL_NUM_TRIPS,
|
||||
MLXSW_THERMAL_TRIP_MASK,
|
||||
@@ -824,8 +828,12 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
|
||||
char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME];
|
||||
int ret;
|
||||
|
||||
- snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d",
|
||||
- gearbox_tz->module + 1);
|
||||
+ if (gearbox_tz->slot_index)
|
||||
+ snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-gearbox%d",
|
||||
+ gearbox_tz->slot_index, gearbox_tz->module + 1);
|
||||
+ else
|
||||
+ snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d",
|
||||
+ gearbox_tz->module + 1);
|
||||
gearbox_tz->tzdev = thermal_zone_device_register(tz_name,
|
||||
MLXSW_THERMAL_NUM_TRIPS,
|
||||
MLXSW_THERMAL_TRIP_MASK,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,35 +0,0 @@
|
||||
From 7e5f922bac5153137a8b1f486728d9d95b4922bc Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Tue, 14 Dec 2021 10:57:37 +0200
|
||||
Subject: [PATCH backport 5.10 123/182] mlxsw: core_thermal: Use exact name of
|
||||
cooling devices for binding
|
||||
|
||||
Modular system supports additional cooling devices "mlxreg_fan1",
|
||||
"mlxreg_fan2", etcetera. Thermal zones in "mlxsw" driver should be
|
||||
bound to the same device as before called "mlxreg_fan". Used exact
|
||||
match for cooling device name to avoid binding to new additional
|
||||
cooling devices.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 4964c9164c2d..64c6a78f3aa0 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -133,8 +133,7 @@ static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal,
|
||||
|
||||
/* Allow mlxsw thermal zone binding to an external cooling device */
|
||||
for (i = 0; i < ARRAY_SIZE(mlxsw_thermal_external_allowed_cdev); i++) {
|
||||
- if (strnstr(cdev->type, mlxsw_thermal_external_allowed_cdev[i],
|
||||
- strlen(cdev->type)))
|
||||
+ if (!strcmp(cdev->type, mlxsw_thermal_external_allowed_cdev[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,49 +0,0 @@
|
||||
From 8d06868f51917926f99299eaac26d6f86eff3593 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 13 Apr 2022 18:17:33 +0300
|
||||
Subject: [PATCH backport 5.10 124/182] mlxsw: core_thermal: Use common define
|
||||
for thermal zone name length
|
||||
|
||||
Replace internal define 'MLXSW_THERMAL_ZONE_MAX_NAME' by common
|
||||
'THERMAL_NAME_LENGTH'.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index 64c6a78f3aa0..b9253c9f70d9 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -21,7 +21,6 @@
|
||||
#define MLXSW_THERMAL_ASIC_TEMP_HOT 105000 /* 105C */
|
||||
#define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */
|
||||
#define MLXSW_THERMAL_MODULE_TEMP_SHIFT (MLXSW_THERMAL_HYSTERESIS_TEMP * 2)
|
||||
-#define MLXSW_THERMAL_ZONE_MAX_NAME 16
|
||||
#define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0)
|
||||
#define MLXSW_THERMAL_MAX_STATE 10
|
||||
#define MLXSW_THERMAL_MIN_STATE 2
|
||||
@@ -685,7 +684,7 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = {
|
||||
static int
|
||||
mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
|
||||
{
|
||||
- char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME];
|
||||
+ char tz_name[THERMAL_NAME_LENGTH];
|
||||
int err;
|
||||
|
||||
if (module_tz->slot_index)
|
||||
@@ -824,7 +823,7 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal,
|
||||
static int
|
||||
mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
|
||||
{
|
||||
- char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME];
|
||||
+ char tz_name[THERMAL_NAME_LENGTH];
|
||||
int ret;
|
||||
|
||||
if (gearbox_tz->slot_index)
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,532 +0,0 @@
|
||||
From 36a2e4e93d7d1ca2ed670b4cf827400ba367e290 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 22 Dec 2021 08:57:27 +0000
|
||||
Subject: [PATCH backport 5.10 125/182] devlink: add support to create line
|
||||
card and expose to user
|
||||
|
||||
Extend the devlink API so the driver is going to be able to create and
|
||||
destroy linecard instances. There can be multiple line cards per devlink
|
||||
device. Expose this new type of object over devlink netlink API to the
|
||||
userspace, with notifications.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
include/net/devlink.h | 15 ++
|
||||
include/uapi/linux/devlink.h | 22 +++
|
||||
net/core/devlink.c | 303 ++++++++++++++++++++++++++++++++++-
|
||||
3 files changed, 339 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index b01bb9bca5a2..e8f046590579 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -31,6 +31,7 @@ struct devlink_dev_stats {
|
||||
struct devlink_ops;
|
||||
|
||||
struct devlink {
|
||||
+ u32 index;
|
||||
struct list_head list;
|
||||
struct list_head port_list;
|
||||
struct list_head sb_list;
|
||||
@@ -44,6 +45,8 @@ struct devlink {
|
||||
struct list_head trap_list;
|
||||
struct list_head trap_group_list;
|
||||
struct list_head trap_policer_list;
|
||||
+ struct list_head linecard_list;
|
||||
+ struct mutex linecards_lock; /* protects linecard_list */
|
||||
const struct devlink_ops *ops;
|
||||
struct xarray snapshot_ids;
|
||||
struct devlink_dev_stats stats;
|
||||
@@ -55,6 +58,8 @@ struct devlink {
|
||||
u8 reload_failed:1,
|
||||
reload_enabled:1,
|
||||
registered:1;
|
||||
+ refcount_t refcount;
|
||||
+ struct completion comp;
|
||||
char priv[0] __aligned(NETDEV_ALIGN);
|
||||
};
|
||||
|
||||
@@ -137,6 +142,13 @@ struct devlink_port {
|
||||
struct mutex reporters_lock; /* Protects reporter_list */
|
||||
};
|
||||
|
||||
+struct devlink_linecard {
|
||||
+ struct list_head list;
|
||||
+ struct devlink *devlink;
|
||||
+ unsigned int index;
|
||||
+ refcount_t refcount;
|
||||
+};
|
||||
+
|
||||
struct devlink_sb_pool_info {
|
||||
enum devlink_sb_pool_type pool_type;
|
||||
u32 size;
|
||||
@@ -1401,6 +1413,9 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro
|
||||
u16 pf, bool external);
|
||||
void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller,
|
||||
u16 pf, u16 vf, bool external);
|
||||
+struct devlink_linecard *devlink_linecard_create(struct devlink *devlink,
|
||||
+ unsigned int linecard_index);
|
||||
+void devlink_linecard_destroy(struct devlink_linecard *linecard);
|
||||
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
|
||||
u32 size, u16 ingress_pools_count,
|
||||
u16 egress_pools_count, u16 ingress_tc_count,
|
||||
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
|
||||
index cf89c318f2ac..ff07ad596035 100644
|
||||
--- a/include/uapi/linux/devlink.h
|
||||
+++ b/include/uapi/linux/devlink.h
|
||||
@@ -126,6 +126,16 @@ enum devlink_command {
|
||||
|
||||
DEVLINK_CMD_HEALTH_REPORTER_TEST,
|
||||
|
||||
+ DEVLINK_CMD_RATE_GET, /* can dump */
|
||||
+ DEVLINK_CMD_RATE_SET,
|
||||
+ DEVLINK_CMD_RATE_NEW,
|
||||
+ DEVLINK_CMD_RATE_DEL,
|
||||
+
|
||||
+ DEVLINK_CMD_LINECARD_GET, /* can dump */
|
||||
+ DEVLINK_CMD_LINECARD_SET,
|
||||
+ DEVLINK_CMD_LINECARD_NEW,
|
||||
+ DEVLINK_CMD_LINECARD_DEL,
|
||||
+
|
||||
/* add new commands above here */
|
||||
__DEVLINK_CMD_MAX,
|
||||
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
|
||||
@@ -529,6 +539,18 @@ enum devlink_attr {
|
||||
DEVLINK_ATTR_RELOAD_ACTION_INFO, /* nested */
|
||||
DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */
|
||||
|
||||
+ DEVLINK_ATTR_PORT_PCI_SF_NUMBER, /* u32 */
|
||||
+
|
||||
+ DEVLINK_ATTR_RATE_TYPE, /* u16 */
|
||||
+ DEVLINK_ATTR_RATE_TX_SHARE, /* u64 */
|
||||
+ DEVLINK_ATTR_RATE_TX_MAX, /* u64 */
|
||||
+ DEVLINK_ATTR_RATE_NODE_NAME, /* string */
|
||||
+ DEVLINK_ATTR_RATE_PARENT_NODE_NAME, /* string */
|
||||
+
|
||||
+ DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */
|
||||
+
|
||||
+ DEVLINK_ATTR_LINECARD_INDEX, /* u32 */
|
||||
+
|
||||
/* add new attributes above here, update the policy in devlink.c */
|
||||
|
||||
__DEVLINK_ATTR_MAX,
|
||||
diff --git a/net/core/devlink.c b/net/core/devlink.c
|
||||
index 72047750dcd9..645fe0612b53 100644
|
||||
--- a/net/core/devlink.c
|
||||
+++ b/net/core/devlink.c
|
||||
@@ -91,6 +91,25 @@ static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_
|
||||
|
||||
static LIST_HEAD(devlink_list);
|
||||
|
||||
+static DEFINE_XARRAY_FLAGS(devlinks, XA_FLAGS_ALLOC);
|
||||
+#define DEVLINK_REGISTERED XA_MARK_1
|
||||
+
|
||||
+/* devlink instances are open to the access from the user space after
|
||||
+ * devlink_register() call. Such logical barrier allows us to have certain
|
||||
+ * expectations related to locking.
|
||||
+ *
|
||||
+ * Before *_register() - we are in initialization stage and no parallel
|
||||
+ * access possible to the devlink instance. All drivers perform that phase
|
||||
+ * by implicitly holding device_lock.
|
||||
+ *
|
||||
+ * After *_register() - users and driver can access devlink instance at
|
||||
+ * the same time.
|
||||
+ */
|
||||
+#define ASSERT_DEVLINK_REGISTERED(d) \
|
||||
+ WARN_ON_ONCE(!xa_get_mark(&devlinks, (d)->index, DEVLINK_REGISTERED))
|
||||
+#define ASSERT_DEVLINK_NOT_REGISTERED(d) \
|
||||
+ WARN_ON_ONCE(xa_get_mark(&devlinks, (d)->index, DEVLINK_REGISTERED))
|
||||
+
|
||||
/* devlink_mutex
|
||||
*
|
||||
* An overall lock guarding every operation coming from userspace.
|
||||
@@ -105,6 +124,19 @@ struct net *devlink_net(const struct devlink *devlink)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devlink_net);
|
||||
|
||||
+void devlink_put(struct devlink *devlink)
|
||||
+{
|
||||
+ if (refcount_dec_and_test(&devlink->refcount))
|
||||
+ complete(&devlink->comp);
|
||||
+}
|
||||
+
|
||||
+struct devlink *__must_check devlink_try_get(struct devlink *devlink)
|
||||
+{
|
||||
+ if (refcount_inc_not_zero(&devlink->refcount))
|
||||
+ return devlink;
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static void __devlink_net_set(struct devlink *devlink, struct net *net)
|
||||
{
|
||||
write_pnet(&devlink->_net, net);
|
||||
@@ -187,6 +219,56 @@ static struct devlink_port *devlink_port_get_from_info(struct devlink *devlink,
|
||||
return devlink_port_get_from_attrs(devlink, info->attrs);
|
||||
}
|
||||
|
||||
+static struct devlink_linecard *
|
||||
+devlink_linecard_get_by_index(struct devlink *devlink,
|
||||
+ unsigned int linecard_index)
|
||||
+{
|
||||
+ struct devlink_linecard *devlink_linecard;
|
||||
+
|
||||
+ list_for_each_entry(devlink_linecard, &devlink->linecard_list, list) {
|
||||
+ if (devlink_linecard->index == linecard_index)
|
||||
+ return devlink_linecard;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static bool devlink_linecard_index_exists(struct devlink *devlink,
|
||||
+ unsigned int linecard_index)
|
||||
+{
|
||||
+ return devlink_linecard_get_by_index(devlink, linecard_index);
|
||||
+}
|
||||
+
|
||||
+static struct devlink_linecard *
|
||||
+devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs)
|
||||
+{
|
||||
+ if (attrs[DEVLINK_ATTR_LINECARD_INDEX]) {
|
||||
+ u32 linecard_index = nla_get_u32(attrs[DEVLINK_ATTR_LINECARD_INDEX]);
|
||||
+ struct devlink_linecard *linecard;
|
||||
+
|
||||
+ mutex_lock(&devlink->linecards_lock);
|
||||
+ linecard = devlink_linecard_get_by_index(devlink, linecard_index);
|
||||
+ if (linecard)
|
||||
+ refcount_inc(&linecard->refcount);
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+ if (!linecard)
|
||||
+ return ERR_PTR(-ENODEV);
|
||||
+ return linecard;
|
||||
+ }
|
||||
+ return ERR_PTR(-EINVAL);
|
||||
+}
|
||||
+
|
||||
+static struct devlink_linecard *
|
||||
+devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info)
|
||||
+{
|
||||
+ return devlink_linecard_get_from_attrs(devlink, info->attrs);
|
||||
+}
|
||||
+
|
||||
+static void devlink_linecard_put(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ if (refcount_dec_and_test(&linecard->refcount))
|
||||
+ kfree(linecard);
|
||||
+}
|
||||
+
|
||||
struct devlink_sb {
|
||||
struct list_head list;
|
||||
unsigned int index;
|
||||
@@ -405,16 +487,20 @@ devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id)
|
||||
|
||||
#define DEVLINK_NL_FLAG_NEED_PORT BIT(0)
|
||||
#define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1)
|
||||
+#define DEVLINK_NL_FLAG_NEED_RATE BIT(2)
|
||||
+#define DEVLINK_NL_FLAG_NEED_RATE_NODE BIT(3)
|
||||
+#define DEVLINK_NL_FLAG_NEED_LINECARD BIT(4)
|
||||
|
||||
/* The per devlink instance lock is taken by default in the pre-doit
|
||||
* operation, yet several commands do not require this. The global
|
||||
* devlink lock is taken and protects from disruption by user-calls.
|
||||
*/
|
||||
-#define DEVLINK_NL_FLAG_NO_LOCK BIT(2)
|
||||
+#define DEVLINK_NL_FLAG_NO_LOCK BIT(5)
|
||||
|
||||
static int devlink_nl_pre_doit(const struct genl_ops *ops,
|
||||
struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
+ struct devlink_linecard *linecard;
|
||||
struct devlink_port *devlink_port;
|
||||
struct devlink *devlink;
|
||||
int err;
|
||||
@@ -439,6 +525,13 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops,
|
||||
devlink_port = devlink_port_get_from_info(devlink, info);
|
||||
if (!IS_ERR(devlink_port))
|
||||
info->user_ptr[1] = devlink_port;
|
||||
+ } else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) {
|
||||
+ linecard = devlink_linecard_get_from_info(devlink, info);
|
||||
+ if (IS_ERR(linecard)) {
|
||||
+ err = PTR_ERR(linecard);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+ info->user_ptr[1] = linecard;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -452,9 +545,14 @@ static int devlink_nl_pre_doit(const struct genl_ops *ops,
|
||||
static void devlink_nl_post_doit(const struct genl_ops *ops,
|
||||
struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
+ struct devlink_linecard *linecard;
|
||||
struct devlink *devlink;
|
||||
|
||||
devlink = info->user_ptr[0];
|
||||
+ if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) {
|
||||
+ linecard = info->user_ptr[1];
|
||||
+ devlink_linecard_put(linecard);
|
||||
+ }
|
||||
if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
|
||||
mutex_unlock(&devlink->lock);
|
||||
mutex_unlock(&devlink_mutex);
|
||||
@@ -1135,6 +1233,132 @@ static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
|
||||
return devlink_port_unsplit(devlink, port_index, info->extack);
|
||||
}
|
||||
|
||||
+static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
+ struct devlink *devlink,
|
||||
+ struct devlink_linecard *linecard,
|
||||
+ enum devlink_command cmd, u32 portid,
|
||||
+ u32 seq, int flags,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ void *hdr;
|
||||
+
|
||||
+ hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
|
||||
+ if (!hdr)
|
||||
+ return -EMSGSIZE;
|
||||
+
|
||||
+ if (devlink_nl_put_handle(msg, devlink))
|
||||
+ goto nla_put_failure;
|
||||
+ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index))
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
+ genlmsg_end(msg, hdr);
|
||||
+ return 0;
|
||||
+
|
||||
+nla_put_failure:
|
||||
+ genlmsg_cancel(msg, hdr);
|
||||
+ return -EMSGSIZE;
|
||||
+}
|
||||
+
|
||||
+static void devlink_linecard_notify(struct devlink_linecard *linecard,
|
||||
+ enum devlink_command cmd)
|
||||
+{
|
||||
+ struct devlink *devlink = linecard->devlink;
|
||||
+ struct sk_buff *msg;
|
||||
+ int err;
|
||||
+
|
||||
+ WARN_ON(cmd != DEVLINK_CMD_LINECARD_NEW &&
|
||||
+ cmd != DEVLINK_CMD_LINECARD_DEL);
|
||||
+
|
||||
+ if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED))
|
||||
+ return;
|
||||
+
|
||||
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
||||
+ if (!msg)
|
||||
+ return;
|
||||
+
|
||||
+ err = devlink_nl_linecard_fill(msg, devlink, linecard, cmd, 0, 0, 0,
|
||||
+ NULL);
|
||||
+ if (err) {
|
||||
+ nlmsg_free(msg);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink),
|
||||
+ msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_cmd_linecard_get_doit(struct sk_buff *skb,
|
||||
+ struct genl_info *info)
|
||||
+{
|
||||
+ struct devlink_linecard *linecard = info->user_ptr[1];
|
||||
+ struct devlink *devlink = linecard->devlink;
|
||||
+ struct sk_buff *msg;
|
||||
+ int err;
|
||||
+
|
||||
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
||||
+ if (!msg)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ err = devlink_nl_linecard_fill(msg, devlink, linecard,
|
||||
+ DEVLINK_CMD_LINECARD_NEW,
|
||||
+ info->snd_portid, info->snd_seq, 0,
|
||||
+ info->extack);
|
||||
+ if (err) {
|
||||
+ nlmsg_free(msg);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ return genlmsg_reply(msg, info);
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg,
|
||||
+ struct netlink_callback *cb)
|
||||
+{
|
||||
+ struct devlink_linecard *linecard;
|
||||
+ struct devlink *devlink;
|
||||
+ int start = cb->args[0];
|
||||
+ unsigned long index;
|
||||
+ int idx = 0;
|
||||
+ int err;
|
||||
+
|
||||
+ mutex_lock(&devlink_mutex);
|
||||
+ xa_for_each_marked(&devlinks, index, devlink, DEVLINK_REGISTERED) {
|
||||
+ if (!devlink_try_get(devlink))
|
||||
+ continue;
|
||||
+
|
||||
+ if (!net_eq(devlink_net(devlink), sock_net(msg->sk)))
|
||||
+ goto retry;
|
||||
+
|
||||
+ mutex_lock(&devlink->linecards_lock);
|
||||
+ list_for_each_entry(linecard, &devlink->linecard_list, list) {
|
||||
+ if (idx < start) {
|
||||
+ idx++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ err = devlink_nl_linecard_fill(msg, devlink, linecard,
|
||||
+ DEVLINK_CMD_LINECARD_NEW,
|
||||
+ NETLINK_CB(cb->skb).portid,
|
||||
+ cb->nlh->nlmsg_seq,
|
||||
+ NLM_F_MULTI,
|
||||
+ cb->extack);
|
||||
+ if (err) {
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+ devlink_put(devlink);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ idx++;
|
||||
+ }
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+retry:
|
||||
+ devlink_put(devlink);
|
||||
+ }
|
||||
+out:
|
||||
+ mutex_unlock(&devlink_mutex);
|
||||
+
|
||||
+ cb->args[0] = idx;
|
||||
+ return msg->len;
|
||||
+}
|
||||
+
|
||||
static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
struct devlink_sb *devlink_sb,
|
||||
enum devlink_command cmd, u32 portid,
|
||||
@@ -7594,6 +7818,19 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
|
||||
[DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_RELOAD_ACTION_DRIVER_REINIT,
|
||||
DEVLINK_RELOAD_ACTION_MAX),
|
||||
[DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(DEVLINK_RELOAD_LIMITS_VALID_MASK),
|
||||
+//<<<<<<< HEAD
|
||||
+//=======
|
||||
+ [DEVLINK_ATTR_PORT_FLAVOUR] = { .type = NLA_U16 },
|
||||
+ [DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16 },
|
||||
+ [DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32 },
|
||||
+ [DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32 },
|
||||
+ [DEVLINK_ATTR_RATE_TYPE] = { .type = NLA_U16 },
|
||||
+ [DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64 },
|
||||
+ [DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64 },
|
||||
+ [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING },
|
||||
+ [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING },
|
||||
+ [DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32 },
|
||||
+//>>>>>>> 1180815a3831... devlink: add support to create line card and expose to user
|
||||
};
|
||||
|
||||
static const struct genl_small_ops devlink_nl_ops[] = {
|
||||
@@ -7633,6 +7870,14 @@ static const struct genl_small_ops devlink_nl_ops[] = {
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.internal_flags = DEVLINK_NL_FLAG_NO_LOCK,
|
||||
},
|
||||
+ {
|
||||
+ .cmd = DEVLINK_CMD_LINECARD_GET,
|
||||
+ .doit = devlink_nl_cmd_linecard_get_doit,
|
||||
+ .dumpit = devlink_nl_cmd_linecard_get_dumpit,
|
||||
+ .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD |
|
||||
+ DEVLINK_NL_FLAG_NO_LOCK,
|
||||
+ /* can be retrieved by unprivileged users */
|
||||
+ },
|
||||
{
|
||||
.cmd = DEVLINK_CMD_SB_GET,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
@@ -7980,6 +8225,7 @@ struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size)
|
||||
xa_init_flags(&devlink->snapshot_ids, XA_FLAGS_ALLOC);
|
||||
__devlink_net_set(devlink, &init_net);
|
||||
INIT_LIST_HEAD(&devlink->port_list);
|
||||
+ INIT_LIST_HEAD(&devlink->linecard_list);
|
||||
INIT_LIST_HEAD(&devlink->sb_list);
|
||||
INIT_LIST_HEAD_RCU(&devlink->dpipe_table_list);
|
||||
INIT_LIST_HEAD(&devlink->resource_list);
|
||||
@@ -7991,6 +8237,8 @@ struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size)
|
||||
INIT_LIST_HEAD(&devlink->trap_policer_list);
|
||||
mutex_init(&devlink->lock);
|
||||
mutex_init(&devlink->reporters_lock);
|
||||
+ mutex_init(&devlink->linecards_lock);
|
||||
+
|
||||
return devlink;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devlink_alloc);
|
||||
@@ -8071,6 +8319,7 @@ EXPORT_SYMBOL_GPL(devlink_reload_disable);
|
||||
*/
|
||||
void devlink_free(struct devlink *devlink)
|
||||
{
|
||||
+ mutex_destroy(&devlink->linecards_lock);
|
||||
mutex_destroy(&devlink->reporters_lock);
|
||||
mutex_destroy(&devlink->lock);
|
||||
WARN_ON(!list_empty(&devlink->trap_policer_list));
|
||||
@@ -8082,6 +8331,7 @@ void devlink_free(struct devlink *devlink)
|
||||
WARN_ON(!list_empty(&devlink->resource_list));
|
||||
WARN_ON(!list_empty(&devlink->dpipe_table_list));
|
||||
WARN_ON(!list_empty(&devlink->sb_list));
|
||||
+ WARN_ON(!list_empty(&devlink->linecard_list));
|
||||
WARN_ON(!list_empty(&devlink->port_list));
|
||||
|
||||
xa_destroy(&devlink->snapshot_ids);
|
||||
@@ -8427,6 +8677,57 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * devlink_linecard_create - Create devlink linecard
|
||||
+ *
|
||||
+ * @devlink: devlink
|
||||
+ * @linecard_index: driver-specific numerical identifier of the linecard
|
||||
+ *
|
||||
+ * Create devlink linecard instance with provided linecard index.
|
||||
+ * Caller can use any indexing, even hw-related one.
|
||||
+ */
|
||||
+struct devlink_linecard *devlink_linecard_create(struct devlink *devlink,
|
||||
+ unsigned int linecard_index)
|
||||
+{
|
||||
+ struct devlink_linecard *linecard;
|
||||
+
|
||||
+ mutex_lock(&devlink->linecards_lock);
|
||||
+ if (devlink_linecard_index_exists(devlink, linecard_index)) {
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+ return ERR_PTR(-EEXIST);
|
||||
+ }
|
||||
+
|
||||
+ linecard = kzalloc(sizeof(*linecard), GFP_KERNEL);
|
||||
+ if (!linecard)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+
|
||||
+ linecard->devlink = devlink;
|
||||
+ linecard->index = linecard_index;
|
||||
+ list_add_tail(&linecard->list, &devlink->linecard_list);
|
||||
+ refcount_set(&linecard->refcount, 1);
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+ return linecard;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_create);
|
||||
+
|
||||
+/**
|
||||
+ * devlink_linecard_destroy - Destroy devlink linecard
|
||||
+ *
|
||||
+ * @linecard: devlink linecard
|
||||
+ */
|
||||
+void devlink_linecard_destroy(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ struct devlink *devlink = linecard->devlink;
|
||||
+
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL);
|
||||
+ mutex_lock(&devlink->linecards_lock);
|
||||
+ list_del(&linecard->list);
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+ devlink_linecard_put(linecard);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_destroy);
|
||||
+
|
||||
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
|
||||
u32 size, u16 ingress_pools_count,
|
||||
u16 egress_pools_count, u16 ingress_tc_count,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,555 +0,0 @@
|
||||
From 37d223fa389636092d519ca903f186d608eed3c8 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Thu, 31 Dec 2020 17:35:08 +0100
|
||||
Subject: [PATCH backport 5.10 126/182] devlink: implement line card
|
||||
provisioning
|
||||
|
||||
In order to be able to configure all needed stuff on a port/netdevice
|
||||
of a line card without the line card being present, introduce line card
|
||||
provisioning. Basically by setting a type, provisioning process will
|
||||
start and driver is supposed to create a placeholder for instances
|
||||
(ports/netdevices) for a line card type.
|
||||
|
||||
Allow the user to query the supported line card types over line card
|
||||
get command. Then implement two netlink command SET to allow user to
|
||||
set/unset the card type.
|
||||
|
||||
On the driver API side, add provision/unprovision ops and supported
|
||||
types array to be advertised. Upon provision op call, the driver should
|
||||
take care of creating the instances for the particular line card type.
|
||||
Introduce provision_set/clear() functions to be called by the driver
|
||||
once the provisioning/unprovisioning is done on its side. These helpers
|
||||
are not to be called directly due to the async nature of provisioning.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
include/net/devlink.h | 41 ++++-
|
||||
include/uapi/linux/devlink.h | 15 ++
|
||||
net/core/devlink.c | 311 ++++++++++++++++++++++++++++++++---
|
||||
3 files changed, 346 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index e8f046590579..44b60085ec16 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -142,11 +142,43 @@ struct devlink_port {
|
||||
struct mutex reporters_lock; /* Protects reporter_list */
|
||||
};
|
||||
|
||||
+struct devlink_linecard_ops;
|
||||
+struct devlink_linecard_type;
|
||||
+
|
||||
struct devlink_linecard {
|
||||
struct list_head list;
|
||||
struct devlink *devlink;
|
||||
unsigned int index;
|
||||
refcount_t refcount;
|
||||
+ const struct devlink_linecard_ops *ops;
|
||||
+ void *priv;
|
||||
+ enum devlink_linecard_state state;
|
||||
+ struct mutex state_lock; /* Protects state */
|
||||
+ const char *type;
|
||||
+ struct devlink_linecard_type *types;
|
||||
+ unsigned int types_count;
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * struct devlink_linecard_ops - Linecard operations
|
||||
+ * @provision: callback to provision the linecard slot with certain
|
||||
+ * type of linecard
|
||||
+ * @unprovision: callback to unprovision the linecard slot
|
||||
+ * @types_init: callback to initialize types list
|
||||
+ * @types_fini: callback to finalize types list
|
||||
+ * @types_get: callback to get next type in list
|
||||
+ */
|
||||
+struct devlink_linecard_ops {
|
||||
+ int (*provision)(struct devlink_linecard *linecard, void *priv,
|
||||
+ const char *type, const void *type_priv,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
+ int (*unprovision)(struct devlink_linecard *linecard, void *priv,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
+ unsigned int (*types_count)(struct devlink_linecard *linecard,
|
||||
+ void *priv);
|
||||
+ void (*types_get)(struct devlink_linecard *linecard,
|
||||
+ void *priv, unsigned int index, const char **type,
|
||||
+ const void **type_priv);
|
||||
};
|
||||
|
||||
struct devlink_sb_pool_info {
|
||||
@@ -1413,9 +1445,14 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro
|
||||
u16 pf, bool external);
|
||||
void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller,
|
||||
u16 pf, u16 vf, bool external);
|
||||
-struct devlink_linecard *devlink_linecard_create(struct devlink *devlink,
|
||||
- unsigned int linecard_index);
|
||||
+struct devlink_linecard *
|
||||
+devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
|
||||
+ const struct devlink_linecard_ops *ops, void *priv);
|
||||
void devlink_linecard_destroy(struct devlink_linecard *linecard);
|
||||
+void devlink_linecard_provision_set(struct devlink_linecard *linecard,
|
||||
+ const char *type);
|
||||
+void devlink_linecard_provision_clear(struct devlink_linecard *linecard);
|
||||
+void devlink_linecard_provision_fail(struct devlink_linecard *linecard);
|
||||
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
|
||||
u32 size, u16 ingress_pools_count,
|
||||
u16 egress_pools_count, u16 ingress_tc_count,
|
||||
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
|
||||
index ff07ad596035..d8833664522f 100644
|
||||
--- a/include/uapi/linux/devlink.h
|
||||
+++ b/include/uapi/linux/devlink.h
|
||||
@@ -334,6 +334,18 @@ enum devlink_reload_limit {
|
||||
|
||||
#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
|
||||
|
||||
+enum devlink_linecard_state {
|
||||
+ DEVLINK_LINECARD_STATE_UNSPEC,
|
||||
+ DEVLINK_LINECARD_STATE_UNPROVISIONED,
|
||||
+ DEVLINK_LINECARD_STATE_UNPROVISIONING,
|
||||
+ DEVLINK_LINECARD_STATE_PROVISIONING,
|
||||
+ DEVLINK_LINECARD_STATE_PROVISIONING_FAILED,
|
||||
+ DEVLINK_LINECARD_STATE_PROVISIONED,
|
||||
+
|
||||
+ __DEVLINK_LINECARD_STATE_MAX,
|
||||
+ DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1
|
||||
+};
|
||||
+
|
||||
enum devlink_attr {
|
||||
/* don't change the order or add anything between, this is ABI! */
|
||||
DEVLINK_ATTR_UNSPEC,
|
||||
@@ -550,6 +562,9 @@ enum devlink_attr {
|
||||
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */
|
||||
|
||||
DEVLINK_ATTR_LINECARD_INDEX, /* u32 */
|
||||
+ DEVLINK_ATTR_LINECARD_STATE, /* u8 */
|
||||
+ DEVLINK_ATTR_LINECARD_TYPE, /* string */
|
||||
+ DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */
|
||||
|
||||
/* add new attributes above here, update the policy in devlink.c */
|
||||
|
||||
diff --git a/net/core/devlink.c b/net/core/devlink.c
|
||||
index 645fe0612b53..943973ffc450 100644
|
||||
--- a/net/core/devlink.c
|
||||
+++ b/net/core/devlink.c
|
||||
@@ -265,8 +265,10 @@ devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info)
|
||||
|
||||
static void devlink_linecard_put(struct devlink_linecard *linecard)
|
||||
{
|
||||
- if (refcount_dec_and_test(&linecard->refcount))
|
||||
+ if (refcount_dec_and_test(&linecard->refcount)) {
|
||||
+ mutex_destroy(&linecard->state_lock);
|
||||
kfree(linecard);
|
||||
+ }
|
||||
}
|
||||
|
||||
struct devlink_sb {
|
||||
@@ -1233,6 +1235,12 @@ static int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
|
||||
return devlink_port_unsplit(devlink, port_index, info->extack);
|
||||
}
|
||||
|
||||
+struct devlink_linecard_type {
|
||||
+ struct list_head list;
|
||||
+ const char *type;
|
||||
+ const void *priv;
|
||||
+};
|
||||
+
|
||||
static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
struct devlink *devlink,
|
||||
struct devlink_linecard *linecard,
|
||||
@@ -1240,7 +1248,10 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
u32 seq, int flags,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
+ struct devlink_linecard_type *linecard_type;
|
||||
+ struct nlattr *attr;
|
||||
void *hdr;
|
||||
+ int i;
|
||||
|
||||
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
|
||||
if (!hdr)
|
||||
@@ -1250,6 +1261,25 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
goto nla_put_failure;
|
||||
if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index))
|
||||
goto nla_put_failure;
|
||||
+ if (nla_put_u8(msg, DEVLINK_ATTR_LINECARD_STATE, linecard->state))
|
||||
+ goto nla_put_failure;
|
||||
+ if (linecard->state >= DEVLINK_LINECARD_STATE_PROVISIONED &&
|
||||
+ nla_put_string(msg, DEVLINK_ATTR_LINECARD_TYPE, linecard->type))
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
+ if (linecard->types_count) {
|
||||
+ attr = nla_nest_start(msg,
|
||||
+ DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES);
|
||||
+ if (!attr)
|
||||
+ goto nla_put_failure;
|
||||
+ for (i = 0; i < linecard->types_count; i++) {
|
||||
+ linecard_type = &linecard->types[i];
|
||||
+ if (nla_put_string(msg, DEVLINK_ATTR_LINECARD_TYPE,
|
||||
+ linecard_type->type))
|
||||
+ goto nla_put_failure;
|
||||
+ }
|
||||
+ nla_nest_end(msg, attr);
|
||||
+ }
|
||||
|
||||
genlmsg_end(msg, hdr);
|
||||
return 0;
|
||||
@@ -1335,12 +1365,14 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg,
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
err = devlink_nl_linecard_fill(msg, devlink, linecard,
|
||||
DEVLINK_CMD_LINECARD_NEW,
|
||||
NETLINK_CB(cb->skb).portid,
|
||||
cb->nlh->nlmsg_seq,
|
||||
NLM_F_MULTI,
|
||||
cb->extack);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
if (err) {
|
||||
mutex_unlock(&devlink->linecards_lock);
|
||||
devlink_put(devlink);
|
||||
@@ -1359,6 +1391,153 @@ static int devlink_nl_cmd_linecard_get_dumpit(struct sk_buff *msg,
|
||||
return msg->len;
|
||||
}
|
||||
|
||||
+static struct devlink_linecard_type *
|
||||
+devlink_linecard_type_lookup(struct devlink_linecard *linecard,
|
||||
+ const char *type)
|
||||
+{
|
||||
+ struct devlink_linecard_type *linecard_type;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < linecard->types_count; i++) {
|
||||
+ linecard_type = &linecard->types[i];
|
||||
+ if (!strcmp(type, linecard_type->type))
|
||||
+ return linecard_type;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static int devlink_linecard_type_set(struct devlink_linecard *linecard,
|
||||
+ const char *type,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct devlink_linecard_type *linecard_type;
|
||||
+ int err;
|
||||
+
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being provisioned");
|
||||
+ err = -EBUSY;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONING) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being unprovisioned");
|
||||
+ err = -EBUSY;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (linecard->state != DEVLINK_LINECARD_STATE_UNPROVISIONED &&
|
||||
+ linecard->state != DEVLINK_LINECARD_STATE_PROVISIONING_FAILED) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Linecard already provisioned");
|
||||
+ err = -EBUSY;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ linecard_type = devlink_linecard_type_lookup(linecard, type);
|
||||
+ if (!linecard_type) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Unsupported provision type provided");
|
||||
+ err = -EINVAL;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONING;
|
||||
+ linecard->type = linecard_type->type;
|
||||
+ devlink_linecard_notify(linecard,
|
||||
+ DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ err = linecard->ops->provision(linecard, linecard->priv,
|
||||
+ linecard_type->type, linecard_type->priv,
|
||||
+ extack);
|
||||
+ if (err) {
|
||||
+ /* Provisioning failed. Assume the linecard is unprovisioned
|
||||
+ * for future operations.
|
||||
+ */
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ }
|
||||
+ return err;
|
||||
+
|
||||
+out:
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int devlink_linecard_type_unset(struct devlink_linecard *linecard,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being provisioned");
|
||||
+ err = -EBUSY;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONING) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Linecard is currently being unprovisioned");
|
||||
+ err = -EBUSY;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING_FAILED) {
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
+ linecard->type = NULL;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ err = 0;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONED ||
|
||||
+ linecard->state == DEVLINK_LINECARD_STATE_UNSPEC) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Linecard is not provisioned");
|
||||
+ err = -EOPNOTSUPP;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONING;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ err = linecard->ops->unprovision(linecard, linecard->priv,
|
||||
+ extack);
|
||||
+ if (err) {
|
||||
+ /* Unprovisioning failed. Assume the linecard is unprovisioned
|
||||
+ * for future operations.
|
||||
+ */
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ }
|
||||
+ return err;
|
||||
+
|
||||
+out:
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
|
||||
+ struct genl_info *info)
|
||||
+{
|
||||
+ struct devlink_linecard *linecard = info->user_ptr[1];
|
||||
+ struct netlink_ext_ack *extack = info->extack;
|
||||
+ int err;
|
||||
+
|
||||
+ if (info->attrs[DEVLINK_ATTR_LINECARD_TYPE]) {
|
||||
+ const char *type;
|
||||
+
|
||||
+ type = nla_data(info->attrs[DEVLINK_ATTR_LINECARD_TYPE]);
|
||||
+ if (strcmp(type, "")) {
|
||||
+ err = devlink_linecard_type_set(linecard, type, extack);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ } else {
|
||||
+ err = devlink_linecard_type_unset(linecard, extack);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
struct devlink_sb *devlink_sb,
|
||||
enum devlink_command cmd, u32 portid,
|
||||
@@ -7818,19 +7997,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
|
||||
[DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_RELOAD_ACTION_DRIVER_REINIT,
|
||||
DEVLINK_RELOAD_ACTION_MAX),
|
||||
[DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(DEVLINK_RELOAD_LIMITS_VALID_MASK),
|
||||
-//<<<<<<< HEAD
|
||||
-//=======
|
||||
- [DEVLINK_ATTR_PORT_FLAVOUR] = { .type = NLA_U16 },
|
||||
- [DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16 },
|
||||
- [DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32 },
|
||||
- [DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32 },
|
||||
- [DEVLINK_ATTR_RATE_TYPE] = { .type = NLA_U16 },
|
||||
- [DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64 },
|
||||
- [DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64 },
|
||||
- [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING },
|
||||
- [DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING },
|
||||
[DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32 },
|
||||
-//>>>>>>> 1180815a3831... devlink: add support to create line card and expose to user
|
||||
+ [DEVLINK_ATTR_LINECARD_TYPE] = { .type = NLA_NUL_STRING },
|
||||
};
|
||||
|
||||
static const struct genl_small_ops devlink_nl_ops[] = {
|
||||
@@ -7878,6 +8046,13 @@ static const struct genl_small_ops devlink_nl_ops[] = {
|
||||
DEVLINK_NL_FLAG_NO_LOCK,
|
||||
/* can be retrieved by unprivileged users */
|
||||
},
|
||||
+ {
|
||||
+ .cmd = DEVLINK_CMD_LINECARD_SET,
|
||||
+ .doit = devlink_nl_cmd_linecard_set_doit,
|
||||
+ .flags = GENL_ADMIN_PERM,
|
||||
+ .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD |
|
||||
+ DEVLINK_NL_FLAG_NO_LOCK,
|
||||
+ },
|
||||
{
|
||||
.cmd = DEVLINK_CMD_SB_GET,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
@@ -8677,35 +8852,85 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int devlink_linecard_types_init(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ struct devlink_linecard_type *linecard_type;
|
||||
+ unsigned int count;
|
||||
+ int i;
|
||||
+
|
||||
+ count = linecard->ops->types_count(linecard, linecard->priv);
|
||||
+ linecard->types = kmalloc_array(count, sizeof(*linecard_type),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!linecard->types)
|
||||
+ return -ENOMEM;
|
||||
+ linecard->types_count = count;
|
||||
+
|
||||
+ for (i = 0; i < count; i++) {
|
||||
+ linecard_type = &linecard->types[i];
|
||||
+ linecard->ops->types_get(linecard, linecard->priv, i,
|
||||
+ &linecard_type->type,
|
||||
+ &linecard_type->priv);
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void devlink_linecard_types_fini(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ kfree(linecard->types);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* devlink_linecard_create - Create devlink linecard
|
||||
*
|
||||
* @devlink: devlink
|
||||
* @linecard_index: driver-specific numerical identifier of the linecard
|
||||
+ * @ops: linecards ops
|
||||
+ * @priv: user priv pointer
|
||||
*
|
||||
* Create devlink linecard instance with provided linecard index.
|
||||
* Caller can use any indexing, even hw-related one.
|
||||
*/
|
||||
-struct devlink_linecard *devlink_linecard_create(struct devlink *devlink,
|
||||
- unsigned int linecard_index)
|
||||
+struct devlink_linecard *
|
||||
+devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
|
||||
+ const struct devlink_linecard_ops *ops, void *priv)
|
||||
{
|
||||
struct devlink_linecard *linecard;
|
||||
+ int err;
|
||||
+
|
||||
+ if (WARN_ON(!ops || !ops->provision || !ops->unprovision ||
|
||||
+ !ops->types_count || !ops->types_get))
|
||||
+ return ERR_PTR(-EINVAL);
|
||||
|
||||
mutex_lock(&devlink->linecards_lock);
|
||||
if (devlink_linecard_index_exists(devlink, linecard_index)) {
|
||||
- mutex_unlock(&devlink->linecards_lock);
|
||||
- return ERR_PTR(-EEXIST);
|
||||
+ linecard = ERR_PTR(-EEXIST);
|
||||
+ goto unlock;
|
||||
}
|
||||
|
||||
linecard = kzalloc(sizeof(*linecard), GFP_KERNEL);
|
||||
- if (!linecard)
|
||||
- return ERR_PTR(-ENOMEM);
|
||||
+ if (!linecard) {
|
||||
+ linecard = ERR_PTR(-ENOMEM);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
|
||||
linecard->devlink = devlink;
|
||||
linecard->index = linecard_index;
|
||||
+ linecard->ops = ops;
|
||||
+ linecard->priv = priv;
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
+ mutex_init(&linecard->state_lock);
|
||||
+
|
||||
+ err = devlink_linecard_types_init(linecard);
|
||||
+ if (err) {
|
||||
+ kfree(linecard);
|
||||
+ linecard = ERR_PTR(err);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+
|
||||
list_add_tail(&linecard->list, &devlink->linecard_list);
|
||||
refcount_set(&linecard->refcount, 1);
|
||||
devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+unlock:
|
||||
mutex_unlock(&devlink->linecards_lock);
|
||||
return linecard;
|
||||
}
|
||||
@@ -8721,6 +8946,7 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard)
|
||||
struct devlink *devlink = linecard->devlink;
|
||||
|
||||
devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL);
|
||||
+ devlink_linecard_types_fini(linecard);
|
||||
mutex_lock(&devlink->linecards_lock);
|
||||
list_del(&linecard->list);
|
||||
mutex_unlock(&devlink->linecards_lock);
|
||||
@@ -8728,6 +8954,53 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devlink_linecard_destroy);
|
||||
|
||||
+/**
|
||||
+ * devlink_linecard_provision_set - Set provisioning on linecard
|
||||
+ *
|
||||
+ * @linecard: devlink linecard
|
||||
+ * @type: linecard type
|
||||
+ */
|
||||
+void devlink_linecard_provision_set(struct devlink_linecard *linecard,
|
||||
+ const char *type)
|
||||
+{
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ WARN_ON(linecard->type && linecard->type != type);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONED;
|
||||
+ linecard->type = type;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_provision_set);
|
||||
+
|
||||
+/**
|
||||
+ * devlink_linecard_provision_clear - Clear provisioning on linecard
|
||||
+ *
|
||||
+ * @linecard: devlink linecard
|
||||
+ */
|
||||
+void devlink_linecard_provision_clear(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
+ linecard->type = NULL;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_provision_clear);
|
||||
+
|
||||
+/**
|
||||
+ * devlink_linecard_provision_fail - Fail provisioning on linecard
|
||||
+ *
|
||||
+ * @linecard: devlink linecard
|
||||
+ */
|
||||
+void devlink_linecard_provision_fail(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONING_FAILED;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_provision_fail);
|
||||
+
|
||||
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
|
||||
u32 size, u16 ingress_pools_count,
|
||||
u16 egress_pools_count, u16 ingress_tc_count,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,99 +0,0 @@
|
||||
From 9edffb671d73df181e382930bda0a3870e6ac120 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Wed, 6 Jan 2021 16:03:43 +0100
|
||||
Subject: [PATCH backport 5.10 127/182] devlink: implement line card active
|
||||
state
|
||||
|
||||
Allow driver to mark a linecard as active. Expose this state to the
|
||||
userspace over devlink netlink interface with proper notifications.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
include/net/devlink.h | 3 +++
|
||||
include/uapi/linux/devlink.h | 1 +
|
||||
net/core/devlink.c | 36 ++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 40 insertions(+)
|
||||
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index 44b60085ec16..d9b2b559c9a2 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -157,6 +157,7 @@ struct devlink_linecard {
|
||||
const char *type;
|
||||
struct devlink_linecard_type *types;
|
||||
unsigned int types_count;
|
||||
+ bool active;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1453,6 +1454,8 @@ void devlink_linecard_provision_set(struct devlink_linecard *linecard,
|
||||
const char *type);
|
||||
void devlink_linecard_provision_clear(struct devlink_linecard *linecard);
|
||||
void devlink_linecard_provision_fail(struct devlink_linecard *linecard);
|
||||
+void devlink_linecard_activate(struct devlink_linecard *linecard);
|
||||
+void devlink_linecard_deactivate(struct devlink_linecard *linecard);
|
||||
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
|
||||
u32 size, u16 ingress_pools_count,
|
||||
u16 egress_pools_count, u16 ingress_tc_count,
|
||||
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
|
||||
index d8833664522f..5ace55666d27 100644
|
||||
--- a/include/uapi/linux/devlink.h
|
||||
+++ b/include/uapi/linux/devlink.h
|
||||
@@ -341,6 +341,7 @@ enum devlink_linecard_state {
|
||||
DEVLINK_LINECARD_STATE_PROVISIONING,
|
||||
DEVLINK_LINECARD_STATE_PROVISIONING_FAILED,
|
||||
DEVLINK_LINECARD_STATE_PROVISIONED,
|
||||
+ DEVLINK_LINECARD_STATE_ACTIVE,
|
||||
|
||||
__DEVLINK_LINECARD_STATE_MAX,
|
||||
DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1
|
||||
diff --git a/net/core/devlink.c b/net/core/devlink.c
|
||||
index 943973ffc450..724633810758 100644
|
||||
--- a/net/core/devlink.c
|
||||
+++ b/net/core/devlink.c
|
||||
@@ -9001,6 +9001,42 @@ void devlink_linecard_provision_fail(struct devlink_linecard *linecard)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devlink_linecard_provision_fail);
|
||||
|
||||
+/**
|
||||
+ * devlink_linecard_activate - Set linecard active
|
||||
+ *
|
||||
+ * @devlink_linecard: devlink linecard
|
||||
+ */
|
||||
+void devlink_linecard_activate(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ WARN_ON(linecard->state != DEVLINK_LINECARD_STATE_PROVISIONED);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_ACTIVE;
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_activate);
|
||||
+
|
||||
+/**
|
||||
+ * devlink_linecard_deactivate - Set linecard inactive
|
||||
+ *
|
||||
+ * @devlink_linecard: devlink linecard
|
||||
+ */
|
||||
+void devlink_linecard_deactivate(struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ bool should_notify = false;
|
||||
+
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ if (linecard->state != DEVLINK_LINECARD_STATE_UNPROVISIONING) {
|
||||
+ WARN_ON(linecard->state != DEVLINK_LINECARD_STATE_ACTIVE);
|
||||
+ linecard->state = DEVLINK_LINECARD_STATE_PROVISIONED;
|
||||
+ should_notify = true;
|
||||
+ }
|
||||
+ if (should_notify)
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_deactivate);
|
||||
+
|
||||
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
|
||||
u32 size, u16 ingress_pools_count,
|
||||
u16 egress_pools_count, u16 ingress_tc_count,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,102 +0,0 @@
|
||||
From fb810d890bd142a7cfc14fb7e5f1519eee366208 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 22 Dec 2021 14:10:14 +0000
|
||||
Subject: [PATCH backport 5.10 128/182] devlink: add port to line card
|
||||
relationship set
|
||||
|
||||
In order to properly inform user about relationship between port and
|
||||
line card, introduce a driver API to set line card for a port. Use this
|
||||
information to extend port devlink netlink message by line card index
|
||||
and also include the line card index into phys_port_name and by that
|
||||
into a netdevice name.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
include/net/devlink.h | 4 ++++
|
||||
net/core/devlink.c | 34 ++++++++++++++++++++++++++++------
|
||||
2 files changed, 32 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index d9b2b559c9a2..3d4ceb2902b8 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -140,6 +140,8 @@ struct devlink_port {
|
||||
struct delayed_work type_warn_dw;
|
||||
struct list_head reporter_list;
|
||||
struct mutex reporters_lock; /* Protects reporter_list */
|
||||
+
|
||||
+ struct devlink_linecard *linecard;
|
||||
};
|
||||
|
||||
struct devlink_linecard_ops;
|
||||
@@ -1446,6 +1448,8 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro
|
||||
u16 pf, bool external);
|
||||
void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller,
|
||||
u16 pf, u16 vf, bool external);
|
||||
+void devlink_port_linecard_set(struct devlink_port *devlink_port,
|
||||
+ struct devlink_linecard *linecard);
|
||||
struct devlink_linecard *
|
||||
devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
|
||||
const struct devlink_linecard_ops *ops, void *priv);
|
||||
diff --git a/net/core/devlink.c b/net/core/devlink.c
|
||||
index 724633810758..b43e93ccc672 100644
|
||||
--- a/net/core/devlink.c
|
||||
+++ b/net/core/devlink.c
|
||||
@@ -905,6 +905,10 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
goto nla_put_failure;
|
||||
if (devlink_nl_port_function_attrs_put(msg, devlink_port, extack))
|
||||
goto nla_put_failure;
|
||||
+ if (devlink_port->linecard &&
|
||||
+ nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX,
|
||||
+ devlink_port->linecard->index))
|
||||
+ goto nla_put_failure;
|
||||
|
||||
genlmsg_end(msg, hdr);
|
||||
return 0;
|
||||
@@ -8795,6 +8799,21 @@ void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devlink_port_attrs_pci_vf_set);
|
||||
|
||||
+/**
|
||||
+ * devlink_port_linecard_set - Link port with a linecard
|
||||
+ *
|
||||
+ * @devlink_port: devlink port
|
||||
+ * @devlink_linecard: devlink linecard
|
||||
+ */
|
||||
+void devlink_port_linecard_set(struct devlink_port *devlink_port,
|
||||
+ struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ if (WARN_ON(devlink_port->devlink))
|
||||
+ return;
|
||||
+ devlink_port->linecard = linecard;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_port_linecard_set);
|
||||
+
|
||||
static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
|
||||
char *name, size_t len)
|
||||
{
|
||||
@@ -8806,12 +8825,15 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
|
||||
|
||||
switch (attrs->flavour) {
|
||||
case DEVLINK_PORT_FLAVOUR_PHYSICAL:
|
||||
- if (!attrs->split)
|
||||
- n = snprintf(name, len, "p%u", attrs->phys.port_number);
|
||||
- else
|
||||
- n = snprintf(name, len, "p%us%u",
|
||||
- attrs->phys.port_number,
|
||||
- attrs->phys.split_subport_number);
|
||||
+ if (devlink_port->linecard)
|
||||
+ n = snprintf(name, len, "l%u",
|
||||
+ devlink_port->linecard->index);
|
||||
+ if (n < len)
|
||||
+ n += snprintf(name + n, len - n, "p%u",
|
||||
+ attrs->phys.port_number);
|
||||
+ if (n < len && attrs->split)
|
||||
+ n += snprintf(name + n, len - n, "s%u",
|
||||
+ attrs->phys.split_subport_number);
|
||||
break;
|
||||
case DEVLINK_PORT_FLAVOUR_CPU:
|
||||
case DEVLINK_PORT_FLAVOUR_DSA:
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,246 +0,0 @@
|
||||
From 13e29cf4f38755ae717615071b07cd438e8819e6 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 19 Feb 2021 09:36:15 +0100
|
||||
Subject: [PATCH backport 5.10 129/182] devlink: introduce linecard info get
|
||||
message
|
||||
|
||||
Allow the driver to provide per line card info get op to fill-up info,
|
||||
similar to the "devlink dev info".
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
include/net/devlink.h | 7 +-
|
||||
include/uapi/linux/devlink.h | 3 +
|
||||
net/core/devlink.c | 135 +++++++++++++++++++++++++++++++++--
|
||||
3 files changed, 140 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index 3d4ceb2902b8..059bed6aef3c 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -162,6 +162,8 @@ struct devlink_linecard {
|
||||
bool active;
|
||||
};
|
||||
|
||||
+struct devlink_info_req;
|
||||
+
|
||||
/**
|
||||
* struct devlink_linecard_ops - Linecard operations
|
||||
* @provision: callback to provision the linecard slot with certain
|
||||
@@ -170,6 +172,7 @@ struct devlink_linecard {
|
||||
* @types_init: callback to initialize types list
|
||||
* @types_fini: callback to finalize types list
|
||||
* @types_get: callback to get next type in list
|
||||
+ * @info_get: callback to get linecard info
|
||||
*/
|
||||
struct devlink_linecard_ops {
|
||||
int (*provision)(struct devlink_linecard *linecard, void *priv,
|
||||
@@ -182,6 +185,9 @@ struct devlink_linecard_ops {
|
||||
void (*types_get)(struct devlink_linecard *linecard,
|
||||
void *priv, unsigned int index, const char **type,
|
||||
const void **type_priv);
|
||||
+ int (*info_get)(struct devlink_linecard *linecard, void *priv,
|
||||
+ struct devlink_info_req *req,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
};
|
||||
|
||||
struct devlink_sb_pool_info {
|
||||
@@ -630,7 +636,6 @@ struct devlink_flash_update_params {
|
||||
#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1)
|
||||
|
||||
struct devlink_region;
|
||||
-struct devlink_info_req;
|
||||
|
||||
/**
|
||||
* struct devlink_region_ops - Region operations
|
||||
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
|
||||
index 5ace55666d27..2c9f7d584b48 100644
|
||||
--- a/include/uapi/linux/devlink.h
|
||||
+++ b/include/uapi/linux/devlink.h
|
||||
@@ -136,6 +136,8 @@ enum devlink_command {
|
||||
DEVLINK_CMD_LINECARD_NEW,
|
||||
DEVLINK_CMD_LINECARD_DEL,
|
||||
|
||||
+ DEVLINK_CMD_LINECARD_INFO_GET, /* can dump */
|
||||
+
|
||||
/* add new commands above here */
|
||||
__DEVLINK_CMD_MAX,
|
||||
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
|
||||
@@ -566,6 +568,7 @@ enum devlink_attr {
|
||||
DEVLINK_ATTR_LINECARD_STATE, /* u8 */
|
||||
DEVLINK_ATTR_LINECARD_TYPE, /* string */
|
||||
DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */
|
||||
+ DEVLINK_ATTR_LINECARD_INFO, /* nested */
|
||||
|
||||
/* add new attributes above here, update the policy in devlink.c */
|
||||
|
||||
diff --git a/net/core/devlink.c b/net/core/devlink.c
|
||||
index b43e93ccc672..04f8038f8e23 100644
|
||||
--- a/net/core/devlink.c
|
||||
+++ b/net/core/devlink.c
|
||||
@@ -1245,6 +1245,10 @@ struct devlink_linecard_type {
|
||||
const void *priv;
|
||||
};
|
||||
|
||||
+struct devlink_info_req {
|
||||
+ struct sk_buff *msg;
|
||||
+};
|
||||
+
|
||||
static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
struct devlink *devlink,
|
||||
struct devlink_linecard *linecard,
|
||||
@@ -1542,6 +1546,125 @@ static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int
|
||||
+devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
+ struct devlink_linecard *linecard,
|
||||
+ enum devlink_command cmd, u32 portid,
|
||||
+ u32 seq, int flags, struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct devlink_info_req req;
|
||||
+ struct nlattr *attr;
|
||||
+ void *hdr;
|
||||
+ int err;
|
||||
+
|
||||
+ hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
|
||||
+ if (!hdr)
|
||||
+ return -EMSGSIZE;
|
||||
+
|
||||
+ err = -EMSGSIZE;
|
||||
+ if (devlink_nl_put_handle(msg, devlink))
|
||||
+ goto nla_put_failure;
|
||||
+ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index))
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
+ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_INFO);
|
||||
+ if (!attr)
|
||||
+ goto nla_put_failure;
|
||||
+ req.msg = msg;
|
||||
+ err = linecard->ops->info_get(linecard, linecard->priv, &req, extack);
|
||||
+ if (err)
|
||||
+ goto nla_put_failure;
|
||||
+ nla_nest_end(msg, attr);
|
||||
+
|
||||
+ genlmsg_end(msg, hdr);
|
||||
+ return 0;
|
||||
+
|
||||
+nla_put_failure:
|
||||
+ genlmsg_cancel(msg, hdr);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_cmd_linecard_info_get_doit(struct sk_buff *skb,
|
||||
+ struct genl_info *info)
|
||||
+{
|
||||
+ struct devlink_linecard *linecard = info->user_ptr[1];
|
||||
+ struct devlink *devlink = linecard->devlink;
|
||||
+ struct sk_buff *msg;
|
||||
+ int err;
|
||||
+
|
||||
+ if (!linecard->ops->info_get)
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
||||
+ if (!msg)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ err = devlink_nl_linecard_info_fill(msg, devlink, linecard,
|
||||
+ DEVLINK_CMD_LINECARD_INFO_GET,
|
||||
+ info->snd_portid, info->snd_seq, 0,
|
||||
+ info->extack);
|
||||
+ if (err) {
|
||||
+ nlmsg_free(msg);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ return genlmsg_reply(msg, info);
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_cmd_linecard_info_get_dumpit(struct sk_buff *msg,
|
||||
+ struct netlink_callback *cb)
|
||||
+{
|
||||
+ struct devlink_linecard *linecard;
|
||||
+ struct devlink *devlink;
|
||||
+ int start = cb->args[0];
|
||||
+ unsigned long index;
|
||||
+ int idx = 0;
|
||||
+ int err = 0;
|
||||
+
|
||||
+ mutex_lock(&devlink_mutex);
|
||||
+ xa_for_each_marked(&devlinks, index, devlink, DEVLINK_REGISTERED) {
|
||||
+ if (!devlink_try_get(devlink))
|
||||
+ continue;
|
||||
+
|
||||
+ if (!net_eq(devlink_net(devlink), sock_net(msg->sk)))
|
||||
+ goto retry;
|
||||
+
|
||||
+ mutex_lock(&devlink->linecards_lock);
|
||||
+ list_for_each_entry(linecard, &devlink->linecard_list, list) {
|
||||
+ if (idx < start || !linecard->ops->info_get) {
|
||||
+ idx++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ mutex_lock(&linecard->state_lock);
|
||||
+ err = devlink_nl_linecard_info_fill(msg, devlink, linecard,
|
||||
+ DEVLINK_CMD_LINECARD_INFO_GET,
|
||||
+ NETLINK_CB(cb->skb).portid,
|
||||
+ cb->nlh->nlmsg_seq,
|
||||
+ NLM_F_MULTI,
|
||||
+ cb->extack);
|
||||
+ mutex_unlock(&linecard->state_lock);
|
||||
+ if (err) {
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+ devlink_put(devlink);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ idx++;
|
||||
+ }
|
||||
+ mutex_unlock(&devlink->linecards_lock);
|
||||
+retry:
|
||||
+ devlink_put(devlink);
|
||||
+ }
|
||||
+out:
|
||||
+ mutex_unlock(&devlink_mutex);
|
||||
+
|
||||
+ if (err != -EMSGSIZE)
|
||||
+ return err;
|
||||
+
|
||||
+ cb->args[0] = idx;
|
||||
+ return msg->len;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
struct devlink_sb *devlink_sb,
|
||||
enum devlink_command cmd, u32 portid,
|
||||
@@ -5455,10 +5578,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
|
||||
return err;
|
||||
}
|
||||
|
||||
-struct devlink_info_req {
|
||||
- struct sk_buff *msg;
|
||||
-};
|
||||
-
|
||||
int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name)
|
||||
{
|
||||
return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME, name);
|
||||
@@ -8057,6 +8176,14 @@ static const struct genl_small_ops devlink_nl_ops[] = {
|
||||
.internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD |
|
||||
DEVLINK_NL_FLAG_NO_LOCK,
|
||||
},
|
||||
+ {
|
||||
+ .cmd = DEVLINK_CMD_LINECARD_INFO_GET,
|
||||
+ .doit = devlink_nl_cmd_linecard_info_get_doit,
|
||||
+ .dumpit = devlink_nl_cmd_linecard_info_get_dumpit,
|
||||
+ .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD |
|
||||
+ DEVLINK_NL_FLAG_NO_LOCK,
|
||||
+ /* can be retrieved by unprivileged users */
|
||||
+ },
|
||||
{
|
||||
.cmd = DEVLINK_CMD_SB_GET,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,316 +0,0 @@
|
||||
From b8243b5c2fdb9871cd55a864b95e197ced9ad532 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 22 Dec 2021 15:11:36 +0000
|
||||
Subject: [PATCH backport 5.10 130/182] devlink: introduce linecard info get
|
||||
message
|
||||
|
||||
Allow the driver to provide per line card info get op to fill-up info,
|
||||
similar to the "devlink dev info".
|
||||
|
||||
devlink: introduce line card devices support
|
||||
|
||||
Line card can contain a device. For example, this can be a gearbox with
|
||||
flash. This flash could be updated. Provide the driver possibility to
|
||||
attach such devices to a line card and expose those to user. Leverage
|
||||
the existing devlink flash update mechanism and allow driver to pass a
|
||||
custom "component name" string identifying the line card device to
|
||||
flash.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
include/net/devlink.h | 12 +++
|
||||
include/uapi/linux/devlink.h | 4 +
|
||||
net/core/devlink.c | 166 +++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 182 insertions(+)
|
||||
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index 059bed6aef3c..06b61c1d7938 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -160,9 +160,11 @@ struct devlink_linecard {
|
||||
struct devlink_linecard_type *types;
|
||||
unsigned int types_count;
|
||||
bool active;
|
||||
+ struct list_head device_list;
|
||||
};
|
||||
|
||||
struct devlink_info_req;
|
||||
+struct devlink_linecard_device;
|
||||
|
||||
/**
|
||||
* struct devlink_linecard_ops - Linecard operations
|
||||
@@ -188,6 +190,9 @@ struct devlink_linecard_ops {
|
||||
int (*info_get)(struct devlink_linecard *linecard, void *priv,
|
||||
struct devlink_info_req *req,
|
||||
struct netlink_ext_ack *extack);
|
||||
+ int (*device_info_get)(struct devlink_linecard_device *device,
|
||||
+ void *priv, struct devlink_info_req *req,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
};
|
||||
|
||||
struct devlink_sb_pool_info {
|
||||
@@ -1459,6 +1464,13 @@ struct devlink_linecard *
|
||||
devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
|
||||
const struct devlink_linecard_ops *ops, void *priv);
|
||||
void devlink_linecard_destroy(struct devlink_linecard *linecard);
|
||||
+struct devlink_linecard_device *
|
||||
+devlink_linecard_device_create(struct devlink_linecard *linecard,
|
||||
+ unsigned int device_index,
|
||||
+ const char *flash_component, void *priv);
|
||||
+void
|
||||
+devlink_linecard_device_destroy(struct devlink_linecard *linecard,
|
||||
+ struct devlink_linecard_device *linecard_device);
|
||||
void devlink_linecard_provision_set(struct devlink_linecard *linecard,
|
||||
const char *type);
|
||||
void devlink_linecard_provision_clear(struct devlink_linecard *linecard);
|
||||
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
|
||||
index 2c9f7d584b48..bac94c3c1bb0 100644
|
||||
--- a/include/uapi/linux/devlink.h
|
||||
+++ b/include/uapi/linux/devlink.h
|
||||
@@ -569,6 +569,10 @@ enum devlink_attr {
|
||||
DEVLINK_ATTR_LINECARD_TYPE, /* string */
|
||||
DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */
|
||||
DEVLINK_ATTR_LINECARD_INFO, /* nested */
|
||||
+ DEVLINK_ATTR_LINECARD_DEVICE_LIST, /* nested */
|
||||
+ DEVLINK_ATTR_LINECARD_DEVICE, /* nested */
|
||||
+ DEVLINK_ATTR_LINECARD_DEVICE_INDEX, /* u32 */
|
||||
+ DEVLINK_ATTR_LINECARD_DEVICE_INFO, /* nested */
|
||||
|
||||
/* add new attributes above here, update the policy in devlink.c */
|
||||
|
||||
diff --git a/net/core/devlink.c b/net/core/devlink.c
|
||||
index 04f8038f8e23..ca014f40ac02 100644
|
||||
--- a/net/core/devlink.c
|
||||
+++ b/net/core/devlink.c
|
||||
@@ -1249,6 +1249,59 @@ struct devlink_info_req {
|
||||
struct sk_buff *msg;
|
||||
};
|
||||
|
||||
+struct devlink_linecard_device {
|
||||
+ struct list_head list;
|
||||
+ unsigned int index;
|
||||
+ const char *flash_component;
|
||||
+ void *priv;
|
||||
+};
|
||||
+
|
||||
+static int
|
||||
+devlink_nl_linecard_device_fill(struct sk_buff *msg,
|
||||
+ struct devlink_linecard *linecard,
|
||||
+ struct devlink_linecard_device *linecard_device)
|
||||
+{
|
||||
+ struct nlattr *attr;
|
||||
+
|
||||
+ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE);
|
||||
+ if (!attr)
|
||||
+ return -EMSGSIZE;
|
||||
+ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX,
|
||||
+ linecard_device->index))
|
||||
+ return -EMSGSIZE;
|
||||
+ if (linecard_device->flash_component &&
|
||||
+ nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,
|
||||
+ linecard_device->flash_component))
|
||||
+ return -EMSGSIZE;
|
||||
+ nla_nest_end(msg, attr);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_linecard_devices_fill(struct sk_buff *msg,
|
||||
+ struct devlink_linecard *linecard)
|
||||
+{
|
||||
+ struct devlink_linecard_device *linecard_device;
|
||||
+ struct nlattr *attr;
|
||||
+ int err;
|
||||
+
|
||||
+ if (list_empty(&linecard->device_list))
|
||||
+ return 0;
|
||||
+
|
||||
+ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_LIST);
|
||||
+ if (!attr)
|
||||
+ return -EMSGSIZE;
|
||||
+ list_for_each_entry(linecard_device, &linecard->device_list, list) {
|
||||
+ err = devlink_nl_linecard_device_fill(msg, linecard,
|
||||
+ linecard_device);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+ nla_nest_end(msg, attr);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
struct devlink *devlink,
|
||||
struct devlink_linecard *linecard,
|
||||
@@ -1259,6 +1312,7 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
struct devlink_linecard_type *linecard_type;
|
||||
struct nlattr *attr;
|
||||
void *hdr;
|
||||
+ int err;
|
||||
int i;
|
||||
|
||||
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
|
||||
@@ -1289,6 +1343,10 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg,
|
||||
nla_nest_end(msg, attr);
|
||||
}
|
||||
|
||||
+ err = devlink_nl_linecard_devices_fill(msg, linecard);
|
||||
+ if (err)
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
genlmsg_end(msg, hdr);
|
||||
return 0;
|
||||
|
||||
@@ -1546,6 +1604,66 @@ static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int
|
||||
+devlink_nl_linecard_device_info_fill(struct sk_buff *msg,
|
||||
+ struct devlink_linecard *linecard,
|
||||
+ struct devlink_linecard_device *linecard_device,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct nlattr *attr, *attr2;
|
||||
+
|
||||
+ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE);
|
||||
+ if (!attr)
|
||||
+ return -EMSGSIZE;
|
||||
+ if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX,
|
||||
+ linecard_device->index))
|
||||
+ return -EMSGSIZE;
|
||||
+ if (linecard->ops->device_info_get) {
|
||||
+ struct devlink_info_req req;
|
||||
+ int err;
|
||||
+
|
||||
+ attr2 = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_INFO);
|
||||
+ if (!attr2)
|
||||
+ return -EMSGSIZE;
|
||||
+ req.msg = msg;
|
||||
+ err = linecard->ops->device_info_get(linecard_device,
|
||||
+ linecard_device->priv,
|
||||
+ &req, extack);
|
||||
+ if (err)
|
||||
+ return -EMSGSIZE;
|
||||
+ nla_nest_end(msg, attr2);
|
||||
+ }
|
||||
+ nla_nest_end(msg, attr);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int devlink_nl_linecard_devices_info_fill(struct sk_buff *msg,
|
||||
+ struct devlink_linecard *linecard,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct devlink_linecard_device *linecard_device;
|
||||
+ struct nlattr *attr;
|
||||
+ int err;
|
||||
+
|
||||
+ if (list_empty(&linecard->device_list))
|
||||
+ return 0;
|
||||
+
|
||||
+ attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_LIST);
|
||||
+ if (!attr)
|
||||
+ return -EMSGSIZE;
|
||||
+ list_for_each_entry(linecard_device, &linecard->device_list, list) {
|
||||
+ err = devlink_nl_linecard_device_info_fill(msg, linecard,
|
||||
+ linecard_device,
|
||||
+ extack);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+ nla_nest_end(msg, attr);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
struct devlink_linecard *linecard,
|
||||
@@ -1576,6 +1694,10 @@ devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink,
|
||||
goto nla_put_failure;
|
||||
nla_nest_end(msg, attr);
|
||||
|
||||
+ err = devlink_nl_linecard_devices_info_fill(msg, linecard, extack);
|
||||
+ if (err)
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
genlmsg_end(msg, hdr);
|
||||
return 0;
|
||||
|
||||
@@ -9068,6 +9190,7 @@ devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
|
||||
linecard->priv = priv;
|
||||
linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
mutex_init(&linecard->state_lock);
|
||||
+ INIT_LIST_HEAD(&linecard->device_list);
|
||||
|
||||
err = devlink_linecard_types_init(linecard);
|
||||
if (err) {
|
||||
@@ -9096,6 +9219,7 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard)
|
||||
|
||||
devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL);
|
||||
devlink_linecard_types_fini(linecard);
|
||||
+ WARN_ON(!list_empty(&linecard->device_list));
|
||||
mutex_lock(&devlink->linecards_lock);
|
||||
list_del(&linecard->list);
|
||||
mutex_unlock(&devlink->linecards_lock);
|
||||
@@ -9103,6 +9227,47 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devlink_linecard_destroy);
|
||||
|
||||
+/**
|
||||
+ * devlink_linecard_device_create - Create a device on linecard
|
||||
+ *
|
||||
+ * @devlink_linecard: devlink linecard
|
||||
+ * @device_index: index of the linecard device
|
||||
+ * @flash_component: name of flash update component,
|
||||
+ * NULL if unable to flash
|
||||
+ */
|
||||
+struct devlink_linecard_device *
|
||||
+devlink_linecard_device_create(struct devlink_linecard *linecard,
|
||||
+ unsigned int device_index,
|
||||
+ const char *flash_component, void *priv)
|
||||
+{
|
||||
+ struct devlink_linecard_device *linecard_device;
|
||||
+
|
||||
+ linecard_device = kzalloc(sizeof(*linecard_device), GFP_KERNEL);
|
||||
+ if (!linecard_device)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+ linecard_device->index = device_index;
|
||||
+ linecard_device->flash_component = flash_component;
|
||||
+ linecard_device->priv = priv;
|
||||
+ mutex_lock(&linecard->devlink->lock);
|
||||
+ list_add_tail(&linecard_device->list, &linecard->device_list);
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ mutex_unlock(&linecard->devlink->lock);
|
||||
+ return linecard_device;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_device_create);
|
||||
+
|
||||
+void
|
||||
+devlink_linecard_device_destroy(struct devlink_linecard *linecard,
|
||||
+ struct devlink_linecard_device *linecard_device)
|
||||
+{
|
||||
+ mutex_lock(&linecard->devlink->lock);
|
||||
+ devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
+ list_del(&linecard_device->list);
|
||||
+ mutex_unlock(&linecard->devlink->lock);
|
||||
+ kfree(linecard_device);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(devlink_linecard_device_destroy);
|
||||
+
|
||||
/**
|
||||
* devlink_linecard_provision_set - Set provisioning on linecard
|
||||
*
|
||||
@@ -9129,6 +9294,7 @@ EXPORT_SYMBOL_GPL(devlink_linecard_provision_set);
|
||||
void devlink_linecard_provision_clear(struct devlink_linecard *linecard)
|
||||
{
|
||||
mutex_lock(&linecard->state_lock);
|
||||
+ WARN_ON(!list_empty(&linecard->device_list));
|
||||
linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED;
|
||||
linecard->type = NULL;
|
||||
devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,99 +0,0 @@
|
||||
From 4a49468e7fc7e94a83703215445d9b3919642eb9 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 29 Jan 2021 08:45:09 +0100
|
||||
Subject: [PATCH backport 5.10 131/182] mlxsw: reg: Add Ports Mapping event
|
||||
Configuration Register
|
||||
|
||||
The PMECR register use to enable/disable event trigger in case of
|
||||
local port mapping change.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 64 +++++++++++++++++++++++
|
||||
1 file changed, 64 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 98c627ffe039..93e3366cfcb9 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -5524,6 +5524,69 @@ static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port,
|
||||
MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
|
||||
}
|
||||
|
||||
+/* PMECR - Ports Mapping event Configuration Register
|
||||
+ * --------------------------------------------------
|
||||
+ * The PMECR register use to enable/disable event trigger in case of
|
||||
+ * local port mapping change.
|
||||
+ */
|
||||
+#define MLXSW_REG_PMECR_ID 0x501B
|
||||
+#define MLXSW_REG_PMECR_LEN 0x20
|
||||
+
|
||||
+MLXSW_REG_DEFINE(pmecr, MLXSW_REG_PMECR_ID, MLXSW_REG_PMECR_LEN);
|
||||
+
|
||||
+/* reg_pmecr_local_port
|
||||
+ * Local port number.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, pmecr, local_port, 0x00, 16, 8);
|
||||
+
|
||||
+/* reg_pmecr_ee
|
||||
+ * Event update enable. If this bit is set, event generation will be updated
|
||||
+ * based on the e field. Only relevant on Set operations.
|
||||
+ * Access: WO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, pmecr, ee, 0x04, 30, 1);
|
||||
+
|
||||
+/* reg_pmecr_eswi
|
||||
+ * Software ignore enable bit. If this bit is set, the value if swi is used.
|
||||
+ * If this bit is clear, the value of swi is ignored.
|
||||
+ * Only relevant on Set operations.
|
||||
+ * Access: WO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, pmecr, eswi, 0x04, 24, 1);
|
||||
+
|
||||
+/* reg_pmecr_swi
|
||||
+ * Software ignore. If this bit is set, the device shouldn't generate events
|
||||
+ * in case of PMLP SET operation but only upon self local port mapping change
|
||||
+ * (if applicable according to e configuration). This is supplementary
|
||||
+ * configuration on top of e value.
|
||||
+ * Access: RW
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, pmecr, swi, 0x04, 8, 1);
|
||||
+
|
||||
+enum mlxsw_reg_pmecr_e {
|
||||
+ MLXSW_REG_PMECR_E_DO_NOT_GENERATE_EVENT,
|
||||
+ MLXSW_REG_PMECR_E_GENERATE_EVENT,
|
||||
+ MLXSW_REG_PMECR_E_GENERATE_SINGLE_EVENT,
|
||||
+};
|
||||
+
|
||||
+/* reg_pmecr_e
|
||||
+ * Event generation on local port mapping change.
|
||||
+ * Access: RW
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, pmecr, e, 0x04, 0, 2);
|
||||
+
|
||||
+static inline void mlxsw_reg_pmecr_pack(char *payload, u8 local_port,
|
||||
+ enum mlxsw_reg_pmecr_e e)
|
||||
+{
|
||||
+ MLXSW_REG_ZERO(pmecr, payload);
|
||||
+ mlxsw_reg_pmecr_local_port_set(payload, local_port);
|
||||
+ mlxsw_reg_pmecr_e_set(payload, e);
|
||||
+ mlxsw_reg_pmecr_ee_set(payload, true);
|
||||
+ mlxsw_reg_pmecr_swi_set(payload, true);
|
||||
+ mlxsw_reg_pmecr_eswi_set(payload, true);
|
||||
+}
|
||||
+
|
||||
/* PMPE - Port Module Plug/Unplug Event Register
|
||||
* ---------------------------------------------
|
||||
* This register reports any operational status change of a module.
|
||||
@@ -11375,6 +11438,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
|
||||
MLXSW_REG(pspa),
|
||||
MLXSW_REG(pmaos),
|
||||
MLXSW_REG(pplr),
|
||||
+ MLXSW_REG(pmecr),
|
||||
MLXSW_REG(pmpe),
|
||||
MLXSW_REG(pddr),
|
||||
MLXSW_REG(pmtm),
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,268 +0,0 @@
|
||||
From 5d8d4899f493e3b18712fc96a45eb020985740b1 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 3 Jan 2022 10:20:49 +0000
|
||||
Subject: [PATCH backport 5.10 132/182] mlxsw: reg: Add Management DownStream
|
||||
Device Query Register
|
||||
|
||||
The MDDQ register allows to query the DownStream device properties.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 234 ++++++++++++++++++++++
|
||||
1 file changed, 234 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 93e3366cfcb9..ad7faeb95646 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10296,6 +10296,239 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
|
||||
*num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
|
||||
}
|
||||
|
||||
+/* MDDQ - Management DownStream Device Query Register
|
||||
+ * --------------------------------------------------
|
||||
+ * This register allows to query the DownStream device properties. The desired
|
||||
+ * information is chosen upon the query_type field and is delivered by 32B
|
||||
+ * of data blocks.
|
||||
+ */
|
||||
+#define MLXSW_REG_MDDQ_ID 0x9161
|
||||
+#define MLXSW_REG_MDDQ_LEN 0x30
|
||||
+
|
||||
+MLXSW_REG_DEFINE(mddq, MLXSW_REG_MDDQ_ID, MLXSW_REG_MDDQ_LEN);
|
||||
+
|
||||
+/* reg_mddq_sie
|
||||
+ * Slot info event enable.
|
||||
+ * When set to '1', each change in the slot_info.provisioned / sr_valid /
|
||||
+ * active / ready will generate an event.
|
||||
+ * Access: RW
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1);
|
||||
+
|
||||
+enum mlxsw_reg_mddq_query_type {
|
||||
+ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1,
|
||||
+ MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO, /* If there are no devices
|
||||
+ * on the slot, data_valid
|
||||
+ * will be '0'.
|
||||
+ */
|
||||
+ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME,
|
||||
+};
|
||||
+
|
||||
+/* reg_mddq_query_type
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8);
|
||||
+
|
||||
+/* reg_mddq_slot_index
|
||||
+ * Slot index. 0 is reserved.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4);
|
||||
+
|
||||
+/* reg_mddq_response_msg_seq
|
||||
+ * Response message sequential number. For a specific request, the response
|
||||
+ * message sequential number is the following one. In addition, the last
|
||||
+ * message should be 0.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, response_msg_seq, 0x04, 16, 8);
|
||||
+
|
||||
+/* reg_mddq_request_msg_seq
|
||||
+ * Request message sequential number.
|
||||
+ * The first message number should be 0.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, request_msg_seq, 0x04, 0, 8);
|
||||
+
|
||||
+/* reg_mddq_data_valid
|
||||
+ * If set, the data in the data field is valid and contain the information
|
||||
+ * for the queried index.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, data_valid, 0x08, 31, 1);
|
||||
+
|
||||
+/* reg_mddq_provisioned
|
||||
+ * If set, the INI file is applied and the card is provisioned.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, provisioned, 0x10, 31, 1);
|
||||
+
|
||||
+/* reg_mddq_sr_valid
|
||||
+ * If set, Shift Register is valid (after being provisioned).
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, sr_valid, 0x10, 30, 1);
|
||||
+
|
||||
+enum mlxsw_reg_mddq_ready {
|
||||
+ MLXSW_REG_MDDQ_READY_NOT_READY,
|
||||
+ MLXSW_REG_MDDQ_READY_READY,
|
||||
+ MLXSW_REG_MDDQ_READY_ERROR,
|
||||
+};
|
||||
+
|
||||
+/* reg_mddq_lc_ready
|
||||
+ * If set, the LC is powered on, matching the INI version and a new FW
|
||||
+ * version can be burnt (if necessary).
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, lc_ready, 0x10, 28, 2);
|
||||
+
|
||||
+/* reg_mddq_active
|
||||
+ * If set, the FW has completed the MDDC.device_enable command.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, active, 0x10, 27, 1);
|
||||
+
|
||||
+/* reg_mddq_hw_revision
|
||||
+ * Major user-configured version number of the current INI file.
|
||||
+ * Valid only when active or ready are '1'.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, hw_revision, 0x14, 16, 16);
|
||||
+
|
||||
+/* reg_mddq_ini_file_version
|
||||
+ * User-configured version number of the current INI file.
|
||||
+ * Valid only when active or lc_ready are '1'.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, ini_file_version, 0x14, 0, 16);
|
||||
+
|
||||
+enum mlxsw_reg_mddq_card_type {
|
||||
+ MLXSW_REG_MDDQ_CARD_TYPE_BUFFALO_4X400G,
|
||||
+ MLXSW_REG_MDDQ_CARD_TYPE_BUFFALO_8X200G,
|
||||
+ MLXSW_REG_MDDQ_CARD_TYPE_BUFFALO_16X100G,
|
||||
+};
|
||||
+
|
||||
+/* reg_mddq_card_type
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, card_type, 0x18, 0, 8);
|
||||
+
|
||||
+static inline void
|
||||
+__mlxsw_reg_mddq_pack(char *payload, u8 slot_index,
|
||||
+ enum mlxsw_reg_mddq_query_type query_type)
|
||||
+{
|
||||
+ MLXSW_REG_ZERO(mddq, payload);
|
||||
+ mlxsw_reg_mddq_slot_index_set(payload, slot_index);
|
||||
+ mlxsw_reg_mddq_query_type_set(payload, query_type);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mddq_slot_info_pack(char *payload, u8 slot_index, bool sie)
|
||||
+{
|
||||
+ __mlxsw_reg_mddq_pack(payload, slot_index,
|
||||
+ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO);
|
||||
+ mlxsw_reg_mddq_sie_set(payload, sie);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index,
|
||||
+ bool *p_provisioned, bool *p_sr_valid,
|
||||
+ enum mlxsw_reg_mddq_ready *p_lc_ready,
|
||||
+ bool *p_active, u16 *p_hw_revision,
|
||||
+ u16 *p_ini_file_version,
|
||||
+ enum mlxsw_reg_mddq_card_type *p_card_type)
|
||||
+{
|
||||
+ *p_slot_index = mlxsw_reg_mddq_slot_index_get(payload);
|
||||
+ *p_provisioned = mlxsw_reg_mddq_provisioned_get(payload);
|
||||
+ *p_sr_valid = mlxsw_reg_mddq_sr_valid_get(payload);
|
||||
+ *p_lc_ready = mlxsw_reg_mddq_lc_ready_get(payload);
|
||||
+ *p_active = mlxsw_reg_mddq_active_get(payload);
|
||||
+ *p_hw_revision = mlxsw_reg_mddq_hw_revision_get(payload);
|
||||
+ *p_ini_file_version = mlxsw_reg_mddq_ini_file_version_get(payload);
|
||||
+ *p_card_type = mlxsw_reg_mddq_card_type_get(payload);
|
||||
+}
|
||||
+
|
||||
+/* reg_mddq_flash_owner
|
||||
+ * If set, the device is the flash owner. Otherwise, a shared flash
|
||||
+ * is used by this device (another device is the flash owner).
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, flash_owner, 0x10, 30, 1);
|
||||
+
|
||||
+/* reg_mddq_device_index
|
||||
+ * Device index. The first device should number 0.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, device_index, 0x10, 0, 8);
|
||||
+
|
||||
+/* reg_mddq_fw_major
|
||||
+ * Major FW version number.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, fw_major, 0x14, 16, 16);
|
||||
+
|
||||
+/* reg_mddq_fw_minor
|
||||
+ * Minor FW version number.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, fw_minor, 0x18, 16, 16);
|
||||
+
|
||||
+/* reg_mddq_fw_sub_minor
|
||||
+ * Sub-minor FW version number.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddq, fw_sub_minor, 0x18, 0, 16);
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index,
|
||||
+ u8 request_msg_seq)
|
||||
+{
|
||||
+ __mlxsw_reg_mddq_pack(payload, slot_index,
|
||||
+ MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO);
|
||||
+ mlxsw_reg_mddq_request_msg_seq_set(payload, request_msg_seq);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq,
|
||||
+ bool *p_data_valid, bool *p_flash_owner,
|
||||
+ u8 *p_device_index, u16 *p_fw_major,
|
||||
+ u16 *p_fw_minor, u16 *p_fw_sub_minor)
|
||||
+{
|
||||
+ *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload);
|
||||
+ *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload);
|
||||
+ if (p_flash_owner)
|
||||
+ *p_flash_owner = mlxsw_reg_mddq_flash_owner_get(payload);
|
||||
+ *p_device_index = mlxsw_reg_mddq_device_index_get(payload);
|
||||
+ if (p_fw_major)
|
||||
+ *p_fw_major = mlxsw_reg_mddq_fw_major_get(payload);
|
||||
+ if (p_fw_minor)
|
||||
+ *p_fw_minor = mlxsw_reg_mddq_fw_minor_get(payload);
|
||||
+ if (p_fw_sub_minor)
|
||||
+ *p_fw_sub_minor = mlxsw_reg_mddq_fw_sub_minor_get(payload);
|
||||
+}
|
||||
+
|
||||
+#define MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN 20
|
||||
+
|
||||
+/* reg_mddq_slot_ascii_name
|
||||
+ * Slot's ASCII name.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM_BUF(reg, mddq, slot_ascii_name, 0x10,
|
||||
+ MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN);
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mddq_slot_name_pack(char *payload, u8 slot_index)
|
||||
+{
|
||||
+ __mlxsw_reg_mddq_pack(payload, slot_index,
|
||||
+ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name)
|
||||
+{
|
||||
+ mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name);
|
||||
+}
|
||||
+
|
||||
/* MFDE - Monitoring FW Debug Register
|
||||
* -----------------------------------
|
||||
*/
|
||||
@@ -11495,6 +11728,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
|
||||
MLXSW_REG(mtptpt),
|
||||
MLXSW_REG(mfgd),
|
||||
MLXSW_REG(mgpir),
|
||||
+ MLXSW_REG(mddq),
|
||||
MLXSW_REG(mfde),
|
||||
MLXSW_REG(tngcr),
|
||||
MLXSW_REG(tnumt),
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,71 +0,0 @@
|
||||
From 14d65a09a9b77a5ed632a73ff006042d26be3226 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Tue, 19 Jan 2021 12:16:58 +0100
|
||||
Subject: [PATCH backport 5.10 133/182] mlxsw: reg: Add Management DownStream
|
||||
Device Control Register
|
||||
|
||||
The MDDC register allows control downstream devices and line cards.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 37 +++++++++++++++++++++++
|
||||
1 file changed, 37 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index ad7faeb95646..cddfe5702140 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10529,6 +10529,42 @@ mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name)
|
||||
mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name);
|
||||
}
|
||||
|
||||
+/* MDDC - Management DownStream Device Control Register
|
||||
+ * ----------------------------------------------------
|
||||
+ * This register allows control downstream devices and line cards.
|
||||
+ */
|
||||
+#define MLXSW_REG_MDDC_ID 0x9163
|
||||
+#define MLXSW_REG_MDDC_LEN 0x30
|
||||
+
|
||||
+MLXSW_REG_DEFINE(mddc, MLXSW_REG_MDDC_ID, MLXSW_REG_MDDC_LEN);
|
||||
+
|
||||
+/* reg_mddc_slot_index
|
||||
+ * Slot index. 0 is reserved.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddc, slot_index, 0x00, 0, 4);
|
||||
+
|
||||
+/* reg_mddc_rst
|
||||
+ * Reset request.
|
||||
+ * Access: RW
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddc, rst, 0x04, 29, 1);
|
||||
+
|
||||
+/* reg_mddc_device_enable
|
||||
+ * When set, FW is the manager and allowed to program the Downstream Device.
|
||||
+ * Access: RW
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddc, device_enable, 0x04, 28, 1);
|
||||
+
|
||||
+static inline void mlxsw_reg_mddc_pack(char *payload, u8 slot_index, bool rst,
|
||||
+ bool device_enable)
|
||||
+{
|
||||
+ MLXSW_REG_ZERO(mddc, payload);
|
||||
+ mlxsw_reg_mddc_slot_index_set(payload, slot_index);
|
||||
+ mlxsw_reg_mddc_rst_set(payload, rst);
|
||||
+ mlxsw_reg_mddc_device_enable_set(payload, device_enable);
|
||||
+}
|
||||
+
|
||||
/* MFDE - Monitoring FW Debug Register
|
||||
* -----------------------------------
|
||||
*/
|
||||
@@ -11729,6 +11765,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
|
||||
MLXSW_REG(mfgd),
|
||||
MLXSW_REG(mgpir),
|
||||
MLXSW_REG(mddq),
|
||||
+ MLXSW_REG(mddc),
|
||||
MLXSW_REG(mfde),
|
||||
MLXSW_REG(tngcr),
|
||||
MLXSW_REG(tnumt),
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,155 +0,0 @@
|
||||
From e9afbd683a14e3369ba25dcb9c8147a8b478b5c0 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Thu, 10 Dec 2020 18:27:38 +0100
|
||||
Subject: [PATCH backport 5.10 134/182] mlxsw: reg: Add Management Binary Code
|
||||
Transfer Register
|
||||
|
||||
The MBCT register allows to transfer binary codes from the Host to
|
||||
the management FW by transferring it by chunks of maximum 1KB.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 120 ++++++++++++++++++++++
|
||||
1 file changed, 120 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index cddfe5702140..e060f054e0a9 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10296,6 +10296,125 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
|
||||
*num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
|
||||
}
|
||||
|
||||
+/* MBCT - Management Binary Code Transfer Register
|
||||
+ * -----------------------------------------------
|
||||
+ * This register allows to transfer binary codes from the Host to
|
||||
+ * the management FW by transferring it by chunks of maximum 1KB.
|
||||
+ */
|
||||
+#define MLXSW_REG_MBCT_ID 0x9120
|
||||
+#define MLXSW_REG_MBCT_LEN 0x420
|
||||
+
|
||||
+MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN);
|
||||
+
|
||||
+/* reg_mbct_slot_index
|
||||
+ * Slot index. 0 is reserved.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4);
|
||||
+
|
||||
+/* reg_mbct_data_size
|
||||
+ * Actual data field size in bytes for the current data transfer.
|
||||
+ * Access: WO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11);
|
||||
+
|
||||
+enum mlxsw_reg_mbct_op {
|
||||
+ MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1,
|
||||
+ MLXSW_REG_MBCT_OP_DATA_TRANSFER, /* Download */
|
||||
+ MLXSW_REG_MBCT_OP_ACTIVATE,
|
||||
+ MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6,
|
||||
+ MLXSW_REG_MBCT_OP_QUERY_STATUS,
|
||||
+};
|
||||
+
|
||||
+/* reg_mbct_op
|
||||
+ * Access: OP
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4);
|
||||
+
|
||||
+/* reg_mbct_last
|
||||
+ * Indicates that the current data field is the last chunk of the INI.
|
||||
+ * Access: WO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1);
|
||||
+
|
||||
+/* reg_mbct_oee
|
||||
+ * Opcode Event Enable. When set an event will be sent once the opcode
|
||||
+ * was executed and the fsm_state has changed.
|
||||
+ * Access: WO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1);
|
||||
+
|
||||
+enum mlxsw_reg_mbct_status {
|
||||
+ /* Partial data transfer completed successfully and ready for next
|
||||
+ * data transfer.
|
||||
+ */
|
||||
+ MLXSW_REG_MBCT_STATUS_PART_DATA = 2,
|
||||
+ MLXSW_REG_MBCT_STATUS_LAST_DATA,
|
||||
+ MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE,
|
||||
+ /* Error - trying to erase INI while it being used. */
|
||||
+ MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE,
|
||||
+ /* Last data transfer completed, applying magic pattern. */
|
||||
+ MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7,
|
||||
+ MLXSW_REG_MBCT_STATUS_INI_ERROR,
|
||||
+ MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED,
|
||||
+ MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11,
|
||||
+};
|
||||
+
|
||||
+/* reg_mbct_status
|
||||
+ * Status.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5);
|
||||
+
|
||||
+enum mlxsw_reg_mbct_fsm_state {
|
||||
+ MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5,
|
||||
+ MLXSW_REG_MBCT_FSM_STATE_ERROR = 6,
|
||||
+};
|
||||
+
|
||||
+/* reg_mbct_fsm_state
|
||||
+ * FSM state.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4);
|
||||
+
|
||||
+#define MLXSW_REG_MBCT_DATA_LEN 1024
|
||||
+
|
||||
+/* reg_mbct_data
|
||||
+ * Up to 1KB of data.
|
||||
+ * Access: WO
|
||||
+ */
|
||||
+MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN);
|
||||
+
|
||||
+static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index,
|
||||
+ enum mlxsw_reg_mbct_op op,
|
||||
+ u16 data_size, bool last, bool oee,
|
||||
+ const char *data)
|
||||
+{
|
||||
+ MLXSW_REG_ZERO(mbct, payload);
|
||||
+ mlxsw_reg_mbct_slot_index_set(payload, slot_index);
|
||||
+ mlxsw_reg_mbct_op_set(payload, op);
|
||||
+ mlxsw_reg_mbct_oee_set(payload, oee);
|
||||
+ if (op == MLXSW_REG_MBCT_OP_DATA_TRANSFER) {
|
||||
+ if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN))
|
||||
+ return;
|
||||
+ mlxsw_reg_mbct_data_size_set(payload, data_size);
|
||||
+ mlxsw_reg_mbct_last_set(payload, last);
|
||||
+ mlxsw_reg_mbct_data_memcpy_to(payload, data);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
|
||||
+ enum mlxsw_reg_mbct_status *p_status,
|
||||
+ enum mlxsw_reg_mbct_fsm_state *p_fsm_state)
|
||||
+{
|
||||
+ if (p_slot_index)
|
||||
+ *p_slot_index = mlxsw_reg_mbct_slot_index_get(payload);
|
||||
+ *p_status = mlxsw_reg_mbct_status_get(payload);
|
||||
+ if (p_fsm_state)
|
||||
+ *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
|
||||
+}
|
||||
+
|
||||
/* MDDQ - Management DownStream Device Query Register
|
||||
* --------------------------------------------------
|
||||
* This register allows to query the DownStream device properties. The desired
|
||||
@@ -11764,6 +11883,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
|
||||
MLXSW_REG(mtptpt),
|
||||
MLXSW_REG(mfgd),
|
||||
MLXSW_REG(mgpir),
|
||||
+ MLXSW_REG(mbct),
|
||||
MLXSW_REG(mddq),
|
||||
MLXSW_REG(mddc),
|
||||
MLXSW_REG(mfde),
|
||||
--
|
||||
2.20.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,206 +0,0 @@
|
||||
From e7379493c9f7e30f7d20459ed07a435095e9a889 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 22 Jan 2021 14:45:06 +0100
|
||||
Subject: [PATCH backport 5.10 136/182] mlxsw: core_linecards: Implement line
|
||||
card activation process
|
||||
|
||||
Allow to process events generated upon line card getting "ready" and
|
||||
"active".
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 3 +
|
||||
.../ethernet/mellanox/mlxsw/core_linecards.c | 85 +++++++++++++++++--
|
||||
2 files changed, 80 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index d3c5d8289a85..ecd91bb8ca77 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -521,6 +521,9 @@ struct mlxsw_linecard {
|
||||
char read_name[MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN];
|
||||
char mbct_pl[MLXSW_REG_MBCT_LEN]; /* too big for stack */
|
||||
bool provisioned;
|
||||
+ bool ready;
|
||||
+ bool active;
|
||||
+ bool unprovision_done;
|
||||
};
|
||||
|
||||
struct mlxsw_linecard_types_info;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
index a324ce2436e8..134437f49219 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
@@ -67,6 +67,8 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
|
||||
static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard)
|
||||
{
|
||||
linecard->provisioned = false;
|
||||
+ linecard->ready = false;
|
||||
+ linecard->active = false;
|
||||
devlink_linecard_provision_fail(linecard->devlink_linecard);
|
||||
}
|
||||
|
||||
@@ -94,10 +96,51 @@ static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard)
|
||||
devlink_linecard_provision_clear(linecard->devlink_linecard);
|
||||
}
|
||||
|
||||
+static int mlxsw_linecard_ready_set(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ char mddc_pl[MLXSW_REG_MDDC_LEN];
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mddc_pack(mddc_pl, linecard->slot_index, false, true);
|
||||
+ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddc), mddc_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ linecard->ready = true;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_ready_clear(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ char mddc_pl[MLXSW_REG_MDDC_LEN];
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mddc_pack(mddc_pl, linecard->slot_index, false, false);
|
||||
+ err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddc), mddc_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ linecard->ready = false;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ linecard->active = true;
|
||||
+ devlink_linecard_activate(linecard->devlink_linecard);
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ linecard->active = false;
|
||||
+ devlink_linecard_deactivate(linecard->devlink_linecard);
|
||||
+}
|
||||
+
|
||||
static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecards *linecards,
|
||||
struct mlxsw_linecard *linecard,
|
||||
- const char *mddq_pl)
|
||||
+ const char *mddq_pl,
|
||||
+ bool process_provision_only)
|
||||
{
|
||||
enum mlxsw_reg_mddq_card_type card_type;
|
||||
enum mlxsw_reg_mddq_ready ready;
|
||||
@@ -132,6 +175,27 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ if (!process_provision_only && !linecard->unprovision_done &&
|
||||
+ ready == MLXSW_REG_MDDQ_READY_READY && !linecard->ready) {
|
||||
+ err = mlxsw_linecard_ready_set(mlxsw_core, linecard);
|
||||
+ if (err)
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (!process_provision_only && !linecard->unprovision_done && active &&
|
||||
+ linecard->active != active && linecard->ready)
|
||||
+ mlxsw_linecard_active_set(linecard);
|
||||
+
|
||||
+ if (!process_provision_only && !active && linecard->active != active)
|
||||
+ mlxsw_linecard_active_clear(linecard);
|
||||
+
|
||||
+ if (!process_provision_only && ready != MLXSW_REG_MDDQ_READY_READY &&
|
||||
+ linecard->ready) {
|
||||
+ err = mlxsw_linecard_ready_clear(mlxsw_core, linecard);
|
||||
+ if (err)
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
if (!provisioned && linecard->provisioned != provisioned)
|
||||
mlxsw_linecard_provision_clear(linecard);
|
||||
|
||||
@@ -146,13 +210,14 @@ int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core);
|
||||
|
||||
return __mlxsw_linecard_status_process(mlxsw_core, linecards, NULL,
|
||||
- mddq_pl);
|
||||
+ mddq_pl, false);
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_linecard_status_process);
|
||||
|
||||
static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecards *linecards,
|
||||
- struct mlxsw_linecard *linecard)
|
||||
+ struct mlxsw_linecard *linecard,
|
||||
+ bool process_provision_only)
|
||||
{
|
||||
char mddq_pl[MLXSW_REG_MDDQ_LEN];
|
||||
int err;
|
||||
@@ -163,7 +228,7 @@ static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core,
|
||||
return err;
|
||||
|
||||
return __mlxsw_linecard_status_process(mlxsw_core, linecards, linecard,
|
||||
- mddq_pl);
|
||||
+ mddq_pl, process_provision_only);
|
||||
}
|
||||
|
||||
static int __mlxsw_linecard_fix_fsm_state(struct mlxsw_linecard *linecard)
|
||||
@@ -308,6 +373,7 @@ static int mlxsw_linecard_provision(struct devlink_linecard *devlink_linecard,
|
||||
|
||||
mutex_lock(&linecard->lock);
|
||||
|
||||
+ linecard->unprovision_done = false;
|
||||
linecards = linecard->linecards;
|
||||
mlxsw_core = linecards->mlxsw_core;
|
||||
mlxsw_reg_mbct_pack(linecard->mbct_pl, linecard->slot_index,
|
||||
@@ -416,6 +482,7 @@ static int mlxsw_linecard_unprovision(struct devlink_linecard *devlink_linecard,
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to erase linecard INI while being used");
|
||||
goto fix_fsm_err_out;
|
||||
}
|
||||
+ linecard->unprovision_done = true;
|
||||
goto out;
|
||||
|
||||
fix_fsm_err_out:
|
||||
@@ -478,7 +545,7 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core,
|
||||
linecard->devlink_linecard = devlink_linecard;
|
||||
|
||||
err = mlxsw_linecard_status_get_and_process(mlxsw_core, linecards,
|
||||
- linecard);
|
||||
+ linecard, true);
|
||||
if (err)
|
||||
goto err_status_get_and_process;
|
||||
|
||||
@@ -514,7 +581,7 @@ static int mlxsw_linecard_post_init(struct mlxsw_core *mlxsw_core,
|
||||
return err;
|
||||
|
||||
err = mlxsw_linecard_status_get_and_process(mlxsw_core, linecards,
|
||||
- linecard);
|
||||
+ linecard, false);
|
||||
if (err)
|
||||
goto err_status_get_and_process;
|
||||
|
||||
@@ -533,6 +600,10 @@ static void mlxsw_linecard_pre_fini(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
linecard = mlxsw_linecard_get(linecards, slot_index);
|
||||
mlxsw_linecard_event_delivery_set(mlxsw_core, linecard, false);
|
||||
+ /* Make sure all scheduled events are processed */
|
||||
+ mlxsw_core_flush_owq();
|
||||
+ if (linecard->active)
|
||||
+ mlxsw_linecard_active_clear(linecard);
|
||||
}
|
||||
|
||||
static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,
|
||||
@@ -754,8 +825,6 @@ void mlxsw_linecards_pre_fini(struct mlxsw_core *mlxsw_core,
|
||||
return;
|
||||
for (i = 0; i < linecards->count; i++)
|
||||
mlxsw_linecard_pre_fini(mlxsw_core, linecards, i + 1);
|
||||
- /* Make sure all scheduled events are processed */
|
||||
- mlxsw_core_flush_owq();
|
||||
}
|
||||
|
||||
void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,99 +0,0 @@
|
||||
From a0e62e8df42c4ae6eabba2ea0c2d076d8c8d06fb Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 22 Dec 2021 16:26:43 +0000
|
||||
Subject: [PATCH backport 5.10 137/182] mlxsw: core: Extend driver ops by
|
||||
remove selected ports op
|
||||
|
||||
In case of line card implementation, the core has to have a way to
|
||||
remove relevant ports manually. Extend the Spectrum driver ops by an op
|
||||
that implements port removal of selected ports upon request.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.c | 9 +++++++++
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 8 ++++++++
|
||||
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 15 +++++++++++++++
|
||||
3 files changed, 32 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
index 246db548f011..2b4f9844b1d6 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
@@ -2870,6 +2870,15 @@ mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_core_port_devlink_port_get);
|
||||
|
||||
+void mlxsw_core_ports_remove_selected(struct mlxsw_core *mlxsw_core,
|
||||
+ bool (*selector)(void *priv, u16 local_port),
|
||||
+ void *priv)
|
||||
+{
|
||||
+ if (WARN_ON(!mlxsw_core->driver->ports_remove_selected))
|
||||
+ return;
|
||||
+ mlxsw_core->driver->ports_remove_selected(mlxsw_core, selector, priv);
|
||||
+}
|
||||
+
|
||||
struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core)
|
||||
{
|
||||
return mlxsw_core->env;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index ecd91bb8ca77..70f97ef74a2c 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -223,6 +223,10 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
|
||||
struct devlink_port *
|
||||
mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
|
||||
u8 local_port);
|
||||
+void mlxsw_core_ports_remove_selected(struct mlxsw_core *mlxsw_core,
|
||||
+ bool (*selector)(void *priv,
|
||||
+ u16 local_port),
|
||||
+ void *priv);
|
||||
struct mlxsw_env *mlxsw_core_env(const struct mlxsw_core *mlxsw_core);
|
||||
int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module);
|
||||
|
||||
@@ -296,6 +300,10 @@ struct mlxsw_driver {
|
||||
unsigned int count, struct netlink_ext_ack *extack);
|
||||
int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
struct netlink_ext_ack *extack);
|
||||
+ void (*ports_remove_selected)(struct mlxsw_core *mlxsw_core,
|
||||
+ bool (*selector)(void *priv,
|
||||
+ u16 local_port),
|
||||
+ void *priv);
|
||||
int (*sb_pool_get)(struct mlxsw_core *mlxsw_core,
|
||||
unsigned int sb_index, u16 pool_index,
|
||||
struct devlink_sb_pool_info *pool_info);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
index bc233a5c8a79..82acff318dcd 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
@@ -1736,6 +1736,20 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)
|
||||
mlxsw_sp->ports = NULL;
|
||||
}
|
||||
|
||||
+static void
|
||||
+mlxsw_sp_ports_remove_selected(struct mlxsw_core *mlxsw_core,
|
||||
+ bool (*selector)(void *priv, u16 local_port),
|
||||
+ void *priv)
|
||||
+{
|
||||
+ struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
|
||||
+ unsigned int max_ports = mlxsw_core_max_ports(mlxsw_core);
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 1; i < max_ports; i++)
|
||||
+ if (mlxsw_sp_port_created(mlxsw_sp, i) && selector(priv, i))
|
||||
+ mlxsw_sp_port_remove(mlxsw_sp, i);
|
||||
+}
|
||||
+
|
||||
static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
|
||||
{
|
||||
unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
|
||||
@@ -3370,6 +3384,7 @@ static struct mlxsw_driver mlxsw_sp3_driver = {
|
||||
.basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set,
|
||||
.port_split = mlxsw_sp_port_split,
|
||||
.port_unsplit = mlxsw_sp_port_unsplit,
|
||||
+ .ports_remove_selected = mlxsw_sp_ports_remove_selected,
|
||||
.sb_pool_get = mlxsw_sp_sb_pool_get,
|
||||
.sb_pool_set = mlxsw_sp_sb_pool_set,
|
||||
.sb_port_pool_get = mlxsw_sp_sb_port_pool_get,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,153 +0,0 @@
|
||||
From 718b7aec4ec4c7e3c327b2ffbf43b27126688836 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 3 Jan 2022 11:22:42 +0000
|
||||
Subject: [PATCH backport 5.10 138/182] mlxsw: spectrum: Add port to linecard
|
||||
mapping
|
||||
|
||||
For each port get slot_index using PMLP register. For ports residing
|
||||
on a linecard, identify it with the linecard by setting mapping
|
||||
using devlink_port_linecard_set() helper. Use linecard slot index for
|
||||
PMTDB register queries.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.c | 18 ++++++++++++++----
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 3 ++-
|
||||
drivers/net/ethernet/mellanox/mlxsw/minimal.c | 2 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/switchib.c | 2 +-
|
||||
drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 2 +-
|
||||
6 files changed, 20 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
index 2b4f9844b1d6..68ef007ac48c 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
@@ -48,6 +48,7 @@ struct mlxsw_core_port {
|
||||
struct devlink_port devlink_port;
|
||||
void *port_driver_priv;
|
||||
u8 local_port;
|
||||
+ struct mlxsw_linecard *linecard;
|
||||
};
|
||||
|
||||
void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port)
|
||||
@@ -2723,7 +2724,7 @@ EXPORT_SYMBOL(mlxsw_core_res_get);
|
||||
|
||||
static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
enum devlink_port_flavour flavour,
|
||||
- u32 port_number, bool split,
|
||||
+ u8 slot_index, u32 port_number, bool split,
|
||||
u32 split_port_subnumber,
|
||||
bool splittable, u32 lanes,
|
||||
const unsigned char *switch_id,
|
||||
@@ -2746,6 +2747,15 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
attrs.switch_id.id_len = switch_id_len;
|
||||
mlxsw_core_port->local_port = local_port;
|
||||
devlink_port_attrs_set(devlink_port, &attrs);
|
||||
+ if (slot_index) {
|
||||
+ struct mlxsw_linecard *linecard;
|
||||
+
|
||||
+ linecard = mlxsw_linecard_get(mlxsw_core->linecards,
|
||||
+ slot_index);
|
||||
+ mlxsw_core_port->linecard = linecard;
|
||||
+ devlink_port_linecard_set(devlink_port,
|
||||
+ linecard->devlink_linecard);
|
||||
+ }
|
||||
err = devlink_port_register(devlink, devlink_port, local_port);
|
||||
if (err)
|
||||
memset(mlxsw_core_port, 0, sizeof(*mlxsw_core_port));
|
||||
@@ -2763,14 +2773,14 @@ static void __mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port)
|
||||
}
|
||||
|
||||
int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
- u32 port_number, bool split,
|
||||
+ u8 slot_index, u32 port_number, bool split,
|
||||
u32 split_port_subnumber,
|
||||
bool splittable, u32 lanes,
|
||||
const unsigned char *switch_id,
|
||||
unsigned char switch_id_len)
|
||||
{
|
||||
return __mlxsw_core_port_init(mlxsw_core, local_port,
|
||||
- DEVLINK_PORT_FLAVOUR_PHYSICAL,
|
||||
+ DEVLINK_PORT_FLAVOUR_PHYSICAL, slot_index,
|
||||
port_number, split, split_port_subnumber,
|
||||
splittable, lanes,
|
||||
switch_id, switch_id_len);
|
||||
@@ -2794,7 +2804,7 @@ int mlxsw_core_cpu_port_init(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
err = __mlxsw_core_port_init(mlxsw_core, MLXSW_PORT_CPU_PORT,
|
||||
DEVLINK_PORT_FLAVOUR_CPU,
|
||||
- 0, false, 0, false, 0,
|
||||
+ 0, 0, false, 0, false, 0,
|
||||
switch_id, switch_id_len);
|
||||
if (err)
|
||||
return err;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index 70f97ef74a2c..8e738ddb39c8 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -202,7 +202,8 @@ void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port);
|
||||
int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
|
||||
- u32 port_number, bool split, u32 split_port_subnumber,
|
||||
+ u8 slot_index, u32 port_number, bool split,
|
||||
+ u32 split_port_subnumber,
|
||||
bool splittable, u32 lanes,
|
||||
const unsigned char *switch_id,
|
||||
unsigned char switch_id_len);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
index 104f1ba0242f..30925f57362e 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
|
||||
@@ -210,7 +210,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module)
|
||||
struct net_device *dev;
|
||||
int err;
|
||||
|
||||
- err = mlxsw_core_port_init(mlxsw_m->core, local_port,
|
||||
+ err = mlxsw_core_port_init(mlxsw_m->core, local_port, 0,
|
||||
module + 1, false, 0, false,
|
||||
0, mlxsw_m->base_mac,
|
||||
sizeof(mlxsw_m->base_mac));
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
index 82acff318dcd..c87267d002c6 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
|
||||
@@ -1399,7 +1399,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
|
||||
int err;
|
||||
|
||||
splittable = lanes > 1 && !split;
|
||||
- err = mlxsw_core_port_init(mlxsw_sp->core, local_port,
|
||||
+ err = mlxsw_core_port_init(mlxsw_sp->core, local_port, 0,
|
||||
port_mapping->module + 1, split,
|
||||
port_mapping->lane / lanes,
|
||||
splittable, lanes,
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchib.c b/drivers/net/ethernet/mellanox/mlxsw/switchib.c
|
||||
index 1e561132eb1e..090b9a103c04 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/switchib.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchib.c
|
||||
@@ -280,7 +280,7 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
|
||||
{
|
||||
int err;
|
||||
|
||||
- err = mlxsw_core_port_init(mlxsw_sib->core, local_port,
|
||||
+ err = mlxsw_core_port_init(mlxsw_sib->core, local_port, 0,
|
||||
module + 1, false, 0, false, 0,
|
||||
mlxsw_sib->hw_id, sizeof(mlxsw_sib->hw_id));
|
||||
if (err) {
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
|
||||
index 131b2a53d261..bf8a54776861 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
|
||||
@@ -1085,7 +1085,7 @@ static int mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port,
|
||||
{
|
||||
int err;
|
||||
|
||||
- err = mlxsw_core_port_init(mlxsw_sx->core, local_port,
|
||||
+ err = mlxsw_core_port_init(mlxsw_sx->core, local_port, 0,
|
||||
module + 1, false, 0, false, 0,
|
||||
mlxsw_sx->hw_id, sizeof(mlxsw_sx->hw_id));
|
||||
if (err) {
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,105 +0,0 @@
|
||||
From 44b270551552a48c2a0799f1660b7bfdd0c10519 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 12 May 2021 22:57:37 +0300
|
||||
Subject: [PATCH backport 5.10 139/182] mlxsw: reg: Introduce Management
|
||||
Temperature Extended Capabilities Register
|
||||
|
||||
Introduce new register MTECR (Management Temperature Extended
|
||||
Capabilities Register). This register exposes the capabilities of the
|
||||
device and system temperature sensing. It provides information for
|
||||
all possible temperature sensors that are on the system.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 67 +++++++++++++++++++++++
|
||||
1 file changed, 67 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index e060f054e0a9..5757c4f40277 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10296,6 +10296,72 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
|
||||
*num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
|
||||
}
|
||||
|
||||
+/* MTECR - Management Temperature Extended Capabilities Register
|
||||
+ * -------------------------------------------------------------
|
||||
+ * MTECR register exposes the capabilities of the device and system
|
||||
+ * temperature sensing.
|
||||
+ */
|
||||
+#define MLXSW_REG_MTECR_ID 0x9109
|
||||
+#define MLXSW_REG_MTECR_LEN 0x60
|
||||
+#define MLXSW_REG_MTECR_SENSOR_MAP_LEN 0x58
|
||||
+
|
||||
+MLXSW_REG_DEFINE(mtecr, MLXSW_REG_MTECR_ID, MLXSW_REG_MTECR_LEN);
|
||||
+
|
||||
+/* reg_mtecr_last_sensor.
|
||||
+ * Last sensor index that is available in the system to read from.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mtecr, last_sensor, 0x00, 16, 12);
|
||||
+
|
||||
+/* reg_mtecr_sensor_count.
|
||||
+ * Number of sensors supported by the device.
|
||||
+ * This includes the ASIC, ambient sensors, Gearboxes etc.
|
||||
+ * QSFP module sensors are not included.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mtecr, sensor_count, 0x00, 0, 12);
|
||||
+
|
||||
+/* reg_mtecr_slot_index.
|
||||
+ * Slot index (0: Main board).
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mtecr, slot_index, 0x04, 28, 4);
|
||||
+
|
||||
+/* reg_mtecr_internal_sensor_count.
|
||||
+ * Number of sensors supported by the device that are in the ASIC.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mtecr, internal_sensor_count, 0x04, 0, 7);
|
||||
+
|
||||
+/* reg_mtecr_sensor_map.
|
||||
+ * Mapping of system sensors supported by the device. Each bit represents a
|
||||
+ * sensor. This field is size variable based on the last_sensor field and in
|
||||
+ * granularity of 32 bits.
|
||||
+ * 0: Not connected or not supported
|
||||
+ * 1: Supports temperature measurements
|
||||
+ *
|
||||
+ */
|
||||
+MLXSW_ITEM_BIT_ARRAY(reg, mtecr, sensor_map, 0x08, MLXSW_REG_MTECR_SENSOR_MAP_LEN, 1);
|
||||
+
|
||||
+static inline void mlxsw_reg_mtecr_pack(char *payload, u8 slot_index)
|
||||
+{
|
||||
+ MLXSW_REG_ZERO(mtecr, payload);
|
||||
+ mlxsw_reg_mtecr_slot_index_set(payload, slot_index);
|
||||
+}
|
||||
+
|
||||
+static inline void mlxsw_reg_mtecr_unpack(char *payload, u16 *sensor_count,
|
||||
+ u16 *last_sensor,
|
||||
+ u8 *internal_sensor_count)
|
||||
+{
|
||||
+ if (sensor_count)
|
||||
+ *sensor_count = mlxsw_reg_mtecr_sensor_count_get(payload);
|
||||
+ if (last_sensor)
|
||||
+ *last_sensor = mlxsw_reg_mtecr_last_sensor_get(payload);
|
||||
+ if (internal_sensor_count)
|
||||
+ *internal_sensor_count =
|
||||
+ mlxsw_reg_mtecr_internal_sensor_count_get(payload);
|
||||
+}
|
||||
+
|
||||
/* MBCT - Management Binary Code Transfer Register
|
||||
* -----------------------------------------------
|
||||
* This register allows to transfer binary codes from the Host to
|
||||
@@ -11883,6 +11949,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
|
||||
MLXSW_REG(mtptpt),
|
||||
MLXSW_REG(mfgd),
|
||||
MLXSW_REG(mgpir),
|
||||
+ MLXSW_REG(mtecr),
|
||||
MLXSW_REG(mbct),
|
||||
MLXSW_REG(mddq),
|
||||
MLXSW_REG(mddc),
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,114 +0,0 @@
|
||||
From 3614c1e72e48e03c64ce88d269d97ee4743f9cc4 Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 13 Dec 2021 12:29:10 +0000
|
||||
Subject: [PATCH backport 5.10 140/182] mlxsw: core: Add APIs for thermal
|
||||
sensor mapping
|
||||
|
||||
Add APIs mlxsw_env_sensor_map_init() and mlxsw_env_sensor_map_fini(().
|
||||
The purpose of the first one is to allocate and create thermal sensors
|
||||
mapping for temperature sensors, presented within the main board or
|
||||
line card. It obtains mapping information from the Management
|
||||
Temperature Extended Capabilities Register, by specifying the relevant
|
||||
device by the number of a slot at which this device is located. Slot
|
||||
zero is used for the main board. The second API just free allocated
|
||||
memory.
|
||||
The motivation is to create dynamic mapping for gearbox thermal sensors
|
||||
access.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 47 +++++++++++++++++++
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.h | 12 +++++
|
||||
2 files changed, 59 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 4553dfa68f96..4f3fc25af013 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -624,6 +624,53 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);
|
||||
|
||||
+int mlxsw_env_sensor_map_create(struct mlxsw_core *core,
|
||||
+ const struct mlxsw_bus_info *bus_info,
|
||||
+ u8 slot_index,
|
||||
+ struct mlxsw_env_gearbox_sensors_map *map)
|
||||
+{
|
||||
+ char mtecr_pl[MLXSW_REG_MTECR_LEN];
|
||||
+ u16 last_sensor, offset;
|
||||
+ int i, bit, err;
|
||||
+
|
||||
+ mlxsw_reg_mtecr_pack(mtecr_pl, slot_index);
|
||||
+ err = mlxsw_reg_query(core, MLXSW_REG(mtecr), mtecr_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ mlxsw_reg_mtecr_unpack(mtecr_pl, &map->sensor_count, &last_sensor, NULL);
|
||||
+ if (!map->sensor_count) {
|
||||
+ map->sensor_bit_map = NULL;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Fill out sensor mapping array. */
|
||||
+ map->sensor_bit_map = kcalloc(map->sensor_count, sizeof(u16), GFP_KERNEL);
|
||||
+ if (!map->sensor_bit_map)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Sensors bitmap is size variable based on the last_sensor field and
|
||||
+ * in granularity of 32 bits. Calculate an offset in payload buffer to
|
||||
+ * start from.
|
||||
+ */
|
||||
+ offset = MLXSW_REG_MTECR_SENSOR_MAP_LEN * 8 - last_sensor - 1;
|
||||
+ offset -= offset % 32;
|
||||
+ for (bit = 0, i = 0; bit <= last_sensor && i < map->sensor_count; bit++) {
|
||||
+ if (mlxsw_reg_mtecr_sensor_map_get(mtecr_pl, bit + offset))
|
||||
+ map->sensor_bit_map[i++] = bit;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL(mlxsw_env_sensor_map_create);
|
||||
+
|
||||
+void mlxsw_env_sensor_map_destroy(const struct mlxsw_bus_info *bus_info,
|
||||
+ u16 *sensor_bit_map)
|
||||
+{
|
||||
+ kfree(sensor_bit_map);
|
||||
+}
|
||||
+EXPORT_SYMBOL(mlxsw_env_sensor_map_destroy);
|
||||
+
|
||||
static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core,
|
||||
u8 slot_index, u8 module,
|
||||
bool *p_has_temp_sensor)
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.h b/drivers/net/ethernet/mellanox/mlxsw/core_env.h
|
||||
index 03d027870d65..336c9ee579cb 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.h
|
||||
@@ -9,6 +9,11 @@
|
||||
struct ethtool_modinfo;
|
||||
struct ethtool_eeprom;
|
||||
|
||||
+struct mlxsw_env_gearbox_sensors_map {
|
||||
+ u16 sensor_count;
|
||||
+ u16 *sensor_bit_map;
|
||||
+};
|
||||
+
|
||||
int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core,
|
||||
u8 slot_index, int module, int off,
|
||||
int *temp);
|
||||
@@ -21,6 +26,13 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev,
|
||||
int module, struct ethtool_eeprom *ee,
|
||||
u8 *data);
|
||||
|
||||
+int mlxsw_env_sensor_map_create(struct mlxsw_core *core,
|
||||
+ const struct mlxsw_bus_info *bus_info,
|
||||
+ u8 slot_index,
|
||||
+ struct mlxsw_env_gearbox_sensors_map *map);
|
||||
+void mlxsw_env_sensor_map_destroy(const struct mlxsw_bus_info *bus_info,
|
||||
+ u16 *sensor_bit_map);
|
||||
+
|
||||
int
|
||||
mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core,
|
||||
u8 slot_index, u8 module,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,126 +0,0 @@
|
||||
From d7353e41900e4d6fa44fa5e51a483b9f01432846 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Thu, 25 Feb 2021 10:17:53 +0100
|
||||
Subject: [PATCH backport 5.10 141/182] mlxsw: reg: Add Management DownStream
|
||||
Device Tunneling Register
|
||||
|
||||
The MDDT register allows deliver query and request messages
|
||||
(PRM registers, commands) to a DownStream device.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/reg.h | 91 +++++++++++++++++++++++
|
||||
1 file changed, 91 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
index 5757c4f40277..7b71e9ae3d51 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
|
||||
@@ -10481,6 +10481,96 @@ mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
|
||||
*p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
|
||||
}
|
||||
|
||||
+/* MDDT - Management DownStream Device Tunneling Register
|
||||
+ * ------------------------------------------------------
|
||||
+ * This register allows deliver query and request messages (PRM registers,
|
||||
+ * commands) to a DownStream device.
|
||||
+ */
|
||||
+#define MLXSW_REG_MDDT_ID 0x9160
|
||||
+#define MLXSW_REG_MDDT_LEN 0x110
|
||||
+
|
||||
+MLXSW_REG_DEFINE(mddt, MLXSW_REG_MDDT_ID, MLXSW_REG_MDDT_LEN);
|
||||
+
|
||||
+/* reg_mddt_slot_index
|
||||
+ * Slot index.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+
|
||||
+MLXSW_ITEM32(reg, mddt, slot_index, 0x00, 8, 4);
|
||||
+
|
||||
+/* reg_mddt_device_index
|
||||
+ * Device index.
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddt, device_index, 0x00, 0, 8);
|
||||
+
|
||||
+/* reg_mddt_read_size
|
||||
+ * Read size in D-Words.
|
||||
+ * Access: OP
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddt, read_size, 0x04, 24, 8);
|
||||
+
|
||||
+/* reg_mddt_write_size
|
||||
+ * Write size in D-Words.
|
||||
+ * Access: OP
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddt, write_size, 0x04, 16, 8);
|
||||
+
|
||||
+enum mlxsw_reg_mddt_status {
|
||||
+ MLXSW_REG_MDDT_STATUS_OK,
|
||||
+};
|
||||
+
|
||||
+/* reg_mddt_status
|
||||
+ * Return code of the Downstream Device to the register that was sent.
|
||||
+ * Access: RO
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddt, status, 0x0C, 24, 8);
|
||||
+
|
||||
+enum mlxsw_reg_mddt_method {
|
||||
+ MLXSW_REG_MDDT_METHOD_QUERY,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+};
|
||||
+
|
||||
+/* reg_mddt_method
|
||||
+ * Access: OP
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddt, method, 0x0C, 22, 2);
|
||||
+
|
||||
+/* reg_mddt_register_id
|
||||
+ * Access: Index
|
||||
+ */
|
||||
+MLXSW_ITEM32(reg, mddt, register_id, 0x0C, 0, 16);
|
||||
+
|
||||
+#define MLXSW_REG_MDDT_PAYLOAD_OFFSET 0x0C
|
||||
+#define MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN 4
|
||||
+
|
||||
+static inline char *mlxsw_reg_mddt_inner_payload(char *payload)
|
||||
+{
|
||||
+ return payload + MLXSW_REG_MDDT_PAYLOAD_OFFSET +
|
||||
+ MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN;
|
||||
+}
|
||||
+
|
||||
+static inline void mlxsw_reg_mddt_pack(char *payload, u8 slot_index,
|
||||
+ u8 device_index,
|
||||
+ enum mlxsw_reg_mddt_method method,
|
||||
+ const struct mlxsw_reg_info *reg,
|
||||
+ char **inner_payload)
|
||||
+{
|
||||
+ int len = reg->len + MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN;
|
||||
+
|
||||
+ if (WARN_ON(len + MLXSW_REG_MDDT_PAYLOAD_OFFSET > MLXSW_REG_MDDT_LEN))
|
||||
+ len = MLXSW_REG_MDDT_LEN - MLXSW_REG_MDDT_PAYLOAD_OFFSET;
|
||||
+
|
||||
+ MLXSW_REG_ZERO(mddt, payload);
|
||||
+ mlxsw_reg_mddt_slot_index_set(payload, slot_index);
|
||||
+ mlxsw_reg_mddt_device_index_set(payload, device_index);
|
||||
+ mlxsw_reg_mddt_method_set(payload, method);
|
||||
+ mlxsw_reg_mddt_register_id_set(payload, reg->id);
|
||||
+ mlxsw_reg_mddt_read_size_set(payload, len / 4);
|
||||
+ mlxsw_reg_mddt_write_size_set(payload, len / 4);
|
||||
+ *inner_payload = mlxsw_reg_mddt_inner_payload(payload);
|
||||
+}
|
||||
+
|
||||
/* MDDQ - Management DownStream Device Query Register
|
||||
* --------------------------------------------------
|
||||
* This register allows to query the DownStream device properties. The desired
|
||||
@@ -11951,6 +12041,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
|
||||
MLXSW_REG(mgpir),
|
||||
MLXSW_REG(mtecr),
|
||||
MLXSW_REG(mbct),
|
||||
+ MLXSW_REG(mddt),
|
||||
MLXSW_REG(mddq),
|
||||
MLXSW_REG(mddc),
|
||||
MLXSW_REG(mfde),
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,224 +0,0 @@
|
||||
From 51f5cf36b8b2c94d8a71bfa17d5f71257048c314 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 26 Feb 2021 13:15:09 +0100
|
||||
Subject: [PATCH backport 5.10 142/182] mlxsw: core_linecards: Probe devices
|
||||
for provisioned line card and attach them
|
||||
|
||||
In case the line card is provisioned, go over all possible existing
|
||||
devices (gearboxes) on it and attach them, so devlink core is aware of
|
||||
them. In case the device can be flashed, register mlxsw flash component.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 3 +
|
||||
.../ethernet/mellanox/mlxsw/core_linecards.c | 113 ++++++++++++++++--
|
||||
2 files changed, 108 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index 8e738ddb39c8..593470d14815 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -533,6 +533,9 @@ struct mlxsw_linecard {
|
||||
bool ready;
|
||||
bool active;
|
||||
bool unprovision_done;
|
||||
+ u16 hw_revision;
|
||||
+ u16 ini_version;
|
||||
+ struct list_head device_list;
|
||||
};
|
||||
|
||||
struct mlxsw_linecard_types_info;
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
index 134437f49219..720ad6d82798 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
@@ -64,27 +64,120 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
|
||||
return linecard->read_name;
|
||||
}
|
||||
|
||||
-static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard)
|
||||
+struct mlxsw_linecard_device {
|
||||
+ struct list_head list;
|
||||
+ u8 index;
|
||||
+ struct mlxsw_linecard *linecard;
|
||||
+ struct devlink_linecard_device *devlink_device;
|
||||
+};
|
||||
+
|
||||
+static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard,
|
||||
+ u8 device_index, bool flash_owner)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device *device;
|
||||
+ int err;
|
||||
+
|
||||
+ device = kzalloc(sizeof(*device), GFP_KERNEL);
|
||||
+ if (!device)
|
||||
+ return -ENOMEM;
|
||||
+ device->index = device_index;
|
||||
+ device->linecard = linecard;
|
||||
+
|
||||
+ device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard,
|
||||
+ device_index,
|
||||
+ NULL, NULL);
|
||||
+ if (IS_ERR(device->devlink_device)) {
|
||||
+ err = PTR_ERR(device->devlink_device);
|
||||
+ goto err_devlink_linecard_device_attach;
|
||||
+ }
|
||||
+
|
||||
+ list_add_tail(&device->list, &linecard->device_list);
|
||||
+ return 0;
|
||||
+
|
||||
+err_devlink_linecard_device_attach:
|
||||
+ kfree(device);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_device_detach(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard,
|
||||
+ struct mlxsw_linecard_device *device)
|
||||
+{
|
||||
+ list_del(&device->list);
|
||||
+ devlink_linecard_device_destroy(linecard->devlink_linecard,
|
||||
+ device->devlink_device);
|
||||
+ kfree(device);
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_devices_attach(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ char mddq_pl[MLXSW_REG_MDDQ_LEN];
|
||||
+ bool flash_owner;
|
||||
+ bool data_valid;
|
||||
+ u8 device_index;
|
||||
+ u8 msg_seq = 0;
|
||||
+ int err;
|
||||
+
|
||||
+ do {
|
||||
+ mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index,
|
||||
+ msg_seq);
|
||||
+ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq,
|
||||
+ &data_valid, &flash_owner,
|
||||
+ &device_index, NULL,
|
||||
+ NULL, NULL);
|
||||
+ if (!data_valid)
|
||||
+ break;
|
||||
+ err = mlxsw_linecard_device_attach(mlxsw_core, linecard,
|
||||
+ device_index, flash_owner);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ } while (msg_seq);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_devices_detach(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device *device, *tmp;
|
||||
+
|
||||
+ list_for_each_entry_safe(device, tmp, &linecard->device_list, list)
|
||||
+ mlxsw_linecard_device_detach(mlxsw_core, linecard, device);
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_provision_fail(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
{
|
||||
linecard->provisioned = false;
|
||||
linecard->ready = false;
|
||||
linecard->active = false;
|
||||
+ mlxsw_linecard_devices_detach(mlxsw_core, linecard);
|
||||
devlink_linecard_provision_fail(linecard->devlink_linecard);
|
||||
}
|
||||
|
||||
static int
|
||||
-mlxsw_linecard_provision_set(struct mlxsw_linecards *linecards,
|
||||
+mlxsw_linecard_provision_set(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards *linecards,
|
||||
struct mlxsw_linecard *linecard,
|
||||
enum mlxsw_reg_mddq_card_type card_type)
|
||||
{
|
||||
const char *type = mlxsw_linecard_types_lookup(linecards, card_type);
|
||||
+ int err;
|
||||
|
||||
if (!type)
|
||||
type = mlxsw_linecard_type_name(linecard);
|
||||
if (!type) {
|
||||
- mlxsw_linecard_provision_fail(linecard);
|
||||
+ mlxsw_linecard_provision_fail(mlxsw_core, linecard);
|
||||
return -EINVAL;
|
||||
}
|
||||
+ err = mlxsw_linecard_devices_attach(mlxsw_core, linecard);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
linecard->provisioned = true;
|
||||
devlink_linecard_provision_set(linecard->devlink_linecard, type);
|
||||
return 0;
|
||||
@@ -93,6 +186,8 @@ mlxsw_linecard_provision_set(struct mlxsw_linecards *linecards,
|
||||
static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard)
|
||||
{
|
||||
linecard->provisioned = false;
|
||||
+ mlxsw_linecard_devices_detach(linecard->linecards->mlxsw_core,
|
||||
+ linecard);
|
||||
devlink_linecard_provision_clear(linecard->devlink_linecard);
|
||||
}
|
||||
|
||||
@@ -169,8 +264,8 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
mutex_lock(&linecard->lock);
|
||||
|
||||
if (provisioned && linecard->provisioned != provisioned) {
|
||||
- err = mlxsw_linecard_provision_set(linecards, linecard,
|
||||
- card_type);
|
||||
+ err = mlxsw_linecard_provision_set(mlxsw_core, linecards,
|
||||
+ linecard, card_type);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
@@ -353,7 +448,7 @@ int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
fix_fsm_err_out:
|
||||
mlxsw_linecard_fix_fsm_state(linecard, fsm_state);
|
||||
- mlxsw_linecard_provision_fail(linecard);
|
||||
+ mlxsw_linecard_provision_fail(mlxsw_core, linecard);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_linecard_bct_process);
|
||||
@@ -415,7 +510,7 @@ static int mlxsw_linecard_provision(struct devlink_linecard *devlink_linecard,
|
||||
fix_fsm_err_out:
|
||||
mlxsw_linecard_fix_fsm_state(linecard, fsm_state);
|
||||
err_out:
|
||||
- mlxsw_linecard_provision_fail(linecard);
|
||||
+ mlxsw_linecard_provision_fail(mlxsw_core, linecard);
|
||||
out:
|
||||
mutex_unlock(&linecard->lock);
|
||||
return err;
|
||||
@@ -488,7 +583,7 @@ static int mlxsw_linecard_unprovision(struct devlink_linecard *devlink_linecard,
|
||||
fix_fsm_err_out:
|
||||
mlxsw_linecard_fix_fsm_state(linecard, fsm_state);
|
||||
err_out:
|
||||
- mlxsw_linecard_provision_fail(linecard);
|
||||
+ mlxsw_linecard_provision_fail(mlxsw_core, linecard);
|
||||
out:
|
||||
mutex_unlock(&linecard->lock);
|
||||
return err;
|
||||
@@ -536,6 +631,7 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core,
|
||||
linecard->slot_index = slot_index;
|
||||
linecard->linecards = linecards;
|
||||
mutex_init(&linecard->lock);
|
||||
+ INIT_LIST_HEAD(&linecard->device_list);
|
||||
|
||||
devlink_linecard = devlink_linecard_create(priv_to_devlink(mlxsw_core),
|
||||
slot_index, &mlxsw_linecard_ops,
|
||||
@@ -613,6 +709,7 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecard *linecard;
|
||||
|
||||
linecard = mlxsw_linecard_get(linecards, slot_index);
|
||||
+ mlxsw_linecard_devices_detach(mlxsw_core, linecard);
|
||||
devlink_linecard_destroy(linecard->devlink_linecard);
|
||||
mutex_destroy(&linecard->lock);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,177 +0,0 @@
|
||||
From e4830f23af9d14fac42764dd077f49de8de7bff2 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Thu, 10 Jun 2021 15:32:00 +0200
|
||||
Subject: [PATCH backport 5.10 143/182] mlxsw: core_linecards: Expose device FW
|
||||
version over device info
|
||||
|
||||
Extend MDDQ to obtain FW version of line card device and implement
|
||||
device_info_get() op to fill up the info with that.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_linecards.c | 104 +++++++++++++++++-
|
||||
1 file changed, 100 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
index 720ad6d82798..cb872f918f01 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
@@ -64,13 +64,31 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
|
||||
return linecard->read_name;
|
||||
}
|
||||
|
||||
+struct mlxsw_linecard_device_info {
|
||||
+ u16 fw_major;
|
||||
+ u16 fw_minor;
|
||||
+ u16 fw_sub_minor;
|
||||
+};
|
||||
+
|
||||
struct mlxsw_linecard_device {
|
||||
struct list_head list;
|
||||
u8 index;
|
||||
struct mlxsw_linecard *linecard;
|
||||
struct devlink_linecard_device *devlink_device;
|
||||
+ struct mlxsw_linecard_device_info info;
|
||||
};
|
||||
|
||||
+static struct mlxsw_linecard_device *
|
||||
+mlxsw_linecard_device_lookup(struct mlxsw_linecard *linecard, u8 index)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device *device;
|
||||
+
|
||||
+ list_for_each_entry(device, &linecard->device_list, list)
|
||||
+ if (device->index == index)
|
||||
+ return device;
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecard *linecard,
|
||||
u8 device_index, bool flash_owner)
|
||||
@@ -86,7 +104,7 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard,
|
||||
device_index,
|
||||
- NULL, NULL);
|
||||
+ NULL, device);
|
||||
if (IS_ERR(device->devlink_device)) {
|
||||
err = PTR_ERR(device->devlink_device);
|
||||
goto err_devlink_linecard_device_attach;
|
||||
@@ -150,6 +168,71 @@ static void mlxsw_linecard_devices_detach(struct mlxsw_core *mlxsw_core,
|
||||
mlxsw_linecard_device_detach(mlxsw_core, linecard, device);
|
||||
}
|
||||
|
||||
+static void mlxsw_linecard_device_update(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard,
|
||||
+ u8 device_index,
|
||||
+ struct mlxsw_linecard_device_info *info)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device *device;
|
||||
+
|
||||
+ device = mlxsw_linecard_device_lookup(linecard, device_index);
|
||||
+ if (!device)
|
||||
+ return;
|
||||
+ device->info = *info;
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_devices_update(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_info info;
|
||||
+ char mddq_pl[MLXSW_REG_MDDQ_LEN];
|
||||
+ bool data_valid;
|
||||
+ u8 device_index;
|
||||
+ u8 msg_seq = 0;
|
||||
+ int err;
|
||||
+
|
||||
+ do {
|
||||
+ mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index,
|
||||
+ msg_seq);
|
||||
+ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq,
|
||||
+ &data_valid, NULL,
|
||||
+ &device_index,
|
||||
+ &info.fw_major,
|
||||
+ &info.fw_minor,
|
||||
+ &info.fw_sub_minor);
|
||||
+ if (!data_valid)
|
||||
+ break;
|
||||
+ mlxsw_linecard_device_update(mlxsw_core, linecard,
|
||||
+ device_index, &info);
|
||||
+ } while (msg_seq);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_linecard_device_info_get(struct devlink_linecard_device *devlink_linecard_device,
|
||||
+ void *priv, struct devlink_info_req *req,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device *device = priv;
|
||||
+ struct mlxsw_linecard_device_info *info;
|
||||
+ char buf[32];
|
||||
+
|
||||
+ if (!device->linecard->active)
|
||||
+ return 0;
|
||||
+
|
||||
+ info = &device->info;
|
||||
+
|
||||
+ sprintf(buf, "%u.%u.%u", info->fw_major, info->fw_minor,
|
||||
+ info->fw_sub_minor);
|
||||
+ return devlink_info_version_running_put(req,
|
||||
+ DEVLINK_INFO_VERSION_GENERIC_FW,
|
||||
+ buf);
|
||||
+}
|
||||
+
|
||||
static void mlxsw_linecard_provision_fail(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecard *linecard)
|
||||
{
|
||||
@@ -219,10 +302,18 @@ static int mlxsw_linecard_ready_clear(struct mlxsw_core *mlxsw_core,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard)
|
||||
+static int mlxsw_linecard_active_set(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecard *linecard,
|
||||
+ u16 hw_revision, u16 ini_version)
|
||||
{
|
||||
+ int err;
|
||||
+
|
||||
+ err = mlxsw_linecard_devices_update(mlxsw_core, linecard);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
linecard->active = true;
|
||||
devlink_linecard_activate(linecard->devlink_linecard);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard)
|
||||
@@ -278,8 +369,12 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
if (!process_provision_only && !linecard->unprovision_done && active &&
|
||||
- linecard->active != active && linecard->ready)
|
||||
- mlxsw_linecard_active_set(linecard);
|
||||
+ linecard->active != active && linecard->ready) {
|
||||
+ err = mlxsw_linecard_active_set(mlxsw_core, linecard,
|
||||
+ hw_revision, ini_version);
|
||||
+ if (err)
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
if (!process_provision_only && !active && linecard->active != active)
|
||||
mlxsw_linecard_active_clear(linecard);
|
||||
@@ -617,6 +712,7 @@ static const struct devlink_linecard_ops mlxsw_linecard_ops = {
|
||||
.unprovision = mlxsw_linecard_unprovision,
|
||||
.types_count = mlxsw_linecard_types_count,
|
||||
.types_get = mlxsw_linecard_types_get,
|
||||
+ .device_info_get = mlxsw_linecard_device_info_get,
|
||||
};
|
||||
|
||||
static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core,
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,244 +0,0 @@
|
||||
From 1eb0843255d6e92aa96d0ea11a15ab1f86b20e4f Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 26 Feb 2021 18:40:28 +0100
|
||||
Subject: [PATCH backport 5.10 144/182] mlxsw: core: Introduce flash update
|
||||
components
|
||||
|
||||
Introduce an infrastructure allowing to have multiple components for
|
||||
flashing purposes that can be registered from inside the driver. Convert
|
||||
the existing "no component" flash update to use the new infra.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.c | 117 +++++++++++++++++++--
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 12 +++
|
||||
include/net/devlink.h | 3 +
|
||||
3 files changed, 125 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
index 68ef007ac48c..f55071982271 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
@@ -91,6 +91,10 @@ struct mlxsw_core {
|
||||
struct devlink_health_reporter *fw_fatal;
|
||||
} health;
|
||||
struct mlxsw_env *env;
|
||||
+ struct list_head flash_component_list;
|
||||
+ struct mutex flash_update_lock; /* Protects component list and component
|
||||
+ * callbacks.
|
||||
+ */
|
||||
unsigned long driver_priv[];
|
||||
/* driver_priv has to be always the last item */
|
||||
};
|
||||
@@ -1113,21 +1117,101 @@ static int mlxsw_core_fw_rev_validate(struct mlxsw_core *mlxsw_core,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int mlxsw_core_fw_flash_cb(struct mlxsw_core *mlxsw_core,
|
||||
+ const struct firmware *firmware,
|
||||
+ struct netlink_ext_ack *extack, void *priv)
|
||||
+{
|
||||
+ return mlxsw_core_fw_flash(mlxsw_core, firmware, extack);
|
||||
+}
|
||||
+
|
||||
+struct mlxsw_core_flash_component {
|
||||
+ struct list_head list;
|
||||
+ const char *name;
|
||||
+ mlxsw_core_flash_update_cb cb;
|
||||
+ void *priv;
|
||||
+};
|
||||
+
|
||||
+static struct mlxsw_core_flash_component *
|
||||
+mlxsw_core_flash_component_lookup(struct mlxsw_core *mlxsw_core,
|
||||
+ const char *name)
|
||||
+{
|
||||
+ struct mlxsw_core_flash_component *component;
|
||||
+
|
||||
+ list_for_each_entry(component, &mlxsw_core->flash_component_list,
|
||||
+ list) {
|
||||
+ if ((name && component->name &&
|
||||
+ !strcmp(name, component->name)) ||
|
||||
+ (!name && !component->name))
|
||||
+ return component;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static int mlxsw_core_fw_flash_update(struct mlxsw_core *mlxsw_core,
|
||||
struct devlink_flash_update_params *params,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
- const struct firmware *firmware;
|
||||
+ struct mlxsw_core_flash_component *component;
|
||||
int err;
|
||||
|
||||
- err = request_firmware_direct(&firmware, params->file_name, mlxsw_core->bus_info->dev);
|
||||
- if (err)
|
||||
- return err;
|
||||
- err = mlxsw_core_fw_flash(mlxsw_core, firmware, extack);
|
||||
- release_firmware(firmware);
|
||||
+ mutex_lock(&mlxsw_core->flash_update_lock);
|
||||
+ component = mlxsw_core_flash_component_lookup(mlxsw_core,
|
||||
+ params->component);
|
||||
+ if (!component) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "Component does not exist");
|
||||
+ err = -ENOENT;
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+ err = component->cb(mlxsw_core, params->fw, extack, component->priv);
|
||||
+unlock:
|
||||
+ mutex_unlock(&mlxsw_core->flash_update_lock);
|
||||
+ return err;
|
||||
+}
|
||||
|
||||
+int mlxsw_core_flash_component_register(struct mlxsw_core *mlxsw_core,
|
||||
+ const char *name,
|
||||
+ mlxsw_core_flash_update_cb cb,
|
||||
+ void *priv)
|
||||
+{
|
||||
+ struct mlxsw_core_flash_component *component;
|
||||
+ int err = 0;
|
||||
+
|
||||
+ mutex_lock(&mlxsw_core->flash_update_lock);
|
||||
+ component = mlxsw_core_flash_component_lookup(mlxsw_core, name);
|
||||
+ if (WARN_ON(component)) {
|
||||
+ err = -EEXIST;
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+ component = kzalloc(sizeof(*component), GFP_KERNEL);
|
||||
+ if (!component) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+ component->name = name;
|
||||
+ component->cb = cb;
|
||||
+ component->priv = priv;
|
||||
+ list_add_tail(&component->list, &mlxsw_core->flash_component_list);
|
||||
+unlock:
|
||||
+ mutex_unlock(&mlxsw_core->flash_update_lock);
|
||||
return err;
|
||||
}
|
||||
+EXPORT_SYMBOL(mlxsw_core_flash_component_register);
|
||||
+
|
||||
+void mlxsw_core_flash_component_unregister(struct mlxsw_core *mlxsw_core,
|
||||
+ const char *name)
|
||||
+{
|
||||
+ struct mlxsw_core_flash_component *component;
|
||||
+
|
||||
+ mutex_lock(&mlxsw_core->flash_update_lock);
|
||||
+ component = mlxsw_core_flash_component_lookup(mlxsw_core, name);
|
||||
+ if (WARN_ON(!component))
|
||||
+ goto unlock;
|
||||
+ list_del(&component->list);
|
||||
+unlock:
|
||||
+ mutex_unlock(&mlxsw_core->flash_update_lock);
|
||||
+ kfree(component);
|
||||
+}
|
||||
+EXPORT_SYMBOL(mlxsw_core_flash_component_unregister);
|
||||
|
||||
static int mlxsw_core_devlink_param_fw_load_policy_validate(struct devlink *devlink, u32 id,
|
||||
union devlink_param_value val,
|
||||
@@ -1572,6 +1656,7 @@ mlxsw_devlink_trap_policer_counter_get(struct devlink *devlink,
|
||||
}
|
||||
|
||||
static const struct devlink_ops mlxsw_devlink_ops = {
|
||||
+ .supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT,
|
||||
.reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
|
||||
BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE),
|
||||
.reload_down = mlxsw_devlink_core_bus_device_reload_down,
|
||||
@@ -1894,6 +1979,16 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
|
||||
mlxsw_core->bus_priv = bus_priv;
|
||||
mlxsw_core->bus_info = mlxsw_bus_info;
|
||||
|
||||
+ if (!reload) {
|
||||
+ INIT_LIST_HEAD(&mlxsw_core->flash_component_list);
|
||||
+ mutex_init(&mlxsw_core->flash_update_lock);
|
||||
+ err = mlxsw_core_flash_component_register(mlxsw_core, NULL,
|
||||
+ mlxsw_core_fw_flash_cb,
|
||||
+ NULL);
|
||||
+ if (err)
|
||||
+ goto err_flash_component_register;
|
||||
+ }
|
||||
+
|
||||
res = mlxsw_driver->res_query_enabled ? &mlxsw_core->res : NULL;
|
||||
err = mlxsw_bus->init(bus_priv, mlxsw_core, mlxsw_driver->profile, res);
|
||||
if (err)
|
||||
@@ -2013,6 +2108,11 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
|
||||
err_register_resources:
|
||||
mlxsw_bus->fini(bus_priv);
|
||||
err_bus_init:
|
||||
+ if (!reload) {
|
||||
+ mlxsw_core_flash_component_unregister(mlxsw_core, NULL);
|
||||
+ mutex_destroy(&mlxsw_core->flash_update_lock);
|
||||
+ }
|
||||
+err_flash_component_register:
|
||||
if (!reload)
|
||||
devlink_free(devlink);
|
||||
err_devlink_alloc:
|
||||
@@ -2081,8 +2181,11 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
|
||||
if (!reload)
|
||||
devlink_resources_unregister(devlink, NULL);
|
||||
mlxsw_core->bus->fini(mlxsw_core->bus_priv);
|
||||
- if (!reload)
|
||||
+ if (!reload) {
|
||||
+ mlxsw_core_flash_component_unregister(mlxsw_core, NULL);
|
||||
+ mutex_destroy(&mlxsw_core->flash_update_lock);
|
||||
devlink_free(devlink);
|
||||
+ }
|
||||
|
||||
return;
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index 593470d14815..30f00da0a48d 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -41,6 +41,18 @@ mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
|
||||
int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
|
||||
void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
|
||||
|
||||
+typedef int (*mlxsw_core_flash_update_cb)(struct mlxsw_core *mlxsw_core,
|
||||
+ const struct firmware *firmware,
|
||||
+ struct netlink_ext_ack *extack,
|
||||
+ void *priv);
|
||||
+
|
||||
+int mlxsw_core_flash_component_register(struct mlxsw_core *mlxsw_core,
|
||||
+ const char *name,
|
||||
+ mlxsw_core_flash_update_cb cb,
|
||||
+ void *priv);
|
||||
+void mlxsw_core_flash_component_unregister(struct mlxsw_core *mlxsw_core,
|
||||
+ const char *name);
|
||||
+
|
||||
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
|
||||
const struct mlxsw_bus *mlxsw_bus,
|
||||
void *bus_priv, bool reload,
|
||||
diff --git a/include/net/devlink.h b/include/net/devlink.h
|
||||
index 06b61c1d7938..fafbec26d2c4 100644
|
||||
--- a/include/net/devlink.h
|
||||
+++ b/include/net/devlink.h
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <net/flow_offload.h>
|
||||
#include <uapi/linux/devlink.h>
|
||||
#include <linux/xarray.h>
|
||||
+#include <linux/firmware.h>
|
||||
|
||||
#define DEVLINK_RELOAD_STATS_ARRAY_SIZE \
|
||||
(__DEVLINK_RELOAD_LIMIT_MAX * __DEVLINK_RELOAD_ACTION_MAX)
|
||||
@@ -624,6 +625,7 @@ enum devlink_param_generic_id {
|
||||
|
||||
/**
|
||||
* struct devlink_flash_update_params - Flash Update parameters
|
||||
+ * @fw: pointer to the firmware data to update from
|
||||
* @file_name: the name of the flash firmware file to update from
|
||||
* @component: the flash component to update
|
||||
*
|
||||
@@ -632,6 +634,7 @@ enum devlink_param_generic_id {
|
||||
* their devlink_ops structure.
|
||||
*/
|
||||
struct devlink_flash_update_params {
|
||||
+ const struct firmware *fw;
|
||||
const char *file_name;
|
||||
const char *component;
|
||||
u32 overwrite_mask;
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,200 +0,0 @@
|
||||
From 81cb237570a4d0251455d17e073337f73c1b4aa9 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 4 Jun 2021 10:25:35 +0200
|
||||
Subject: [PATCH backport 5.10 145/182] mlxfw: Get the PSID value using op
|
||||
instead of passing it in struct
|
||||
|
||||
In preparation for line card device flashing, where the PSID is going to
|
||||
be obtained dynamically using MGIR register for each individual line
|
||||
card device. So convert the PSID value get to an extra op.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlx5/core/fw.c | 18 +++++++++++++--
|
||||
drivers/net/ethernet/mellanox/mlxfw/mlxfw.h | 4 ++--
|
||||
.../net/ethernet/mellanox/mlxfw/mlxfw_fsm.c | 23 ++++++++++++++-----
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.c | 19 +++++++++++++--
|
||||
4 files changed, 52 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
|
||||
index 02558ac2ace6..06edfd5b12e0 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
|
||||
@@ -494,6 +494,20 @@ struct mlx5_mlxfw_dev {
|
||||
struct mlx5_core_dev *mlx5_core_dev;
|
||||
};
|
||||
|
||||
+static const char *mlx5_psid_get(struct mlxfw_dev *mlxfw_dev, u16 *psid_size)
|
||||
+{
|
||||
+ struct mlx5_mlxfw_dev *mlx5_mlxfw_dev =
|
||||
+ container_of(mlxfw_dev, struct mlx5_mlxfw_dev, mlxfw_dev);
|
||||
+ struct mlx5_core_dev *dev = mlx5_mlxfw_dev->mlx5_core_dev;
|
||||
+
|
||||
+ *psid_size = MLX5_BOARD_ID_LEN;
|
||||
+ return dev->board_id;
|
||||
+}
|
||||
+
|
||||
+static void mlx5_psid_put(const char *psid)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
static int mlx5_component_query(struct mlxfw_dev *mlxfw_dev,
|
||||
u16 component_index, u32 *p_max_size,
|
||||
u8 *p_align_bits, u16 *p_max_write_size)
|
||||
@@ -651,6 +665,8 @@ static int mlx5_fsm_reactivate(struct mlxfw_dev *mlxfw_dev, u8 *status)
|
||||
}
|
||||
|
||||
static const struct mlxfw_dev_ops mlx5_mlxfw_dev_ops = {
|
||||
+ .psid_get = mlx5_psid_get,
|
||||
+ .psid_put = mlx5_psid_put,
|
||||
.component_query = mlx5_component_query,
|
||||
.fsm_lock = mlx5_fsm_lock,
|
||||
.fsm_component_update = mlx5_fsm_component_update,
|
||||
@@ -670,8 +686,6 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev,
|
||||
struct mlx5_mlxfw_dev mlx5_mlxfw_dev = {
|
||||
.mlxfw_dev = {
|
||||
.ops = &mlx5_mlxfw_dev_ops,
|
||||
- .psid = dev->board_id,
|
||||
- .psid_size = strlen(dev->board_id),
|
||||
.devlink = priv_to_devlink(dev),
|
||||
},
|
||||
.mlx5_core_dev = dev
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
|
||||
index 7654841a05c2..b83651246c1f 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
struct mlxfw_dev {
|
||||
const struct mlxfw_dev_ops *ops;
|
||||
- const char *psid;
|
||||
- u16 psid_size;
|
||||
struct devlink *devlink;
|
||||
};
|
||||
|
||||
@@ -70,6 +68,8 @@ enum mlxfw_fsm_reactivate_status {
|
||||
};
|
||||
|
||||
struct mlxfw_dev_ops {
|
||||
+ const char * (*psid_get)(struct mlxfw_dev *mlxfw_dev, u16 *psid_size);
|
||||
+ void (*psid_put)(const char *psid);
|
||||
int (*component_query)(struct mlxfw_dev *mlxfw_dev, u16 component_index,
|
||||
u32 *p_max_size, u8 *p_align_bits,
|
||||
u16 *p_max_write_size);
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
|
||||
index bcd166911d44..329ddf1b3b89 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
|
||||
@@ -303,7 +303,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
-static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
|
||||
+static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, const char *psid,
|
||||
+ u16 psid_size, u32 fwhandle,
|
||||
struct mlxfw_mfa2_file *mfa2_file,
|
||||
bool reactivate_supp,
|
||||
struct netlink_ext_ack *extack)
|
||||
@@ -312,8 +313,7 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
|
||||
int err;
|
||||
int i;
|
||||
|
||||
- err = mlxfw_mfa2_file_component_count(mfa2_file, mlxfw_dev->psid,
|
||||
- mlxfw_dev->psid_size,
|
||||
+ err = mlxfw_mfa2_file_component_count(mfa2_file, psid, psid_size,
|
||||
&component_count);
|
||||
if (err) {
|
||||
MLXFW_ERR_MSG(mlxfw_dev, extack,
|
||||
@@ -324,8 +324,8 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
|
||||
for (i = 0; i < component_count; i++) {
|
||||
struct mlxfw_mfa2_component *comp;
|
||||
|
||||
- comp = mlxfw_mfa2_file_component_get(mfa2_file, mlxfw_dev->psid,
|
||||
- mlxfw_dev->psid_size, i);
|
||||
+ comp = mlxfw_mfa2_file_component_get(mfa2_file, psid,
|
||||
+ psid_size, i);
|
||||
if (IS_ERR(comp)) {
|
||||
err = PTR_ERR(comp);
|
||||
MLXFW_ERR_MSG(mlxfw_dev, extack,
|
||||
@@ -350,6 +350,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
|
||||
{
|
||||
struct mlxfw_mfa2_file *mfa2_file;
|
||||
bool reactivate_supp = true;
|
||||
+ const char *psid;
|
||||
+ u16 psid_size;
|
||||
u32 fwhandle;
|
||||
int err;
|
||||
|
||||
@@ -392,8 +394,16 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
|
||||
if (err)
|
||||
goto err_state_wait_reactivate_to_locked;
|
||||
|
||||
- err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file,
|
||||
+ psid = mlxfw_dev->ops->psid_get(mlxfw_dev, &psid_size);
|
||||
+ if (IS_ERR(psid)) {
|
||||
+ err = PTR_ERR(psid);
|
||||
+ goto err_psid_get;
|
||||
+ }
|
||||
+
|
||||
+ err = mlxfw_flash_components(mlxfw_dev, psid, psid_size,
|
||||
+ fwhandle, mfa2_file,
|
||||
reactivate_supp, extack);
|
||||
+ mlxfw_dev->ops->psid_put(psid);
|
||||
if (err)
|
||||
goto err_flash_components;
|
||||
|
||||
@@ -423,6 +433,7 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
|
||||
err_state_wait_activate_to_locked:
|
||||
err_fsm_activate:
|
||||
err_flash_components:
|
||||
+err_psid_get:
|
||||
err_state_wait_reactivate_to_locked:
|
||||
err_fsm_reactivate:
|
||||
err_state_wait_idle_to_locked:
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
index f55071982271..8c128078105a 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
|
||||
@@ -890,6 +890,21 @@ struct mlxsw_core_fw_info {
|
||||
struct mlxsw_core *mlxsw_core;
|
||||
};
|
||||
|
||||
+static const char *mlxsw_core_fw_psid_get(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u16 *psid_size)
|
||||
+{
|
||||
+ struct mlxsw_core_fw_info *mlxsw_core_fw_info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_core_fw_info, mlxfw_dev);
|
||||
+ struct mlxsw_core *mlxsw_core = mlxsw_core_fw_info->mlxsw_core;
|
||||
+
|
||||
+ *psid_size = strlen(mlxsw_core->bus_info->psid);
|
||||
+ return mlxsw_core->bus_info->psid;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_core_fw_psid_put(const char *psid)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
static int mlxsw_core_fw_component_query(struct mlxfw_dev *mlxfw_dev,
|
||||
u16 component_index, u32 *p_max_size,
|
||||
u8 *p_align_bits, u16 *p_max_write_size)
|
||||
@@ -1028,6 +1043,8 @@ static void mlxsw_core_fw_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
|
||||
}
|
||||
|
||||
static const struct mlxfw_dev_ops mlxsw_core_fw_mlxsw_dev_ops = {
|
||||
+ .psid_get = mlxsw_core_fw_psid_get,
|
||||
+ .psid_put = mlxsw_core_fw_psid_put,
|
||||
.component_query = mlxsw_core_fw_component_query,
|
||||
.fsm_lock = mlxsw_core_fw_fsm_lock,
|
||||
.fsm_component_update = mlxsw_core_fw_fsm_component_update,
|
||||
@@ -1045,8 +1062,6 @@ static int mlxsw_core_fw_flash(struct mlxsw_core *mlxsw_core, const struct firmw
|
||||
struct mlxsw_core_fw_info mlxsw_core_fw_info = {
|
||||
.mlxfw_dev = {
|
||||
.ops = &mlxsw_core_fw_mlxsw_dev_ops,
|
||||
- .psid = mlxsw_core->bus_info->psid,
|
||||
- .psid_size = strlen(mlxsw_core->bus_info->psid),
|
||||
.devlink = priv_to_devlink(mlxsw_core),
|
||||
},
|
||||
.mlxsw_core = mlxsw_core
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,401 +0,0 @@
|
||||
From 0e642e558b98e1a686b39acb53f53c1fb9735b02 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 5 Mar 2021 09:33:21 +0100
|
||||
Subject: [PATCH backport 5.10 146/182] mlxsw: core_linecards: Implement line
|
||||
card device flashing
|
||||
|
||||
Generate flash component name and register it internally within mlxsw
|
||||
for flashing. Also, propagate the component name to devlink core which
|
||||
exposes the information about device being flashable and the component
|
||||
name to use to the user. Implement flashing using MDDT register and
|
||||
mlxfw.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_linecards.c | 335 +++++++++++++++++-
|
||||
1 file changed, 334 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
index cb872f918f01..9f9ee582fce2 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
@@ -73,6 +73,7 @@ struct mlxsw_linecard_device_info {
|
||||
struct mlxsw_linecard_device {
|
||||
struct list_head list;
|
||||
u8 index;
|
||||
+ char component_name[16];
|
||||
struct mlxsw_linecard *linecard;
|
||||
struct devlink_linecard_device *devlink_device;
|
||||
struct mlxsw_linecard_device_info info;
|
||||
@@ -89,11 +90,322 @@ mlxsw_linecard_device_lookup(struct mlxsw_linecard *linecard, u8 index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+struct mlxsw_linecard_device_fw_info {
|
||||
+ struct mlxfw_dev mlxfw_dev;
|
||||
+ struct mlxsw_core *mlxsw_core;
|
||||
+ struct mlxsw_linecard_device *device;
|
||||
+};
|
||||
+
|
||||
+static const char *
|
||||
+mlxsw_linecard_device_fw_psid_get(struct mlxfw_dev *mlxfw_dev, u16 *psid_size)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mgir_pl;
|
||||
+ char *psid;
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_QUERY,
|
||||
+ MLXSW_REG(mgir), &mgir_pl);
|
||||
+
|
||||
+ mlxsw_reg_mgir_pack(mgir_pl);
|
||||
+ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+ if (err)
|
||||
+ return ERR_PTR(err);
|
||||
+ psid = kzalloc(MLXSW_REG_MGIR_FW_INFO_PSID_SIZE, GFP_KERNEL);
|
||||
+ if (!psid)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+
|
||||
+ mlxsw_reg_mgir_fw_info_psid_memcpy_from(mgir_pl, psid);
|
||||
+ *psid_size = strlen(psid);
|
||||
+ return psid;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_device_fw_psid_put(const char *psid)
|
||||
+{
|
||||
+ kfree(psid);
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_device_fw_component_query(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u16 component_index,
|
||||
+ u32 *p_max_size,
|
||||
+ u8 *p_align_bits,
|
||||
+ u16 *p_max_write_size)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcqi_pl;
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_QUERY,
|
||||
+ MLXSW_REG(mcqi), &mcqi_pl);
|
||||
+
|
||||
+ mlxsw_reg_mcqi_pack(mcqi_pl, component_index);
|
||||
+ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ mlxsw_reg_mcqi_unpack(mcqi_pl, p_max_size, p_align_bits,
|
||||
+ p_max_write_size);
|
||||
+
|
||||
+ *p_align_bits = max_t(u8, *p_align_bits, 2);
|
||||
+ *p_max_write_size = min_t(u16, *p_max_write_size,
|
||||
+ MLXSW_REG_MCDA_MAX_DATA_LEN);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_device_fw_fsm_lock(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 *fwhandle)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ u8 control_state;
|
||||
+ char *mcc_pl;
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_QUERY,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, 0, 0, 0, 0);
|
||||
+ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ mlxsw_reg_mcc_unpack(mcc_pl, fwhandle, NULL, &control_state);
|
||||
+ if (control_state != MLXFW_FSM_STATE_IDLE)
|
||||
+ return -EBUSY;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_QUERY,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE,
|
||||
+ 0, *fwhandle, 0);
|
||||
+ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_linecard_device_fw_fsm_component_update(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle,
|
||||
+ u16 component_index,
|
||||
+ u32 component_size)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcc_pl;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT,
|
||||
+ component_index, fwhandle, component_size);
|
||||
+ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_linecard_device_fw_fsm_block_download(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle, u8 *data,
|
||||
+ u16 size, u32 offset)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcda_pl;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+ MLXSW_REG(mcda), &mcda_pl);
|
||||
+ mlxsw_reg_mcda_pack(mcda_pl, fwhandle, offset, size, data);
|
||||
+ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_linecard_device_fw_fsm_component_verify(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle, u16 component_index)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcc_pl;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT,
|
||||
+ component_index, fwhandle, 0);
|
||||
+ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_device_fw_fsm_activate(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcc_pl;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_ACTIVATE,
|
||||
+ 0, fwhandle, 0);
|
||||
+ return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mlxsw_linecard_device_fw_fsm_query_state(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle,
|
||||
+ enum mlxfw_fsm_state *fsm_state,
|
||||
+ enum mlxfw_fsm_state_err *fsm_state_err)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ u8 control_state;
|
||||
+ u8 error_code;
|
||||
+ char *mcc_pl;
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_QUERY,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, 0, 0, fwhandle, 0);
|
||||
+ err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ mlxsw_reg_mcc_unpack(mcc_pl, NULL, &error_code, &control_state);
|
||||
+ *fsm_state = control_state;
|
||||
+ *fsm_state_err = min_t(enum mlxfw_fsm_state_err, error_code,
|
||||
+ MLXFW_FSM_STATE_ERR_MAX);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_device_fw_fsm_cancel(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcc_pl;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_CANCEL,
|
||||
+ 0, fwhandle, 0);
|
||||
+ mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_linecard_device_fw_fsm_release(struct mlxfw_dev *mlxfw_dev,
|
||||
+ u32 fwhandle)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info *info =
|
||||
+ container_of(mlxfw_dev, struct mlxsw_linecard_device_fw_info,
|
||||
+ mlxfw_dev);
|
||||
+ struct mlxsw_linecard_device *device = info->device;
|
||||
+ struct mlxsw_core *mlxsw_core = info->mlxsw_core;
|
||||
+ char mddt_pl[MLXSW_REG_MDDT_LEN];
|
||||
+ char *mcc_pl;
|
||||
+
|
||||
+ mlxsw_reg_mddt_pack(mddt_pl, device->linecard->slot_index,
|
||||
+ device->index,
|
||||
+ MLXSW_REG_MDDT_METHOD_WRITE,
|
||||
+ MLXSW_REG(mcc), &mcc_pl);
|
||||
+ mlxsw_reg_mcc_pack(mcc_pl,
|
||||
+ MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE,
|
||||
+ 0, fwhandle, 0);
|
||||
+ mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddt), mddt_pl);
|
||||
+}
|
||||
+
|
||||
+static const struct mlxfw_dev_ops mlxsw_linecard_device_dev_ops = {
|
||||
+ .psid_get = mlxsw_linecard_device_fw_psid_get,
|
||||
+ .psid_put = mlxsw_linecard_device_fw_psid_put,
|
||||
+ .component_query = mlxsw_linecard_device_fw_component_query,
|
||||
+ .fsm_lock = mlxsw_linecard_device_fw_fsm_lock,
|
||||
+ .fsm_component_update = mlxsw_linecard_device_fw_fsm_component_update,
|
||||
+ .fsm_block_download = mlxsw_linecard_device_fw_fsm_block_download,
|
||||
+ .fsm_component_verify = mlxsw_linecard_device_fw_fsm_component_verify,
|
||||
+ .fsm_activate = mlxsw_linecard_device_fw_fsm_activate,
|
||||
+ .fsm_query_state = mlxsw_linecard_device_fw_fsm_query_state,
|
||||
+ .fsm_cancel = mlxsw_linecard_device_fw_fsm_cancel,
|
||||
+ .fsm_release = mlxsw_linecard_device_fw_fsm_release,
|
||||
+};
|
||||
+
|
||||
+static int mlxsw_linecard_device_fw_flash(struct mlxsw_core *mlxsw_core,
|
||||
+ const struct firmware *firmware,
|
||||
+ struct mlxsw_linecard_device *device,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device_fw_info info = {
|
||||
+ .mlxfw_dev = {
|
||||
+ .ops = &mlxsw_linecard_device_dev_ops,
|
||||
+ .devlink = priv_to_devlink(mlxsw_core),
|
||||
+ },
|
||||
+ .mlxsw_core = mlxsw_core,
|
||||
+ .device = device,
|
||||
+ };
|
||||
+
|
||||
+ return mlxfw_firmware_flash(&info.mlxfw_dev, firmware, extack);
|
||||
+}
|
||||
+
|
||||
+static int mlxsw_linecard_device_flash_cb(struct mlxsw_core *mlxsw_core,
|
||||
+ const struct firmware *firmware,
|
||||
+ struct netlink_ext_ack *extack, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_linecard_device *device = priv;
|
||||
+
|
||||
+ return mlxsw_linecard_device_fw_flash(mlxsw_core, firmware,
|
||||
+ device, extack);
|
||||
+}
|
||||
+
|
||||
static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecard *linecard,
|
||||
u8 device_index, bool flash_owner)
|
||||
{
|
||||
struct mlxsw_linecard_device *device;
|
||||
+ char *component_name = NULL;
|
||||
int err;
|
||||
|
||||
device = kzalloc(sizeof(*device), GFP_KERNEL);
|
||||
@@ -102,9 +414,23 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
|
||||
device->index = device_index;
|
||||
device->linecard = linecard;
|
||||
|
||||
+ if (flash_owner) {
|
||||
+ snprintf(device->component_name,
|
||||
+ sizeof(device->component_name), "lc%u_dev%u",
|
||||
+ linecard->slot_index, device->index);
|
||||
+ component_name = device->component_name;
|
||||
+ err = mlxsw_core_flash_component_register(mlxsw_core,
|
||||
+ component_name,
|
||||
+ mlxsw_linecard_device_flash_cb,
|
||||
+ device);
|
||||
+ if (err)
|
||||
+ goto err_flash_component_register;
|
||||
+ }
|
||||
+
|
||||
device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard,
|
||||
device_index,
|
||||
- NULL, device);
|
||||
+ component_name,
|
||||
+ device);
|
||||
if (IS_ERR(device->devlink_device)) {
|
||||
err = PTR_ERR(device->devlink_device);
|
||||
goto err_devlink_linecard_device_attach;
|
||||
@@ -114,6 +440,10 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
|
||||
return 0;
|
||||
|
||||
err_devlink_linecard_device_attach:
|
||||
+ if (flash_owner)
|
||||
+ mlxsw_core_flash_component_unregister(mlxsw_core,
|
||||
+ device->component_name);
|
||||
+err_flash_component_register:
|
||||
kfree(device);
|
||||
return err;
|
||||
}
|
||||
@@ -125,6 +455,9 @@ static void mlxsw_linecard_device_detach(struct mlxsw_core *mlxsw_core,
|
||||
list_del(&device->list);
|
||||
devlink_linecard_device_destroy(linecard->devlink_linecard,
|
||||
device->devlink_device);
|
||||
+ if (strlen(device->component_name))
|
||||
+ mlxsw_core_flash_component_unregister(mlxsw_core,
|
||||
+ device->component_name);
|
||||
kfree(device);
|
||||
}
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,277 +0,0 @@
|
||||
From 5e3bebf1e096e4770cad3aaf3d03fa22429fe5f9 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Pirko <jiri@nvidia.com>
|
||||
Date: Fri, 22 Jan 2021 15:01:06 +0100
|
||||
Subject: [PATCH backport 5.10 147/182] mlxsw: core_linecards: Introduce ops
|
||||
for linecards status change tracking
|
||||
|
||||
Introduce an infrastructure allowing the core to register set of ops
|
||||
which are called whenever line card gets provisione/unprovisioned
|
||||
and active/inactive.
|
||||
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core.h | 22 +++
|
||||
.../ethernet/mellanox/mlxsw/core_linecards.c | 134 +++++++++++++++++-
|
||||
2 files changed, 150 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
index 30f00da0a48d..10ea541bb19d 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
|
||||
@@ -582,4 +582,26 @@ int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core,
|
||||
const char *mbct_pl);
|
||||
|
||||
+struct mlxsw_linecards_event_ops {
|
||||
+ int (*got_provisioned)(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard,
|
||||
+ void *priv);
|
||||
+ void (*got_unprovisioned)(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard,
|
||||
+ void *priv);
|
||||
+ void (*got_active)(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard,
|
||||
+ void *priv);
|
||||
+ void (*got_inactive)(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard,
|
||||
+ void *priv);
|
||||
+};
|
||||
+
|
||||
+int mlxsw_linecards_event_ops_register(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards_event_ops *ops,
|
||||
+ void *priv);
|
||||
+void mlxsw_linecards_event_ops_unregister(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards_event_ops *ops,
|
||||
+ void *priv);
|
||||
+
|
||||
#endif
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
index 9f9ee582fce2..3a2fdd22dc21 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
|
||||
@@ -576,6 +576,59 @@ static void mlxsw_linecard_provision_fail(struct mlxsw_core *mlxsw_core,
|
||||
devlink_linecard_provision_fail(linecard->devlink_linecard);
|
||||
}
|
||||
|
||||
+struct mlxsw_linecards_event_ops_item {
|
||||
+ struct list_head list;
|
||||
+ struct mlxsw_linecards_event_ops *event_ops;
|
||||
+ void *priv;
|
||||
+};
|
||||
+
|
||||
+static int
|
||||
+mlxsw_linecard_provision_cbs_call(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards *linecards,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ struct mlxsw_linecards_event_ops_item *item;
|
||||
+ int err;
|
||||
+
|
||||
+ list_for_each_entry(item, &linecards->event_ops_list, list) {
|
||||
+ if (!item->event_ops->got_provisioned)
|
||||
+ continue;
|
||||
+ err = item->event_ops->got_provisioned(mlxsw_core,
|
||||
+ linecard->slot_index,
|
||||
+ linecard, item->priv);
|
||||
+ if (err)
|
||||
+ goto rollback;
|
||||
+ }
|
||||
+ return 0;
|
||||
+
|
||||
+rollback:
|
||||
+ list_for_each_entry_continue_reverse(item, &linecards->event_ops_list,
|
||||
+ list) {
|
||||
+ if (!item->event_ops->got_unprovisioned)
|
||||
+ continue;
|
||||
+ item->event_ops->got_unprovisioned(mlxsw_core,
|
||||
+ linecard->slot_index,
|
||||
+ linecard, item->priv);
|
||||
+ }
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mlxsw_linecard_unprovision_cbs_call(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards *linecards,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
+{
|
||||
+ struct mlxsw_linecards_event_ops_item *item;
|
||||
+
|
||||
+ list_for_each_entry(item, &linecards->event_ops_list, list) {
|
||||
+ if (!item->event_ops->got_unprovisioned)
|
||||
+ continue;
|
||||
+ item->event_ops->got_unprovisioned(mlxsw_core,
|
||||
+ linecard->slot_index,
|
||||
+ linecard, item->priv);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int
|
||||
mlxsw_linecard_provision_set(struct mlxsw_core *mlxsw_core,
|
||||
struct mlxsw_linecards *linecards,
|
||||
@@ -594,14 +647,27 @@ mlxsw_linecard_provision_set(struct mlxsw_core *mlxsw_core,
|
||||
err = mlxsw_linecard_devices_attach(mlxsw_core, linecard);
|
||||
if (err)
|
||||
return err;
|
||||
+ err = mlxsw_linecard_provision_cbs_call(mlxsw_core, linecards,
|
||||
+ linecard);
|
||||
+ if (err)
|
||||
+ goto err_cbs_call;
|
||||
linecard->provisioned = true;
|
||||
devlink_linecard_provision_set(linecard->devlink_linecard, type);
|
||||
return 0;
|
||||
+
|
||||
+err_cbs_call:
|
||||
+ mlxsw_linecard_devices_detach(linecard->linecards->mlxsw_core,
|
||||
+ linecard);
|
||||
+ return err;
|
||||
}
|
||||
|
||||
-static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard)
|
||||
+static void mlxsw_linecard_provision_clear(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards *linecards,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
{
|
||||
linecard->provisioned = false;
|
||||
+ mlxsw_linecard_unprovision_cbs_call(mlxsw_core, linecards,
|
||||
+ linecard);
|
||||
mlxsw_linecard_devices_detach(linecard->linecards->mlxsw_core,
|
||||
linecard);
|
||||
devlink_linecard_provision_clear(linecard->devlink_linecard);
|
||||
@@ -636,22 +702,43 @@ static int mlxsw_linecard_ready_clear(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
static int mlxsw_linecard_active_set(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards *linecards,
|
||||
struct mlxsw_linecard *linecard,
|
||||
u16 hw_revision, u16 ini_version)
|
||||
{
|
||||
+ struct mlxsw_linecards_event_ops_item *item;
|
||||
int err;
|
||||
|
||||
err = mlxsw_linecard_devices_update(mlxsw_core, linecard);
|
||||
if (err)
|
||||
return err;
|
||||
+
|
||||
linecard->active = true;
|
||||
+ linecard->hw_revision = hw_revision;
|
||||
+ linecard->ini_version = ini_version;
|
||||
+ list_for_each_entry(item, &linecards->event_ops_list, list) {
|
||||
+ if (!item->event_ops->got_active)
|
||||
+ continue;
|
||||
+ item->event_ops->got_active(mlxsw_core, linecard->slot_index,
|
||||
+ linecard, item->priv);
|
||||
+ }
|
||||
devlink_linecard_activate(linecard->devlink_linecard);
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard)
|
||||
+static void mlxsw_linecard_active_clear(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards *linecards,
|
||||
+ struct mlxsw_linecard *linecard)
|
||||
{
|
||||
+ struct mlxsw_linecards_event_ops_item *item;
|
||||
+
|
||||
linecard->active = false;
|
||||
+ list_for_each_entry(item, &linecards->event_ops_list, list) {
|
||||
+ if (!item->event_ops->got_inactive)
|
||||
+ continue;
|
||||
+ item->event_ops->got_inactive(mlxsw_core, linecard->slot_index,
|
||||
+ linecard, item->priv);
|
||||
+ }
|
||||
devlink_linecard_deactivate(linecard->devlink_linecard);
|
||||
}
|
||||
|
||||
@@ -703,14 +790,14 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
if (!process_provision_only && !linecard->unprovision_done && active &&
|
||||
linecard->active != active && linecard->ready) {
|
||||
- err = mlxsw_linecard_active_set(mlxsw_core, linecard,
|
||||
+ err = mlxsw_linecard_active_set(mlxsw_core, linecards, linecard,
|
||||
hw_revision, ini_version);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!process_provision_only && !active && linecard->active != active)
|
||||
- mlxsw_linecard_active_clear(linecard);
|
||||
+ mlxsw_linecard_active_clear(mlxsw_core, linecards, linecard);
|
||||
|
||||
if (!process_provision_only && ready != MLXSW_REG_MDDQ_READY_READY &&
|
||||
linecard->ready) {
|
||||
@@ -720,7 +807,7 @@ static int __mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
|
||||
}
|
||||
|
||||
if (!provisioned && linecard->provisioned != provisioned)
|
||||
- mlxsw_linecard_provision_clear(linecard);
|
||||
+ mlxsw_linecard_provision_clear(mlxsw_core, linecards, linecard);
|
||||
|
||||
out:
|
||||
mutex_unlock(&linecard->lock);
|
||||
@@ -1128,7 +1215,7 @@ static void mlxsw_linecard_pre_fini(struct mlxsw_core *mlxsw_core,
|
||||
/* Make sure all scheduled events are processed */
|
||||
mlxsw_core_flush_owq();
|
||||
if (linecard->active)
|
||||
- mlxsw_linecard_active_clear(linecard);
|
||||
+ mlxsw_linecard_active_clear(mlxsw_core, linecards, linecard);
|
||||
}
|
||||
|
||||
static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,
|
||||
@@ -1287,6 +1374,7 @@ int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
|
||||
linecards->count = slot_count;
|
||||
linecards->mlxsw_core = mlxsw_core;
|
||||
linecards->bus_info = bus_info;
|
||||
+ INIT_LIST_HEAD(&linecards->event_ops_list);
|
||||
|
||||
linecards->wq = alloc_workqueue("mlxsw_linecards", 0, 0);
|
||||
if (!linecards->wq) {
|
||||
@@ -1360,6 +1448,7 @@ void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
if (!linecards)
|
||||
return;
|
||||
+ WARN_ON(!list_empty(&linecards->event_ops_list));
|
||||
for (i = 0; i < linecards->count; i++)
|
||||
mlxsw_linecard_fini(mlxsw_core, linecards, i + 1);
|
||||
mlxsw_linecard_types_fini(linecards);
|
||||
@@ -1367,4 +1456,37 @@ void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core,
|
||||
kfree(linecards);
|
||||
}
|
||||
|
||||
+int mlxsw_linecards_event_ops_register(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards_event_ops *ops,
|
||||
+ void *priv)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core);
|
||||
+ struct mlxsw_linecards_event_ops_item *item;
|
||||
+
|
||||
+ item = kzalloc(sizeof(*item), GFP_KERNEL);
|
||||
+ if (!item)
|
||||
+ return -ENOMEM;
|
||||
+ item->event_ops = ops;
|
||||
+ item->priv = priv;
|
||||
+ list_add_tail(&item->list, &linecards->event_ops_list);
|
||||
+ return 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL(mlxsw_linecards_event_ops_register);
|
||||
+
|
||||
+void mlxsw_linecards_event_ops_unregister(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_linecards_event_ops *ops,
|
||||
+ void *priv)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core);
|
||||
+ struct mlxsw_linecards_event_ops_item *item, *tmp;
|
||||
+
|
||||
+ list_for_each_entry_safe(item, tmp, &linecards->event_ops_list, list) {
|
||||
+ if (item->event_ops == ops && item->priv == priv) {
|
||||
+ list_del(&item->list);
|
||||
+ kfree(item);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL(mlxsw_linecards_event_ops_unregister);
|
||||
+
|
||||
MODULE_FIRMWARE(MLXSW_LINECARDS_INI_BUNDLE_FILE);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,133 +0,0 @@
|
||||
From d037308b118ee4a1ccf557dc3f1c47b81bb62c4c Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Mon, 13 Dec 2021 12:54:36 +0000
|
||||
Subject: [PATCH backport 5.10 148/182] mlxsw: core: Add interfaces for line
|
||||
card initialization and de-initialization
|
||||
|
||||
Add callback functions for line card cables info initialization and
|
||||
de-initialization.
|
||||
|
||||
The line card initialization / de-initialization APIs are to be called
|
||||
when line card is set to active / inactive state by got_active() /
|
||||
got_inactive() callbacks from line card state machine.
|
||||
Access to cable info and real number of modules is available only after
|
||||
line card is activated.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_env.c | 78 +++++++++++++++++++
|
||||
1 file changed, 78 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
index 4f3fc25af013..98f7cf672d9e 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
|
||||
@@ -1160,6 +1160,77 @@ mlxsw_env_module_event_disable(struct mlxsw_env *mlxsw_env, u8 slot_index)
|
||||
{
|
||||
}
|
||||
|
||||
+static void
|
||||
+mlxsw_env_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_env *mlxsw_env = priv;
|
||||
+ char mgpir_pl[MLXSW_REG_MGPIR_LEN];
|
||||
+ int err;
|
||||
+
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, slot_index);
|
||||
+ err = mlxsw_reg_query(mlxsw_env->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
+ if (err)
|
||||
+ return;
|
||||
+
|
||||
+ mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL,
|
||||
+ &mlxsw_env->line_cards[slot_index]->module_count,
|
||||
+ NULL);
|
||||
+ mlxsw_env_module_event_enable(mlxsw_env, slot_index);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mlxsw_env_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_env *mlxsw_env = priv;
|
||||
+
|
||||
+ mlxsw_env_module_event_disable(mlxsw_env, slot_index);
|
||||
+}
|
||||
+
|
||||
+static struct mlxsw_linecards_event_ops mlxsw_env_event_ops = {
|
||||
+ .got_active = mlxsw_env_got_active,
|
||||
+ .got_inactive = mlxsw_env_got_inactive,
|
||||
+};
|
||||
+
|
||||
+static int mlxsw_env_linecards_register(struct mlxsw_env *mlxsw_env)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_env->core);
|
||||
+ int err;
|
||||
+
|
||||
+ if (!linecards || !linecards->count)
|
||||
+ return 0;
|
||||
+
|
||||
+ err = mlxsw_linecards_event_ops_register(mlxsw_env->core,
|
||||
+ &mlxsw_env_event_ops,
|
||||
+ mlxsw_env);
|
||||
+ if (err)
|
||||
+ goto err_linecards_event_ops_register;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_linecards_event_ops_register:
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_env_linecards_unregister(struct mlxsw_env *mlxsw_env)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_env->core);
|
||||
+ int i;
|
||||
+
|
||||
+ if (!linecards || !linecards->count)
|
||||
+ return;
|
||||
+
|
||||
+ for (i = 1; i <= linecards->count; i++) {
|
||||
+ if (mlxsw_env->line_cards[i]->module_count)
|
||||
+ mlxsw_env_got_inactive(mlxsw_env->core, i, NULL,
|
||||
+ mlxsw_env);
|
||||
+ }
|
||||
+
|
||||
+ mlxsw_linecards_event_ops_unregister(mlxsw_env->core,
|
||||
+ &mlxsw_env_event_ops, mlxsw_env);
|
||||
+}
|
||||
+
|
||||
int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
{
|
||||
u8 module_count, num_of_slots, max_module_count;
|
||||
@@ -1196,6 +1267,10 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
mutex_init(&env->line_cards_lock);
|
||||
*p_env = env;
|
||||
|
||||
+ err = mlxsw_env_linecards_register(env);
|
||||
+ if (err)
|
||||
+ goto err_linecards_register;
|
||||
+
|
||||
err = mlxsw_env_temp_warn_event_register(mlxsw_core);
|
||||
if (err)
|
||||
goto err_temp_warn_event_register;
|
||||
@@ -1223,6 +1298,8 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
|
||||
err_module_plug_event_register:
|
||||
mlxsw_env_temp_warn_event_unregister(env);
|
||||
err_temp_warn_event_register:
|
||||
+ mlxsw_env_linecards_unregister(env);
|
||||
+err_linecards_register:
|
||||
mutex_destroy(&env->line_cards_lock);
|
||||
mlxsw_env_line_cards_free(env);
|
||||
err_mlxsw_env_line_cards_alloc:
|
||||
@@ -1237,6 +1314,7 @@ void mlxsw_env_fini(struct mlxsw_env *env)
|
||||
/* Make sure there is no more event work scheduled. */
|
||||
mlxsw_core_flush_owq();
|
||||
mlxsw_env_temp_warn_event_unregister(env);
|
||||
+ mlxsw_env_linecards_unregister(env);
|
||||
mutex_destroy(&env->line_cards_lock);
|
||||
mlxsw_env_line_cards_free(env);
|
||||
kfree(env);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,213 +0,0 @@
|
||||
From 71416a2dd1900ac8eb9b7d5cd08911d331b074ff Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 12 May 2021 22:57:39 +0300
|
||||
Subject: [PATCH backport 5.10 149/182] mlxsw: core_thermal: Add interfaces for
|
||||
line card initialization and de-initialization
|
||||
|
||||
Add callback functions for line card thermal area initialization and
|
||||
de-initialization. Each line card is associated with the relevant
|
||||
thermal area, which may contain thermal zones for cages and gearboxes
|
||||
found on this line card.
|
||||
|
||||
The line card thermal initialization / de-initialization APIs are to be
|
||||
called when line card is set to active / inactive state by
|
||||
got_active() / got_inactive() callbacks from line card state machine.
|
||||
|
||||
For example thermal zone for module #9 located at line card #7 will
|
||||
have type:
|
||||
mlxsw-lc7-module9.
|
||||
And thermal zone for gearbox #2 located at line card #5 will have type:
|
||||
mlxsw-lc5-gearbox2.
|
||||
|
||||
For now the slot index is always 0 and field 'name' of the structure
|
||||
'mlxsw_hwmon_dev' is empty. For line card this field is supposed to
|
||||
be initialized to 'lc#n', when line card in slot #n is enabled.
|
||||
|
||||
Add validation of modules number found on main board in function
|
||||
mlxsw_thermal_modules_init(). On modular system this counter might be
|
||||
zero.
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
.../ethernet/mellanox/mlxsw/core_thermal.c | 129 ++++++++++++++++++
|
||||
1 file changed, 129 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
index b9253c9f70d9..529108aea3c6 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -88,6 +88,7 @@ struct mlxsw_thermal_module {
|
||||
};
|
||||
|
||||
struct mlxsw_thermal_area {
|
||||
+ struct mlxsw_thermal *parent;
|
||||
struct mlxsw_thermal_module *tz_module_arr;
|
||||
u8 tz_module_num;
|
||||
struct mlxsw_thermal_module *tz_gearbox_arr;
|
||||
@@ -105,6 +106,7 @@ struct mlxsw_thermal {
|
||||
u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1];
|
||||
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
|
||||
struct mlxsw_thermal_area *main;
|
||||
+ struct mlxsw_thermal_area **linecards;
|
||||
unsigned int tz_highest_score;
|
||||
struct thermal_zone_device *tz_highest_dev;
|
||||
};
|
||||
@@ -948,6 +950,126 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal,
|
||||
mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]);
|
||||
}
|
||||
|
||||
+static void
|
||||
+mlxsw_thermal_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_env_gearbox_sensors_map map;
|
||||
+ struct mlxsw_thermal *thermal = priv;
|
||||
+ struct mlxsw_thermal_area *lc;
|
||||
+ int err;
|
||||
+
|
||||
+ lc = kzalloc(sizeof(*lc), GFP_KERNEL);
|
||||
+ if (!lc)
|
||||
+ return;
|
||||
+
|
||||
+ lc->slot_index = slot_index;
|
||||
+ lc->parent = thermal;
|
||||
+ thermal->linecards[slot_index - 1] = lc;
|
||||
+ err = mlxsw_thermal_modules_init(thermal->bus_info->dev, thermal->core,
|
||||
+ thermal, lc);
|
||||
+ if (err)
|
||||
+ goto err_thermal_linecard_modules_init;
|
||||
+
|
||||
+ err = mlxsw_env_sensor_map_create(thermal->core, thermal->bus_info,
|
||||
+ linecard->slot_index, &map);
|
||||
+ if (err)
|
||||
+ goto err_thermal_linecard_env_sensor_map_create;
|
||||
+
|
||||
+ lc->gearbox_sensor_map = map.sensor_bit_map;
|
||||
+ lc->tz_gearbox_num = map.sensor_count;
|
||||
+ lc->tz_gearbox_arr = kcalloc(lc->tz_gearbox_num, sizeof(*lc->tz_gearbox_arr),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!lc->tz_gearbox_arr) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto err_tz_gearbox_arr_alloc;
|
||||
+ }
|
||||
+
|
||||
+ err = mlxsw_thermal_gearboxes_init(thermal->bus_info->dev, thermal->core,
|
||||
+ thermal, lc);
|
||||
+ if (err)
|
||||
+ goto err_thermal_linecard_gearboxes_init;
|
||||
+
|
||||
+ return;
|
||||
+
|
||||
+err_thermal_linecard_gearboxes_init:
|
||||
+ kfree(lc->tz_gearbox_arr);
|
||||
+err_tz_gearbox_arr_alloc:
|
||||
+ mlxsw_env_sensor_map_destroy(thermal->bus_info,
|
||||
+ lc->gearbox_sensor_map);
|
||||
+err_thermal_linecard_env_sensor_map_create:
|
||||
+ mlxsw_thermal_modules_fini(thermal, lc);
|
||||
+err_thermal_linecard_modules_init:
|
||||
+ kfree(lc);
|
||||
+ thermal->linecards[slot_index - 1] = NULL;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_thermal_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_thermal *thermal = priv;
|
||||
+ struct mlxsw_thermal_area *lc = thermal->linecards[slot_index - 1];
|
||||
+
|
||||
+ mlxsw_thermal_gearboxes_fini(thermal, lc);
|
||||
+ kfree(lc->tz_gearbox_arr);
|
||||
+ mlxsw_env_sensor_map_destroy(thermal->bus_info,
|
||||
+ lc->gearbox_sensor_map);
|
||||
+ mlxsw_thermal_modules_fini(thermal, lc);
|
||||
+ kfree(lc);
|
||||
+ thermal->linecards[slot_index - 1] = NULL;
|
||||
+}
|
||||
+
|
||||
+static struct mlxsw_linecards_event_ops mlxsw_thermal_event_ops = {
|
||||
+ .got_active = mlxsw_thermal_got_active,
|
||||
+ .got_inactive = mlxsw_thermal_got_inactive,
|
||||
+};
|
||||
+
|
||||
+static int mlxsw_thermal_linecards_register(struct mlxsw_core *mlxsw_core,
|
||||
+ struct mlxsw_thermal *thermal)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core);
|
||||
+ int err;
|
||||
+
|
||||
+ if (!linecards || !linecards->count)
|
||||
+ return 0;
|
||||
+
|
||||
+ thermal->linecards = kcalloc(linecards->count, sizeof(*thermal->linecards),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!thermal->linecards)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ err = mlxsw_linecards_event_ops_register(mlxsw_core,
|
||||
+ &mlxsw_thermal_event_ops,
|
||||
+ thermal);
|
||||
+ if (err)
|
||||
+ goto err_linecards_event_ops_register;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_linecards_event_ops_register:
|
||||
+ kfree(thermal->linecards);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_thermal_linecards_unregister(struct mlxsw_thermal *thermal)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(thermal->core);
|
||||
+ int i;
|
||||
+
|
||||
+ if (!linecards || !linecards->count)
|
||||
+ return;
|
||||
+
|
||||
+ for (i = 1; i <= linecards->count; i++) {
|
||||
+ if (thermal->linecards[i - 1])
|
||||
+ mlxsw_thermal_got_inactive(thermal->core, i, NULL,
|
||||
+ thermal);
|
||||
+ }
|
||||
+
|
||||
+ mlxsw_linecards_event_ops_unregister(thermal->core,
|
||||
+ &mlxsw_thermal_event_ops, thermal);
|
||||
+ kfree(thermal->linecards);
|
||||
+}
|
||||
+
|
||||
int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
const struct mlxsw_bus_info *bus_info,
|
||||
struct mlxsw_thermal **p_thermal)
|
||||
@@ -1052,6 +1174,10 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
if (err)
|
||||
goto err_thermal_gearboxes_init;
|
||||
|
||||
+ err = mlxsw_thermal_linecards_register(core, thermal);
|
||||
+ if (err)
|
||||
+ goto err_linecards_register;
|
||||
+
|
||||
err = thermal_zone_device_enable(thermal->tzdev);
|
||||
if (err)
|
||||
goto err_thermal_zone_device_enable;
|
||||
@@ -1060,6 +1186,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
||||
return 0;
|
||||
|
||||
err_thermal_zone_device_enable:
|
||||
+ mlxsw_thermal_linecards_unregister(thermal);
|
||||
+err_linecards_register:
|
||||
mlxsw_thermal_gearboxes_fini(thermal, thermal->main);
|
||||
err_thermal_gearboxes_init:
|
||||
mlxsw_thermal_gearboxes_main_fini(thermal->main);
|
||||
@@ -1087,6 +1215,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
|
||||
{
|
||||
int i;
|
||||
|
||||
+ mlxsw_thermal_linecards_unregister(thermal);
|
||||
mlxsw_thermal_gearboxes_fini(thermal, thermal->main);
|
||||
mlxsw_thermal_gearboxes_main_fini(thermal->main);
|
||||
mlxsw_thermal_modules_fini(thermal, thermal->main);
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,235 +0,0 @@
|
||||
From 7405ad4281c96aedcf879357d03487556abed05d Mon Sep 17 00:00:00 2001
|
||||
From: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Date: Wed, 12 May 2021 22:57:42 +0300
|
||||
Subject: [PATCH backport 5.10 150/182] mlxsw: core_hwmon: Add interfaces for
|
||||
line card initialization and de-initialization
|
||||
|
||||
Add callback functions for line card 'hwmon' initialization and
|
||||
de-initialization. Each line card is associated with the relevant
|
||||
'hwmon' device, which may contain thermal attributes for the cages
|
||||
and gearboxes found on this line card.
|
||||
|
||||
The line card 'hwmon' initialization / de-initialization APIs are to be
|
||||
called when line card is set to active / inactive state by
|
||||
got_active() / got_inactive() callbacks from line card state machine.
|
||||
|
||||
For example cage temperature for module #9 located at line card #7 will
|
||||
be exposed by utility 'sensors' like:
|
||||
linecard#07
|
||||
front panel 009: +32.0C (crit = +70.0C, emerg = +80.0C)
|
||||
And temperature for gearbox #3 located at line card #5 will be exposed
|
||||
like:
|
||||
linecard#05
|
||||
gearbox 003: +41.0C (highest = +41.0C)
|
||||
|
||||
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||||
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
|
||||
---
|
||||
.../net/ethernet/mellanox/mlxsw/core_hwmon.c | 137 +++++++++++++++++-
|
||||
1 file changed, 134 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
index 6af23f4724e4..a27146ccafc5 100644
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#define MLXSW_HWMON_ATTR_PER_SENSOR 3
|
||||
#define MLXSW_HWMON_ATTR_PER_MODULE 7
|
||||
#define MLXSW_HWMON_ATTR_PER_GEARBOX 4
|
||||
+#define MLXSW_HWMON_DEV_NAME_LEN_MAX 16
|
||||
|
||||
#define MLXSW_HWMON_ATTR_COUNT (MLXSW_HWMON_SENSORS_MAX_COUNT * MLXSW_HWMON_ATTR_PER_SENSOR + \
|
||||
MLXSW_HWMON_MODULES_MAX_COUNT * MLXSW_HWMON_ATTR_PER_MODULE + \
|
||||
@@ -42,6 +43,7 @@ mlxsw_hwmon_get_attr_index(int index, int count, u16 *gearbox_sensor_map)
|
||||
}
|
||||
|
||||
struct mlxsw_hwmon_dev {
|
||||
+ char name[MLXSW_HWMON_DEV_NAME_LEN_MAX];
|
||||
struct mlxsw_hwmon *hwmon;
|
||||
struct device *hwmon_dev;
|
||||
struct attribute_group group;
|
||||
@@ -59,6 +61,7 @@ struct mlxsw_hwmon {
|
||||
struct mlxsw_core *core;
|
||||
const struct mlxsw_bus_info *bus_info;
|
||||
struct mlxsw_hwmon_dev *main;
|
||||
+ struct mlxsw_hwmon_dev **linecards;
|
||||
};
|
||||
|
||||
static ssize_t mlxsw_hwmon_temp_show(struct device *dev,
|
||||
@@ -405,9 +408,14 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev,
|
||||
{
|
||||
struct mlxsw_hwmon_attr *mlxsw_hwmon_attr =
|
||||
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
|
||||
+ struct mlxsw_hwmon_dev *mlxsw_hwmon_dev;
|
||||
+ int index = mlxsw_hwmon_attr->type_index;
|
||||
+
|
||||
+ mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev;
|
||||
+ if (strlen(mlxsw_hwmon_dev->name))
|
||||
+ index += 1;
|
||||
|
||||
- return sprintf(buf, "front panel %03u\n",
|
||||
- mlxsw_hwmon_attr->type_index);
|
||||
+ return sprintf(buf, "front panel %03u\n", index);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
@@ -691,7 +699,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev)
|
||||
u8 module_sensor_max;
|
||||
int i, err;
|
||||
|
||||
- mlxsw_reg_mgpir_pack(mgpir_pl, 0);
|
||||
+ mlxsw_reg_mgpir_pack(mgpir_pl, mlxsw_hwmon_dev->slot_index);
|
||||
err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -819,6 +827,122 @@ mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, u8 gbox_num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void
|
||||
+mlxsw_hwmon_got_active(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_hwmon *hwmon = priv;
|
||||
+ struct device *dev = hwmon->bus_info->dev;
|
||||
+ struct mlxsw_env_gearbox_sensors_map map;
|
||||
+ struct mlxsw_hwmon_dev *lc;
|
||||
+ int err;
|
||||
+
|
||||
+ lc = kzalloc(sizeof(*lc), GFP_KERNEL);
|
||||
+ if (!lc)
|
||||
+ return;
|
||||
+ lc->slot_index = slot_index;
|
||||
+ lc->hwmon = hwmon;
|
||||
+ err = mlxsw_hwmon_module_init(lc);
|
||||
+ if (err)
|
||||
+ goto err_hwmon_linecard_module_init;
|
||||
+
|
||||
+ err = mlxsw_env_sensor_map_create(hwmon->core,
|
||||
+ hwmon->bus_info, slot_index,
|
||||
+ &map);
|
||||
+ if (err)
|
||||
+ goto err_hwmon_linecard_env_sensor_map_create;
|
||||
+
|
||||
+ lc->gearbox_sensor_map = map.sensor_bit_map;
|
||||
+ err = mlxsw_hwmon_gearbox_init(lc, map.sensor_count);
|
||||
+ if (err)
|
||||
+ goto err_hwmon_linecard_gearbox_init;
|
||||
+
|
||||
+ lc->groups[0] = &lc->group;
|
||||
+ lc->group.attrs = lc->attrs;
|
||||
+ sprintf(lc->name, "%s#%02u", "linecard", slot_index);
|
||||
+ lc->hwmon_dev = hwmon_device_register_with_groups(dev, (const char *) lc->name,
|
||||
+ lc, lc->groups);
|
||||
+ if (IS_ERR(lc->hwmon_dev)) {
|
||||
+ err = PTR_ERR(lc->hwmon_dev);
|
||||
+ goto err_hwmon_linecard_register;
|
||||
+ }
|
||||
+ hwmon->linecards[slot_index - 1] = lc;
|
||||
+
|
||||
+ return;
|
||||
+
|
||||
+err_hwmon_linecard_register:
|
||||
+err_hwmon_linecard_gearbox_init:
|
||||
+ mlxsw_env_sensor_map_destroy(hwmon->bus_info,
|
||||
+ lc->gearbox_sensor_map);
|
||||
+err_hwmon_linecard_env_sensor_map_create:
|
||||
+err_hwmon_linecard_module_init:
|
||||
+ kfree(lc);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mlxsw_hwmon_got_inactive(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
+ const struct mlxsw_linecard *linecard, void *priv)
|
||||
+{
|
||||
+ struct mlxsw_hwmon *hwmon = priv;
|
||||
+ struct mlxsw_hwmon_dev *lc = hwmon->linecards[slot_index - 1];
|
||||
+
|
||||
+ if (lc->hwmon_dev)
|
||||
+ hwmon_device_unregister(lc->hwmon_dev);
|
||||
+ mlxsw_env_sensor_map_destroy(hwmon->bus_info,
|
||||
+ lc->gearbox_sensor_map);
|
||||
+ kfree(lc);
|
||||
+ hwmon->linecards[slot_index - 1] = NULL;
|
||||
+}
|
||||
+
|
||||
+static struct mlxsw_linecards_event_ops mlxsw_hwmon_event_ops = {
|
||||
+ .got_active = mlxsw_hwmon_got_active,
|
||||
+ .got_inactive = mlxsw_hwmon_got_inactive,
|
||||
+};
|
||||
+
|
||||
+static int mlxsw_hwmon_linecards_register(struct mlxsw_hwmon *hwmon)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(hwmon->core);
|
||||
+ int err;
|
||||
+
|
||||
+ if (!linecards || !linecards->count)
|
||||
+ return 0;
|
||||
+
|
||||
+ hwmon->linecards = kcalloc(linecards->count, sizeof(*hwmon->linecards),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!hwmon->linecards)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ err = mlxsw_linecards_event_ops_register(hwmon->core,
|
||||
+ &mlxsw_hwmon_event_ops,
|
||||
+ hwmon);
|
||||
+ if (err)
|
||||
+ goto err_linecards_event_ops_register;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_linecards_event_ops_register:
|
||||
+ kfree(hwmon->linecards);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void mlxsw_hwmon_linecards_unregister(struct mlxsw_hwmon *hwmon)
|
||||
+{
|
||||
+ struct mlxsw_linecards *linecards = mlxsw_core_linecards(hwmon->core);
|
||||
+ int i;
|
||||
+
|
||||
+ if (!linecards || !linecards->count)
|
||||
+ return;
|
||||
+
|
||||
+ for (i = 1; i <= linecards->count; i++) {
|
||||
+ if (hwmon->linecards[i - 1])
|
||||
+ mlxsw_hwmon_got_inactive(hwmon->core, i, NULL, hwmon);
|
||||
+ }
|
||||
+
|
||||
+ mlxsw_linecards_event_ops_unregister(hwmon->core,
|
||||
+ &mlxsw_hwmon_event_ops, hwmon);
|
||||
+ kfree(hwmon->linecards);
|
||||
+}
|
||||
+
|
||||
int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
const struct mlxsw_bus_info *mlxsw_bus_info,
|
||||
struct mlxsw_hwmon **p_hwmon)
|
||||
@@ -872,10 +996,16 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
goto err_hwmon_register;
|
||||
}
|
||||
|
||||
+ err = mlxsw_hwmon_linecards_register(mlxsw_hwmon);
|
||||
+ if (err)
|
||||
+ goto err_linecards_register;
|
||||
+
|
||||
mlxsw_hwmon->main->hwmon_dev = hwmon_dev;
|
||||
*p_hwmon = mlxsw_hwmon;
|
||||
return 0;
|
||||
|
||||
+err_linecards_register:
|
||||
+ hwmon_device_unregister(mlxsw_hwmon->main->hwmon_dev);
|
||||
err_hwmon_register:
|
||||
err_gearbox_init:
|
||||
mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main);
|
||||
@@ -891,6 +1021,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
|
||||
|
||||
void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon)
|
||||
{
|
||||
+ mlxsw_hwmon_linecards_unregister(mlxsw_hwmon);
|
||||
hwmon_device_unregister(mlxsw_hwmon->main->hwmon_dev);
|
||||
mlxsw_hwmon_gearbox_main_fini(mlxsw_hwmon->main);
|
||||
kfree(mlxsw_hwmon->main);
|
||||
--
|
||||
2.20.1
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user