drivers/network/bcm57xx: Fix MAC_TX_LENGTHS and other #709
Open
igorsh
wants to merge 5 commits from
igorsh/kolibrios:bcm57xx into bcm57xx
pull from: igorsh/kolibrios:bcm57xx
merge into: KolibriOS:bcm57xx
KolibriOS:main
KolibriOS:docpack-rework
KolibriOS:animage-menu-fix
KolibriOS:kfm-update
KolibriOS:chore/update-cmm_apps
KolibriOS:asm-xml-lib
KolibriOS:cpu-task-manager
KolibriOS:opendial-update
KolibriOS:kernel-socket-ring-sparse
KolibriOS:kernel-net-tsc-seed
KolibriOS:kernel-tcp-sender-fixes
KolibriOS:nvme
KolibriOS:kernel-unload-driver
KolibriOS:net-arp-nowait
KolibriOS:tcp-close-rst
KolibriOS:kernel-tcp-send-after-close
KolibriOS:kernel-tcp-rexmt-timer
KolibriOS:drivers-usbrndis-throughput
KolibriOS:kernel-arp-remove-index
KolibriOS:usbstor-media-poll
KolibriOS:setup-rework
KolibriOS:sweetbread-meos-copyrights
KolibriOS:kernel-tcp-reassembly-queue
KolibriOS:iconv-cp866-dash
KolibriOS:vesa20-putimage-runs
KolibriOS:bcm57xx
KolibriOS:open-fix-587
KolibriOS:drivers-include-linux49-backports
KolibriOS:MarvellYukon-II
KolibriOS:MarvellYukon-I
KolibriOS:egor00f-patch-1
KolibriOS:rdsave-rewrite
KolibriOS:fix_602
KolibriOS:kernel-tcp-socket-list-locking
KolibriOS:network/getsockname
KolibriOS:rewrite_ide_drv
KolibriOS:apps/table-msvc-to-tcc
KolibriOS:netsurf-4
KolibriOS:vidmode-s3ide-clgd54xx-kms-etc
KolibriOS:updf-1.5
KolibriOS:pr-fs-unhardcode
KolibriOS:kbd-busoff
KolibriOS:webview-4
KolibriOS:workflow-fuse
KolibriOS:add-license-file-header-to-guide
KolibriOS:shell-improve-cpuid
KolibriOS:qrcodegen
KolibriOS:ci/update
KolibriOS:laser-tank-fix-win-height
KolibriOS:improvement/commit-and-branch-styles
KolibriOS:docs/libs
Dismiss Review
Are you sure you want to dismiss this review?
Labels
Clear labels
Influence/Text/TYPO
AI
Eolite
FS
GSoC
Good First PR
HLL
HardwareTested
IRCC
Influence/Settings
Lang/C
Lang/FASM
Pay for the code
Subsystem/API
Subsystem/Audio
Subsystem/Graphics
Subsystem/IPC and events
Subsystem/Memory
Subsystem/Network
Subsystem/Services(daemon)
Subsystem/Taskmanager
Subsystem/VFS
Subsystem/Window
This issue or PR in the Google Source of Code program
The issue is suitable to beginners
Paid task
infinity service, audio drivers, midi, speacker, audio programs
vesa, vga, framebuffer, cursors, blitter, and video drivers
pipes, signals, events, shared memory
virt and phys memory allocators, malloc and other
userspace and kernel(for example: serial) services
process, threads, run apps, scheduler
drivers from filesystem, fs api, blkdev, programs that work with the file system
windows, skins, buttons, mouse and keyboard code for windows (not the base code)
Category
Applications
Category
Drivers
Category
General
Category
Kernel
Category
Libraries
Kind
Breaking
Breaking change that won't be backward compatible
Kind
Bug
Something is not working
Kind
Build
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Security
This is security issue
Kind
Testing
Issue or pull request related to testing
PR
Ready to merge
Pull request is ready for merge
PR
Conflicts
PR conflicts with main
PR
Dependent
This PR is dependent on another PR
PR
Request changes
Changes requested in pull request
PR
Review required
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: KolibriOS/kolibrios#709
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Root cause: MAC_TX_LENGTHS was defined as 0x046c, which is the receive
MAC status register. The inter packet gap went into a status register
and the real transmit lengths register at 0x0464 was never programmed,
so the send engine stalled as soon as the peer's window let it keep
more than a handful of frames in flight.
4 commits on bcm57xx:
register. One line, the actual fix.
SYNC_CHANGED were off by one bit.
An unreadable PHY is not evidence, and a false verdict here is
destructive: the stack never re-resolves a route for a socket it
already has, so a connection with data in flight is over for good.
chip's consumer index only inside the span actually handed over,
restart the ring on the chip's index when reclaiming, and count a
frame refused for a full ring as an overrun, not a drop.
1. The link-down confirmation runs inside the interrupt handler.
check_linkis called fromint_handleron aMACSTAT_LINK_CHANGEDattention, and the new.downpath doesdelay_usis a busy wait — one MMIO read per microsecond, by its own comment — so this spins ~10 ms in interrupt context, blocking the scheduler and every other device's interrupt for that whole time, and hammering the PCI bus while it does. It is not once per outage either: when the confirm withdraws the verdict the state stays up, so a flapping port pays the 10 ms on every attention.The confirmation itself is a good idea; it just cannot happen here. Options, roughly in order of preference: let the next link attention be the confirmation (record a "down pending" state and decide on the following one), move the recheck to a timer or worker context, or — if it has to stay inline — drop it to a few hundred microseconds and accept the weaker evidence.
2.
dbg_worthyis called with the counter in the wrong register.dbg_worthyreads eax (cmp eax, DBG_EVENTS), and every other call site in the file loads eax. Here eax still holds the chip's consumer index, so the rate limiting keys off a ring slot number: withDBG_EVENTS = 16and a 512-slot ring, a stale consumer at slot 100 is silently dropped forever while one at slot 256 prints on every single occurrence.txstale_countis incremented and never read. The message wants eax for its own%u, so:Smaller notes:
MACSTAT_TXSTAT_OFLOW = 0x08000000— tg3 calls this bitTXSTAT_UNDERRUN; 0x04000000 is the RX overrun. Since the point of the commit is getting the definitions exactly right, the name is worth matching.tx_reclaim_allnow trustsstatus_block.tx_cons_idxunconditionally — the very fieldtx_cleanwas just taught to distrust. It is defensible because the send engine is stopped there and the index is final, but that is the reason the new comment should give.;;line in thecheck_linkheader comment, and a doubled empty;line in thetx_cleanone.netcfg: show Broadcom for vendor id 14E4, already merged as #708, plus a merge commit. Rebasing would leave the four commits that are actually this PR.Also, please, cleanup comments and remove redundant info from them, if possible.
Jeffrey has already rewritten this driver from scratch #683
089f7dc750to0c13f332d6Я туда и шлю PR в bcm57xx
The two earlier findings are properly fixed: the confirmation no longer busy-waits
in the interrupt handler, and
dbg_worthynow gets its counter in eax. One newissue in
link_poll.The stall moved rather than went away.
link_pollholdsspin_lock_irqsaveacross the whole
check_linkcall:check_linkdoes two or threephy_reads, and each one can spinup to 5000 register reads — about a microsecond apiece by this driver's own
reckoning, so ~5 ms per read. When the MI interface answers normally this is
microseconds and invisible. When it does not — the exact case this mechanism
exists for — it is ~10 ms with interrupts disabled, ~15 ms if AUX_STAT times out
too. Narrower than the old 10 ms in the interrupt handler, since it needs a dead
MI rather than any link event, but the same class of problem.
Two fixes, either works:
link_suspectread and write, and sample the PHYoutside it.
link_pollwould take the lock, read the ladder, drop it, callcheck_link, then take it again to commit —check_linkalready toleratesrunning unlocked, since the interrupt path calls it that way.
transaction; a few hundred would bound the worst case to well under a
millisecond and still never trip on healthy hardware.
0c13f332d6toc01ce770ceView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.