Compare commits
6
Commits
ac6d09bc63
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d233798113 | ||
|
|
8eb4f40a36 | ||
|
|
f121a3ec30 | ||
|
|
570cc7c74a | ||
|
|
e66589a654 | ||
|
|
bb3bdc9e2b |
No files matched your search
Generated
+210
-12
@@ -2,7 +2,7 @@
|
||||
"nodes": {
|
||||
"arion": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts_2",
|
||||
"flake-parts": "flake-parts_3",
|
||||
"haskell-flake": "haskell-flake",
|
||||
"nixpkgs": [
|
||||
"frappix",
|
||||
@@ -169,9 +169,11 @@
|
||||
"clan-core": [
|
||||
"clan-core"
|
||||
],
|
||||
"devshell": "devshell",
|
||||
"flake-parts": [
|
||||
"flake-parts"
|
||||
],
|
||||
"hermes-agent": "hermes-agent",
|
||||
"nixos-mailserver": "nixos-mailserver",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
@@ -181,11 +183,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1790583225,
|
||||
"narHash": "sha256-Nhgf1hptHA9pgcGN4U1wQqDg1cc3t6oCT/HCgBcRs/w=",
|
||||
"lastModified": 1793614125,
|
||||
"narHash": "sha256-BsitI6IZ727mUtKQjN14eYHbnAsskuDB5A9co16R+oc=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "b2749dcc6ebe5d055b691f32dd47039f745a7d0e",
|
||||
"revCount": 203,
|
||||
"rev": "b2b5daaed71c7d4f0b9a8b3cf31b5c1469dfdc2e",
|
||||
"revCount": 497,
|
||||
"type": "git",
|
||||
"url": "https://git.b4l.co.th/B4L/cnx-network-clan"
|
||||
},
|
||||
@@ -222,6 +224,27 @@
|
||||
}
|
||||
},
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791918082,
|
||||
"narHash": "sha256-oN9JrhRfHa7MUTdUq+11dHn7u0Z4WfEA4mhzBq0/zoQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "9e29c63dde99a2d80c94b3d024c9768c01544558",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
@@ -312,6 +335,28 @@
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1782949081,
|
||||
"narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts_2": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
@@ -331,7 +376,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts_2": {
|
||||
"flake-parts_3": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"frappix",
|
||||
@@ -522,7 +567,57 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hermes-agent": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"home-manager": "home-manager",
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"nixpkgs"
|
||||
],
|
||||
"npm-lockfile-fix": "npm-lockfile-fix",
|
||||
"pyproject-build-systems": "pyproject-build-systems",
|
||||
"pyproject-nix": "pyproject-nix",
|
||||
"uv2nix": "uv2nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1792043576,
|
||||
"narHash": "sha256-i9rob9jtBv6XTV0acNbHDEUM+9f3ZsN1zJkD6dMBzTc=",
|
||||
"owner": "NousResearch",
|
||||
"repo": "hermes-agent",
|
||||
"rev": "d923a5eb487a17c0a68801bba9ef0f56c81040a8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NousResearch",
|
||||
"ref": "v0.22.2",
|
||||
"repo": "hermes-agent",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1786487128,
|
||||
"narHash": "sha256-ad60hrRVhH/bo3Jl1YLzO+QcS3mUNZr9LNJdzhMO2P4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "f404edbfa4117810c96b97048299242fc50e5362",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
@@ -843,11 +938,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1785198005,
|
||||
"narHash": "sha256-falBPi+PJtMx0vwII8L24wjDGXNZMwRiVXsw8WTXLEo=",
|
||||
"lastModified": 1792432400,
|
||||
"narHash": "sha256-ayqyWcMFat+/FPyzm6iABDWyQwqKw4dG5yY6tcmN53Y=",
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "nixos-mailserver",
|
||||
"rev": "d357b9f048c5532ec81b0e0034c0b8463d5ddd46",
|
||||
"rev": "b3e735a82a531e34ea3df3495026ca1d8a4e62fe",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
@@ -919,6 +1014,28 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"npm-lockfile-fix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775903712,
|
||||
"narHash": "sha256-2GV79U6iVH4gKAPWYrxUReB0S41ty/Y3dBLquU8AlaA=",
|
||||
"owner": "jeslie0",
|
||||
"repo": "npm-lockfile-fix",
|
||||
"rev": "c6093acb0c0548e0f9b8b3d82918823721930fe8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "jeslie0",
|
||||
"repo": "npm-lockfile-fix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"paisano": {
|
||||
"inputs": {
|
||||
"call-flake": "call-flake",
|
||||
@@ -988,15 +1105,69 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pyproject-build-systems": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"nixpkgs"
|
||||
],
|
||||
"pyproject-nix": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"pyproject-nix"
|
||||
],
|
||||
"uv2nix": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"uv2nix"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1785115949,
|
||||
"narHash": "sha256-8AM37BfyGaL2v/SZyg4PupRxJ01Y4htvM+WrTjWrPpo=",
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "build-system-pkgs",
|
||||
"rev": "62c0d86027edb1c4f39a5facc09876348144f7c9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "build-system-pkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pyproject-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1784591072,
|
||||
"narHash": "sha256-zP/WaDxrRu8GANZM61+V2LT/7ycEEdoyLWn7M6WzU7M=",
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "pyproject.nix",
|
||||
"rev": "e3b599ca2e7fcf93d4edf65d7f19bbf6491724f3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "pyproject.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"clan-community": "clan-community",
|
||||
"clan-core": "clan-core",
|
||||
"cnx-network": "cnx-network",
|
||||
"devshell": "devshell",
|
||||
"flake-parts": "flake-parts",
|
||||
"devshell": "devshell_2",
|
||||
"flake-parts": "flake-parts_2",
|
||||
"frappix": "frappix",
|
||||
"home-manager": "home-manager",
|
||||
"home-manager": "home-manager_2",
|
||||
"import-tree": "import-tree",
|
||||
"liminix": "liminix",
|
||||
"matthew-hardware": "matthew-hardware",
|
||||
@@ -1187,6 +1358,33 @@
|
||||
"url": "https://git.atagen.co/atagen/unf"
|
||||
}
|
||||
},
|
||||
"uv2nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"nixpkgs"
|
||||
],
|
||||
"pyproject-nix": [
|
||||
"cnx-network",
|
||||
"hermes-agent",
|
||||
"pyproject-nix"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1785277507,
|
||||
"narHash": "sha256-9Tq3UDX2hD/aveW/HvkBlAmEwJTOlY5HQXJM+L5BGmE=",
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "uv2nix",
|
||||
"rev": "5a836d395cbf5fc22670eb98dd4aa4fc4d406977",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "uv2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"yants": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
||||
@@ -82,8 +82,14 @@ in
|
||||
};
|
||||
|
||||
# 10.1.<id>.0/24, router .1, DHCP pool .100-.199.
|
||||
# ipv6SubnetId: which /64 of the DHCPv6-PD prefix the VLAN announces.
|
||||
# lan defaults to 0 (whole prefix on AIS's bare /64). mgmt would default
|
||||
# to its VLAN id (10); keep it at 1 so it also fits a /61-/63 delegation.
|
||||
vlans = {
|
||||
mgmt.id = 10;
|
||||
mgmt = {
|
||||
id = 10;
|
||||
ipv6SubnetId = 1;
|
||||
};
|
||||
lan.id = 20;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
sitename = "tempoerp.newedge.house";
|
||||
sitename = "b4lerp.newedge.house";
|
||||
in
|
||||
{
|
||||
clan.core.settings.machine.description = "VM machine that host ERPNext for tempo";
|
||||
clan.core.settings.machine.description = "VM machine that host ERPNext for Buildforlife";
|
||||
imports = [
|
||||
inputs.frappix.nixosModules.x86_64-linux.frappix
|
||||
];
|
||||
@@ -17,6 +17,7 @@ in
|
||||
inputs.self.overlays.frappixLibsOverlay
|
||||
inputs.self.overlays.frappixPythonOverlay
|
||||
inputs.self.overlays.frappixToolsOverlay
|
||||
inputs.self.overlays.frappixAppsOverlay
|
||||
inputs.self.overlays.posthogPr578265Overlay # TEMPORARY, see overlays/nixpkgs-pr-578265-posthog.nix
|
||||
inputs.self.overlays.frappixFixupsOverlay
|
||||
];
|
||||
@@ -43,13 +44,13 @@ in
|
||||
|
||||
services.frappe = {
|
||||
enable = true;
|
||||
project = "poyerp";
|
||||
project = "b4lerp";
|
||||
gunicorn_workers = 2;
|
||||
adminPassword = config.clan.core.vars.generators.frappix.files.adminPassword.path;
|
||||
apps = [
|
||||
pkgs.frappix.erpnext
|
||||
pkgs.frappix.hrms
|
||||
pkgs.frappix.crm
|
||||
pkgs.frappix.default_thai_company
|
||||
];
|
||||
sites = {
|
||||
"${sitename}" = {
|
||||
@@ -58,7 +59,7 @@ in
|
||||
"frappe"
|
||||
"erpnext"
|
||||
"hrms"
|
||||
"crm"
|
||||
"default_thai_company"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -44,20 +44,6 @@
|
||||
};
|
||||
systemd.coredump.enable = false;
|
||||
|
||||
# Upstream 07d9958739 (mainline 2026-05, not in linux-6.18.y). The MT7531
|
||||
# switch on the Flint 2 hangs off MDIO, and mt7530_get_stats64 took the
|
||||
# MDIO mutex under the RCU read lock that /proc/net/dev holds, so any
|
||||
# stats reader (zerotier-one, node exporter, `ip -s link`) that raced a
|
||||
# PHY access oopsed the box: "BUG: scheduling while atomic" ->
|
||||
# "Unable to handle kernel paging request" on 2026-09-20 09:02 UTC.
|
||||
# Drop once boot.kernelPackages moves to a kernel that carries it.
|
||||
boot.kernelPatches = [
|
||||
{
|
||||
name = "mt7530-get-stats64-atomic";
|
||||
patch = ./mt7530-get-stats64-atomic.patch;
|
||||
}
|
||||
];
|
||||
|
||||
# nixpkgs' services.blocky check runs the aarch64 blocky in a
|
||||
# system.checks derivation, which an x86_64 builder without binfmt cannot
|
||||
# execute (`--max-jobs 0` -> Exec format error). Validate the same YAML
|
||||
@@ -84,97 +70,6 @@
|
||||
22
|
||||
];
|
||||
|
||||
# AIS delegates a single /64 over PPPoE (seen 2026-10-02: "ppp0: DHCP:
|
||||
# received delegated prefix 2405:9800:b910:1f5d::/64"). The router
|
||||
# service hands out sub-prefixes with SubnetId=auto, so whichever VLAN
|
||||
# interface comes up first takes the whole /64 -- on this box vlan-mgmt
|
||||
# did, and vlan-lan logged "Couldn't find a suitable prefix. Ran out of
|
||||
# address space": no RA prefix on lan, so clients had no global IPv6.
|
||||
# Pin the ids: lan (where the clients are) always gets subnet 0, i.e.
|
||||
# the entire prefix when it is a /64; mgmt asks for subnet 1, which
|
||||
# fails harmlessly on a /64 (mgmt is reached over v4 and the meshes) and
|
||||
# starts working unchanged if AIS ever delegates wider. Drop once
|
||||
# cnx-network's router service exposes a per-VLAN subnet id.
|
||||
systemd.network.networks."40-vlan-lan".dhcpPrefixDelegationConfig.SubnetId = lib.mkForce "0x0";
|
||||
systemd.network.networks."40-vlan-mgmt".dhcpPrefixDelegationConfig.SubnetId = lib.mkForce "0x1";
|
||||
|
||||
# Interim copy of cnx-network-clan 45643d6 (router/ipv6: deprecate
|
||||
# withdrawn DHCPv6-PD prefixes); drop when the input is bumped past it.
|
||||
# networkd never deprecates a prefix it stops announcing (systemd#29651):
|
||||
# on every reboot the first PPPoE session lands on another AIS BNG, is
|
||||
# torn down minutes later, and the reconnect brings a different /64.
|
||||
# networkd announces the new prefix at once but clients keep the old
|
||||
# one preferred for the rest of its 1800 s lifetime, so RFC 6724 source
|
||||
# selection picks the dead prefix and every v6 connection fails for up
|
||||
# to 30 minutes (2026-10-08 07:57). Watch vlan-* for networkd removing a
|
||||
# dynamic (PD) address and send up to three RAs with that /64 at
|
||||
# preferred lifetime 0, one short-lived radvd per RA (SIGKILLed: no
|
||||
# shutdown RA with router lifetime 0), stopping as soon as the prefix is
|
||||
# back on the interface -- a plain flap re-delegates the same /64 within
|
||||
# seconds and a deprecating RA sent after networkd re-announced it would
|
||||
# leave clients deprecated until the next periodic RA (08:19 today).
|
||||
systemd.services.router-radv-deprecate = {
|
||||
description = "Deprecate withdrawn DHCPv6-PD prefixes on the VLANs";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "systemd-networkd.service" ];
|
||||
path = [
|
||||
pkgs.iproute2
|
||||
pkgs.ipcalc
|
||||
pkgs.radvd
|
||||
];
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = 2;
|
||||
RuntimeDirectory = "router-radv-deprecate";
|
||||
};
|
||||
script = ''
|
||||
conf=$RUNTIME_DIRECTORY/radvd.conf
|
||||
pid=$RUNTIME_DIRECTORY/radvd.pid
|
||||
|
||||
# /64s of the global addresses currently on an interface.
|
||||
prefixes_on() {
|
||||
ip -o -6 addr show dev "$1" scope global | while read -r _ _ _ a _; do
|
||||
echo "$(ipcalc --no-decorate -n "$a")/''${a##*/}"
|
||||
done
|
||||
}
|
||||
|
||||
# "Deleted 4: vlan-lan inet6 2001:db8::1/64 scope global dynamic mngtmpaddr \ valid_lft ..."
|
||||
ip -o -6 monitor address | while read -r event _ dev _ addr _ scope rest; do
|
||||
[[ $event == Deleted && $dev == vlan-* && $scope == global && $rest == *dynamic* ]] || continue
|
||||
prefix="$(ipcalc --no-decorate -n "$addr")/''${addr##*/}"
|
||||
cat > "$conf" <<EOF
|
||||
interface $dev {
|
||||
AdvSendAdvert on;
|
||||
MinRtrAdvInterval 3;
|
||||
MaxRtrAdvInterval 4;
|
||||
AdvDefaultLifetime 1800;
|
||||
AdvCurHopLimit 0;
|
||||
prefix $prefix {
|
||||
AdvOnLink on;
|
||||
AdvAutonomous on;
|
||||
AdvPreferredLifetime 0;
|
||||
AdvValidLifetime 7200;
|
||||
};
|
||||
};
|
||||
EOF
|
||||
for _ in 1 2 3; do
|
||||
if prefixes_on "$dev" | grep -qxF "$prefix"; then
|
||||
echo "$dev: $prefix is back, leaving it announced"
|
||||
break
|
||||
fi
|
||||
echo "$dev: deprecating withdrawn prefix $prefix"
|
||||
rm -f "$pid"
|
||||
# radvd sends its first RA on start; the next would follow 3-4 s later.
|
||||
radvd -C "$conf" -p "$pid" -n -m stderr &
|
||||
sleep 1
|
||||
kill -KILL $! 2>/dev/null || true
|
||||
wait $! || true
|
||||
sleep 2
|
||||
done
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services.heartbeat-push = {
|
||||
description = "Heartbeat push to uptime monitor";
|
||||
serviceConfig = {
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
From 07d99587396024932e02474c3a5bede71d108454 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sat, 2 May 2026 11:55:02 +0100
|
||||
Subject: net: dsa: mt7530: fix .get_stats64 sleeping in atomic context
|
||||
|
||||
The .get_stats64 callback runs in atomic context, but on
|
||||
MDIO-connected switches every register read acquires the MDIO bus
|
||||
mutex, which can sleep:
|
||||
[ 12.645973] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:609
|
||||
[ 12.654442] in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 759, name: grep
|
||||
[ 12.663377] preempt_count: 0, expected: 0
|
||||
[ 12.667410] RCU nest depth: 1, expected: 0
|
||||
[ 12.671511] INFO: lockdep is turned off.
|
||||
[ 12.675441] CPU: 0 UID: 0 PID: 759 Comm: grep Tainted: G S W 7.0.0+ #0 PREEMPT
|
||||
[ 12.675453] Tainted: [S]=CPU_OUT_OF_SPEC, [W]=WARN
|
||||
[ 12.675456] Hardware name: Bananapi BPI-R64 (DT)
|
||||
[ 12.675459] Call trace:
|
||||
[ 12.675462] show_stack+0x14/0x1c (C)
|
||||
[ 12.675477] dump_stack_lvl+0x68/0x8c
|
||||
[ 12.675487] dump_stack+0x14/0x1c
|
||||
[ 12.675495] __might_resched+0x14c/0x220
|
||||
[ 12.675504] __might_sleep+0x44/0x80
|
||||
[ 12.675511] __mutex_lock+0x50/0xb10
|
||||
[ 12.675523] mutex_lock_nested+0x20/0x30
|
||||
[ 12.675532] mt7530_get_stats64+0x40/0x2ac
|
||||
[ 12.675542] dsa_user_get_stats64+0x2c/0x40
|
||||
[ 12.675553] dev_get_stats+0x44/0x1e0
|
||||
[ 12.675564] dev_seq_printf_stats+0x24/0xe0
|
||||
[ 12.675575] dev_seq_show+0x14/0x3c
|
||||
[ 12.675583] seq_read_iter+0x37c/0x480
|
||||
[ 12.675595] seq_read+0xd0/0xec
|
||||
[ 12.675605] proc_reg_read+0x94/0xe4
|
||||
[ 12.675615] vfs_read+0x98/0x29c
|
||||
[ 12.675625] ksys_read+0x54/0xdc
|
||||
[ 12.675633] __arm64_sys_read+0x18/0x20
|
||||
[ 12.675642] invoke_syscall.constprop.0+0x54/0xec
|
||||
[ 12.675653] do_el0_svc+0x3c/0xb4
|
||||
[ 12.675662] el0_svc+0x38/0x200
|
||||
[ 12.675670] el0t_64_sync_handler+0x98/0xdc
|
||||
[ 12.675679] el0t_64_sync+0x158/0x15c
|
||||
|
||||
For MDIO-connected switches, poll MIB counters asynchronously using a
|
||||
delayed workqueue every second and let .get_stats64 return the cached
|
||||
values under a spinlock. A mod_delayed_work() call on each read
|
||||
triggers an immediate refresh so counters stay responsive when queried
|
||||
more frequently.
|
||||
|
||||
MMIO-connected switches (MT7988, EN7581, AN7583) are not affected
|
||||
because their regmap does not sleep, so they continue to read MIB
|
||||
counters directly in .get_stats64.
|
||||
|
||||
Fixes: 88c810f35ed5 ("net: dsa: mt7530: implement .get_stats64")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Acked-by: Chester A. Unal <chester.a.unal@arinc9.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://patch.msgid.link/6940b913da2c29156f0feff74b678d3c526ee84c.1777719253.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
drivers/net/dsa/mt7530.h | 8 ++++++
|
||||
2 files changed, 80 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
|
||||
index b9423389c2ef0..44d670904ad89 100644
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -25,6 +25,9 @@
|
||||
|
||||
#include "mt7530.h"
|
||||
|
||||
+#define MT7530_STATS_POLL_INTERVAL (1 * HZ)
|
||||
+#define MT7530_STATS_RATE_LIMIT (HZ / 10)
|
||||
+
|
||||
static struct mt753x_pcs *pcs_to_mt753x_pcs(struct phylink_pcs *pcs)
|
||||
{
|
||||
return container_of(pcs, struct mt753x_pcs, pcs);
|
||||
@@ -906,10 +909,9 @@ static void mt7530_get_rmon_stats(struct dsa_switch *ds, int port,
|
||||
*ranges = mt7530_rmon_ranges;
|
||||
}
|
||||
|
||||
-static void mt7530_get_stats64(struct dsa_switch *ds, int port,
|
||||
- struct rtnl_link_stats64 *storage)
|
||||
+static void mt7530_read_port_stats64(struct mt7530_priv *priv, int port,
|
||||
+ struct rtnl_link_stats64 *storage)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
uint64_t data;
|
||||
|
||||
/* MIB counter doesn't provide a FramesTransmittedOK but instead
|
||||
@@ -951,6 +953,54 @@ static void mt7530_get_stats64(struct dsa_switch *ds, int port,
|
||||
&storage->rx_crc_errors);
|
||||
}
|
||||
|
||||
+static void mt7530_stats_refresh(struct mt7530_priv *priv)
|
||||
+{
|
||||
+ struct rtnl_link_stats64 stats = {};
|
||||
+ struct dsa_port *dp;
|
||||
+ int port;
|
||||
+
|
||||
+ dsa_switch_for_each_user_port(dp, priv->ds) {
|
||||
+ port = dp->index;
|
||||
+
|
||||
+ mt7530_read_port_stats64(priv, port, &stats);
|
||||
+
|
||||
+ spin_lock_bh(&priv->stats_lock);
|
||||
+ priv->ports[port].stats = stats;
|
||||
+ priv->stats_last = jiffies;
|
||||
+ spin_unlock_bh(&priv->stats_lock);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void mt7530_stats_poll(struct work_struct *work)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = container_of(work, struct mt7530_priv,
|
||||
+ stats_work.work);
|
||||
+
|
||||
+ mt7530_stats_refresh(priv);
|
||||
+ schedule_delayed_work(&priv->stats_work,
|
||||
+ MT7530_STATS_POLL_INTERVAL);
|
||||
+}
|
||||
+
|
||||
+static void mt7530_get_stats64(struct dsa_switch *ds, int port,
|
||||
+ struct rtnl_link_stats64 *storage)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+ bool refresh;
|
||||
+
|
||||
+ if (priv->bus) {
|
||||
+ spin_lock_bh(&priv->stats_lock);
|
||||
+ *storage = priv->ports[port].stats;
|
||||
+ refresh = time_after(jiffies, priv->stats_last +
|
||||
+ MT7530_STATS_RATE_LIMIT);
|
||||
+ spin_unlock_bh(&priv->stats_lock);
|
||||
+ if (refresh)
|
||||
+ mod_delayed_work(system_percpu_wq,
|
||||
+ &priv->stats_work, 0);
|
||||
+ } else {
|
||||
+ mt7530_read_port_stats64(priv, port, storage);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void mt7530_get_eth_ctrl_stats(struct dsa_switch *ds, int port,
|
||||
struct ethtool_eth_ctrl_stats *ctrl_stats)
|
||||
{
|
||||
@@ -3137,9 +3187,24 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq_domain)
|
||||
mt7530_free_mdio_irq(priv);
|
||||
|
||||
+ if (!ret && priv->bus) {
|
||||
+ mt7530_stats_refresh(priv);
|
||||
+ schedule_delayed_work(&priv->stats_work,
|
||||
+ MT7530_STATS_POLL_INTERVAL);
|
||||
+ }
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static void
|
||||
+mt753x_teardown(struct dsa_switch *ds)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ if (priv->bus)
|
||||
+ cancel_delayed_work_sync(&priv->stats_work);
|
||||
+}
|
||||
+
|
||||
static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
|
||||
struct ethtool_keee *e)
|
||||
{
|
||||
@@ -3257,6 +3322,7 @@ static int mt7988_setup(struct dsa_switch *ds)
|
||||
static const struct dsa_switch_ops mt7530_switch_ops = {
|
||||
.get_tag_protocol = mtk_get_tag_protocol,
|
||||
.setup = mt753x_setup,
|
||||
+ .teardown = mt753x_teardown,
|
||||
.preferred_default_local_cpu_port = mt753x_preferred_default_local_cpu_port,
|
||||
.get_strings = mt7530_get_strings,
|
||||
.get_ethtool_stats = mt7530_get_ethtool_stats,
|
||||
@@ -3395,6 +3461,9 @@ mt7530_probe_common(struct mt7530_priv *priv)
|
||||
priv->ds->ops = &mt7530_switch_ops;
|
||||
priv->ds->phylink_mac_ops = &mt753x_phylink_mac_ops;
|
||||
mutex_init(&priv->reg_mutex);
|
||||
+ spin_lock_init(&priv->stats_lock);
|
||||
+ INIT_DELAYED_WORK(&priv->stats_work, mt7530_stats_poll);
|
||||
+
|
||||
dev_set_drvdata(dev, priv);
|
||||
|
||||
return 0;
|
||||
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
|
||||
index 3e0090bed298d..dd33b0df3419e 100644
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -796,6 +796,7 @@ struct mt7530_fdb {
|
||||
* @pvid: The VLAN specified is to be considered a PVID at ingress. Any
|
||||
* untagged frames will be assigned to the related VLAN.
|
||||
* @sgmii_pcs: Pointer to PCS instance for SerDes ports
|
||||
+ * @stats: Cached port statistics for MDIO-connected switches
|
||||
*/
|
||||
struct mt7530_port {
|
||||
bool enable;
|
||||
@@ -803,6 +804,7 @@ struct mt7530_port {
|
||||
u32 pm;
|
||||
u16 pvid;
|
||||
struct phylink_pcs *sgmii_pcs;
|
||||
+ struct rtnl_link_stats64 stats;
|
||||
};
|
||||
|
||||
/* Port 5 mode definitions of the MT7530 switch */
|
||||
@@ -875,6 +877,9 @@ struct mt753x_info {
|
||||
* @create_sgmii: Pointer to function creating SGMII PCS instance(s)
|
||||
* @active_cpu_ports: Holding the active CPU ports
|
||||
* @mdiodev: The pointer to the MDIO device structure
|
||||
+ * @stats_lock: Protects cached per-port stats from concurrent access
|
||||
+ * @stats_work: Delayed work for polling MIB counters on MDIO switches
|
||||
+ * @stats_last: Jiffies timestamp of last MIB counter poll
|
||||
*/
|
||||
struct mt7530_priv {
|
||||
struct device *dev;
|
||||
@@ -900,6 +905,9 @@ struct mt7530_priv {
|
||||
int (*create_sgmii)(struct mt7530_priv *priv);
|
||||
u8 active_cpu_ports;
|
||||
struct mdio_device *mdiodev;
|
||||
+ spinlock_t stats_lock; /* protects cached stats counters */
|
||||
+ struct delayed_work stats_work;
|
||||
+ unsigned long stats_last;
|
||||
};
|
||||
|
||||
struct mt7530_hw_vlan_entry {
|
||||
--
|
||||
cgit 1.3.1-korg
|
||||
|
||||
@@ -11,8 +11,8 @@ let
|
||||
domain = "git.b4l.co.th";
|
||||
owner = "newedge";
|
||||
repo = "default_thai_company";
|
||||
rev = "c8fb98374989a22d0c907aa44877f247391a49ac";
|
||||
sha256 = "sha256-c+pqds4l3Laldgf3+Rj2Ug693kFJYDB1j4a15j4U5SY=";
|
||||
rev = "6dd557ee970c6966b74593b32eae70eb2a55c601";
|
||||
sha256 = "sha256-PUuQ3ElbjSGV5ApGT2uMVbORB8Pk2/IMe6M6xNLWxK0=";
|
||||
};
|
||||
in
|
||||
buildPythonPackage (finalAttrs: {
|
||||
|
||||
Reference in new issue
Block a user