[Accton] sfpi: add per-port per-reason syslog rate limiting - #210
Open
eric271110 wants to merge 4 commits into
Open
[Accton] sfpi: add per-port per-reason syslog rate limiting#210eric271110 wants to merge 4 commits into
eric271110 wants to merge 4 commits into
Conversation
Platforms: as7535-28xb, as7926-40xfb, as7946-30xb, as7946-74xkb, as9716_32d, as9726-32d, as9736-64d, as9737-32db, as9817-64, as9817-64-nb, as9926-24d, as9926-24db. * Add log_reason enum, per-port sfp_log_mgmt state (should_log flag per reason + last-known sfp_present_rec) and helpers syslog_ctrl() / reset_log_ctrl(). * Route every port-scoped syslog(LOG_ERR, ...) through syslog_ctrl() so each (port, reason) is only logged once until state changes. * In onlp_sfpi_is_present(), re-arm the log_ctrl flags whenever the presence result changes (module insert/remove or transition to/from E_INTERNAL), so the next failure re-emits one log line. * CPLD-level syslog calls with no port context are left untouched. Signed-off-by: Eric Yang <eric_yang@accton.com>
…LOG_ERROR platforms Platforms: as4625-54t, as4630-54pe, as4630-54te, as5835-54t, as5835-54x, as5915-18x, as5916-54x, as5916-54xks, as5916-54xl, as7326-56x, as7515-24x, as7712-32x, as7726-32x, as7816-64x. * Reuse the log_reason enum, sfp_log_mgmt state and syslog_ctrl() / reset_log_ctrl() helpers introduced for the syslog-based platforms, so all Accton sfpi drivers share the same rate-limiting model. * Convert port-scoped AIM_LOG_ERROR calls in these drivers to syslog_ctrl() so each (port, reason) only emits one log entry until the port state changes. Strip trailing \r\n from converted messages since syslog does not require them. * In onlp_sfpi_is_present(), re-arm log_ctrl whenever the presence result changes: on a real module insertion (present transitions to 1), and on the first read failure after a successful read (transition into E_INTERNAL). This mirrors the behavior in 098a42b so downstream failures re-emit one log line after the underlying state has changed. * CPLD-level AIM_LOG_ERROR calls with no port context (e.g. in presence_bitmap_get / rx_los_bitmap_get) are rewritten as plain syslog(LOG_ERR, ...) to keep the logging channel consistent with the syslog-based platforms; they are not rate-limited because the bitmap APIs have no port to key the log_ctrl on. Signed-off-by: Eric Yang <eric_yang@accton.com>
eric271110
force-pushed
the
reduce_syslog_linux_6.1
branch
2 times, most recently
from
August 26, 2026 06:30
7f05c9d to
55aa4c7
Compare
…common log_ctrl module Platforms: as4625-54t, as4630-54pe, as4630-54te, as5835-54t, as5835-54x, as5915-18x, as5916-54x, as5916-54xks, as5916-54xl, as7326-56x, as7515-24x, as7535-28xb, as7712-32x, as7726-32x, as7816-64x, as7926-40xfb, as7946-30xb, as7946-74xkb, as9716_32d, as9726-32d, as9736-64d, as9737-32db, as9817-64, as9817-64-nb, as9926-24d, as9926-24db. * Move the log_reason enum, sfp_log_mgmt state and syslog_ctrl() / reset_log_ctrl() helpers previously duplicated in every platform sfpi.c into a shared header/source under packages/platforms/accton/x86-64/common (log_ctrl.h / log_ctrl.c), so all Accton sfpi drivers share one implementation of the rate-limiting model. * Generalize the primitive: syslog_ctrl() / reset_log_ctrl() now operate on a plain struct log_ctrl array plus an entry count, instead of being tied to struct sfp_log_mgmt. This leaves room for future domains (fan, PSU, ...) to reuse the same throttling primitive with their own reason enums. * Rename the SFP reason enum values with an SFP_ prefix (SFP_PRESENT_UNABLE_TO_GET_STATUS, ...) and rename the terminator to SFP_LOG_REASON_COUNT to avoid symbol collisions when other domains are added later. Rename the sfp_present_rec field to present_rec to match the shared struct layout. * Update each platform sfpi.c to include "log_ctrl.h" and drop its private copy of the enum, struct and helpers. Update each platform's module/make.mk to compile the shared log_ctrl.c and add the common include path, so the linker picks up one copy of the helpers instead of per-platform duplicates. Signed-off-by: Eric Yang <eric_yang@accton.com>
eric271110
force-pushed
the
reduce_syslog_linux_6.1
branch
from
August 27, 2026 07:26
55aa4c7 to
dcbe9df
Compare
Platforms: as4625-54t, as4630-54pe, as4630-54te, as5835-54t,
as5835-54x, as5915-18x, as5916-54x, as5916-54xks, as5916-54xl,
as7326-56x, as7515-24x, as7535-28xb, as7712-32x, as7726-32x,
as7816-64x, as7926-40xfb, as7946-30xb, as7946-74xkb, as9716_32d,
as9726-32d, as9736-64d, as9737-32db, as9817-64, as9817-64-nb,
as9926-24d, as9926-24db.
* Collapse the 21 per-control sfp_log_reason values into 8 buckets
split by hardware target (CPLD/FPGA attribute vs. optical module
EEPROM) crossed with access mechanism (sysfs file via fopen() /
onlp_file_* vs. direct i2c via onlp_i2c_*). This reduces the number
of independent syslog rate-limiting slots per port from 21 to 8 and
gives each remaining slot a clear troubleshooting meaning.
* New reason enum:
SFP_SYSFS_READ_FAIL CPLD/FPGA attribute file read.
SFP_SYSFS_WRITE_FAIL CPLD/FPGA attribute file write.
SFP_EEPROM_SYSFS_READ_FAIL EEPROM data file read via sysfs
(module_eeprom_%d or at24-style
/sys/bus/i2c/devices/<bus>-0050/eeprom).
SFP_EEPROM_SYSFS_WRITE_FAIL EEPROM data file write via sysfs.
SFP_I2C_READ_TARGET_FAIL Direct i2c read of the final byte
carrying the requested data (e.g. the
QSFP tx_disable byte).
SFP_I2C_WRITE_TARGET_FAIL Direct i2c write of the final byte.
SFP_I2C_PREP_FAIL Direct i2c access to an auxiliary
byte needed to reach a target byte
(identifier, status byte, page/bank
select, control byte).
SFP_INVALID_DATA_SIZE Value-level anomaly where the I/O
succeeded but the returned data
violates an invariant (currently the
eeprom size != 256 check).
* Update every platform sfpi.c to emit the new reason values at each
syslog_ctrl() call site based on which underlying access path was
used. Existing log message strings that carried the sub-step detail
(e.g. "read identifier from eeprom fail", "write bank to eeprom
fail") are preserved so per-step context stays visible in the log
even though the enum key is now coarser.
* Refine the eeprom size-mismatch log to report the actual size
returned instead of "size is different!", making the check easier
to diagnose.
Signed-off-by: Eric Yang <eric_yang@accton.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.