From 9cf0128e64ab4ecd46f734d5c9870549cd29053f Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 13 Mar 2025 11:21:01 +0100 Subject: [PATCH 01/16] selftests: mptcp: add pm sysctl mapping tests This patch checks if the newly added net.mptcp.path_manager is mapped successfully from or to the old net.mptcp.pm_type in userspace_pm.sh. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250313-net-next-mptcp-pm-ops-intro-v1-12-f4e4a88efc50@kernel.org Signed-off-by: Paolo Abeni --- .../selftests/net/mptcp/userspace_pm.sh | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 3651f73451cf..333064b0b5ac 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -117,7 +117,36 @@ cleanup() trap cleanup EXIT # Create and configure network namespaces for testing +print_title "Init" mptcp_lib_ns_init ns1 ns2 + +# check path_manager and pm_type sysctl mapping +if [ -f /proc/sys/net/mptcp/path_manager ]; then + ip netns exec "$ns1" sysctl -q net.mptcp.path_manager=userspace + pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)" + if [ "${pm_type}" != "1" ]; then + test_fail "unexpected pm_type: ${pm_type}" + mptcp_lib_result_print_all_tap + exit ${KSFT_FAIL} + fi + + ip netns exec "$ns1" sysctl -q net.mptcp.path_manager=error 2>/dev/null + pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)" + if [ "${pm_type}" != "1" ]; then + test_fail "unexpected pm_type after error: ${pm_type}" + mptcp_lib_result_print_all_tap + exit ${KSFT_FAIL} + fi + + ip netns exec "$ns1" sysctl -q net.mptcp.pm_type=0 + pm_name="$(ip netns exec "$ns1" sysctl -n net.mptcp.path_manager)" + if [ "${pm_name}" != "kernel" ]; then + test_fail "unexpected path-manager: ${pm_name}" + mptcp_lib_result_print_all_tap + exit ${KSFT_FAIL} + fi +fi + for i in "$ns1" "$ns2" ;do ip netns exec "$i" sysctl -q net.mptcp.pm_type=1 done @@ -152,7 +181,6 @@ mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid sleep 0.5 mptcp_lib_subtests_last_ts_reset -print_title "Init" print_test "Created network namespaces ns1, ns2" test_pass -- 2.51.0 From f3009d0d6ab78053117f8857b921a8237f4d17b3 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 14 Mar 2025 13:10:57 +0300 Subject: [PATCH 02/16] net: atm: fix use after free in lec_send() The ->send() operation frees skb so save the length before calling ->send() to avoid a use after free. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Dan Carpenter Reviewed-by: Simon Horman Link: https://patch.msgid.link/c751531d-4af4-42fe-affe-6104b34b791d@stanley.mountain Signed-off-by: Paolo Abeni --- net/atm/lec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/atm/lec.c b/net/atm/lec.c index ffef658862db..a948dd47c3f3 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -181,6 +181,7 @@ static void lec_send(struct atm_vcc *vcc, struct sk_buff *skb) { struct net_device *dev = skb->dev; + unsigned int len = skb->len; ATM_SKB(skb)->vcc = vcc; atm_account_tx(vcc, skb); @@ -191,7 +192,7 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb) } dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; + dev->stats.tx_bytes += len; } static void lec_tx_timeout(struct net_device *dev, unsigned int txqueue) -- 2.51.0 From 47a9b5e52abd2b717dfc8b9460589f89936d93cf Mon Sep 17 00:00:00 2001 From: MD Danish Anwar Date: Fri, 14 Mar 2025 15:57:21 +0530 Subject: [PATCH 03/16] net: ti: icssg-prueth: Add lock to stats Currently the API emac_update_hardware_stats() reads different ICSSG stats without any lock protection. This API gets called by .ndo_get_stats64() which is only under RCU protection and nothing else. Add lock to this API so that the reading of statistics happens during lock. Fixes: c1e10d5dc7a1 ("net: ti: icssg-prueth: Add ICSSG Stats") Signed-off-by: MD Danish Anwar Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250314102721.1394366-1-danishanwar@ti.com Signed-off-by: Paolo Abeni --- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 1 + drivers/net/ethernet/ti/icssg/icssg_prueth.h | 2 ++ drivers/net/ethernet/ti/icssg/icssg_stats.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 00ed97860547..9a75733e3f8f 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1679,6 +1679,7 @@ static int prueth_probe(struct platform_device *pdev) } spin_lock_init(&prueth->vtbl_lock); + spin_lock_init(&prueth->stats_lock); /* setup netdev interfaces */ if (eth0_node) { ret = prueth_netdev_init(prueth, eth0_node); diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h index 329b46e9ee53..f41786b05741 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -305,6 +305,8 @@ struct prueth { int default_vlan; /** @vtbl_lock: Lock for vtbl in shared memory */ spinlock_t vtbl_lock; + /** @stats_lock: Lock for reading icssg stats */ + spinlock_t stats_lock; }; struct emac_tx_ts_response { diff --git a/drivers/net/ethernet/ti/icssg/icssg_stats.c b/drivers/net/ethernet/ti/icssg/icssg_stats.c index 8800bd3a8d07..6f0edae38ea2 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_stats.c +++ b/drivers/net/ethernet/ti/icssg/icssg_stats.c @@ -26,6 +26,8 @@ void emac_update_hardware_stats(struct prueth_emac *emac) u32 val, reg; int i; + spin_lock(&prueth->stats_lock); + for (i = 0; i < ARRAY_SIZE(icssg_all_miig_stats); i++) { regmap_read(prueth->miig_rt, base + icssg_all_miig_stats[i].offset, @@ -51,6 +53,8 @@ void emac_update_hardware_stats(struct prueth_emac *emac) emac->pa_stats[i] += val; } } + + spin_unlock(&prueth->stats_lock); } void icssg_stats_work_handler(struct work_struct *work) -- 2.51.0 From 986ffb3a57c5650fb8bf6d59a8f0f07046abfeb6 Mon Sep 17 00:00:00 2001 From: Justin Iurman Date: Fri, 14 Mar 2025 13:00:46 +0100 Subject: [PATCH 04/16] net: lwtunnel: fix recursion loops This patch acts as a parachute, catch all solution, by detecting recursion loops in lwtunnel users and taking care of them (e.g., a loop between routes, a loop within the same route, etc). In general, such loops are the consequence of pathological configurations. Each lwtunnel user is still free to catch such loops early and do whatever they want with them. It will be the case in a separate patch for, e.g., seg6 and seg6_local, in order to provide drop reasons and update statistics. Another example of a lwtunnel user taking care of loops is ioam6, which has valid use cases that include loops (e.g., inline mode), and which is addressed by the next patch in this series. Overall, this patch acts as a last resort to catch loops and drop packets, since we don't want to leak something unintentionally because of a pathological configuration in lwtunnels. The solution in this patch reuses dev_xmit_recursion(), dev_xmit_recursion_inc(), and dev_xmit_recursion_dec(), which seems fine considering the context. Closes: https://lore.kernel.org/netdev/2bc9e2079e864a9290561894d2a602d6@akamai.com/ Closes: https://lore.kernel.org/netdev/Z7NKYMY7fJT5cYWu@shredder/ Fixes: ffce41962ef6 ("lwtunnel: support dst output redirect function") Fixes: 2536862311d2 ("lwt: Add support to redirect dst.input") Fixes: 14972cbd34ff ("net: lwtunnel: Handle fragmentation") Signed-off-by: Justin Iurman Link: https://patch.msgid.link/20250314120048.12569-2-justin.iurman@uliege.be Signed-off-by: Paolo Abeni --- net/core/lwtunnel.c | 65 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c index 711cd3b4347a..4417a18b3e95 100644 --- a/net/core/lwtunnel.c +++ b/net/core/lwtunnel.c @@ -23,6 +23,8 @@ #include #include +#include "dev.h" + DEFINE_STATIC_KEY_FALSE(nf_hooks_lwtunnel_enabled); EXPORT_SYMBOL_GPL(nf_hooks_lwtunnel_enabled); @@ -325,13 +327,23 @@ EXPORT_SYMBOL_GPL(lwtunnel_cmp_encap); int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb) { - struct dst_entry *dst = skb_dst(skb); const struct lwtunnel_encap_ops *ops; struct lwtunnel_state *lwtstate; - int ret = -EINVAL; + struct dst_entry *dst; + int ret; + + if (dev_xmit_recursion()) { + net_crit_ratelimited("%s(): recursion limit reached on datapath\n", + __func__); + ret = -ENETDOWN; + goto drop; + } - if (!dst) + dst = skb_dst(skb); + if (!dst) { + ret = -EINVAL; goto drop; + } lwtstate = dst->lwtstate; if (lwtstate->type == LWTUNNEL_ENCAP_NONE || @@ -341,8 +353,11 @@ int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb) ret = -EOPNOTSUPP; rcu_read_lock(); ops = rcu_dereference(lwtun_encaps[lwtstate->type]); - if (likely(ops && ops->output)) + if (likely(ops && ops->output)) { + dev_xmit_recursion_inc(); ret = ops->output(net, sk, skb); + dev_xmit_recursion_dec(); + } rcu_read_unlock(); if (ret == -EOPNOTSUPP) @@ -359,13 +374,23 @@ EXPORT_SYMBOL_GPL(lwtunnel_output); int lwtunnel_xmit(struct sk_buff *skb) { - struct dst_entry *dst = skb_dst(skb); const struct lwtunnel_encap_ops *ops; struct lwtunnel_state *lwtstate; - int ret = -EINVAL; + struct dst_entry *dst; + int ret; + + if (dev_xmit_recursion()) { + net_crit_ratelimited("%s(): recursion limit reached on datapath\n", + __func__); + ret = -ENETDOWN; + goto drop; + } - if (!dst) + dst = skb_dst(skb); + if (!dst) { + ret = -EINVAL; goto drop; + } lwtstate = dst->lwtstate; @@ -376,8 +401,11 @@ int lwtunnel_xmit(struct sk_buff *skb) ret = -EOPNOTSUPP; rcu_read_lock(); ops = rcu_dereference(lwtun_encaps[lwtstate->type]); - if (likely(ops && ops->xmit)) + if (likely(ops && ops->xmit)) { + dev_xmit_recursion_inc(); ret = ops->xmit(skb); + dev_xmit_recursion_dec(); + } rcu_read_unlock(); if (ret == -EOPNOTSUPP) @@ -394,13 +422,23 @@ EXPORT_SYMBOL_GPL(lwtunnel_xmit); int lwtunnel_input(struct sk_buff *skb) { - struct dst_entry *dst = skb_dst(skb); const struct lwtunnel_encap_ops *ops; struct lwtunnel_state *lwtstate; - int ret = -EINVAL; + struct dst_entry *dst; + int ret; - if (!dst) + if (dev_xmit_recursion()) { + net_crit_ratelimited("%s(): recursion limit reached on datapath\n", + __func__); + ret = -ENETDOWN; goto drop; + } + + dst = skb_dst(skb); + if (!dst) { + ret = -EINVAL; + goto drop; + } lwtstate = dst->lwtstate; if (lwtstate->type == LWTUNNEL_ENCAP_NONE || @@ -410,8 +448,11 @@ int lwtunnel_input(struct sk_buff *skb) ret = -EOPNOTSUPP; rcu_read_lock(); ops = rcu_dereference(lwtun_encaps[lwtstate->type]); - if (likely(ops && ops->input)) + if (likely(ops && ops->input)) { + dev_xmit_recursion_inc(); ret = ops->input(skb); + dev_xmit_recursion_dec(); + } rcu_read_unlock(); if (ret == -EOPNOTSUPP) -- 2.51.0 From 3e7a60b368eadf6c30a4a79dea1eb8f88b6d620d Mon Sep 17 00:00:00 2001 From: Justin Iurman Date: Fri, 14 Mar 2025 13:00:47 +0100 Subject: [PATCH 05/16] net: ipv6: ioam6: fix lwtunnel_output() loop Fix the lwtunnel_output() reentry loop in ioam6_iptunnel when the destination is the same after transformation. Note that a check on the destination address was already performed, but it was not enough. This is the example of a lwtunnel user taking care of loops without relying only on the last resort detection offered by lwtunnel. Fixes: 8cb3bf8bff3c ("ipv6: ioam: Add support for the ip6ip6 encapsulation") Signed-off-by: Justin Iurman Link: https://patch.msgid.link/20250314120048.12569-3-justin.iurman@uliege.be Signed-off-by: Paolo Abeni --- net/ipv6/ioam6_iptunnel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c index 2c383c12a431..09065187378e 100644 --- a/net/ipv6/ioam6_iptunnel.c +++ b/net/ipv6/ioam6_iptunnel.c @@ -337,7 +337,6 @@ static int ioam6_do_encap(struct net *net, struct sk_buff *skb, static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb) { struct dst_entry *dst = skb_dst(skb), *cache_dst = NULL; - struct in6_addr orig_daddr; struct ioam6_lwt *ilwt; int err = -EINVAL; u32 pkt_cnt; @@ -352,8 +351,6 @@ static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb) if (pkt_cnt % ilwt->freq.n >= ilwt->freq.k) goto out; - orig_daddr = ipv6_hdr(skb)->daddr; - local_bh_disable(); cache_dst = dst_cache_get(&ilwt->cache); local_bh_enable(); @@ -422,7 +419,10 @@ do_encap: goto drop; } - if (!ipv6_addr_equal(&orig_daddr, &ipv6_hdr(skb)->daddr)) { + /* avoid lwtunnel_output() reentry loop when destination is the same + * after transformation (e.g., with the inline mode) + */ + if (dst->lwtstate != cache_dst->lwtstate) { skb_dst_drop(skb); skb_dst_set(skb, cache_dst); return dst_output(net, sk, skb); -- 2.51.0 From 3ed61b8938c66680e13a1d1929afb9b145c26a86 Mon Sep 17 00:00:00 2001 From: Justin Iurman Date: Fri, 14 Mar 2025 13:00:48 +0100 Subject: [PATCH 06/16] selftests: net: test for lwtunnel dst ref loops As recently specified by commit 0ea09cbf8350 ("docs: netdev: add a note on selftest posting") in net-next, the selftest is therefore shipped in this series. However, this selftest does not really test this series. It needs this series to avoid crashing the kernel. What it really tests, thanks to kmemleak, is what was fixed by the following commits: - commit c71a192976de ("net: ipv6: fix dst refleaks in rpl, seg6 and ioam6 lwtunnels") - commit 92191dd10730 ("net: ipv6: fix dst ref loops in rpl, seg6 and ioam6 lwtunnels") - commit c64a0727f9b1 ("net: ipv6: fix dst ref loop on input in seg6 lwt") - commit 13e55fbaec17 ("net: ipv6: fix dst ref loop on input in rpl lwt") - commit 0e7633d7b95b ("net: ipv6: fix dst ref loop in ila lwtunnel") - commit 5da15a9c11c1 ("net: ipv6: fix missing dst ref drop in ila lwtunnel") Signed-off-by: Justin Iurman Link: https://patch.msgid.link/20250314120048.12569-4-justin.iurman@uliege.be Signed-off-by: Paolo Abeni --- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/config | 2 + .../selftests/net/lwt_dst_cache_ref_loop.sh | 246 ++++++++++++++++++ 3 files changed, 249 insertions(+) create mode 100755 tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 5916f3b81c39..843ab747645d 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -101,6 +101,7 @@ TEST_PROGS += vlan_bridge_binding.sh TEST_PROGS += bpf_offload.py TEST_PROGS += ipv6_route_update_soft_lockup.sh TEST_PROGS += busy_poll_test.sh +TEST_PROGS += lwt_dst_cache_ref_loop.sh # YNL files, must be before "include ..lib.mk" YNL_GEN_FILES := busy_poller netlink-dumps diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index 5b9baf708950..61e5116987f3 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -107,3 +107,5 @@ CONFIG_XFRM_INTERFACE=m CONFIG_XFRM_USER=m CONFIG_IP_NF_MATCH_RPFILTER=m CONFIG_IP6_NF_MATCH_RPFILTER=m +CONFIG_IPV6_ILA=m +CONFIG_IPV6_RPL_LWTUNNEL=y diff --git a/tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh b/tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh new file mode 100755 index 000000000000..881eb399798f --- /dev/null +++ b/tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh @@ -0,0 +1,246 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# +# Author: Justin Iurman +# +# WARNING +# ------- +# This is just a dummy script that triggers encap cases with possible dst cache +# reference loops in affected lwt users (see list below). Some cases are +# pathological configurations for simplicity, others are valid. Overall, we +# don't want this issue to happen, no matter what. In order to catch any +# reference loops, kmemleak MUST be used. The results alone are always blindly +# successful, don't rely on them. Note that the following tests may crash the +# kernel if the fix to prevent lwtunnel_{input|output|xmit}() reentry loops is +# not present. +# +# Affected lwt users so far (please update accordingly if needed): +# - ila_lwt (output only) +# - ioam6_iptunnel (output only) +# - rpl_iptunnel (both input and output) +# - seg6_iptunnel (both input and output) + +source lib.sh + +check_compatibility() +{ + setup_ns tmp_node &>/dev/null + if [ $? != 0 ]; then + echo "SKIP: Cannot create netns." + exit $ksft_skip + fi + + ip link add name veth0 netns $tmp_node type veth \ + peer name veth1 netns $tmp_node &>/dev/null + local ret=$? + + ip -netns $tmp_node link set veth0 up &>/dev/null + ret=$((ret + $?)) + + ip -netns $tmp_node link set veth1 up &>/dev/null + ret=$((ret + $?)) + + if [ $ret != 0 ]; then + echo "SKIP: Cannot configure links." + cleanup_ns $tmp_node + exit $ksft_skip + fi + + lsmod 2>/dev/null | grep -q "ila" + ila_lsmod=$? + [ $ila_lsmod != 0 ] && modprobe ila &>/dev/null + + ip -netns $tmp_node route add 2001:db8:1::/64 \ + encap ila 1:2:3:4 csum-mode no-action ident-type luid \ + hook-type output \ + dev veth0 &>/dev/null + + ip -netns $tmp_node route add 2001:db8:2::/64 \ + encap ioam6 trace prealloc type 0x800000 ns 0 size 4 \ + dev veth0 &>/dev/null + + ip -netns $tmp_node route add 2001:db8:3::/64 \ + encap rpl segs 2001:db8:3::1 dev veth0 &>/dev/null + + ip -netns $tmp_node route add 2001:db8:4::/64 \ + encap seg6 mode inline segs 2001:db8:4::1 dev veth0 &>/dev/null + + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap ila" + skip_ila=$? + + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap ioam6" + skip_ioam6=$? + + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap rpl" + skip_rpl=$? + + ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap seg6" + skip_seg6=$? + + cleanup_ns $tmp_node +} + +setup() +{ + setup_ns alpha beta gamma &>/dev/null + + ip link add name veth-alpha netns $alpha type veth \ + peer name veth-betaL netns $beta &>/dev/null + + ip link add name veth-betaR netns $beta type veth \ + peer name veth-gamma netns $gamma &>/dev/null + + ip -netns $alpha link set veth-alpha name veth0 &>/dev/null + ip -netns $beta link set veth-betaL name veth0 &>/dev/null + ip -netns $beta link set veth-betaR name veth1 &>/dev/null + ip -netns $gamma link set veth-gamma name veth0 &>/dev/null + + ip -netns $alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null + ip -netns $alpha link set veth0 up &>/dev/null + ip -netns $alpha link set lo up &>/dev/null + ip -netns $alpha route add 2001:db8:2::/64 \ + via 2001:db8:1::1 dev veth0 &>/dev/null + + ip -netns $beta addr add 2001:db8:1::1/64 dev veth0 &>/dev/null + ip -netns $beta addr add 2001:db8:2::1/64 dev veth1 &>/dev/null + ip -netns $beta link set veth0 up &>/dev/null + ip -netns $beta link set veth1 up &>/dev/null + ip -netns $beta link set lo up &>/dev/null + ip -netns $beta route del 2001:db8:2::/64 + ip -netns $beta route add 2001:db8:2::/64 dev veth1 + ip netns exec $beta \ + sysctl -wq net.ipv6.conf.all.forwarding=1 &>/dev/null + + ip -netns $gamma addr add 2001:db8:2::2/64 dev veth0 &>/dev/null + ip -netns $gamma link set veth0 up &>/dev/null + ip -netns $gamma link set lo up &>/dev/null + ip -netns $gamma route add 2001:db8:1::/64 \ + via 2001:db8:2::1 dev veth0 &>/dev/null + + sleep 1 + + ip netns exec $alpha ping6 -c 5 -W 1 2001:db8:2::2 &>/dev/null + if [ $? != 0 ]; then + echo "SKIP: Setup failed." + exit $ksft_skip + fi + + sleep 1 +} + +cleanup() +{ + cleanup_ns $alpha $beta $gamma + [ $ila_lsmod != 0 ] && modprobe -r ila &>/dev/null +} + +run_ila() +{ + if [ $skip_ila != 0 ]; then + echo "SKIP: ila (output)" + return + fi + + ip -netns $beta route del 2001:db8:2::/64 + ip -netns $beta route add 2001:db8:2:0:0:0:0:2/128 \ + encap ila 2001:db8:2:0 csum-mode no-action ident-type luid \ + hook-type output \ + dev veth1 &>/dev/null + sleep 1 + + echo "TEST: ila (output)" + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null + sleep 1 + + ip -netns $beta route del 2001:db8:2:0:0:0:0:2/128 + ip -netns $beta route add 2001:db8:2::/64 dev veth1 + sleep 1 +} + +run_ioam6() +{ + if [ $skip_ioam6 != 0 ]; then + echo "SKIP: ioam6 (output)" + return + fi + + ip -netns $beta route change 2001:db8:2::/64 \ + encap ioam6 trace prealloc type 0x800000 ns 1 size 4 \ + dev veth1 &>/dev/null + sleep 1 + + echo "TEST: ioam6 (output)" + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null + sleep 1 +} + +run_rpl() +{ + if [ $skip_rpl != 0 ]; then + echo "SKIP: rpl (input)" + echo "SKIP: rpl (output)" + return + fi + + ip -netns $beta route change 2001:db8:2::/64 \ + encap rpl segs 2001:db8:2::2 \ + dev veth1 &>/dev/null + sleep 1 + + echo "TEST: rpl (input)" + ip netns exec $alpha ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null + sleep 1 + + echo "TEST: rpl (output)" + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null + sleep 1 +} + +run_seg6() +{ + if [ $skip_seg6 != 0 ]; then + echo "SKIP: seg6 (input)" + echo "SKIP: seg6 (output)" + return + fi + + ip -netns $beta route change 2001:db8:2::/64 \ + encap seg6 mode inline segs 2001:db8:2::2 \ + dev veth1 &>/dev/null + sleep 1 + + echo "TEST: seg6 (input)" + ip netns exec $alpha ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null + sleep 1 + + echo "TEST: seg6 (output)" + ip netns exec $beta ping6 -c 2 -W 1 2001:db8:2::2 &>/dev/null + sleep 1 +} + +run() +{ + run_ila + run_ioam6 + run_rpl + run_seg6 +} + +if [ "$(id -u)" -ne 0 ]; then + echo "SKIP: Need root privileges." + exit $ksft_skip +fi + +if [ ! -x "$(command -v ip)" ]; then + echo "SKIP: Could not run test without ip tool." + exit $ksft_skip +fi + +check_compatibility + +trap cleanup EXIT + +setup +run + +exit $ksft_pass -- 2.51.0 From 2c1f97a52cb827a5f2768e67a9dddffae1ed47ab Mon Sep 17 00:00:00 2001 From: Arthur Mongodin Date: Fri, 14 Mar 2025 21:11:31 +0100 Subject: [PATCH 07/16] mptcp: Fix data stream corruption in the address announcement Because of the size restriction in the TCP options space, the MPTCP ADD_ADDR option is exclusive and cannot be sent with other MPTCP ones. For this reason, in the linked mptcp_out_options structure, group of fields linked to different options are part of the same union. There is a case where the mptcp_pm_add_addr_signal() function can modify opts->addr, but not ended up sending an ADD_ADDR. Later on, back in mptcp_established_options, other options will be sent, but with unexpected data written in other fields due to the union, e.g. in opts->ext_copy. This could lead to a data stream corruption in the next packet. Using an intermediate variable, prevents from corrupting previously established DSS option. The assignment of the ADD_ADDR option parameters is now done once we are sure this ADD_ADDR option can be set in the packet, e.g. after having dropped other suboptions. Fixes: 1bff1e43a30e ("mptcp: optimize out option generation") Cc: stable@vger.kernel.org Suggested-by: Paolo Abeni Signed-off-by: Arthur Mongodin Reviewed-by: Matthieu Baerts (NGI0) [ Matt: the commit message has been updated: long lines splits and some clarifications. ] Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250314-net-mptcp-fix-data-stream-corr-sockopt-v1-1-122dbb249db3@kernel.org Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index fd2de185bc93..23949ae2a3a8 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -651,6 +651,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff * struct mptcp_sock *msk = mptcp_sk(subflow->conn); bool drop_other_suboptions = false; unsigned int opt_size = *size; + struct mptcp_addr_info addr; bool echo; int len; @@ -659,7 +660,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff * */ if (!mptcp_pm_should_add_signal(msk) || (opts->suboptions & (OPTION_MPTCP_MPJ_ACK | OPTION_MPTCP_MPC_ACK)) || - !mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &opts->addr, + !mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &addr, &echo, &drop_other_suboptions)) return false; @@ -672,7 +673,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff * else if (opts->suboptions & OPTION_MPTCP_DSS) return false; - len = mptcp_add_addr_len(opts->addr.family, echo, !!opts->addr.port); + len = mptcp_add_addr_len(addr.family, echo, !!addr.port); if (remaining < len) return false; @@ -689,6 +690,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff * opts->ahmac = 0; *size -= opt_size; } + opts->addr = addr; opts->suboptions |= OPTION_MPTCP_ADD_ADDR; if (!echo) { MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDRTX); -- 2.51.0 From 23b763302ce068d7c97441e75434dc9f903adc7d Mon Sep 17 00:00:00 2001 From: Alexander Mikhalitsyn Date: Fri, 14 Mar 2025 22:41:54 +0100 Subject: [PATCH 08/16] tools headers: Sync uapi/asm-generic/socket.h with the kernel sources This also fixes a wrong definitions for SCM_TS_OPT_ID & SO_RCVPRIORITY. Accidentally found while working on another patchset. Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Vadim Fedorenko Cc: Willem de Bruijn Cc: Jason Xing Cc: Anna Emese Nyiri Cc: Kuniyuki Iwashima Cc: Paolo Abeni Fixes: a89568e9be75 ("selftests: txtimestamp: add SCM_TS_OPT_ID test") Fixes: e45469e594b2 ("sock: Introduce SO_RCVPRIORITY socket option") Link: https://lore.kernel.org/netdev/20250314195257.34854-1-kuniyu@amazon.com/ Reviewed-by: Kuniyuki Iwashima Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Willem de Bruijn Reviewed-by: Jason Xing Link: https://patch.msgid.link/20250314214155.16046-1-aleksandr.mikhalitsyn@canonical.com Signed-off-by: Paolo Abeni --- tools/include/uapi/asm-generic/socket.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/include/uapi/asm-generic/socket.h b/tools/include/uapi/asm-generic/socket.h index ffff554a5230..aa5016ff3d91 100644 --- a/tools/include/uapi/asm-generic/socket.h +++ b/tools/include/uapi/asm-generic/socket.h @@ -119,14 +119,31 @@ #define SO_DETACH_REUSEPORT_BPF 68 +#define SO_PREFER_BUSY_POLL 69 +#define SO_BUSY_POLL_BUDGET 70 + +#define SO_NETNS_COOKIE 71 + +#define SO_BUF_LOCK 72 + +#define SO_RESERVE_MEM 73 + +#define SO_TXREHASH 74 + #define SO_RCVMARK 75 #define SO_PASSPIDFD 76 #define SO_PEERPIDFD 77 -#define SCM_TS_OPT_ID 78 +#define SO_DEVMEM_LINEAR 78 +#define SCM_DEVMEM_LINEAR SO_DEVMEM_LINEAR +#define SO_DEVMEM_DMABUF 79 +#define SCM_DEVMEM_DMABUF SO_DEVMEM_DMABUF +#define SO_DEVMEM_DONTNEED 80 + +#define SCM_TS_OPT_ID 81 -#define SO_RCVPRIORITY 79 +#define SO_RCVPRIORITY 82 #if !defined(__KERNEL__) -- 2.51.0 From 90a7138619a0c55e2aefaad27b12ffc2ddbeed78 Mon Sep 17 00:00:00 2001 From: Lin Ma Date: Sun, 16 Mar 2025 00:51:13 +0800 Subject: [PATCH 09/16] net/neighbor: add missing policy for NDTPA_QUEUE_LENBYTES Previous commit 8b5c171bb3dc ("neigh: new unresolved queue limits") introduces new netlink attribute NDTPA_QUEUE_LENBYTES to represent approximative value for deprecated QUEUE_LEN. However, it forgot to add the associated nla_policy in nl_ntbl_parm_policy array. Fix it with one simple NLA_U32 type policy. Fixes: 8b5c171bb3dc ("neigh: new unresolved queue limits") Signed-off-by: Lin Ma Link: https://patch.msgid.link/20250315165113.37600-1-linma@zju.edu.cn Signed-off-by: Paolo Abeni --- net/core/neighbour.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index bd0251bd74a1..1a620f903c56 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -2250,6 +2250,7 @@ static const struct nla_policy nl_neightbl_policy[NDTA_MAX+1] = { static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = { [NDTPA_IFINDEX] = { .type = NLA_U32 }, [NDTPA_QUEUE_LEN] = { .type = NLA_U32 }, + [NDTPA_QUEUE_LENBYTES] = { .type = NLA_U32 }, [NDTPA_PROXY_QLEN] = { .type = NLA_U32 }, [NDTPA_APP_PROBES] = { .type = NLA_U32 }, [NDTPA_UCAST_PROBES] = { .type = NLA_U32 }, -- 2.51.0 From 355d940f4d5ae56ed082a455ce2cc737c7e898e8 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 19 Mar 2025 22:26:45 +0100 Subject: [PATCH 10/16] Revert "selftests: Add IPv6 link-local address generation tests for GRE devices." This reverts commit 6f50175ccad4278ed3a9394c00b797b75441bd6e. Commit 183185a18ff9 ("gre: Fix IPv6 link-local address generation.") is going to be reverted. So let's revert the corresponding kselftest first. Signed-off-by: Guillaume Nault Link: https://patch.msgid.link/259a9e98f7f1be7ce02b53d0b4afb7c18a8ff747.1742418408.git.gnault@redhat.com Acked-by: Stanislav Fomichev Signed-off-by: Paolo Abeni --- tools/testing/selftests/net/Makefile | 1 - .../testing/selftests/net/gre_ipv6_lladdr.sh | 177 ------------------ 2 files changed, 178 deletions(-) delete mode 100755 tools/testing/selftests/net/gre_ipv6_lladdr.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 843ab747645d..8f32b4f01aee 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -31,7 +31,6 @@ TEST_PROGS += veth.sh TEST_PROGS += ioam6.sh TEST_PROGS += gro.sh TEST_PROGS += gre_gso.sh -TEST_PROGS += gre_ipv6_lladdr.sh TEST_PROGS += cmsg_so_mark.sh TEST_PROGS += cmsg_so_priority.sh TEST_PROGS += cmsg_time.sh cmsg_ipv6.sh diff --git a/tools/testing/selftests/net/gre_ipv6_lladdr.sh b/tools/testing/selftests/net/gre_ipv6_lladdr.sh deleted file mode 100755 index 5b34f6e1f831..000000000000 --- a/tools/testing/selftests/net/gre_ipv6_lladdr.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 - -source ./lib.sh - -PAUSE_ON_FAIL="no" - -# The trap function handler -# -exit_cleanup_all() -{ - cleanup_all_ns - - exit "${EXIT_STATUS}" -} - -# Add fake IPv4 and IPv6 networks on the loopback device, to be used as -# underlay by future GRE devices. -# -setup_basenet() -{ - ip -netns "${NS0}" link set dev lo up - ip -netns "${NS0}" address add dev lo 192.0.2.10/24 - ip -netns "${NS0}" address add dev lo 2001:db8::10/64 nodad -} - -# Check if network device has an IPv6 link-local address assigned. -# -# Parameters: -# -# * $1: The network device to test -# * $2: An extra regular expression that should be matched (to verify the -# presence of extra attributes) -# * $3: The expected return code from grep (to allow checking the absence of -# a link-local address) -# * $4: The user visible name for the scenario being tested -# -check_ipv6_ll_addr() -{ - local DEV="$1" - local EXTRA_MATCH="$2" - local XRET="$3" - local MSG="$4" - - RET=0 - set +e - ip -netns "${NS0}" -6 address show dev "${DEV}" scope link | grep "fe80::" | grep -q "${EXTRA_MATCH}" - check_err_fail "${XRET}" $? "" - log_test "${MSG}" - set -e -} - -# Create a GRE device and verify that it gets an IPv6 link-local address as -# expected. -# -# Parameters: -# -# * $1: The device type (gre, ip6gre, gretap or ip6gretap) -# * $2: The local underlay IP address (can be an IPv4, an IPv6 or "any") -# * $3: The remote underlay IP address (can be an IPv4, an IPv6 or "any") -# * $4: The IPv6 interface identifier generation mode to use for the GRE -# device (eui64, none, stable-privacy or random). -# -test_gre_device() -{ - local GRE_TYPE="$1" - local LOCAL_IP="$2" - local REMOTE_IP="$3" - local MODE="$4" - local ADDR_GEN_MODE - local MATCH_REGEXP - local MSG - - ip link add netns "${NS0}" name gretest type "${GRE_TYPE}" local "${LOCAL_IP}" remote "${REMOTE_IP}" - - case "${MODE}" in - "eui64") - ADDR_GEN_MODE=0 - MATCH_REGEXP="" - MSG="${GRE_TYPE}, mode: 0 (EUI64), ${LOCAL_IP} -> ${REMOTE_IP}" - XRET=0 - ;; - "none") - ADDR_GEN_MODE=1 - MATCH_REGEXP="" - MSG="${GRE_TYPE}, mode: 1 (none), ${LOCAL_IP} -> ${REMOTE_IP}" - XRET=1 # No link-local address should be generated - ;; - "stable-privacy") - ADDR_GEN_MODE=2 - MATCH_REGEXP="stable-privacy" - MSG="${GRE_TYPE}, mode: 2 (stable privacy), ${LOCAL_IP} -> ${REMOTE_IP}" - XRET=0 - # Initialise stable_secret (required for stable-privacy mode) - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.stable_secret="2001:db8::abcd" - ;; - "random") - ADDR_GEN_MODE=3 - MATCH_REGEXP="stable-privacy" - MSG="${GRE_TYPE}, mode: 3 (random), ${LOCAL_IP} -> ${REMOTE_IP}" - XRET=0 - ;; - esac - - # Check that IPv6 link-local address is generated when device goes up - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}" - ip -netns "${NS0}" link set dev gretest up - check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "config: ${MSG}" - - # Now disable link-local address generation - ip -netns "${NS0}" link set dev gretest down - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode=1 - ip -netns "${NS0}" link set dev gretest up - - # Check that link-local address generation works when re-enabled while - # the device is already up - ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}" - check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "update: ${MSG}" - - ip -netns "${NS0}" link del dev gretest -} - -test_gre4() -{ - local GRE_TYPE - local MODE - - for GRE_TYPE in "gre" "gretap"; do - printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n" - - for MODE in "eui64" "none" "stable-privacy" "random"; do - test_gre_device "${GRE_TYPE}" 192.0.2.10 192.0.2.11 "${MODE}" - test_gre_device "${GRE_TYPE}" any 192.0.2.11 "${MODE}" - test_gre_device "${GRE_TYPE}" 192.0.2.10 any "${MODE}" - done - done -} - -test_gre6() -{ - local GRE_TYPE - local MODE - - for GRE_TYPE in "ip6gre" "ip6gretap"; do - printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n" - - for MODE in "eui64" "none" "stable-privacy" "random"; do - test_gre_device "${GRE_TYPE}" 2001:db8::10 2001:db8::11 "${MODE}" - test_gre_device "${GRE_TYPE}" any 2001:db8::11 "${MODE}" - test_gre_device "${GRE_TYPE}" 2001:db8::10 any "${MODE}" - done - done -} - -usage() -{ - echo "Usage: $0 [-p]" - exit 1 -} - -while getopts :p o -do - case $o in - p) PAUSE_ON_FAIL="yes";; - *) usage;; - esac -done - -setup_ns NS0 - -set -e -trap exit_cleanup_all EXIT - -setup_basenet - -test_gre4 -test_gre6 -- 2.51.0 From fc486c2d060f67d672ddad81724f7c8a4d329570 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 19 Mar 2025 22:26:50 +0100 Subject: [PATCH 11/16] Revert "gre: Fix IPv6 link-local address generation." This reverts commit 183185a18ff96751db52a46ccf93fff3a1f42815. This patch broke net/forwarding/ip6gre_custom_multipath_hash.sh in some circumstances (https://lore.kernel.org/netdev/Z9RIyKZDNoka53EO@mini-arch/). Let's revert it while the problem is being investigated. Fixes: 183185a18ff9 ("gre: Fix IPv6 link-local address generation.") Signed-off-by: Guillaume Nault Link: https://patch.msgid.link/8b1ce738eb15dd841aab9ef888640cab4f6ccfea.1742418408.git.gnault@redhat.com Acked-by: Stanislav Fomichev Signed-off-by: Paolo Abeni --- net/ipv6/addrconf.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 8b6258819dad..ac8cc1076536 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -3209,13 +3209,16 @@ static void add_v4_addrs(struct inet6_dev *idev) struct in6_addr addr; struct net_device *dev; struct net *net = dev_net(idev->dev); - int scope, plen; + int scope, plen, offset = 0; u32 pflags = 0; ASSERT_RTNL(); memset(&addr, 0, sizeof(struct in6_addr)); - memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4); + /* in case of IP6GRE the dev_addr is an IPv6 and therefore we use only the last 4 bytes */ + if (idev->dev->addr_len == sizeof(struct in6_addr)) + offset = sizeof(struct in6_addr) - 4; + memcpy(&addr.s6_addr32[3], idev->dev->dev_addr + offset, 4); if (!(idev->dev->flags & IFF_POINTOPOINT) && idev->dev->type == ARPHRD_SIT) { scope = IPV6_ADDR_COMPATv4; @@ -3526,13 +3529,7 @@ static void addrconf_gre_config(struct net_device *dev) return; } - /* Generate the IPv6 link-local address using addrconf_addr_gen(), - * unless we have an IPv4 GRE device not bound to an IP address and - * which is in EUI64 mode (as __ipv6_isatap_ifid() would fail in this - * case). Such devices fall back to add_v4_addrs() instead. - */ - if (!(dev->type == ARPHRD_IPGRE && *(__be32 *)dev->dev_addr == 0 && - idev->cnf.addr_gen_mode == IN6_ADDR_GEN_MODE_EUI64)) { + if (dev->type == ARPHRD_ETHER) { addrconf_addr_gen(idev, true); return; } -- 2.51.0 From feaee98c6c505494e2188e5c644b881f5c81ee59 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Wed, 12 Mar 2025 10:22:12 +0100 Subject: [PATCH 12/16] MAINTAINERS: Add Andrea Mayer as a maintainer of SRv6 Andrea has made significant contributions to SRv6 support in Linux. Acknowledge the work and on-going interest in Srv6 support with a maintainers entry for these files so hopefully he is included on patches going forward. Signed-off-by: David Ahern Acked-by: Andrea Mayer Link: https://patch.msgid.link/20250312092212.46299-1-dsahern@kernel.org Signed-off-by: Paolo Abeni --- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 625f3758c880..1ca95d95c489 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16663,6 +16663,17 @@ F: net/mptcp/ F: tools/testing/selftests/bpf/*/*mptcp*.[ch] F: tools/testing/selftests/net/mptcp/ +NETWORKING [SRv6] +M: Andrea Mayer +L: netdev@vger.kernel.org +S: Maintained +T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git +F: include/linux/seg6* +F: include/net/seg6* +F: include/uapi/linux/seg6* +F: net/ipv6/seg6* +F: tools/testing/selftests/net/srv6* + NETWORKING [TCP] M: Eric Dumazet M: Neal Cardwell -- 2.51.0 From 3fed9fda150d393d3f3f91a5631dab1e0c15d582 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 12 Mar 2025 09:51:19 +0100 Subject: [PATCH 13/16] net: remove sb1000 cable modem driver This one is hilariously outdated, it provided a faster downlink over TV cable for users of analog modems in the 1990s, through an ISA card. The web page for the userspace tools has been broken for 25 years, and the driver has only ever seen mechanical updates. Link: http://web.archive.org/web/20000611165545/http://home.adelphia.net:80/~siglercm/sb1000.html Signed-off-by: Arnd Bergmann Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250312085236.2531870-1-arnd@kernel.org Signed-off-by: Paolo Abeni --- .../networking/device_drivers/cable/index.rst | 18 - .../device_drivers/cable/sb1000.rst | 222 ---- .../networking/device_drivers/index.rst | 1 - arch/powerpc/configs/ppc6xx_defconfig | 1 - drivers/acpi/acpi_pnp.c | 2 - drivers/net/Kconfig | 24 - drivers/net/Makefile | 1 - drivers/net/sb1000.c | 1179 ----------------- include/uapi/linux/if_cablemodem.h | 23 - 9 files changed, 1471 deletions(-) delete mode 100644 Documentation/networking/device_drivers/cable/index.rst delete mode 100644 Documentation/networking/device_drivers/cable/sb1000.rst delete mode 100644 drivers/net/sb1000.c delete mode 100644 include/uapi/linux/if_cablemodem.h diff --git a/Documentation/networking/device_drivers/cable/index.rst b/Documentation/networking/device_drivers/cable/index.rst deleted file mode 100644 index cce3c4392972..000000000000 --- a/Documentation/networking/device_drivers/cable/index.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) - -Cable Modem Device Drivers -========================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - sb1000 - -.. only:: subproject and html - - Indices - ======= - - * :ref:`genindex` diff --git a/Documentation/networking/device_drivers/cable/sb1000.rst b/Documentation/networking/device_drivers/cable/sb1000.rst deleted file mode 100644 index c8582ca4034d..000000000000 --- a/Documentation/networking/device_drivers/cable/sb1000.rst +++ /dev/null @@ -1,222 +0,0 @@ -.. SPDX-License-Identifier: GPL-2.0 - -=================== -SB100 device driver -=================== - -sb1000 is a module network device driver for the General Instrument (also known -as NextLevel) SURFboard1000 internal cable modem board. This is an ISA card -which is used by a number of cable TV companies to provide cable modem access. -It's a one-way downstream-only cable modem, meaning that your upstream net link -is provided by your regular phone modem. - -This driver was written by Franco Venturi . He deserves -a great deal of thanks for this wonderful piece of code! - -Needed tools -============ - -Support for this device is now a part of the standard Linux kernel. The -driver source code file is drivers/net/sb1000.c. In addition to this -you will need: - -1. The "cmconfig" program. This is a utility which supplements "ifconfig" - to configure the cable modem and network interface (usually called "cm0"); - -2. Several PPP scripts which live in /etc/ppp to make connecting via your - cable modem easy. - - These utilities can be obtained from: - - http://www.jacksonville.net/~fventuri/ - - in Franco's original source code distribution .tar.gz file. Support for - the sb1000 driver can be found at: - - - http://web.archive.org/web/%2E/http://home.adelphia.net/~siglercm/sb1000.html - - http://web.archive.org/web/%2E/http://linuxpower.cx/~cable/ - - along with these utilities. - -3. The standard isapnp tools. These are necessary to configure your SB1000 - card at boot time (or afterwards by hand) since it's a PnP card. - - If you don't have these installed as a standard part of your Linux - distribution, you can find them at: - - http://www.roestock.demon.co.uk/isapnptools/ - - or check your Linux distribution binary CD or their web site. For help with - isapnp, pnpdump, or /etc/isapnp.conf, go to: - - http://www.roestock.demon.co.uk/isapnptools/isapnpfaq.html - -Using the driver -================ - -To make the SB1000 card work, follow these steps: - -1. Run ``make config``, or ``make menuconfig``, or ``make xconfig``, whichever - you prefer, in the top kernel tree directory to set up your kernel - configuration. Make sure to say "Y" to "Prompt for development drivers" - and to say "M" to the sb1000 driver. Also say "Y" or "M" to all the standard - networking questions to get TCP/IP and PPP networking support. - -2. **BEFORE** you build the kernel, edit drivers/net/sb1000.c. Make sure - to redefine the value of READ_DATA_PORT to match the I/O address used - by isapnp to access your PnP cards. This is the value of READPORT in - /etc/isapnp.conf or given by the output of pnpdump. - -3. Build and install the kernel and modules as usual. - -4. Boot your new kernel following the usual procedures. - -5. Set up to configure the new SB1000 PnP card by capturing the output - of "pnpdump" to a file and editing this file to set the correct I/O ports, - IRQ, and DMA settings for all your PnP cards. Make sure none of the settings - conflict with one another. Then test this configuration by running the - "isapnp" command with your new config file as the input. Check for - errors and fix as necessary. (As an aside, I use I/O ports 0x110 and - 0x310 and IRQ 11 for my SB1000 card and these work well for me. YMMV.) - Then save the finished config file as /etc/isapnp.conf for proper - configuration on subsequent reboots. - -6. Download the original file sb1000-1.1.2.tar.gz from Franco's site or one of - the others referenced above. As root, unpack it into a temporary directory - and do a ``make cmconfig`` and then ``install -c cmconfig /usr/local/sbin``. - Don't do ``make install`` because it expects to find all the utilities built - and ready for installation, not just cmconfig. - -7. As root, copy all the files under the ppp/ subdirectory in Franco's - tar file into /etc/ppp, being careful not to overwrite any files that are - already in there. Then modify ppp@gi-on to set the correct login name, - phone number, and frequency for the cable modem. Also edit pap-secrets - to specify your login name and password and any site-specific information - you need. - -8. Be sure to modify /etc/ppp/firewall to use ipchains instead of - the older ipfwadm commands from the 2.0.x kernels. There's a neat utility to - convert ipfwadm commands to ipchains commands: - - http://users.dhp.com/~whisper/ipfwadm2ipchains/ - - You may also wish to modify the firewall script to implement a different - firewalling scheme. - -9. Start the PPP connection via the script /etc/ppp/ppp@gi-on. You must be - root to do this. It's better to use a utility like sudo to execute - frequently used commands like this with root permissions if possible. If you - connect successfully the cable modem interface will come up and you'll see a - driver message like this at the console:: - - cm0: sb1000 at (0x110,0x310), csn 1, S/N 0x2a0d16d8, IRQ 11. - sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net) - - The "ifconfig" command should show two new interfaces, ppp0 and cm0. - - The command "cmconfig cm0" will give you information about the cable modem - interface. - -10. Try pinging a site via ``ping -c 5 www.yahoo.com``, for example. You should - see packets received. - -11. If you can't get site names (like www.yahoo.com) to resolve into - IP addresses (like 204.71.200.67), be sure your /etc/resolv.conf file - has no syntax errors and has the right nameserver IP addresses in it. - If this doesn't help, try something like ``ping -c 5 204.71.200.67`` to - see if the networking is running but the DNS resolution is where the - problem lies. - -12. If you still have problems, go to the support web sites mentioned above - and read the information and documentation there. - -Common problems -=============== - -1. Packets go out on the ppp0 interface but don't come back on the cm0 - interface. It looks like I'm connected but I can't even ping any - numerical IP addresses. (This happens predominantly on Debian systems due - to a default boot-time configuration script.) - -Solution - As root ``echo 0 > /proc/sys/net/ipv4/conf/cm0/rp_filter`` so it - can share the same IP address as the ppp0 interface. Note that this - command should probably be added to the /etc/ppp/cablemodem script - *right*between* the "/sbin/ifconfig" and "/sbin/cmconfig" commands. - You may need to do this to /proc/sys/net/ipv4/conf/ppp0/rp_filter as well. - If you do this to /proc/sys/net/ipv4/conf/default/rp_filter on each reboot - (in rc.local or some such) then any interfaces can share the same IP - addresses. - -2. I get "unresolved symbol" error messages on executing ``insmod sb1000.o``. - -Solution - You probably have a non-matching kernel source tree and - /usr/include/linux and /usr/include/asm header files. Make sure you - install the correct versions of the header files in these two directories. - Then rebuild and reinstall the kernel. - -3. When isapnp runs it reports an error, and my SB1000 card isn't working. - -Solution - There's a problem with later versions of isapnp using the "(CHECK)" - option in the lines that allocate the two I/O addresses for the SB1000 card. - This first popped up on RH 6.0. Delete "(CHECK)" for the SB1000 I/O addresses. - Make sure they don't conflict with any other pieces of hardware first! Then - rerun isapnp and go from there. - -4. I can't execute the /etc/ppp/ppp@gi-on file. - -Solution - As root do ``chmod ug+x /etc/ppp/ppp@gi-on``. - -5. The firewall script isn't working (with 2.2.x and higher kernels). - -Solution - Use the ipfwadm2ipchains script referenced above to convert the - /etc/ppp/firewall script from the deprecated ipfwadm commands to ipchains. - -6. I'm getting *tons* of firewall deny messages in the /var/kern.log, - /var/messages, and/or /var/syslog files, and they're filling up my /var - partition!!! - -Solution - First, tell your ISP that you're receiving DoS (Denial of Service) - and/or portscanning (UDP connection attempts) attacks! Look over the deny - messages to figure out what the attack is and where it's coming from. Next, - edit /etc/ppp/cablemodem and make sure the ",nobroadcast" option is turned on - to the "cmconfig" command (uncomment that line). If you're not receiving these - denied packets on your broadcast interface (IP address xxx.yyy.zzz.255 - typically), then someone is attacking your machine in particular. Be careful - out there.... - -7. Everything seems to work fine but my computer locks up after a while - (and typically during a lengthy download through the cable modem)! - -Solution - You may need to add a short delay in the driver to 'slow down' the - SURFboard because your PC might not be able to keep up with the transfer rate - of the SB1000. To do this, it's probably best to download Franco's - sb1000-1.1.2.tar.gz archive and build and install sb1000.o manually. You'll - want to edit the 'Makefile' and look for the 'SB1000_DELAY' - define. Uncomment those 'CFLAGS' lines (and comment out the default ones) - and try setting the delay to something like 60 microseconds with: - '-DSB1000_DELAY=60'. Then do ``make`` and as root ``make install`` and try - it out. If it still doesn't work or you like playing with the driver, you may - try other numbers. Remember though that the higher the delay, the slower the - driver (which slows down the rest of the PC too when it is actively - used). Thanks to Ed Daiga for this tip! - -Credits -======= - -This README came from Franco Venturi's original README file which is -still supplied with his driver .tar.gz archive. I and all other sb1000 users -owe Franco a tremendous "Thank you!" Additional thanks goes to Carl Patten -and Ralph Bonnell who are now managing the Linux SB1000 web site, and to -the SB1000 users who reported and helped debug the common problems listed -above. - - - Clemmitt Sigler - csigler@vt.edu diff --git a/Documentation/networking/device_drivers/index.rst b/Documentation/networking/device_drivers/index.rst index 0dd30a84ce25..a254af25b7ef 100644 --- a/Documentation/networking/device_drivers/index.rst +++ b/Documentation/networking/device_drivers/index.rst @@ -9,7 +9,6 @@ Contents: :maxdepth: 2 atm/index - cable/index can/index cellular/index ethernet/index diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig index ca0c90e95837..e69260b5d67f 100644 --- a/arch/powerpc/configs/ppc6xx_defconfig +++ b/arch/powerpc/configs/ppc6xx_defconfig @@ -485,7 +485,6 @@ CONFIG_VIA_VELOCITY=m CONFIG_PCMCIA_XIRC2PS=m CONFIG_FDDI=y CONFIG_SKFP=m -CONFIG_NET_SB1000=m CONFIG_BROADCOM_PHY=m CONFIG_CICADA_PHY=m CONFIG_DAVICOM_PHY=m diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c index 01abf26764b0..435ec60a9682 100644 --- a/drivers/acpi/acpi_pnp.c +++ b/drivers/acpi/acpi_pnp.c @@ -120,8 +120,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {"IBM0071"}, /* smsc-ircc2 */ {"SMCf010"}, - /* sb1000 */ - {"GIC1000"}, /* parport_pc */ {"PNP0400"}, /* Standard LPT Printer Port */ {"PNP0401"}, /* ECP Printer Port */ diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 1fd5acdc73c6..271520510b5f 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -518,30 +518,6 @@ source "drivers/net/hippi/Kconfig" source "drivers/net/ipa/Kconfig" -config NET_SB1000 - tristate "General Instruments Surfboard 1000" - depends on ISA && PNP - help - This is a driver for the General Instrument (also known as - NextLevel) SURFboard 1000 internal - cable modem. This is an ISA card which is used by a number of cable - TV companies to provide cable modem access. It's a one-way - downstream-only cable modem, meaning that your upstream net link is - provided by your regular phone modem. - - At present this driver only compiles as a module, so say M here if - you have this card. The module will be called sb1000. Then read - for - information on how to use this module, as it needs special ppp - scripts for establishing a connection. Further documentation - and the necessary scripts can be found at: - - - - - - If you don't have this card, of course say N. - source "drivers/net/phy/Kconfig" source "drivers/net/pse-pd/Kconfig" diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 13743d0e83b5..75333251a01a 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -69,7 +69,6 @@ obj-$(CONFIG_PPPOL2TP) += ppp/ obj-$(CONFIG_PPTP) += ppp/ obj-$(CONFIG_SLIP) += slip/ obj-$(CONFIG_SLHC) += slip/ -obj-$(CONFIG_NET_SB1000) += sb1000.o obj-$(CONFIG_SUNGEM_PHY) += sungem_phy.o obj-$(CONFIG_WAN) += wan/ obj-$(CONFIG_WLAN) += wireless/ diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c deleted file mode 100644 index c3f8020571ad..000000000000 --- a/drivers/net/sb1000.c +++ /dev/null @@ -1,1179 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* sb1000.c: A General Instruments SB1000 driver for linux. */ -/* - Written 1998 by Franco Venturi. - - Copyright 1998 by Franco Venturi. - Copyright 1994,1995 by Donald Becker. - Copyright 1993 United States Government as represented by the - Director, National Security Agency. - - This driver is for the General Instruments SB1000 (internal SURFboard) - - The author may be reached as fventuri@mediaone.net - - - Changes: - - 981115 Steven Hirsch - - Linus changed the timer interface. Should work on all recent - development kernels. - - 980608 Steven Hirsch - - Small changes to make it work with 2.1.x kernels. Hopefully, - nothing major will change before official release of Linux 2.2. - - Merged with 2.2 - Alan Cox -*/ - -static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n"; - -#include -#include -#include -#include -#include -#include -#include /* for SIOGCM/SIOSCM stuff */ -#include -#include -#include -#include -#include -#include /* for udelay() */ -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef SB1000_DEBUG -static int sb1000_debug = SB1000_DEBUG; -#else -static const int sb1000_debug = 1; -#endif - -static const int SB1000_IO_EXTENT = 8; -/* SB1000 Maximum Receive Unit */ -static const int SB1000_MRU = 1500; /* octects */ - -#define NPIDS 4 -struct sb1000_private { - struct sk_buff *rx_skb[NPIDS]; - short rx_dlen[NPIDS]; - unsigned int rx_frames; - short rx_error_count; - short rx_error_dpc_count; - unsigned char rx_session_id[NPIDS]; - unsigned char rx_frame_id[NPIDS]; - unsigned char rx_pkt_type[NPIDS]; -}; - -/* prototypes for Linux interface */ -extern int sb1000_probe(struct net_device *dev); -static int sb1000_open(struct net_device *dev); -static int sb1000_siocdevprivate(struct net_device *dev, struct ifreq *ifr, - void __user *data, int cmd); -static netdev_tx_t sb1000_start_xmit(struct sk_buff *skb, - struct net_device *dev); -static irqreturn_t sb1000_interrupt(int irq, void *dev_id); -static int sb1000_close(struct net_device *dev); - - -/* SB1000 hardware routines to be used during open/configuration phases */ -static int card_wait_for_busy_clear(const int ioaddr[], - const char* name); -static int card_wait_for_ready(const int ioaddr[], const char* name, - unsigned char in[]); -static int card_send_command(const int ioaddr[], const char* name, - const unsigned char out[], unsigned char in[]); - -/* SB1000 hardware routines to be used during frame rx interrupt */ -static int sb1000_wait_for_ready(const int ioaddr[], const char* name); -static int sb1000_wait_for_ready_clear(const int ioaddr[], - const char* name); -static void sb1000_send_command(const int ioaddr[], const char* name, - const unsigned char out[]); -static void sb1000_read_status(const int ioaddr[], unsigned char in[]); -static void sb1000_issue_read_command(const int ioaddr[], - const char* name); - -/* SB1000 commands for open/configuration */ -static int sb1000_reset(const int ioaddr[], const char* name); -static int sb1000_check_CRC(const int ioaddr[], const char* name); -static inline int sb1000_start_get_set_command(const int ioaddr[], - const char* name); -static int sb1000_end_get_set_command(const int ioaddr[], - const char* name); -static int sb1000_activate(const int ioaddr[], const char* name); -static int sb1000_get_firmware_version(const int ioaddr[], - const char* name, unsigned char version[], int do_end); -static int sb1000_get_frequency(const int ioaddr[], const char* name, - int* frequency); -static int sb1000_set_frequency(const int ioaddr[], const char* name, - int frequency); -static int sb1000_get_PIDs(const int ioaddr[], const char* name, - short PID[]); -static int sb1000_set_PIDs(const int ioaddr[], const char* name, - const short PID[]); - -/* SB1000 commands for frame rx interrupt */ -static int sb1000_rx(struct net_device *dev); -static void sb1000_error_dpc(struct net_device *dev); - -static const struct pnp_device_id sb1000_pnp_ids[] = { - { "GIC1000", 0 }, - { "", 0 } -}; -MODULE_DEVICE_TABLE(pnp, sb1000_pnp_ids); - -static const struct net_device_ops sb1000_netdev_ops = { - .ndo_open = sb1000_open, - .ndo_start_xmit = sb1000_start_xmit, - .ndo_siocdevprivate = sb1000_siocdevprivate, - .ndo_stop = sb1000_close, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; - -static int -sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) -{ - struct net_device *dev; - unsigned short ioaddr[2], irq; - unsigned int serial_number; - int error = -ENODEV; - u8 addr[ETH_ALEN]; - - if (pnp_device_attach(pdev) < 0) - return -ENODEV; - if (pnp_activate_dev(pdev) < 0) - goto out_detach; - - if (!pnp_port_valid(pdev, 0) || !pnp_port_valid(pdev, 1)) - goto out_disable; - if (!pnp_irq_valid(pdev, 0)) - goto out_disable; - - serial_number = pdev->card->serial; - - ioaddr[0] = pnp_port_start(pdev, 0); - ioaddr[1] = pnp_port_start(pdev, 0); - - irq = pnp_irq(pdev, 0); - - if (!request_region(ioaddr[0], 16, "sb1000")) - goto out_disable; - if (!request_region(ioaddr[1], 16, "sb1000")) - goto out_release_region0; - - dev = alloc_etherdev(sizeof(struct sb1000_private)); - if (!dev) { - error = -ENOMEM; - goto out_release_regions; - } - - - dev->base_addr = ioaddr[0]; - /* mem_start holds the second I/O address */ - dev->mem_start = ioaddr[1]; - dev->irq = irq; - - if (sb1000_debug > 0) - printk(KERN_NOTICE "%s: sb1000 at (%#3.3lx,%#3.3lx), " - "S/N %#8.8x, IRQ %d.\n", dev->name, dev->base_addr, - dev->mem_start, serial_number, dev->irq); - - /* - * The SB1000 is an rx-only cable modem device. The uplink is a modem - * and we do not want to arp on it. - */ - dev->flags = IFF_POINTOPOINT|IFF_NOARP; - - SET_NETDEV_DEV(dev, &pdev->dev); - - if (sb1000_debug > 0) - printk(KERN_NOTICE "%s", version); - - dev->netdev_ops = &sb1000_netdev_ops; - - /* hardware address is 0:0:serial_number */ - addr[0] = 0; - addr[1] = 0; - addr[2] = serial_number >> 24 & 0xff; - addr[3] = serial_number >> 16 & 0xff; - addr[4] = serial_number >> 8 & 0xff; - addr[5] = serial_number >> 0 & 0xff; - eth_hw_addr_set(dev, addr); - - pnp_set_drvdata(pdev, dev); - - error = register_netdev(dev); - if (error) - goto out_free_netdev; - return 0; - - out_free_netdev: - free_netdev(dev); - out_release_regions: - release_region(ioaddr[1], 16); - out_release_region0: - release_region(ioaddr[0], 16); - out_disable: - pnp_disable_dev(pdev); - out_detach: - pnp_device_detach(pdev); - return error; -} - -static void -sb1000_remove_one(struct pnp_dev *pdev) -{ - struct net_device *dev = pnp_get_drvdata(pdev); - - unregister_netdev(dev); - release_region(dev->base_addr, 16); - release_region(dev->mem_start, 16); - free_netdev(dev); -} - -static struct pnp_driver sb1000_driver = { - .name = "sb1000", - .id_table = sb1000_pnp_ids, - .probe = sb1000_probe_one, - .remove = sb1000_remove_one, -}; - - -/* - * SB1000 hardware routines to be used during open/configuration phases - */ - -static const int TimeOutJiffies = (875 * HZ) / 100; - -/* Card Wait For Busy Clear (cannot be used during an interrupt) */ -static int -card_wait_for_busy_clear(const int ioaddr[], const char* name) -{ - unsigned char a; - unsigned long timeout; - - a = inb(ioaddr[0] + 7); - timeout = jiffies + TimeOutJiffies; - while (a & 0x80 || a & 0x40) { - /* a little sleep */ - yield(); - - a = inb(ioaddr[0] + 7); - if (time_after_eq(jiffies, timeout)) { - printk(KERN_WARNING "%s: card_wait_for_busy_clear timeout\n", - name); - return -ETIME; - } - } - - return 0; -} - -/* Card Wait For Ready (cannot be used during an interrupt) */ -static int -card_wait_for_ready(const int ioaddr[], const char* name, unsigned char in[]) -{ - unsigned char a; - unsigned long timeout; - - a = inb(ioaddr[1] + 6); - timeout = jiffies + TimeOutJiffies; - while (a & 0x80 || !(a & 0x40)) { - /* a little sleep */ - yield(); - - a = inb(ioaddr[1] + 6); - if (time_after_eq(jiffies, timeout)) { - printk(KERN_WARNING "%s: card_wait_for_ready timeout\n", - name); - return -ETIME; - } - } - - in[1] = inb(ioaddr[0] + 1); - in[2] = inb(ioaddr[0] + 2); - in[3] = inb(ioaddr[0] + 3); - in[4] = inb(ioaddr[0] + 4); - in[0] = inb(ioaddr[0] + 5); - in[6] = inb(ioaddr[0] + 6); - in[5] = inb(ioaddr[1] + 6); - return 0; -} - -/* Card Send Command (cannot be used during an interrupt) */ -static int -card_send_command(const int ioaddr[], const char* name, - const unsigned char out[], unsigned char in[]) -{ - int status; - - if ((status = card_wait_for_busy_clear(ioaddr, name))) - return status; - outb(0xa0, ioaddr[0] + 6); - outb(out[2], ioaddr[0] + 1); - outb(out[3], ioaddr[0] + 2); - outb(out[4], ioaddr[0] + 3); - outb(out[5], ioaddr[0] + 4); - outb(out[1], ioaddr[0] + 5); - outb(0xa0, ioaddr[0] + 6); - outb(out[0], ioaddr[0] + 7); - if (out[0] != 0x20 && out[0] != 0x30) { - if ((status = card_wait_for_ready(ioaddr, name, in))) - return status; - inb(ioaddr[0] + 7); - if (sb1000_debug > 3) - printk(KERN_DEBUG "%s: card_send_command " - "out: %02x%02x%02x%02x%02x%02x " - "in: %02x%02x%02x%02x%02x%02x%02x\n", name, - out[0], out[1], out[2], out[3], out[4], out[5], - in[0], in[1], in[2], in[3], in[4], in[5], in[6]); - } else { - if (sb1000_debug > 3) - printk(KERN_DEBUG "%s: card_send_command " - "out: %02x%02x%02x%02x%02x%02x\n", name, - out[0], out[1], out[2], out[3], out[4], out[5]); - } - - if (out[1] != 0x1b) { - if (out[0] >= 0x80 && in[0] != (out[1] | 0x80)) - return -EIO; - } - return 0; -} - - -/* - * SB1000 hardware routines to be used during frame rx interrupt - */ -static const int Sb1000TimeOutJiffies = 7 * HZ; - -/* Card Wait For Ready (to be used during frame rx) */ -static int -sb1000_wait_for_ready(const int ioaddr[], const char* name) -{ - unsigned long timeout; - - timeout = jiffies + Sb1000TimeOutJiffies; - while (inb(ioaddr[1] + 6) & 0x80) { - if (time_after_eq(jiffies, timeout)) { - printk(KERN_WARNING "%s: sb1000_wait_for_ready timeout\n", - name); - return -ETIME; - } - } - timeout = jiffies + Sb1000TimeOutJiffies; - while (!(inb(ioaddr[1] + 6) & 0x40)) { - if (time_after_eq(jiffies, timeout)) { - printk(KERN_WARNING "%s: sb1000_wait_for_ready timeout\n", - name); - return -ETIME; - } - } - inb(ioaddr[0] + 7); - return 0; -} - -/* Card Wait For Ready Clear (to be used during frame rx) */ -static int -sb1000_wait_for_ready_clear(const int ioaddr[], const char* name) -{ - unsigned long timeout; - - timeout = jiffies + Sb1000TimeOutJiffies; - while (inb(ioaddr[1] + 6) & 0x80) { - if (time_after_eq(jiffies, timeout)) { - printk(KERN_WARNING "%s: sb1000_wait_for_ready_clear timeout\n", - name); - return -ETIME; - } - } - timeout = jiffies + Sb1000TimeOutJiffies; - while (inb(ioaddr[1] + 6) & 0x40) { - if (time_after_eq(jiffies, timeout)) { - printk(KERN_WARNING "%s: sb1000_wait_for_ready_clear timeout\n", - name); - return -ETIME; - } - } - return 0; -} - -/* Card Send Command (to be used during frame rx) */ -static void -sb1000_send_command(const int ioaddr[], const char* name, - const unsigned char out[]) -{ - outb(out[2], ioaddr[0] + 1); - outb(out[3], ioaddr[0] + 2); - outb(out[4], ioaddr[0] + 3); - outb(out[5], ioaddr[0] + 4); - outb(out[1], ioaddr[0] + 5); - outb(out[0], ioaddr[0] + 7); - if (sb1000_debug > 3) - printk(KERN_DEBUG "%s: sb1000_send_command out: %02x%02x%02x%02x" - "%02x%02x\n", name, out[0], out[1], out[2], out[3], out[4], out[5]); -} - -/* Card Read Status (to be used during frame rx) */ -static void -sb1000_read_status(const int ioaddr[], unsigned char in[]) -{ - in[1] = inb(ioaddr[0] + 1); - in[2] = inb(ioaddr[0] + 2); - in[3] = inb(ioaddr[0] + 3); - in[4] = inb(ioaddr[0] + 4); - in[0] = inb(ioaddr[0] + 5); -} - -/* Issue Read Command (to be used during frame rx) */ -static void -sb1000_issue_read_command(const int ioaddr[], const char* name) -{ - static const unsigned char Command0[6] = {0x20, 0x00, 0x00, 0x01, 0x00, 0x00}; - - sb1000_wait_for_ready_clear(ioaddr, name); - outb(0xa0, ioaddr[0] + 6); - sb1000_send_command(ioaddr, name, Command0); -} - - -/* - * SB1000 commands for open/configuration - */ -/* reset SB1000 card */ -static int -sb1000_reset(const int ioaddr[], const char* name) -{ - static const unsigned char Command0[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int port, status; - - port = ioaddr[1] + 6; - outb(0x4, port); - inb(port); - udelay(1000); - outb(0x0, port); - inb(port); - ssleep(1); - outb(0x4, port); - inb(port); - udelay(1000); - outb(0x0, port); - inb(port); - udelay(0); - - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - if (st[3] != 0xf0) - return -EIO; - return 0; -} - -/* check SB1000 firmware CRC */ -static int -sb1000_check_CRC(const int ioaddr[], const char* name) -{ - static const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int status; - - /* check CRC */ - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - if (st[1] != st[3] || st[2] != st[4]) - return -EIO; - return 0; -} - -static inline int -sb1000_start_get_set_command(const int ioaddr[], const char* name) -{ - static const unsigned char Command0[6] = {0x80, 0x1b, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - - return card_send_command(ioaddr, name, Command0, st); -} - -static int -sb1000_end_get_set_command(const int ioaddr[], const char* name) -{ - static const unsigned char Command0[6] = {0x80, 0x1b, 0x02, 0x00, 0x00, 0x00}; - static const unsigned char Command1[6] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int status; - - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - return card_send_command(ioaddr, name, Command1, st); -} - -static int -sb1000_activate(const int ioaddr[], const char* name) -{ - static const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int status; - - ssleep(1); - status = card_send_command(ioaddr, name, Command0, st); - if (status) - return status; - status = card_send_command(ioaddr, name, Command1, st); - if (status) - return status; - if (st[3] != 0xf1) { - status = sb1000_start_get_set_command(ioaddr, name); - if (status) - return status; - return -EIO; - } - udelay(1000); - return sb1000_start_get_set_command(ioaddr, name); -} - -/* get SB1000 firmware version */ -static int -sb1000_get_firmware_version(const int ioaddr[], const char* name, - unsigned char version[], int do_end) -{ - static const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int status; - - if ((status = sb1000_start_get_set_command(ioaddr, name))) - return status; - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - if (st[0] != 0xa3) - return -EIO; - version[0] = st[1]; - version[1] = st[2]; - if (do_end) - return sb1000_end_get_set_command(ioaddr, name); - else - return 0; -} - -/* get SB1000 frequency */ -static int -sb1000_get_frequency(const int ioaddr[], const char* name, int* frequency) -{ - static const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int status; - - udelay(1000); - if ((status = sb1000_start_get_set_command(ioaddr, name))) - return status; - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - *frequency = ((st[1] << 8 | st[2]) << 8 | st[3]) << 8 | st[4]; - return sb1000_end_get_set_command(ioaddr, name); -} - -/* set SB1000 frequency */ -static int -sb1000_set_frequency(const int ioaddr[], const char* name, int frequency) -{ - unsigned char st[7]; - int status; - unsigned char Command0[6] = {0x80, 0x29, 0x00, 0x00, 0x00, 0x00}; - - const int FrequencyLowerLimit = 57000; - const int FrequencyUpperLimit = 804000; - - if (frequency < FrequencyLowerLimit || frequency > FrequencyUpperLimit) { - printk(KERN_ERR "%s: frequency chosen (%d kHz) is not in the range " - "[%d,%d] kHz\n", name, frequency, FrequencyLowerLimit, - FrequencyUpperLimit); - return -EINVAL; - } - udelay(1000); - if ((status = sb1000_start_get_set_command(ioaddr, name))) - return status; - Command0[5] = frequency & 0xff; - frequency >>= 8; - Command0[4] = frequency & 0xff; - frequency >>= 8; - Command0[3] = frequency & 0xff; - frequency >>= 8; - Command0[2] = frequency & 0xff; - return card_send_command(ioaddr, name, Command0, st); -} - -/* get SB1000 PIDs */ -static int -sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[]) -{ - static const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - int status; - - udelay(1000); - if ((status = sb1000_start_get_set_command(ioaddr, name))) - return status; - - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - PID[0] = st[1] << 8 | st[2]; - - if ((status = card_send_command(ioaddr, name, Command1, st))) - return status; - PID[1] = st[1] << 8 | st[2]; - - if ((status = card_send_command(ioaddr, name, Command2, st))) - return status; - PID[2] = st[1] << 8 | st[2]; - - if ((status = card_send_command(ioaddr, name, Command3, st))) - return status; - PID[3] = st[1] << 8 | st[2]; - - return sb1000_end_get_set_command(ioaddr, name); -} - -/* set SB1000 PIDs */ -static int -sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]) -{ - static const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; - - unsigned char st[7]; - short p; - int status; - unsigned char Command0[6] = {0x80, 0x31, 0x00, 0x00, 0x00, 0x00}; - unsigned char Command1[6] = {0x80, 0x32, 0x00, 0x00, 0x00, 0x00}; - unsigned char Command2[6] = {0x80, 0x33, 0x00, 0x00, 0x00, 0x00}; - unsigned char Command3[6] = {0x80, 0x34, 0x00, 0x00, 0x00, 0x00}; - - udelay(1000); - if ((status = sb1000_start_get_set_command(ioaddr, name))) - return status; - - p = PID[0]; - Command0[3] = p & 0xff; - p >>= 8; - Command0[2] = p & 0xff; - if ((status = card_send_command(ioaddr, name, Command0, st))) - return status; - - p = PID[1]; - Command1[3] = p & 0xff; - p >>= 8; - Command1[2] = p & 0xff; - if ((status = card_send_command(ioaddr, name, Command1, st))) - return status; - - p = PID[2]; - Command2[3] = p & 0xff; - p >>= 8; - Command2[2] = p & 0xff; - if ((status = card_send_command(ioaddr, name, Command2, st))) - return status; - - p = PID[3]; - Command3[3] = p & 0xff; - p >>= 8; - Command3[2] = p & 0xff; - if ((status = card_send_command(ioaddr, name, Command3, st))) - return status; - - if ((status = card_send_command(ioaddr, name, Command4, st))) - return status; - return sb1000_end_get_set_command(ioaddr, name); -} - - -static void -sb1000_print_status_buffer(const char* name, unsigned char st[], - unsigned char buffer[], int size) -{ - int i, j, k; - - printk(KERN_DEBUG "%s: status: %02x %02x\n", name, st[0], st[1]); - if (buffer[24] == 0x08 && buffer[25] == 0x00 && buffer[26] == 0x45) { - printk(KERN_DEBUG "%s: length: %d protocol: %d from: %d.%d.%d.%d:%d " - "to %d.%d.%d.%d:%d\n", name, buffer[28] << 8 | buffer[29], - buffer[35], buffer[38], buffer[39], buffer[40], buffer[41], - buffer[46] << 8 | buffer[47], - buffer[42], buffer[43], buffer[44], buffer[45], - buffer[48] << 8 | buffer[49]); - } else { - for (i = 0, k = 0; i < (size + 7) / 8; i++) { - printk(KERN_DEBUG "%s: %s", name, i ? " " : "buffer:"); - for (j = 0; j < 8 && k < size; j++, k++) - printk(" %02x", buffer[k]); - printk("\n"); - } - } -} - -/* - * SB1000 commands for frame rx interrupt - */ -/* receive a single frame and assemble datagram - * (this is the heart of the interrupt routine) - */ -static int -sb1000_rx(struct net_device *dev) -{ - -#define FRAMESIZE 184 - unsigned char st[2], buffer[FRAMESIZE], session_id, frame_id; - short dlen; - int ioaddr, ns; - unsigned int skbsize; - struct sk_buff *skb; - struct sb1000_private *lp = netdev_priv(dev); - struct net_device_stats *stats = &dev->stats; - - /* SB1000 frame constants */ - const int FrameSize = FRAMESIZE; - const int NewDatagramHeaderSkip = 8; - const int NewDatagramHeaderSize = NewDatagramHeaderSkip + 18; - const int NewDatagramDataSize = FrameSize - NewDatagramHeaderSize; - const int ContDatagramHeaderSkip = 7; - const int ContDatagramHeaderSize = ContDatagramHeaderSkip + 1; - const int ContDatagramDataSize = FrameSize - ContDatagramHeaderSize; - const int TrailerSize = 4; - - ioaddr = dev->base_addr; - - insw(ioaddr, (unsigned short*) st, 1); -#ifdef XXXDEBUG -printk("cm0: received: %02x %02x\n", st[0], st[1]); -#endif /* XXXDEBUG */ - lp->rx_frames++; - - /* decide if it is a good or bad frame */ - for (ns = 0; ns < NPIDS; ns++) { - session_id = lp->rx_session_id[ns]; - frame_id = lp->rx_frame_id[ns]; - if (st[0] == session_id) { - if (st[1] == frame_id || (!frame_id && (st[1] & 0xf0) == 0x30)) { - goto good_frame; - } else if ((st[1] & 0xf0) == 0x30 && (st[0] & 0x40)) { - goto skipped_frame; - } else { - goto bad_frame; - } - } else if (st[0] == (session_id | 0x40)) { - if ((st[1] & 0xf0) == 0x30) { - goto skipped_frame; - } else { - goto bad_frame; - } - } - } - goto bad_frame; - -skipped_frame: - stats->rx_frame_errors++; - skb = lp->rx_skb[ns]; - if (sb1000_debug > 1) - printk(KERN_WARNING "%s: missing frame(s): got %02x %02x " - "expecting %02x %02x\n", dev->name, st[0], st[1], - skb ? session_id : session_id | 0x40, frame_id); - if (skb) { - dev_kfree_skb(skb); - skb = NULL; - } - -good_frame: - lp->rx_frame_id[ns] = 0x30 | ((st[1] + 1) & 0x0f); - /* new datagram */ - if (st[0] & 0x40) { - /* get data length */ - insw(ioaddr, buffer, NewDatagramHeaderSize / 2); -#ifdef XXXDEBUG -printk("cm0: IP identification: %02x%02x fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]); -#endif /* XXXDEBUG */ - if (buffer[0] != NewDatagramHeaderSkip) { - if (sb1000_debug > 1) - printk(KERN_WARNING "%s: new datagram header skip error: " - "got %02x expecting %02x\n", dev->name, buffer[0], - NewDatagramHeaderSkip); - stats->rx_length_errors++; - insw(ioaddr, buffer, NewDatagramDataSize / 2); - goto bad_frame_next; - } - dlen = ((buffer[NewDatagramHeaderSkip + 3] & 0x0f) << 8 | - buffer[NewDatagramHeaderSkip + 4]) - 17; - if (dlen > SB1000_MRU) { - if (sb1000_debug > 1) - printk(KERN_WARNING "%s: datagram length (%d) greater " - "than MRU (%d)\n", dev->name, dlen, SB1000_MRU); - stats->rx_length_errors++; - insw(ioaddr, buffer, NewDatagramDataSize / 2); - goto bad_frame_next; - } - lp->rx_dlen[ns] = dlen; - /* compute size to allocate for datagram */ - skbsize = dlen + FrameSize; - if ((skb = alloc_skb(skbsize, GFP_ATOMIC)) == NULL) { - if (sb1000_debug > 1) - printk(KERN_WARNING "%s: can't allocate %d bytes long " - "skbuff\n", dev->name, skbsize); - stats->rx_dropped++; - insw(ioaddr, buffer, NewDatagramDataSize / 2); - goto dropped_frame; - } - skb->dev = dev; - skb_reset_mac_header(skb); - skb->protocol = (unsigned short) buffer[NewDatagramHeaderSkip + 16]; - insw(ioaddr, skb_put(skb, NewDatagramDataSize), - NewDatagramDataSize / 2); - lp->rx_skb[ns] = skb; - } else { - /* continuation of previous datagram */ - insw(ioaddr, buffer, ContDatagramHeaderSize / 2); - if (buffer[0] != ContDatagramHeaderSkip) { - if (sb1000_debug > 1) - printk(KERN_WARNING "%s: cont datagram header skip error: " - "got %02x expecting %02x\n", dev->name, buffer[0], - ContDatagramHeaderSkip); - stats->rx_length_errors++; - insw(ioaddr, buffer, ContDatagramDataSize / 2); - goto bad_frame_next; - } - skb = lp->rx_skb[ns]; - insw(ioaddr, skb_put(skb, ContDatagramDataSize), - ContDatagramDataSize / 2); - dlen = lp->rx_dlen[ns]; - } - if (skb->len < dlen + TrailerSize) { - lp->rx_session_id[ns] &= ~0x40; - return 0; - } - - /* datagram completed: send to upper level */ - skb_trim(skb, dlen); - __netif_rx(skb); - stats->rx_bytes+=dlen; - stats->rx_packets++; - lp->rx_skb[ns] = NULL; - lp->rx_session_id[ns] |= 0x40; - return 0; - -bad_frame: - insw(ioaddr, buffer, FrameSize / 2); - if (sb1000_debug > 1) - printk(KERN_WARNING "%s: frame error: got %02x %02x\n", - dev->name, st[0], st[1]); - stats->rx_frame_errors++; -bad_frame_next: - if (sb1000_debug > 2) - sb1000_print_status_buffer(dev->name, st, buffer, FrameSize); -dropped_frame: - stats->rx_errors++; - if (ns < NPIDS) { - if ((skb = lp->rx_skb[ns])) { - dev_kfree_skb(skb); - lp->rx_skb[ns] = NULL; - } - lp->rx_session_id[ns] |= 0x40; - } - return -1; -} - -static void -sb1000_error_dpc(struct net_device *dev) -{ - static const unsigned char Command0[6] = {0x80, 0x26, 0x00, 0x00, 0x00, 0x00}; - - char *name; - unsigned char st[5]; - int ioaddr[2]; - struct sb1000_private *lp = netdev_priv(dev); - const int ErrorDpcCounterInitialize = 200; - - ioaddr[0] = dev->base_addr; - /* mem_start holds the second I/O address */ - ioaddr[1] = dev->mem_start; - name = dev->name; - - sb1000_wait_for_ready_clear(ioaddr, name); - sb1000_send_command(ioaddr, name, Command0); - sb1000_wait_for_ready(ioaddr, name); - sb1000_read_status(ioaddr, st); - if (st[1] & 0x10) - lp->rx_error_dpc_count = ErrorDpcCounterInitialize; -} - - -/* - * Linux interface functions - */ -static int -sb1000_open(struct net_device *dev) -{ - char *name; - int ioaddr[2], status; - struct sb1000_private *lp = netdev_priv(dev); - const unsigned short FirmwareVersion[] = {0x01, 0x01}; - - ioaddr[0] = dev->base_addr; - /* mem_start holds the second I/O address */ - ioaddr[1] = dev->mem_start; - name = dev->name; - - /* initialize sb1000 */ - if ((status = sb1000_reset(ioaddr, name))) - return status; - ssleep(1); - if ((status = sb1000_check_CRC(ioaddr, name))) - return status; - - /* initialize private data before board can catch interrupts */ - lp->rx_skb[0] = NULL; - lp->rx_skb[1] = NULL; - lp->rx_skb[2] = NULL; - lp->rx_skb[3] = NULL; - lp->rx_dlen[0] = 0; - lp->rx_dlen[1] = 0; - lp->rx_dlen[2] = 0; - lp->rx_dlen[3] = 0; - lp->rx_frames = 0; - lp->rx_error_count = 0; - lp->rx_error_dpc_count = 0; - lp->rx_session_id[0] = 0x50; - lp->rx_session_id[1] = 0x48; - lp->rx_session_id[2] = 0x44; - lp->rx_session_id[3] = 0x42; - lp->rx_frame_id[0] = 0; - lp->rx_frame_id[1] = 0; - lp->rx_frame_id[2] = 0; - lp->rx_frame_id[3] = 0; - if (request_irq(dev->irq, sb1000_interrupt, 0, "sb1000", dev)) { - return -EAGAIN; - } - - if (sb1000_debug > 2) - printk(KERN_DEBUG "%s: Opening, IRQ %d\n", name, dev->irq); - - /* Activate board and check firmware version */ - udelay(1000); - if ((status = sb1000_activate(ioaddr, name))) - return status; - udelay(0); - if ((status = sb1000_get_firmware_version(ioaddr, name, version, 0))) - return status; - if (version[0] != FirmwareVersion[0] || version[1] != FirmwareVersion[1]) - printk(KERN_WARNING "%s: found firmware version %x.%02x " - "(should be %x.%02x)\n", name, version[0], version[1], - FirmwareVersion[0], FirmwareVersion[1]); - - - netif_start_queue(dev); - return 0; /* Always succeed */ -} - -static int sb1000_siocdevprivate(struct net_device *dev, struct ifreq *ifr, - void __user *data, int cmd) -{ - char* name; - unsigned char version[2]; - short PID[4]; - int ioaddr[2], status, frequency; - unsigned int stats[5]; - struct sb1000_private *lp = netdev_priv(dev); - - if (!(dev && dev->flags & IFF_UP)) - return -ENODEV; - - ioaddr[0] = dev->base_addr; - /* mem_start holds the second I/O address */ - ioaddr[1] = dev->mem_start; - name = dev->name; - - switch (cmd) { - case SIOCGCMSTATS: /* get statistics */ - stats[0] = dev->stats.rx_bytes; - stats[1] = lp->rx_frames; - stats[2] = dev->stats.rx_packets; - stats[3] = dev->stats.rx_errors; - stats[4] = dev->stats.rx_dropped; - if (copy_to_user(data, stats, sizeof(stats))) - return -EFAULT; - status = 0; - break; - - case SIOCGCMFIRMWARE: /* get firmware version */ - if ((status = sb1000_get_firmware_version(ioaddr, name, version, 1))) - return status; - if (copy_to_user(data, version, sizeof(version))) - return -EFAULT; - break; - - case SIOCGCMFREQUENCY: /* get frequency */ - if ((status = sb1000_get_frequency(ioaddr, name, &frequency))) - return status; - if (put_user(frequency, (int __user *)data)) - return -EFAULT; - break; - - case SIOCSCMFREQUENCY: /* set frequency */ - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - if (get_user(frequency, (int __user *)data)) - return -EFAULT; - if ((status = sb1000_set_frequency(ioaddr, name, frequency))) - return status; - break; - - case SIOCGCMPIDS: /* get PIDs */ - if ((status = sb1000_get_PIDs(ioaddr, name, PID))) - return status; - if (copy_to_user(data, PID, sizeof(PID))) - return -EFAULT; - break; - - case SIOCSCMPIDS: /* set PIDs */ - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - if (copy_from_user(PID, data, sizeof(PID))) - return -EFAULT; - if ((status = sb1000_set_PIDs(ioaddr, name, PID))) - return status; - /* set session_id, frame_id and pkt_type too */ - lp->rx_session_id[0] = 0x50 | (PID[0] & 0x0f); - lp->rx_session_id[1] = 0x48; - lp->rx_session_id[2] = 0x44; - lp->rx_session_id[3] = 0x42; - lp->rx_frame_id[0] = 0; - lp->rx_frame_id[1] = 0; - lp->rx_frame_id[2] = 0; - lp->rx_frame_id[3] = 0; - break; - - default: - status = -EINVAL; - break; - } - return status; -} - -/* transmit function: do nothing since SB1000 can't send anything out */ -static netdev_tx_t -sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - printk(KERN_WARNING "%s: trying to transmit!!!\n", dev->name); - /* sb1000 can't xmit datagrams */ - dev_kfree_skb(skb); - return NETDEV_TX_OK; -} - -/* SB1000 interrupt handler. */ -static irqreturn_t sb1000_interrupt(int irq, void *dev_id) -{ - static const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; - - char *name; - unsigned char st; - int ioaddr[2]; - struct net_device *dev = dev_id; - struct sb1000_private *lp = netdev_priv(dev); - - const int MaxRxErrorCount = 6; - - ioaddr[0] = dev->base_addr; - /* mem_start holds the second I/O address */ - ioaddr[1] = dev->mem_start; - name = dev->name; - - /* is it a good interrupt? */ - st = inb(ioaddr[1] + 6); - if (!(st & 0x08 && st & 0x20)) { - return IRQ_NONE; - } - - if (sb1000_debug > 3) - printk(KERN_DEBUG "%s: entering interrupt\n", dev->name); - - st = inb(ioaddr[0] + 7); - if (sb1000_rx(dev)) - lp->rx_error_count++; -#ifdef SB1000_DELAY - udelay(SB1000_DELAY); -#endif /* SB1000_DELAY */ - sb1000_issue_read_command(ioaddr, name); - if (st & 0x01) { - sb1000_error_dpc(dev); - sb1000_issue_read_command(ioaddr, name); - } - if (lp->rx_error_dpc_count && !(--lp->rx_error_dpc_count)) { - sb1000_wait_for_ready_clear(ioaddr, name); - sb1000_send_command(ioaddr, name, Command0); - sb1000_wait_for_ready(ioaddr, name); - sb1000_issue_read_command(ioaddr, name); - } - if (lp->rx_error_count >= MaxRxErrorCount) { - sb1000_wait_for_ready_clear(ioaddr, name); - sb1000_send_command(ioaddr, name, Command1); - sb1000_wait_for_ready(ioaddr, name); - sb1000_issue_read_command(ioaddr, name); - lp->rx_error_count = 0; - } - - return IRQ_HANDLED; -} - -static int sb1000_close(struct net_device *dev) -{ - int i; - int ioaddr[2]; - struct sb1000_private *lp = netdev_priv(dev); - - if (sb1000_debug > 2) - printk(KERN_DEBUG "%s: Shutting down sb1000.\n", dev->name); - - netif_stop_queue(dev); - - ioaddr[0] = dev->base_addr; - /* mem_start holds the second I/O address */ - ioaddr[1] = dev->mem_start; - - free_irq(dev->irq, dev); - /* If we don't do this, we can't re-insmod it later. */ - release_region(ioaddr[1], SB1000_IO_EXTENT); - release_region(ioaddr[0], SB1000_IO_EXTENT); - - /* free rx_skb's if needed */ - for (i=0; i<4; i++) { - if (lp->rx_skb[i]) { - dev_kfree_skb(lp->rx_skb[i]); - } - } - return 0; -} - -MODULE_AUTHOR("Franco Venturi "); -MODULE_DESCRIPTION("General Instruments SB1000 driver"); -MODULE_LICENSE("GPL"); - -module_pnp_driver(sb1000_driver); diff --git a/include/uapi/linux/if_cablemodem.h b/include/uapi/linux/if_cablemodem.h deleted file mode 100644 index 1f65130bf2a6..000000000000 --- a/include/uapi/linux/if_cablemodem.h +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -#ifndef _LINUX_CABLEMODEM_H_ -#define _LINUX_CABLEMODEM_H_ -/* - * Author: Franco Venturi - * Copyright 1998 Franco Venturi - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at - * your option) any later version. - */ - -/* some useful defines for sb1000.c e cmconfig.c - fv */ -#define SIOCGCMSTATS (SIOCDEVPRIVATE+0) /* get cable modem stats */ -#define SIOCGCMFIRMWARE (SIOCDEVPRIVATE+1) /* get cm firmware version */ -#define SIOCGCMFREQUENCY (SIOCDEVPRIVATE+2) /* get cable modem frequency */ -#define SIOCSCMFREQUENCY (SIOCDEVPRIVATE+3) /* set cable modem frequency */ -#define SIOCGCMPIDS (SIOCDEVPRIVATE+4) /* get cable modem PIDs */ -#define SIOCSCMPIDS (SIOCDEVPRIVATE+5) /* set cable modem PIDs */ - -#endif -- 2.51.0 From 62e36b2441354000ef87bdcc6515986b46a40fc8 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Thu, 13 Mar 2025 20:44:25 +0100 Subject: [PATCH 14/16] net: phy: realtek: remove call to devm_hwmon_sanitize_name Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument. Signed-off-by: Heiner Kallweit Link: https://patch.msgid.link/6e8d26f4-8d0a-4c83-aec3-378847a377eb@gmail.com Reviewed-by: Maxime Chevallier Signed-off-by: Paolo Abeni --- drivers/net/phy/realtek/realtek_hwmon.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/phy/realtek/realtek_hwmon.c b/drivers/net/phy/realtek/realtek_hwmon.c index 1ecb410bb941..ac96e2d1ebe8 100644 --- a/drivers/net/phy/realtek/realtek_hwmon.c +++ b/drivers/net/phy/realtek/realtek_hwmon.c @@ -63,16 +63,11 @@ static const struct hwmon_chip_info rtl822x_hwmon_chip_info = { int rtl822x_hwmon_init(struct phy_device *phydev) { struct device *hwdev, *dev = &phydev->mdio.dev; - const char *name; /* Ensure over-temp alarm is reset. */ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSALRM, 3); - name = devm_hwmon_sanitize_name(dev, dev_name(dev)); - if (IS_ERR(name)) - return PTR_ERR(name); - - hwdev = devm_hwmon_device_register_with_info(dev, name, phydev, + hwdev = devm_hwmon_device_register_with_info(dev, NULL, phydev, &rtl822x_hwmon_chip_info, NULL); return PTR_ERR_OR_ZERO(hwdev); -- 2.51.0 From 91ee219624307154675bf067aef83693390f91f2 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Thu, 13 Mar 2025 20:45:06 +0100 Subject: [PATCH 15/16] net: phy: tja11xx: remove call to devm_hwmon_sanitize_name Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument. Note that neither priv->hwmon_name nor priv->hwmon_dev are used outside tja11xx_hwmon_register. Signed-off-by: Heiner Kallweit Link: https://patch.msgid.link/4452cb7e-1a2f-4213-b49f-9de196be9204@gmail.com Reviewed-by: Maxime Chevallier Signed-off-by: Paolo Abeni --- drivers/net/phy/nxp-tja11xx.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index 601094fe24ca..07e94a2478ac 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -87,8 +87,6 @@ #define TJA110X_RMII_MODE_REFCLK_IN BIT(0) struct tja11xx_priv { - char *hwmon_name; - struct device *hwmon_dev; struct phy_device *phydev; struct work_struct phy_register_work; u32 flags; @@ -508,19 +506,12 @@ static const struct hwmon_chip_info tja11xx_hwmon_chip_info = { static int tja11xx_hwmon_register(struct phy_device *phydev, struct tja11xx_priv *priv) { - struct device *dev = &phydev->mdio.dev; - - priv->hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev)); - if (IS_ERR(priv->hwmon_name)) - return PTR_ERR(priv->hwmon_name); - - priv->hwmon_dev = - devm_hwmon_device_register_with_info(dev, priv->hwmon_name, - phydev, - &tja11xx_hwmon_chip_info, - NULL); + struct device *hdev, *dev = &phydev->mdio.dev; - return PTR_ERR_OR_ZERO(priv->hwmon_dev); + hdev = devm_hwmon_device_register_with_info(dev, NULL, phydev, + &tja11xx_hwmon_chip_info, + NULL); + return PTR_ERR_OR_ZERO(hdev); } static int tja11xx_parse_dt(struct phy_device *phydev) -- 2.51.0 From 0426bd18af928b729e89e35a5f8c5b613da03dbf Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Thu, 13 Mar 2025 20:45:42 +0100 Subject: [PATCH 16/16] net: phy: mxl-gpy: remove call to devm_hwmon_sanitize_name Since c909e68f8127 ("hwmon: (core) Use device name as a fallback in devm_hwmon_device_register_with_info") we can simply provide NULL as name argument. Signed-off-by: Heiner Kallweit Link: https://patch.msgid.link/e34c4802-20ce-4556-a47c-812e602e8526@gmail.com Reviewed-by: Maxime Chevallier Signed-off-by: Paolo Abeni --- drivers/net/phy/mxl-gpy.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index a6cca8d43253..0c8dc16ee7bd 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -225,14 +225,8 @@ static int gpy_hwmon_register(struct phy_device *phydev) { struct device *dev = &phydev->mdio.dev; struct device *hwmon_dev; - char *hwmon_name; - hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev)); - if (IS_ERR(hwmon_name)) - return PTR_ERR(hwmon_name); - - hwmon_dev = devm_hwmon_device_register_with_info(dev, hwmon_name, - phydev, + hwmon_dev = devm_hwmon_device_register_with_info(dev, NULL, phydev, &gpy_hwmon_chip_info, NULL); -- 2.51.0