commit_title
stringlengths 13
124
| commit_body
stringlengths 0
1.9k
| release_summary
stringclasses 52
values | changes_summary
stringlengths 1
758
| release_affected_domains
stringclasses 33
values | release_affected_drivers
stringclasses 51
values | domain_of_changes
stringlengths 2
571
| language_set
stringclasses 983
values | diffstat_files
int64 1
300
| diffstat_insertions
int64 0
309k
| diffstat_deletions
int64 0
168k
| commit_diff
stringlengths 92
23.4M
| category
stringclasses 108
values | commit_hash
stringlengths 34
40
| related_people
stringlengths 0
370
| domain
stringclasses 21
values | subdomain
stringclasses 241
values | leaf_module
stringlengths 0
912
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mlxsw: add ecn configurations with ipinip tunnels
|
initialize ecn mapping registers during router init according to inet_ecn_encapsulate() and inet_ecn_decapsulate().
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c', 'h']
| 3
| 73
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +#include <net/inet_ecn.h> +#include "reg.h" + +static int mlxsw_sp_ipip_ecn_encap_init_one(struct mlxsw_sp *mlxsw_sp, + u8 inner_ecn, u8 outer_ecn) +{ + char tieem_pl[mlxsw_reg_tieem_len]; + + mlxsw_reg_tieem_pack(tieem_pl, inner_ecn, outer_ecn); + return mlxsw_reg_write(mlxsw_sp->core, mlxsw_reg(tieem), tieem_pl); +} + +int mlxsw_sp_ipip_ecn_encap_init(struct mlxsw_sp *mlxsw_sp) +{ + int i; + + /* iterate over inner ecn values */ + for (i = inet_ecn_not_ect; i <= inet_ecn_ce; i++) { + u8 outer_ecn = inet_ecn_encapsulate(0, i); + int err; + + err = mlxsw_sp_ipip_ecn_encap_init_one(mlxsw_sp, i, outer_ecn); + if (err) + return err; + } + + return 0; +} + +static int mlxsw_sp_ipip_ecn_decap_init_one(struct mlxsw_sp *mlxsw_sp, + u8 inner_ecn, u8 outer_ecn) +{ + char tidem_pl[mlxsw_reg_tidem_len]; + bool trap_en, set_ce = false; + u8 new_inner_ecn; + + trap_en = __inet_ecn_decapsulate(outer_ecn, inner_ecn, &set_ce); + new_inner_ecn = set_ce ? inet_ecn_ce : inner_ecn; + + mlxsw_reg_tidem_pack(tidem_pl, outer_ecn, inner_ecn, new_inner_ecn, + trap_en, trap_en ? mlxsw_trap_id_decap_ecn0 : 0); + return mlxsw_reg_write(mlxsw_sp->core, mlxsw_reg(tidem), tidem_pl); +} + +int mlxsw_sp_ipip_ecn_decap_init(struct mlxsw_sp *mlxsw_sp) +{ + int i, j, err; + + /* iterate over inner ecn values */ + for (i = inet_ecn_not_ect; i <= inet_ecn_ce; i++) { + /* iterate over outer ecn values */ + for (j = inet_ecn_not_ect; j <= inet_ecn_ce; j++) { + err = mlxsw_sp_ipip_ecn_decap_init_one(mlxsw_sp, i, j); + if (err) + return err; + } + } + + return 0; +} diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c + int err; + + + err = mlxsw_sp_ipip_ecn_encap_init(mlxsw_sp); + if (err) + return err; + err = mlxsw_sp_ipip_ecn_decap_init(mlxsw_sp); + if (err) + return err; + diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +int mlxsw_sp_ipip_ecn_encap_init(struct mlxsw_sp *mlxsw_sp); +int mlxsw_sp_ipip_ecn_decap_init(struct mlxsw_sp *mlxsw_sp); +
|
Networking
|
4a44ee67a7cd6603d28d71f8fe5e4e0e4dfae1e5
|
amit cohen
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum_trap: reorder cases according to enum order
|
move l3_drops case to appear after l2_drops case.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 2
| 2
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c - case devlink_trap_group_generic_id_l3_drops:/* fall through */ - case devlink_trap_group_generic_id_l2_drops: + case devlink_trap_group_generic_id_l2_drops: /* fall through */ + case devlink_trap_group_generic_id_l3_drops:
|
Networking
|
f528dfc460ef015bb612595112508ef469d0d3b9
|
amit cohen jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
devlink: add tunnel generic packet traps
|
add packet traps that can report packets that were dropped during tunnel decapsulation.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'c', 'rst']
| 3
| 16
| 0
|
--- diff --git a/documentation/networking/devlink/devlink-trap.rst b/documentation/networking/devlink/devlink-trap.rst --- a/documentation/networking/devlink/devlink-trap.rst +++ b/documentation/networking/devlink/devlink-trap.rst + * - ''decap_error'' + - ''exception'' + - traps nve and ipinip packets that the device decided to drop because of + failure during decapsulation (e.g., packet being too short, reserved + bits set in vxlan header) - contains packet traps for packets that were dropped by the device due to + * - ''tunnel_drops'' + - contains packet traps for packets that were dropped by the device during + tunnel encapsulation / decapsulation diff --git a/include/net/devlink.h b/include/net/devlink.h --- a/include/net/devlink.h +++ b/include/net/devlink.h + devlink_trap_generic_id_decap_error, + devlink_trap_group_generic_id_tunnel_drops, +#define devlink_trap_generic_name_decap_error \ + "decap_error" +#define devlink_trap_group_generic_name_tunnel_drops \ + "tunnel_drops" diff --git a/net/core/devlink.c b/net/core/devlink.c --- a/net/core/devlink.c +++ b/net/core/devlink.c + devlink_trap(decap_error, exception), + devlink_trap_group(tunnel_drops),
|
Networking
|
13c056ec7d006b11557cebd9f1803edd646d2876
|
amit cohen jiri pirko jiri mellanox com
|
documentation
|
networking
|
devlink
|
mlxsw: add tunnel devlink-trap support
|
add the trap ids and trap group used to report tunnel drops. register tunnel packet traps and associated tunnel trap group with devlink during driver initialization.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'c']
| 4
| 19
| 3
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h + mlxsw_reg_htgt_trap_group_sp_tunnel_discards, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c - mlxsw_sp_rxl_mark(ipip_decap_error, trap_to_cpu, router_exp, false), - mlxsw_sp_rxl_mark(decap_ecn0, trap_to_cpu, router_exp, false), diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c + mlxsw_sp_trap_exception(decap_error, tunnel_drops), + mlxsw_sp_rxl_exception(decap_ecn0, router_exp, trap_exception_to_cpu), + mlxsw_sp_rxl_exception(ipip_decap_error, router_exp, + trap_exception_to_cpu), + mlxsw_sp_rxl_exception(discard_dec_pkt, tunnel_discards, + trap_exception_to_cpu), + devlink_trap_generic_id_decap_error, + devlink_trap_generic_id_decap_error, + devlink_trap_generic_id_decap_error, - case devlink_trap_group_generic_id_l3_drops: + case devlink_trap_group_generic_id_l3_drops: /* fall through */ + case devlink_trap_group_generic_id_tunnel_drops: + case devlink_trap_group_generic_id_tunnel_drops: + group_id = mlxsw_reg_htgt_trap_group_sp_tunnel_discards; + policer_id = mlxsw_sp_discard_policer_id; + priority = 0; + tc = 1; + break; diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h --- a/drivers/net/ethernet/mellanox/mlxsw/trap.h +++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h + mlxsw_trap_id_discard_dec_pkt = 0x188,
|
Networking
|
a318bf621a6eabc45e51ed9297b4c01991bfd7e4
|
amit cohen jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
selftests: devlink_trap_tunnel_vxlan: add test case for decap_error
|
test that the trap is triggered under the right conditions and that devlink counters increase.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 1
| 276
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 +# +# test devlink-trap tunnel drops and exceptions functionality over mlxsw. +# check all traps to make sure they are triggered under the right +# conditions. + +# +--------------------+ +# | h1 (vrf) | +# | + $h1 | +# | | 192.0.2.1/28 | +# +----|---------------+ +# | +# +----|----------------------------------------------------------------------+ +# | sw | | +# | +--|--------------------------------------------------------------------+ | +# | | + $swp1 br1 (802.1d) | | +# | | | | +# | | + vx1 (vxlan) | | +# | | local 192.0.2.17 | | +# | | id 1000 dstport $vxport | | +# | +-----------------------------------------------------------------------+ | +# | | +# | + $rp1 | +# | | 192.0.2.17/28 | +# +----|----------------------------------------------------------------------+ +# | +# +----|--------------------------------------------------------+ +# | | vrf2 | +# | + $rp2 | +# | 192.0.2.18/28 | +# | | +# +-------------------------------------------------------------+ + +lib_dir=$(dirname $0)/../../../net/forwarding + +all_tests=" + decap_error_test +" + +num_netifs=4 +source $lib_dir/lib.sh +source $lib_dir/tc_common.sh +source $lib_dir/devlink_lib.sh + +: ${vxport:=4789} +export vxport + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/28 +} + +switch_create() +{ + ip link add name br1 type bridge vlan_filtering 0 mcast_snooping 0 + # make sure the bridge uses the mac address of the local port and not + # that of the vxlan's device. + ip link set dev br1 address $(mac_get $swp1) + ip link set dev br1 up + + tc qdisc add dev $swp1 clsact + ip link set dev $swp1 master br1 + ip link set dev $swp1 up + + ip link add name vx1 type vxlan id 1000 local 192.0.2.17 \ + dstport "$vxport" nolearning noudpcsum tos inherit ttl 100 + ip link set dev vx1 master br1 + ip link set dev vx1 up + + ip address add dev $rp1 192.0.2.17/28 + ip link set dev $rp1 up +} + +switch_destroy() +{ + ip link set dev $rp1 down + ip address del dev $rp1 192.0.2.17/28 + + ip link set dev vx1 down + ip link set dev vx1 nomaster + ip link del dev vx1 + + ip link set dev $swp1 down + ip link set dev $swp1 nomaster + tc qdisc del dev $swp1 clsact + + ip link set dev br1 down + ip link del dev br1 +} + +vrf2_create() +{ + simple_if_init $rp2 192.0.2.18/28 +} + +vrf2_destroy() +{ + simple_if_fini $rp2 192.0.2.18/28 +} + +setup_prepare() +{ + h1=${netifs[p1]} + swp1=${netifs[p2]} + + rp1=${netifs[p3]} + rp2=${netifs[p4]} + + vrf_prepare + forwarding_enable + h1_create + switch_create + vrf2_create +} + +cleanup() +{ + pre_cleanup + + vrf2_destroy + switch_destroy + h1_destroy + forwarding_restore + vrf_cleanup +} + +ecn_payload_get() +{ + dest_mac=$(mac_get $h1) + p=$(: + )"08:"$( : vxlan flags + )"00:00:00:"$( : vxlan reserved + )"00:03:e8:"$( : vxlan vni : 1000 + )"00:"$( : vxlan reserved + )"$dest_mac:"$( : eth daddr + )"00:00:00:00:00:00:"$( : eth saddr + )"08:00:"$( : eth type + )"45:"$( : ip version + ihl + )"00:"$( : ip tos + )"00:14:"$( : ip total length + )"00:00:"$( : ip identification + )"20:00:"$( : ip flags + frag off + )"40:"$( : ip ttl + )"00:"$( : ip proto + )"d6:e5:"$( : ip header csum + )"c0:00:02:03:"$( : ip saddr: 192.0.2.3 + )"c0:00:02:01:"$( : ip daddr: 192.0.2.1 + ) + echo $p +} + +ecn_decap_test() +{ + local trap_name="decap_error" + local group_name="tunnel_drops" + local desc=$1; shift + local ecn_desc=$1; shift + local outer_tos=$1; shift + local mz_pid + + ret=0 + + tc filter add dev $swp1 egress protocol ip pref 1 handle 101 \ + flower src_ip 192.0.2.3 dst_ip 192.0.2.1 action pass + + rp1_mac=$(mac_get $rp1) + payload=$(ecn_payload_get) + + ip vrf exec v$rp2 $mz $rp2 -c 0 -d 1msec -b $rp1_mac -b 192.0.2.17 \ + -t udp sp=12345,dp=$vxport,tos=$outer_tos,p=$payload -q & + mz_pid=$! + + devlink_trap_exception_test $trap_name $group_name + + tc_check_packets "dev $swp1 egress" 101 0 + check_err $? "packets were not dropped" + + log_test "$desc: inner ecn is not ect and outer is $ecn_desc" + + kill $mz_pid && wait $mz_pid &> /dev/null + tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower +} + +reserved_bits_payload_get() +{ + dest_mac=$(mac_get $h1) + p=$(: + )"08:"$( : vxlan flags + )"01:00:00:"$( : vxlan reserved + )"00:03:e8:"$( : vxlan vni : 1000 + )"00:"$( : vxlan reserved + )"$dest_mac:"$( : eth daddr + )"00:00:00:00:00:00:"$( : eth saddr + )"08:00:"$( : eth type + )"45:"$( : ip version + ihl + )"00:"$( : ip tos + )"00:14:"$( : ip total length + )"00:00:"$( : ip identification + )"20:00:"$( : ip flags + frag off + )"40:"$( : ip ttl + )"00:"$( : ip proto + )"00:00:"$( : ip header csum + )"c0:00:02:03:"$( : ip saddr: 192.0.2.3 + )"c0:00:02:01:"$( : ip daddr: 192.0.2.1 + ) + echo $p +} + +short_payload_get() +{ + dest_mac=$(mac_get $h1) + p=$(: + )"08:"$( : vxlan flags + )"01:00:00:"$( : vxlan reserved + )"00:03:e8:"$( : vxlan vni : 1000 + )"00:"$( : vxlan reserved + ) + echo $p +} + +corrupted_packet_test() +{ + local trap_name="decap_error" + local group_name="tunnel_drops" + local desc=$1; shift + local payload_get=$1; shift + local mz_pid + + ret=0 + + # in case of too short packet, there is no any inner packet, + # so the matching will always succeed + tc filter add dev $swp1 egress protocol ip pref 1 handle 101 \ + flower skip_hw src_ip 192.0.2.3 dst_ip 192.0.2.1 action pass + + rp1_mac=$(mac_get $rp1) + payload=$($payload_get) + ip vrf exec v$rp2 $mz $rp2 -c 0 -d 1msec -b $rp1_mac \ + -b 192.0.2.17 -t udp sp=12345,dp=$vxport,p=$payload -q & + mz_pid=$! + + devlink_trap_exception_test $trap_name $group_name + + tc_check_packets "dev $swp1 egress" 101 0 + check_err $? "packets were not dropped" + + log_test "$desc" + + kill $mz_pid && wait $mz_pid &> /dev/null + tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower +} + +decap_error_test() +{ + ecn_decap_test "decap error" "ect(1)" 01 + ecn_decap_test "decap error" "ect(0)" 02 + ecn_decap_test "decap error" "ce" 03 + + corrupted_packet_test "decap error: reserved bits in use" \ + "reserved_bits_payload_get" + corrupted_packet_test "decap error: no l2 header" "short_payload_get" +} + +trap cleanup exit + +setup_prepare +setup_wait +tests_run + +exit $exit_status
|
Networking
|
ca264ef6ed7cc1f15201d298a44fb79e2c63449c
|
amit cohen jiri pirko jiri mellanox com
|
tools
|
testing
|
drivers, mlxsw, net, selftests
|
selftests: devlink_trap_tunnel_ipip: add test case for decap_error
|
test that the trap is triggered under the right conditions and that devlink counters increase.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 1
| 265
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 +# +# test devlink-trap tunnel exceptions functionality over mlxsw. +# check all exception traps to make sure they are triggered under the right +# conditions. + +# +-------------------------+ +# | h1 | +# | $h1 + | +# | 192.0.2.1/28 | | +# +-------------------|-----+ +# | +# +-------------------|-----+ +# | sw1 | | +# | $swp1 + | +# | 192.0.2.2/28 | +# | | +# | + g1a (gre) | +# | loc=192.0.2.65 | +# | rem=192.0.2.66 | +# | tos=inherit | +# | | +# | + $rp1 | +# | | 198.51.100.1/28 | +# +--|----------------------+ +# | +# +--|----------------------+ +# | | vrf2 | +# | + $rp2 | +# | 198.51.100.2/28 | +# +-------------------------+ + +lib_dir=$(dirname $0)/../../../net/forwarding + +all_tests=" + decap_error_test +" + +num_netifs=4 +source $lib_dir/lib.sh +source $lib_dir/tc_common.sh +source $lib_dir/devlink_lib.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/28 +} + +vrf2_create() +{ + simple_if_init $rp2 198.51.100.2/28 +} + +vrf2_destroy() +{ + simple_if_fini $rp2 198.51.100.2/28 +} + +switch_create() +{ + __addr_add_del $swp1 add 192.0.2.2/28 + tc qdisc add dev $swp1 clsact + ip link set dev $swp1 up + + tunnel_create g1 gre 192.0.2.65 192.0.2.66 tos inherit + __addr_add_del g1 add 192.0.2.65/32 + ip link set dev g1 up + + __addr_add_del $rp1 add 198.51.100.1/28 + ip link set dev $rp1 up +} + +switch_destroy() +{ + ip link set dev $rp1 down + __addr_add_del $rp1 del 198.51.100.1/28 + + ip link set dev g1 down + __addr_add_del g1 del 192.0.2.65/32 + tunnel_destroy g1 + + ip link set dev $swp1 down + tc qdisc del dev $swp1 clsact + __addr_add_del $swp1 del 192.0.2.2/28 +} + +setup_prepare() +{ + h1=${netifs[p1]} + swp1=${netifs[p2]} + + rp1=${netifs[p3]} + rp2=${netifs[p4]} + + forwarding_enable + vrf_prepare + h1_create + switch_create + vrf2_create +} + +cleanup() +{ + pre_cleanup + + vrf2_destroy + switch_destroy + h1_destroy + vrf_cleanup + forwarding_restore +} + +ecn_payload_get() +{ + p=$(: + )"0"$( : gre flags + )"0:00:"$( : reserved + version + )"08:00:"$( : eth protocol type + )"4"$( : ip version + )"5:"$( : ihl + )"00:"$( : ip tos + )"00:14:"$( : ip total length + )"00:00:"$( : ip identification + )"20:00:"$( : ip flags + frag off + )"30:"$( : ip ttl + )"01:"$( : ip proto + )"e7:e6:"$( : ip header csum + )"c0:00:01:01:"$( : ip saddr : 192.0.1.1 + )"c0:00:02:01:"$( : ip daddr : 192.0.2.1 + ) + echo $p +} + +ecn_decap_test() +{ + local trap_name="decap_error" + local group_name="tunnel_drops" + local desc=$1; shift + local ecn_desc=$1; shift + local outer_tos=$1; shift + local mz_pid + + ret=0 + + tc filter add dev $swp1 egress protocol ip pref 1 handle 101 \ + flower src_ip 192.0.1.1 dst_ip 192.0.2.1 action pass + + rp1_mac=$(mac_get $rp1) + rp2_mac=$(mac_get $rp2) + payload=$(ecn_payload_get) + + ip vrf exec v$rp2 $mz $rp2 -c 0 -d 1msec -a $rp2_mac -b $rp1_mac \ + -a 192.0.2.66 -b 192.0.2.65 -t ip \ + len=48,tos=$outer_tos,proto=47,p=$payload -q & + + mz_pid=$! + + devlink_trap_exception_test $trap_name $group_name + + tc_check_packets "dev $swp1 egress" 101 0 + check_err $? "packets were not dropped" + + log_test "$desc: inner ecn is not ect and outer is $ecn_desc" + + kill $mz_pid && wait $mz_pid &> /dev/null + tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower +} + +ipip_payload_get() +{ + local flags=$1; shift + local key=$1; shift + + p=$(: + )"$flags"$( : gre flags + )"0:00:"$( : reserved + version + )"08:00:"$( : eth protocol type + )"$key"$( : key + )"4"$( : ip version + )"5:"$( : ihl + )"00:"$( : ip tos + )"00:14:"$( : ip total length + )"00:00:"$( : ip identification + )"20:00:"$( : ip flags + frag off + )"30:"$( : ip ttl + )"01:"$( : ip proto + )"e7:e6:"$( : ip header csum + )"c0:00:01:01:"$( : ip saddr : 192.0.1.1 + )"c0:00:02:01:"$( : ip daddr : 192.0.2.1 + ) + echo $p +} + +no_matching_tunnel_test() +{ + local trap_name="decap_error" + local group_name="tunnel_drops" + local desc=$1; shift + local sip=$1; shift + local mz_pid + + ret=0 + + tc filter add dev $swp1 egress protocol ip pref 1 handle 101 \ + flower src_ip 192.0.1.1 dst_ip 192.0.2.1 action pass + + rp1_mac=$(mac_get $rp1) + rp2_mac=$(mac_get $rp2) + payload=$(ipip_payload_get "$@") + + ip vrf exec v$rp2 $mz $rp2 -c 0 -d 1msec -a $rp2_mac -b $rp1_mac \ + -a $sip -b 192.0.2.65 -t ip len=48,proto=47,p=$payload -q & + mz_pid=$! + + devlink_trap_exception_test $trap_name $group_name + + tc_check_packets "dev $swp1 egress" 101 0 + check_err $? "packets were not dropped" + + log_test "$desc" + + kill $mz_pid && wait $mz_pid &> /dev/null + tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower +} + +decap_error_test() +{ + # correct source ip - the remote address + local sip=192.0.2.66 + + ecn_decap_test "decap error" "ect(1)" 01 + ecn_decap_test "decap error" "ect(0)" 02 + ecn_decap_test "decap error" "ce" 03 + + no_matching_tunnel_test "decap error: source ip check failed" \ + 192.0.2.68 "0" + no_matching_tunnel_test \ + "decap error: key exists but was not expected" $sip "2" ":e9:" + + # destroy the tunnel and create new one with key + __addr_add_del g1 del 192.0.2.65/32 + tunnel_destroy g1 + + tunnel_create g1 gre 192.0.2.65 192.0.2.66 tos inherit key 233 + __addr_add_del g1 add 192.0.2.65/32 + + no_matching_tunnel_test \ + "decap error: key does not exist but was expected" $sip "0" + no_matching_tunnel_test \ + "decap error: packet has a wrong key field" $sip "2" "e8:" +} + +trap cleanup exit + +setup_prepare +setup_wait +tests_run + +exit $exit_status
|
Networking
|
27942c700017ba84c8fcfcc921bbaf8a91caaefd
|
amit cohen jiri pirko jiri mellanox com
|
tools
|
testing
|
drivers, mlxsw, net, selftests
|
devlink: add overlay source mac is multicast trap
|
add packet trap that can report nve packets that the device decided to drop because their overlay source mac is multicast.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'c', 'rst']
| 3
| 8
| 0
|
--- diff --git a/documentation/networking/devlink/devlink-trap.rst b/documentation/networking/devlink/devlink-trap.rst --- a/documentation/networking/devlink/devlink-trap.rst +++ b/documentation/networking/devlink/devlink-trap.rst - traps nve and ipinip packets that the device decided to drop because of + * - ''overlay_smac_is_mc'' + - ''drop'' + - traps nve packets that the device decided to drop because their overlay + source mac is multicast diff --git a/include/net/devlink.h b/include/net/devlink.h --- a/include/net/devlink.h +++ b/include/net/devlink.h + devlink_trap_generic_id_overlay_smac_mc, +#define devlink_trap_generic_name_overlay_smac_mc \ + "overlay_smac_is_mc" diff --git a/net/core/devlink.c b/net/core/devlink.c --- a/net/core/devlink.c +++ b/net/core/devlink.c + devlink_trap(overlay_smac_mc, drop),
|
Networking
|
c3cae4916e57d2f0364d5e7769218547fb1b7c60
|
amit cohen jiri pirko jiri mellanox com
|
documentation
|
networking
|
devlink
|
mlxsw: add overlay_smac_mc trap
|
add a trap for nve packets that the device decided to drop because their overlay source mac is multicast.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c', 'h']
| 2
| 4
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c + mlxsw_sp_trap_drop(overlay_smac_mc, tunnel_drops), + mlxsw_sp_rxl_discard(overlay_smac_mc, tunnel_discards), + devlink_trap_generic_id_overlay_smac_mc, diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h --- a/drivers/net/ethernet/mellanox/mlxsw/trap.h +++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h + mlxsw_trap_id_discard_overlay_smac_mc = 0x190,
|
Networking
|
3aed0722f7d75240ab7ea0ee2813f6a82f53c60e
|
amit cohen jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
selftests: devlink_trap_tunnel_vxlan: add test case for overlay_smac_is_mc
|
test that the trap is triggered under the right conditions and that devlink counters increase when action is trap.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add tunnel devlink-trap support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 1
| 54
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh + overlay_smac_is_mc_test +mc_smac_payload_get() +{ + dest_mac=$(mac_get $h1) + source_mac=01:02:03:04:05:06 + p=$(: + )"08:"$( : vxlan flags + )"00:00:00:"$( : vxlan reserved + )"00:03:e8:"$( : vxlan vni : 1000 + )"00:"$( : vxlan reserved + )"$dest_mac:"$( : eth daddr + )"$source_mac:"$( : eth saddr + )"08:00:"$( : eth type + )"45:"$( : ip version + ihl + )"00:"$( : ip tos + )"00:14:"$( : ip total length + )"00:00:"$( : ip identification + )"20:00:"$( : ip flags + frag off + )"40:"$( : ip ttl + )"00:"$( : ip proto + )"00:00:"$( : ip header csum + )"c0:00:02:03:"$( : ip saddr: 192.0.2.3 + )"c0:00:02:01:"$( : ip daddr: 192.0.2.1 + ) + echo $p +} + +overlay_smac_is_mc_test() +{ + local trap_name="overlay_smac_is_mc" + local group_name="tunnel_drops" + local mz_pid + + ret=0 + + # the matching will be checked on devlink_trap_drop_test() + # and the filter will be removed on devlink_trap_drop_cleanup() + tc filter add dev $swp1 egress protocol ip pref 1 handle 101 \ + flower src_mac 01:02:03:04:05:06 action pass + + rp1_mac=$(mac_get $rp1) + payload=$(mc_smac_payload_get) + + ip vrf exec v$rp2 $mz $rp2 -c 0 -d 1msec -b $rp1_mac \ + -b 192.0.2.17 -t udp sp=12345,dp=$vxport,p=$payload -q & + mz_pid=$! + + devlink_trap_drop_test $trap_name $group_name $swp1 + + log_test "overlay source mac is multicast" + + devlink_trap_drop_cleanup $mz_pid $swp1 "ip" +} +
|
Networking
|
b3073dfba8ee95697ebcafab90489ee847a74433
|
amit cohen jiri pirko jiri mellanox com
|
tools
|
testing
|
drivers, mlxsw, net, selftests
|
net: sched: sch_tbf: don't overwrite backlog before dumping
|
in 2011, in commit b0460e4484f9 ("sch_tbf: report backlog information"), tbf started copying backlog depth from the child qdisc before dumping, with the motivation that the backlog was otherwise not visible in "tc -s qdisc show".
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 0
| 1
|
--- diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c - sch->qstats.backlog = q->qdisc->qstats.backlog;
|
Networking
|
c2070152747ebc294f018e4b28bf2d9f719a6b36
|
petr machata
|
net
|
sched
| |
net: sched: make tbf qdisc offloadable
|
invoke ndo_setup_tc as appropriate to signal init / replacement, destroying and dumping of tbf qdisc.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'c']
| 3
| 78
| 0
|
--- diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h + tc_setup_qdisc_tbf, diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h +enum tc_tbf_command { + tc_tbf_replace, + tc_tbf_destroy, + tc_tbf_stats, +}; + +struct tc_tbf_qopt_offload_replace_params { + struct psched_ratecfg rate; + u32 max_size; + struct gnet_stats_queue *qstats; +}; + +struct tc_tbf_qopt_offload { + enum tc_tbf_command command; + u32 handle; + u32 parent; + union { + struct tc_tbf_qopt_offload_replace_params replace_params; + struct tc_qopt_offload_stats stats; + }; +}; + diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c +#include <net/pkt_cls.h> +static void tbf_offload_change(struct qdisc *sch) +{ + struct tbf_sched_data *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + struct tc_tbf_qopt_offload qopt; + + if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) + return; + + qopt.command = tc_tbf_replace; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + qopt.replace_params.rate = q->rate; + qopt.replace_params.max_size = q->max_size; + qopt.replace_params.qstats = &sch->qstats; + + dev->netdev_ops->ndo_setup_tc(dev, tc_setup_qdisc_tbf, &qopt); +} + +static void tbf_offload_destroy(struct qdisc *sch) +{ + struct net_device *dev = qdisc_dev(sch); + struct tc_tbf_qopt_offload qopt; + + if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) + return; + + qopt.command = tc_tbf_destroy; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + dev->netdev_ops->ndo_setup_tc(dev, tc_setup_qdisc_tbf, &qopt); +} + +static int tbf_offload_dump(struct qdisc *sch) +{ + struct tc_tbf_qopt_offload qopt; + + qopt.command = tc_tbf_stats; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + qopt.stats.bstats = &sch->bstats; + qopt.stats.qstats = &sch->qstats; + + return qdisc_offload_dump_helper(sch, tc_setup_qdisc_tbf, &qopt); +} + + + tbf_offload_change(sch); + tbf_offload_destroy(sch); + int err; + + err = tbf_offload_dump(sch); + if (err) + return err;
|
Networking
|
ef6aadcc76c97e25f62adc4e9d19684d3e5d0b87
|
petr machata jiri pirko jiri mellanox com
|
net
|
sched
| |
mlxsw: spectrum_qdisc: extract a per-tc stat function
|
extract from mlxsw_sp_qdisc_get_prio_stats() two new functions: mlxsw_sp_qdisc_collect_tc_stats() to accumulate stats for that one tc only, and mlxsw_sp_qdisc_update_stats() that makes the stats relative to base values stored earlier. use them from mlxsw_sp_qdisc_get_red_stats().
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 70
| 49
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +static void +mlxsw_sp_qdisc_collect_tc_stats(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + u64 *p_tx_bytes, u64 *p_tx_packets, + u64 *p_drops, u64 *p_backlog) +{ + u8 tclass_num = mlxsw_sp_qdisc->tclass_num; + struct mlxsw_sp_port_xstats *xstats; + u64 tx_bytes, tx_packets; + + xstats = &mlxsw_sp_port->periodic_hw_stats.xstats; + mlxsw_sp_qdisc_bstats_per_priority_get(xstats, + mlxsw_sp_qdisc->prio_bitmap, + &tx_packets, &tx_bytes); + + *p_tx_packets += tx_packets; + *p_tx_bytes += tx_bytes; + *p_drops += xstats->wred_drop[tclass_num] + + mlxsw_sp_xstats_tail_drop(xstats, tclass_num); + *p_backlog += mlxsw_sp_xstats_backlog(xstats, tclass_num); +} + +static void +mlxsw_sp_qdisc_update_stats(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + u64 tx_bytes, u64 tx_packets, + u64 drops, u64 backlog, + struct tc_qopt_offload_stats *stats_ptr) +{ + struct mlxsw_sp_qdisc_stats *stats_base = &mlxsw_sp_qdisc->stats_base; + + tx_bytes -= stats_base->tx_bytes; + tx_packets -= stats_base->tx_packets; + drops -= stats_base->drops; + backlog -= stats_base->backlog; + + _bstats_update(stats_ptr->bstats, tx_bytes, tx_packets); + stats_ptr->qstats->drops += drops; + stats_ptr->qstats->backlog += mlxsw_sp_cells_bytes(mlxsw_sp, backlog); + + stats_base->backlog += backlog; + stats_base->drops += drops; + stats_base->tx_bytes += tx_bytes; + stats_base->tx_packets += tx_packets; +} + - u64 tx_bytes, tx_packets, overlimits, drops, backlog; + u64 tx_packets = 0; + u64 tx_bytes = 0; + u64 backlog = 0; + u64 overlimits; + u64 drops = 0; - mlxsw_sp_qdisc_bstats_per_priority_get(xstats, - mlxsw_sp_qdisc->prio_bitmap, - &tx_packets, &tx_bytes); - tx_bytes = tx_bytes - stats_base->tx_bytes; - tx_packets = tx_packets - stats_base->tx_packets; - + mlxsw_sp_qdisc_collect_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, + &tx_bytes, &tx_packets, + &drops, &backlog); - drops = xstats->wred_drop[tclass_num] + - mlxsw_sp_xstats_tail_drop(xstats, tclass_num) - - stats_base->drops; - backlog = mlxsw_sp_xstats_backlog(xstats, tclass_num); - _bstats_update(stats_ptr->bstats, tx_bytes, tx_packets); + mlxsw_sp_qdisc_update_stats(mlxsw_sp_port->mlxsw_sp, mlxsw_sp_qdisc, + tx_bytes, tx_packets, drops, backlog, + stats_ptr); - stats_ptr->qstats->drops += drops; - stats_ptr->qstats->backlog += - mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp, - backlog) - - mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp, - stats_base->backlog); - - stats_base->backlog = backlog; - stats_base->drops += drops; - stats_base->tx_bytes += tx_bytes; - stats_base->tx_packets += tx_packets; + - u64 tx_bytes, tx_packets, drops = 0, backlog = 0; - struct mlxsw_sp_qdisc_stats *stats_base; - struct mlxsw_sp_port_xstats *xstats; - struct rtnl_link_stats64 *stats; + struct mlxsw_sp_qdisc *tc_qdisc; + u64 tx_packets = 0; + u64 tx_bytes = 0; + u64 backlog = 0; + u64 drops = 0; - xstats = &mlxsw_sp_port->periodic_hw_stats.xstats; - stats = &mlxsw_sp_port->periodic_hw_stats.stats; - stats_base = &mlxsw_sp_qdisc->stats_base; - - tx_bytes = stats->tx_bytes - stats_base->tx_bytes; - tx_packets = stats->tx_packets - stats_base->tx_packets; - - drops += mlxsw_sp_xstats_tail_drop(xstats, i); - drops += xstats->wred_drop[i]; - backlog += mlxsw_sp_xstats_backlog(xstats, i); + tc_qdisc = &mlxsw_sp_port->tclass_qdiscs[i]; + mlxsw_sp_qdisc_collect_tc_stats(mlxsw_sp_port, tc_qdisc, + &tx_bytes, &tx_packets, + &drops, &backlog); - drops = drops - stats_base->drops; - _bstats_update(stats_ptr->bstats, tx_bytes, tx_packets); - stats_ptr->qstats->drops += drops; - stats_ptr->qstats->backlog += - mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp, - backlog) - - mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp, - stats_base->backlog); - stats_base->backlog = backlog; - stats_base->drops += drops; - stats_base->tx_bytes += tx_bytes; - stats_base->tx_packets += tx_packets; + mlxsw_sp_qdisc_update_stats(mlxsw_sp_port->mlxsw_sp, mlxsw_sp_qdisc, + tx_bytes, tx_packets, drops, backlog, + stats_ptr);
|
Networking
|
cf9af379cd672d6873ae97ec416148708c6575e9
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum_qdisc: add mlxsw_sp_qdisc_get_class_stats()
|
add a wrapper around mlxsw_sp_qdisc_collect_tc_stats() and mlxsw_sp_qdisc_update_stats() for the simple case of doing both in one go: mlxsw_sp_qdisc_get_class_stats(). dispatch to that function from mlxsw_sp_qdisc_get_red_stats(). this new function will be useful for other leaf qdiscs as well.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 19
| 10
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +static void +mlxsw_sp_qdisc_get_tc_stats(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + struct tc_qopt_offload_stats *stats_ptr) +{ + u64 tx_packets = 0; + u64 tx_bytes = 0; + u64 backlog = 0; + u64 drops = 0; + + mlxsw_sp_qdisc_collect_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, + &tx_bytes, &tx_packets, + &drops, &backlog); + mlxsw_sp_qdisc_update_stats(mlxsw_sp_port->mlxsw_sp, mlxsw_sp_qdisc, + tx_bytes, tx_packets, drops, backlog, + stats_ptr); +} + - u64 tx_packets = 0; - u64 tx_bytes = 0; - u64 backlog = 0; - u64 drops = 0; - mlxsw_sp_qdisc_collect_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, - &tx_bytes, &tx_packets, - &drops, &backlog); + mlxsw_sp_qdisc_get_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, stats_ptr); - mlxsw_sp_qdisc_update_stats(mlxsw_sp_port->mlxsw_sp, mlxsw_sp_qdisc, - tx_bytes, tx_packets, drops, backlog, - stats_ptr);
|
Networking
|
3d0d592193dce954bf5ccac5128080830dd8e982
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum_qdisc: extract a common leaf unoffload function
|
when the red qdisc is unoffloaded, it needs to reduce the reported backlog by the amount that is in the hw, so that only the sw backlog is contained in the counter. the same thing will need to be done by tbf, and likely any other leaf qdisc as well.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 14
| 5
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c -mlxsw_sp_qdisc_red_unoffload(struct mlxsw_sp_port *mlxsw_sp_port, - struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, - void *params) +mlxsw_sp_qdisc_leaf_unoffload(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + struct gnet_stats_queue *qstats) - struct tc_red_qopt_offload_params *p = params; - p->qstats->backlog -= backlog; + qstats->backlog -= backlog; +static void +mlxsw_sp_qdisc_red_unoffload(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_red_qopt_offload_params *p = params; + + mlxsw_sp_qdisc_leaf_unoffload(mlxsw_sp_port, mlxsw_sp_qdisc, p->qstats); +} +
|
Networking
|
be1d5a8a7728cc734fc31b837796e7addc4ba832
|
petr machata
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: reg: add max_shaper_bs to qos ets element configuration
|
the qeec register configures scheduling elements. one of the bits of configuration is the burst size to use for the shaper installed on the element. add the necessary fields to support this configuration.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h']
| 1
| 15
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +/* reg_qeec_max_shaper_bs + * max shaper burst size + * burst size is 2^max_shaper_bs * 512 bits + * for spectrum-1: range is: 5..25 + * for spectrum-2: range is: 11..25 + * reserved when ptps = 1 + * access: rw + */ +mlxsw_item32(reg, qeec, max_shaper_bs, 0x1c, 0, 6); + +#define mlxsw_reg_qeec_highest_shaper_bs 25 +#define mlxsw_reg_qeec_lowest_shaper_bs_sp1 5 +#define mlxsw_reg_qeec_lowest_shaper_bs_sp2 11 +#define mlxsw_reg_qeec_lowest_shaper_bs_sp3 5 +
|
Networking
|
23effa2479bae2fbea69493afaab9914ee3862ca
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: reg: increase mlxsw_reg_qeec_mas_dis
|
as the port speeds grow, the current value of "unlimited shaper", 200000000kbps, might become lower than the actually supported speeds. bump it to the maximum value that fits in the corresponding qeec field, which is about 2.1tbps.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h']
| 1
| 2
| 2
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h -/* a large max rate will disable the max shaper. */ -#define mlxsw_reg_qeec_mas_dis 200000000 /* kbps */ +/* the largest max shaper value possible to disable the shaper. */ +#define mlxsw_reg_qeec_mas_dis ((1u << 31) - 1) /* kbps */
|
Networking
|
92afbfedb77d59a4077d292b88a316f3de706344
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum: add lowest_shaper_bs to struct mlxsw_sp
|
lower limit of burst size configuration is dependent on system type. add a datum to track the value. initialize as appropriate in mlxsw_spx_init().
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c', 'h']
| 2
| 4
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c + mlxsw_sp->lowest_shaper_bs = mlxsw_reg_qeec_lowest_shaper_bs_sp1; + mlxsw_sp->lowest_shaper_bs = mlxsw_reg_qeec_lowest_shaper_bs_sp2; + mlxsw_sp->lowest_shaper_bs = mlxsw_reg_qeec_lowest_shaper_bs_sp3; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h + u32 lowest_shaper_bs;
|
Networking
|
47259544e0fc0659f74f6ca6680745658969a803
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum: configure shaper rate and burst size together
|
in order to allow configuration of burst size together with shaper rate, extend mlxsw_sp_port_ets_maxrate_set() with a burst_size argument. convert call sites to pass 0 (for default).
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c', 'h']
| 3
| 10
| 8
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c - u8 next_index, u32 maxrate) + u8 next_index, u32 maxrate, u8 burst_size) + mlxsw_reg_qeec_max_shaper_bs_set(qeec_pl, burst_size); - mlxsw_reg_qeec_mas_dis); + mlxsw_reg_qeec_mas_dis, 0); - mlxsw_reg_qeec_mas_dis); + mlxsw_reg_qeec_mas_dis, 0); - mlxsw_reg_qeec_mas_dis); + mlxsw_reg_qeec_mas_dis, 0); - mlxsw_reg_qeec_mas_dis); + mlxsw_reg_qeec_mas_dis, 0); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h - u8 next_index, u32 maxrate); + u8 next_index, u32 maxrate, u8 burst_size); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c - maxrate->tc_maxrate[i]); + maxrate->tc_maxrate[i], 0); - i, 0, my_maxrate->tc_maxrate[i]); + i, 0, + my_maxrate->tc_maxrate[i], 0);
|
Networking
|
dbacf8ba5860e79d5191b0868bffa9e351d205e4
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum_qdisc: support offloading of tbf qdisc
|
react to the tc messages that were introduced in a preceding patch and configure egress maximum shaper as appropriate. tbf can be used as a root qdisc or under one of prio or strict ets bands.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c', 'h']
| 3
| 203
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c + case tc_setup_qdisc_tbf: + return mlxsw_sp_setup_tc_tbf(mlxsw_sp_port, type_data); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, + struct tc_tbf_qopt_offload *p); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c + mlxsw_sp_qdisc_tbf, +static void +mlxsw_sp_setup_tc_qdisc_leaf_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc) +{ + u64 backlog_cells = 0; + u64 tx_packets = 0; + u64 tx_bytes = 0; + u64 drops = 0; + + mlxsw_sp_qdisc_collect_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, + &tx_bytes, &tx_packets, + &drops, &backlog_cells); + + mlxsw_sp_qdisc->stats_base.tx_packets = tx_packets; + mlxsw_sp_qdisc->stats_base.tx_bytes = tx_bytes; + mlxsw_sp_qdisc->stats_base.drops = drops; + mlxsw_sp_qdisc->stats_base.backlog = 0; +} + +static int +mlxsw_sp_qdisc_tbf_destroy(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc) +{ + struct mlxsw_sp_qdisc *root_qdisc = mlxsw_sp_port->root_qdisc; + + if (root_qdisc != mlxsw_sp_qdisc) + root_qdisc->stats_base.backlog -= + mlxsw_sp_qdisc->stats_base.backlog; + + return mlxsw_sp_port_ets_maxrate_set(mlxsw_sp_port, + mlxsw_reg_qeec_hr_subgroup, + mlxsw_sp_qdisc->tclass_num, 0, + mlxsw_reg_qeec_mas_dis, 0); +} + +static int +mlxsw_sp_qdisc_tbf_bs(struct mlxsw_sp_port *mlxsw_sp_port, + u32 max_size, u8 *p_burst_size) +{ + /* tbf burst size is configured in bytes. the asic burst size value is + * ((2 ^ bs) * 512 bits. convert the tbf bytes to 512-bit units. + */ + u32 bs512 = max_size / 64; + u8 bs = fls(bs512); + + if (!bs) + return -einval; + --bs; + + /* demand a power of two. */ + if ((1 << bs) != bs512) + return -einval; + + if (bs < mlxsw_sp_port->mlxsw_sp->lowest_shaper_bs || + bs > mlxsw_reg_qeec_highest_shaper_bs) + return -einval; + + *p_burst_size = bs; + return 0; +} + +static u32 +mlxsw_sp_qdisc_tbf_max_size(u8 bs) +{ + return (1u << bs) * 64; +} + +static u64 +mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p) +{ + /* tbf interface is in bytes/s, whereas spectrum asic is configured in + * kbits/s. + */ + return p->rate.rate_bytes_ps / 1000 * 8; +} + +static int +mlxsw_sp_qdisc_tbf_check_params(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_tbf_qopt_offload_replace_params *p = params; + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + u64 rate_kbps = mlxsw_sp_qdisc_tbf_rate_kbps(p); + u8 burst_size; + int err; + + if (rate_kbps >= mlxsw_reg_qeec_mas_dis) { + dev_err(mlxsw_sp_port->mlxsw_sp->bus_info->dev, + "spectrum: tbf: rate of %llukbps must be below %u ", + rate_kbps, mlxsw_reg_qeec_mas_dis); + return -einval; + } + + err = mlxsw_sp_qdisc_tbf_bs(mlxsw_sp_port, p->max_size, &burst_size); + if (err) { + u8 highest_shaper_bs = mlxsw_reg_qeec_highest_shaper_bs; + + dev_err(mlxsw_sp->bus_info->dev, + "spectrum: tbf: invalid burst size of %u, must be a power of two between %u and %u", + p->max_size, + mlxsw_sp_qdisc_tbf_max_size(mlxsw_sp->lowest_shaper_bs), + mlxsw_sp_qdisc_tbf_max_size(highest_shaper_bs)); + return -einval; + } + + return 0; +} + +static int +mlxsw_sp_qdisc_tbf_replace(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_tbf_qopt_offload_replace_params *p = params; + u64 rate_kbps = mlxsw_sp_qdisc_tbf_rate_kbps(p); + u8 burst_size; + int err; + + err = mlxsw_sp_qdisc_tbf_bs(mlxsw_sp_port, p->max_size, &burst_size); + if (warn_on_once(err)) + /* check_params above was supposed to reject this value. */ + return -einval; + + /* configure subgroup shaper, so that both uc and mc traffic is subject + * to shaping. that is unlike red, however uc queue lengths are going to + * be different than mc ones due to different pool and quota + * configurations, so the configuration is not applicable. for shaper on + * the other hand, subjecting the overall stream to the configured + * shaper makes sense. also note that that is what we do for + * ieee_setmaxrate(). + */ + return mlxsw_sp_port_ets_maxrate_set(mlxsw_sp_port, + mlxsw_reg_qeec_hr_subgroup, + mlxsw_sp_qdisc->tclass_num, 0, + rate_kbps, burst_size); +} + +static void +mlxsw_sp_qdisc_tbf_unoffload(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_tbf_qopt_offload_replace_params *p = params; + + mlxsw_sp_qdisc_leaf_unoffload(mlxsw_sp_port, mlxsw_sp_qdisc, p->qstats); +} + +static int +mlxsw_sp_qdisc_get_tbf_stats(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + struct tc_qopt_offload_stats *stats_ptr) +{ + mlxsw_sp_qdisc_get_tc_stats(mlxsw_sp_port, mlxsw_sp_qdisc, + stats_ptr); + return 0; +} + +static struct mlxsw_sp_qdisc_ops mlxsw_sp_qdisc_ops_tbf = { + .type = mlxsw_sp_qdisc_tbf, + .check_params = mlxsw_sp_qdisc_tbf_check_params, + .replace = mlxsw_sp_qdisc_tbf_replace, + .unoffload = mlxsw_sp_qdisc_tbf_unoffload, + .destroy = mlxsw_sp_qdisc_tbf_destroy, + .get_stats = mlxsw_sp_qdisc_get_tbf_stats, + .clean_stats = mlxsw_sp_setup_tc_qdisc_leaf_clean_stats, +}; + +int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, + struct tc_tbf_qopt_offload *p) +{ + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc; + + mlxsw_sp_qdisc = mlxsw_sp_qdisc_find(mlxsw_sp_port, p->parent, false); + if (!mlxsw_sp_qdisc) + return -eopnotsupp; + + if (p->command == tc_tbf_replace) + return mlxsw_sp_qdisc_replace(mlxsw_sp_port, p->handle, + mlxsw_sp_qdisc, + &mlxsw_sp_qdisc_ops_tbf, + &p->replace_params); + + if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, + mlxsw_sp_qdisc_tbf)) + return -eopnotsupp; + + switch (p->command) { + case tc_tbf_destroy: + return mlxsw_sp_qdisc_destroy(mlxsw_sp_port, mlxsw_sp_qdisc); + case tc_tbf_stats: + return mlxsw_sp_qdisc_get_stats(mlxsw_sp_port, mlxsw_sp_qdisc, + &p->stats); + default: + return -eopnotsupp; + } +} +
|
Networking
|
a44f58c41bfbb921c1c4586bed9ad26aa2c6208a
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
selftests: move two functions from mlxsw's qos_lib to lib
|
the function humanize() is used for converting value in bits/s to a human-friendly approximate value in kbps, mbps or gbps. there is nothing hardware-specific in that, so move the function to lib.sh.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 2
| 24
| 24
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh --- a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh -humanize() -{ - local speed=$1; shift - - for unit in bps kbps mbps gbps; do - if (($(echo "$speed < 1024" | bc))); then - break - fi - - speed=$(echo "scale=1; $speed / 1024" | bc) - done - - echo "$speed${unit}" -} - -rate() -{ - local t0=$1; shift - local t1=$1; shift - local interval=$1; shift - - echo $((8 * (t1 - t0) / interval)) -} - diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh +humanize() +{ + local speed=$1; shift + + for unit in bps kbps mbps gbps; do + if (($(echo "$speed < 1024" | bc))); then + break + fi + + speed=$(echo "scale=1; $speed / 1024" | bc) + done + + echo "$speed${unit}" +} + +rate() +{ + local t0=$1; shift + local t1=$1; shift + local interval=$1; shift + + echo $((8 * (t1 - t0) / interval)) +} +
|
Networking
|
adc6c7ec11293117ec2763ccbe17d58349e011cf
|
petr machata
|
tools
|
testing
|
drivers, forwarding, mlxsw, net, selftests
|
selftests: forwarding: lib: add helpers for busywaiting
|
the function busywait() is handy as a safety-latched variant of a while loop. many selftests deal specifically with counter values, and busywaiting on them is likely to be rather common (it is not quite common now, but busywait() has not been around for very long). to facilitate expressing simply what is tested, introduce two helpers:
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 1
| 18
| 0
|
- until_counter_is(), which can be used as a predicate passed to - busywait_for_counter(), which is useful for waiting until a given counter --- diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh +until_counter_is() +{ + local value=$1; shift + local current=$("$@") + + echo $((current)) + ((current >= value)) +} + +busywait_for_counter() +{ + local timeout=$1; shift + local delta=$1; shift + + local base=$("$@") + busywait "$timeout" until_counter_is $((base + delta)) "$@" +} +
|
Networking
|
4121d9479b24c20ff7d3e7b62a7cf330fae7b2af
|
petr machata
|
tools
|
testing
|
forwarding, net, selftests
|
selftests: forwarding: lib: allow reading tc rule byte counters
|
the function tc_rule_stats_get() fetches a packet counter of a given tc rule. extend it to support byte counters as well by adding an optional argument with selector.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 1
| 2
| 1
|
--- diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh + local selector=${1:-.packets}; shift - | jq '.[1].options.actions[].stats.packets' + | jq ".[1].options.actions[].stats$selector"
|
Networking
|
c143139b7fd36cb66afb4423ac14a1efd8a45609
|
petr machata
|
tools
|
testing
|
forwarding, net, selftests
|
selftests: mlxsw: add a tbf selftest
|
add a test that runs traffic across a port throttled with tbf. the test checks that the observed throughput is within +-5% from the installed shaper.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
offload tbf
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 8
| 344
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_ets.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_ets.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_ets.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +source qos_lib.sh +bail_on_lldpad + +lib_dir=$(dirname $0)/../../../net/forwarding +tcflags=skip_sw +source $lib_dir/sch_tbf_ets.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_prio.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_prio.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_prio.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +source qos_lib.sh +bail_on_lldpad + +lib_dir=$(dirname $0)/../../../net/forwarding +tcflags=skip_sw +source $lib_dir/sch_tbf_prio.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_root.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_root.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_tbf_root.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +source qos_lib.sh +bail_on_lldpad + +lib_dir=$(dirname $0)/../../../net/forwarding +tcflags=skip_sw +source $lib_dir/sch_tbf_root.sh diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh +# spdx-license-identifier: gpl-2.0 + +# this test sends a stream of traffic from h1 through a switch, to h2. on the +# egress port from the switch ($swp2), a shaper is installed. the test verifies +# that the rates on the port match the configured shaper. +# +# in order to test per-class shaping, $swp2 actually contains tbf under prio or +# ets, with two different configurations. traffic is prioritized using 802.1p. +# +# +-------------------------------------------+ +# | h1 | +# | + $h1.10 $h1.11 + | +# | | 192.0.2.1/28 192.0.2.17/28 | | +# | | | | +# | \______________ _____________/ | +# | \ / | +# | + $h1 | +# +---------------------|---------------------+ +# | +# +---------------------|---------------------+ +# | sw + $swp1 | +# | _______________/ \_______________ | +# | / \ | +# | +-|--------------+ +--------------|-+ | +# | | + $swp1.10 | | $swp1.11 + | | +# | | | | | | +# | | br10 | | br11 | | +# | | | | | | +# | | + $swp2.10 | | $swp2.11 + | | +# | +-|--------------+ +--------------|-+ | +# | \_______________ ______________/ | +# | \ / | +# | + $swp2 | +# +---------------------|---------------------+ +# | +# +---------------------|---------------------+ +# | h2 + $h2 | +# | ______________/ \______________ | +# | / \ | +# | | | | +# | + $h2.10 $h2.11 + | +# | 192.0.2.2/28 192.0.2.18/28 | +# +-------------------------------------------+ + +num_netifs=4 +check_tc="yes" +source $lib_dir/lib.sh + +ipaddr() +{ + local host=$1; shift + local vlan=$1; shift + + echo 192.0.2.$((16 * (vlan - 10) + host)) +} + +host_create() +{ + local dev=$1; shift + local host=$1; shift + + simple_if_init $dev + mtu_set $dev 10000 + + vlan_create $dev 10 v$dev $(ipaddr $host 10)/28 + ip link set dev $dev.10 type vlan egress 0:0 + + vlan_create $dev 11 v$dev $(ipaddr $host 11)/28 + ip link set dev $dev.11 type vlan egress 0:1 +} + +host_destroy() +{ + local dev=$1; shift + + vlan_destroy $dev 11 + vlan_destroy $dev 10 + mtu_restore $dev + simple_if_fini $dev +} + +h1_create() +{ + host_create $h1 1 +} + +h1_destroy() +{ + host_destroy $h1 +} + +h2_create() +{ + host_create $h2 2 + + tc qdisc add dev $h2 clsact + tc filter add dev $h2 ingress pref 1010 prot 802.1q \ + flower $tcflags vlan_id 10 action pass + tc filter add dev $h2 ingress pref 1011 prot 802.1q \ + flower $tcflags vlan_id 11 action pass +} + +h2_destroy() +{ + tc qdisc del dev $h2 clsact + host_destroy $h2 +} + +switch_create() +{ + local intf + local vlan + + ip link add dev br10 type bridge + ip link add dev br11 type bridge + + for intf in $swp1 $swp2; do + ip link set dev $intf up + mtu_set $intf 10000 + + for vlan in 10 11; do + vlan_create $intf $vlan + ip link set dev $intf.$vlan master br$vlan + ip link set dev $intf.$vlan up + done + done + + for vlan in 10 11; do + ip link set dev $swp1.$vlan type vlan ingress 0:0 1:1 + done + + ip link set dev br10 up + ip link set dev br11 up +} + +switch_destroy() +{ + local intf + local vlan + + # a test may have been interrupted mid-run, with qdisc installed. delete + # it here. + tc qdisc del dev $swp2 root 2>/dev/null + + ip link set dev br11 down + ip link set dev br10 down + + for intf in $swp2 $swp1; do + for vlan in 11 10; do + ip link set dev $intf.$vlan down + ip link set dev $intf.$vlan nomaster + vlan_destroy $intf $vlan + done + + mtu_restore $intf + ip link set dev $intf down + done + + ip link del dev br11 + ip link del dev br10 +} + +setup_prepare() +{ + h1=${netifs[p1]} + swp1=${netifs[p2]} + + swp2=${netifs[p3]} + h2=${netifs[p4]} + + swp3=${netifs[p5]} + h3=${netifs[p6]} + + swp4=${netifs[p7]} + swp5=${netifs[p8]} + + h2_mac=$(mac_get $h2) + + vrf_prepare + + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + + vrf_cleanup +} + +ping_ipv4() +{ + ping_test $h1.10 $(ipaddr 2 10) " vlan 10" + ping_test $h1.11 $(ipaddr 2 11) " vlan 11" +} + +tbf_get_counter() +{ + local vlan=$1; shift + + tc_rule_stats_get $h2 10$vlan ingress .bytes +} + +do_tbf_test() +{ + local vlan=$1; shift + local mbit=$1; shift + + start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 2 $vlan) $h2_mac + sleep 5 # wait for the burst to dwindle + + local t2=$(busywait_for_counter 1000 +1 tbf_get_counter $vlan) + sleep 10 + local t3=$(tbf_get_counter $vlan) + stop_traffic + + ret=0 + + # note: tbf uses 10^6 mbits, not 2^20 ones. + local er=$((mbit * 1000 * 1000)) + local nr=$(rate $t2 $t3 10) + local nr_pct=$((100 * (nr - er) / er)) + ((-5 <= nr_pct && nr_pct <= 5)) + check_err $? "expected rate $(humanize $er), got $(humanize $nr), which is $nr_pct% off. required accuracy is +-5%." + + log_test "tc $((vlan - 10)): tbf rate ${mbit}mbit" +} diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_ets.sh b/tools/testing/selftests/net/forwarding/sch_tbf_ets.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_tbf_ets.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +qdisc="ets strict" +: ${lib_dir:=.} +source $lib_dir/sch_tbf_etsprio.sh diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh b/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +all_tests=" + ping_ipv4 + tbf_test +" +source $lib_dir/sch_tbf_core.sh + +tbf_test_one() +{ + local bs=$1; shift + + tc qdisc replace dev $swp2 parent 10:3 handle 103: tbf \ + rate 400mbit burst $bs limit 1m + tc qdisc replace dev $swp2 parent 10:2 handle 102: tbf \ + rate 800mbit burst $bs limit 1m + + do_tbf_test 10 400 $bs + do_tbf_test 11 800 $bs +} + +tbf_test() +{ + # this test is used for both ets and prio. even though we only need two + # bands, prio demands a minimum of three. + tc qdisc add dev $swp2 root handle 10: $qdisc 3 priomap 2 1 0 + tbf_test_one 128k + tc qdisc del dev $swp2 root +} + +trap cleanup exit + +setup_prepare +setup_wait + +tests_run + +exit $exit_status diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_prio.sh b/tools/testing/selftests/net/forwarding/sch_tbf_prio.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_tbf_prio.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +qdisc="prio bands" +: ${lib_dir:=.} +source $lib_dir/sch_tbf_etsprio.sh diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_root.sh b/tools/testing/selftests/net/forwarding/sch_tbf_root.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_tbf_root.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +all_tests=" + ping_ipv4 + tbf_test +" +: ${lib_dir:=.} +source $lib_dir/sch_tbf_core.sh + +tbf_test_one() +{ + local bs=$1; shift + + tc qdisc replace dev $swp2 root handle 108: tbf \ + rate 400mbit burst $bs limit 1m + do_tbf_test 10 400 $bs +} + +tbf_test() +{ + tbf_test_one 128k + tc qdisc del dev $swp2 root +} + +trap cleanup exit + +setup_prepare +setup_wait + +tests_run + +exit $exit_status
|
Networking
|
e814c58d454d952778fbb70bd0e71564f8c49f28
|
petr machata
|
tools
|
testing
|
drivers, forwarding, mlxsw, net, selftests
|
mlxsw: reg: add qos port dscp to priority mapping register
|
add qpdp. this register controls the port default switch priority and color. the default switch priority and color are used for frames where the trust state uses default values. currently there are two cases where this applies: a port is in trust-pcp state, but a packet arrives untagged; and a port is in trust-dscp state, but a non-ip packet arrives.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
allow setting default port priority
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h']
| 1
| 33
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +/* qpdp - qos port dscp to priority mapping register + * ------------------------------------------------- + * this register controls the port default switch priority and color. the + * default switch priority and color are used for frames where the trust state + * uses default values. all member ports of a lag should be configured with the + * same default values. + */ +#define mlxsw_reg_qpdp_id 0x4007 +#define mlxsw_reg_qpdp_len 0x8 + +mlxsw_reg_define(qpdp, mlxsw_reg_qpdp_id, mlxsw_reg_qpdp_len); + +/* reg_qpdp_local_port + * local port. supported for data packets from cpu port. + * access: index + */ +mlxsw_item32(reg, qpdp, local_port, 0x00, 16, 8); + +/* reg_qpdp_switch_prio + * default port switch priority (default 0) + * access: rw + */ +mlxsw_item32(reg, qpdp, switch_prio, 0x04, 0, 4); + +static inline void mlxsw_reg_qpdp_pack(char *payload, u8 local_port, + u8 switch_prio) +{ + mlxsw_reg_zero(qpdp, payload); + mlxsw_reg_qpdp_local_port_set(payload, local_port); + mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio); +} + + mlxsw_reg(qpdp),
|
Networking
|
d8446884f8d0b2b9f124b98cdf2d9b8c5fe128ba
|
petr machata jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum_dcb: allow setting default port priority
|
when app tlv selector 1 (ethertype) is used with pid of 0, the corresponding entry specifies "default application priority [...] when application priority is not otherwise specified."
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
allow setting default port priority
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 17
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c +static int +mlxsw_sp_port_dcb_app_update_qpdp(struct mlxsw_sp_port *mlxsw_sp_port, + u8 default_prio) +{ + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + char qpdp_pl[mlxsw_reg_qpdp_len]; + + mlxsw_reg_qpdp_pack(qpdp_pl, mlxsw_sp_port->local_port, default_prio); + return mlxsw_reg_write(mlxsw_sp->core, mlxsw_reg(qpdp), qpdp_pl); +} + + err = mlxsw_sp_port_dcb_app_update_qpdp(mlxsw_sp_port, default_prio); + if (err) { + netdev_err(mlxsw_sp_port->dev, "couldn't configure port default priority "); + return err; + } +
|
Networking
|
379a00dd21618f4354d41b1ac148188e005dbc05
|
petr machata
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
selftests: mlxsw: add a self-test for port-default priority
|
send non-ip traffic to a port and observe that it gets prioritized according to the lldptool app=$prio,1,0 rules.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
allow setting default port priority
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 2
| 199
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +# test for port-default priority. non-ip packets ingress $swp1 and are +# prioritized according to the default priority specified at the port. +# rx_octets_prio_* counters are used to verify the prioritization. +# +# +-----------------------+ +# | h1 | +# | + $h1 | +# | | 192.0.2.1/28 | +# +----|------------------+ +# | +# +----|------------------+ +# | sw | | +# | + $swp1 | +# | 192.0.2.2/28 | +# | app=<prio>,1,0 | +# +-----------------------+ + +all_tests=" + ping_ipv4 + test_defprio +" + +lib_dir=$(dirname $0)/../../../net/forwarding + +num_netifs=2 +: ${hit_timeout:=1000} # ms +source $lib_dir/lib.sh + +declare -a app + +defprio_install() +{ + local dev=$1; shift + local prio=$1; shift + local app="app=$prio,1,0" + + lldptool -t -i $dev -v app $app >/dev/null + lldpad_app_wait_set $dev + app[$prio]=$app +} + +defprio_uninstall() +{ + local dev=$1; shift + local prio=$1; shift + local app=${app[$prio]} + + lldptool -t -i $dev -v app -d $app >/dev/null + lldpad_app_wait_del + unset app[$prio] +} + +defprio_flush() +{ + local dev=$1; shift + local prio + + if ((${#app[@]})); then + lldptool -t -i $dev -v app -d ${app[@]} >/dev/null + fi + lldpad_app_wait_del + app=() +} + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/28 +} + +switch_create() +{ + ip link set dev $swp1 up + ip addr add dev $swp1 192.0.2.2/28 +} + +switch_destroy() +{ + defprio_flush $swp1 + ip addr del dev $swp1 192.0.2.2/28 + ip link set dev $swp1 down +} + +setup_prepare() +{ + h1=${netifs[p1]} + swp1=${netifs[p2]} + + vrf_prepare + + h1_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h1_destroy + + vrf_cleanup +} + +ping_ipv4() +{ + ping_test $h1 192.0.2.2 +} + +wait_for_packets() +{ + local t0=$1; shift + local prio_observe=$1; shift + + local t1=$(ethtool_stats_get $swp1 rx_frames_prio_$prio_observe) + local delta=$((t1 - t0)) + echo $delta + ((delta >= 10)) +} + +__test_defprio() +{ + local prio_install=$1; shift + local prio_observe=$1; shift + local delta + local key + local i + + ret=0 + + defprio_install $swp1 $prio_install + + local t0=$(ethtool_stats_get $swp1 rx_frames_prio_$prio_observe) + mausezahn -q $h1 -d 100m -c 10 -t arp reply + delta=$(busywait "$hit_timeout" wait_for_packets $t0 $prio_observe) + + check_err $? "default priority $prio_install/$prio_observe: expected to capture 10 packets, got $delta." + log_test "default priority $prio_install/$prio_observe" + + defprio_uninstall $swp1 $prio_install +} + +test_defprio() +{ + local prio + + for prio in {0..7}; do + __test_defprio $prio $prio + done + + defprio_install $swp1 3 + __test_defprio 0 3 + __test_defprio 1 3 + __test_defprio 2 3 + __test_defprio 4 4 + __test_defprio 5 5 + __test_defprio 6 6 + __test_defprio 7 7 + defprio_uninstall $swp1 3 +} + +trap cleanup exit + +setup_prepare +setup_wait + +tests_run + +exit $exit_status diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh +busywait() +{ + local timeout=$1; shift + + local start_time="$(date -u +%s%3n)" + while true + do + local out + out=$("$@") + local ret=$? + if ((!ret)); then + echo -n "$out" + return 0 + fi + + local current_time="$(date -u +%s%3n)" + if ((current_time - start_time > timeout)); then + echo -n "$out" + return 1 + fi + done +} +
|
Networking
|
c5341bcc337ca762faa58790c2065c76cd05f2e6
|
petr machata jiri pirko jiri mellanox com
|
tools
|
testing
|
drivers, forwarding, mlxsw, net, selftests
|
net: pkt_cls: clarify a comment
|
the bit about negating hw backlog left me scratching my head. clarify the comment.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h']
| 1
| 2
| 3
|
--- diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h - /* in case that a prio qdisc is offloaded and now is changed to a - * non-offloadedable config, it needs to update the backlog & qlen - * values to negate the hw backlog & qlen values (and only them). + /* at the point of un-offloading the qdisc, the reported backlog and + * qlen need to be reduced by the portion that is in hw.
|
Networking
|
9586a992fb752b14ac18fc86fe086b0e3372fff4
|
petr machata jiri pirko jiri mellanox com ido schimmel idosch mellanox com
|
include
|
net
| |
mlxsw: spectrum_qdisc: clarify a comment
|
expand the comment at mlxsw_sp_qdisc_prio_graft() to make the problem that this function is trying to handle clearer.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 24
| 7
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c -/* grafting is not supported in mlxsw. it will result in un-offloading of the - * grafted qdisc as well as the qdisc in the qdisc new location. - * (however, if the graft is to the location where the qdisc is already at, it - * will be ignored completely and won't cause un-offloading). +/* linux allows linking of qdiscs to arbitrary classes (so long as the resulting + * graph is free of cycles). these operations do not change the parent handle + * though, which means it can be incomplete (if there is more than one class + * where the qdisc in question is grafted) or outright wrong (if the qdisc was + * linked to a different class and then removed from the original class). + * + * e.g. consider this sequence of operations: + * + * # tc qdisc add dev swp1 root handle 1: prio + * # tc qdisc add dev swp1 parent 1:3 handle 13: red limit 1000000 avpkt 10000 + * red: set bandwidth to 10mbit + * # tc qdisc link dev swp1 handle 13: parent 1:2 + * + * at this point, both 1:2 and 1:3 have the same red qdisc instance as their + * child. but red will still only claim that 1:3 is its parent. if it's removed + * from that band, its only parent will be 1:2, but it will continue to claim + * that it is in fact 1:3. + * + * the notification for child qdisc replace (e.g. tc_red_replace) comes before + * the notification for parent graft (e.g. tc_prio_graft). we take the replace + * notification to offload the child qdisc, based on its parent handle, and use + * the graft operation to validate that the class where the child is actually + * grafted corresponds to the parent handle. if the two don't match, we + * unoffload the child. - /* check if the grafted qdisc is already in its "new" location. if so - - * nothing needs to be done. - */
|
Networking
|
5bc146c90e9eed409210809fae3c0efebef68ae1
|
petr machata jiri pirko jiri mellanox com ido schimmel idosch mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum: rename mlxsw_reg_qeec_hierarcy_* enumerators
|
these enums want to be named mlxsw_reg_qeec_hierarchy_, but due to a typo lack the second h. that is confusing and complicates searching.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'c']
| 3
| 18
| 20
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h - mlxsw_reg_qeec_hierarcy_port, - mlxsw_reg_qeec_hierarcy_group, - mlxsw_reg_qeec_hierarcy_subgroup, - mlxsw_reg_qeec_hierarcy_tc, + mlxsw_reg_qeec_hr_port, + mlxsw_reg_qeec_hr_group, + mlxsw_reg_qeec_hr_subgroup, + mlxsw_reg_qeec_hr_tc, - mlxsw_reg_qeec_element_hierarchy_set(payload, - mlxsw_reg_qeec_hierarcy_port); + mlxsw_reg_qeec_element_hierarchy_set(payload, mlxsw_reg_qeec_hr_port); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c - mlxsw_reg_qeec_hierarcy_group, 0, 0, false, - 0); + mlxsw_reg_qeec_hr_group, 0, 0, false, 0); - mlxsw_reg_qeec_hierarcy_subgroup, i, + mlxsw_reg_qeec_hr_subgroup, i, - mlxsw_reg_qeec_hierarcy_tc, i, i, + mlxsw_reg_qeec_hr_tc, i, i, - mlxsw_reg_qeec_hierarcy_tc, + mlxsw_reg_qeec_hr_tc, - mlxsw_reg_qeec_hierarcy_port, 0, 0, + mlxsw_reg_qeec_hr_port, 0, 0, - mlxsw_reg_qeec_hierarcy_subgroup, + mlxsw_reg_qeec_hr_subgroup, - mlxsw_reg_qeec_hierarcy_tc, + mlxsw_reg_qeec_hr_tc, - mlxsw_reg_qeec_hierarcy_tc, + mlxsw_reg_qeec_hr_tc, - mlxsw_reg_qeec_hierarcy_tc, + mlxsw_reg_qeec_hr_tc, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c - mlxsw_reg_qeec_hierarcy_subgroup, i, + mlxsw_reg_qeec_hr_subgroup, i, - mlxsw_reg_qeec_hierarcy_subgroup, i, + mlxsw_reg_qeec_hr_subgroup, i, - mlxsw_reg_qeec_hierarcy_subgroup, + mlxsw_reg_qeec_hr_subgroup, - mlxsw_reg_qeec_hierarcy_subgroup, + mlxsw_reg_qeec_hr_subgroup,
|
Networking
|
9cf9b925d5387b501732dcbc8fe3c77104d423f8
|
petr machata
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
net: sch_ets: add a new qdisc
|
introduces a new qdisc, which is based on 802.1q-2014 wording. it is prio-like in how it is configured, meaning one needs to specify how many bands there are, how many are strict and how many are dwrr, quanta for the latter, and priomap.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'kconfig', 'c', 'makefile']
| 4
| 768
| 0
|
--- diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h +/* ets */ + +#define tcq_ets_max_bands 16 + +enum { + tca_ets_unspec, + tca_ets_nbands, /* u8 */ + tca_ets_nstrict, /* u8 */ + tca_ets_quanta, /* nested tca_ets_quanta_band */ + tca_ets_quanta_band, /* u32 */ + tca_ets_priomap, /* nested tca_ets_priomap_band */ + tca_ets_priomap_band, /* u8 */ + __tca_ets_max, +}; + +#define tca_ets_max (__tca_ets_max - 1) + diff --git a/net/sched/kconfig b/net/sched/kconfig --- a/net/sched/kconfig +++ b/net/sched/kconfig +config net_sch_ets + tristate "enhanced transmission selection scheduler (ets)" + help + the enhanced transmission selection scheduler is a classful + queuing discipline that merges functionality of prio and drr + qdiscs in one scheduler. ets makes it easy to configure a set of + strict and bandwidth-sharing bands to implement the transmission + selection described in 802.1qaz. + + say y here if you want to use the ets packet scheduling + algorithm. + + to compile this driver as a module, choose m here: the module + will be called sch_ets. + + if unsure, say n. + ---help--- diff --git a/net/sched/makefile b/net/sched/makefile --- a/net/sched/makefile +++ b/net/sched/makefile +obj-$(config_net_sch_ets) += sch_ets.o diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c --- /dev/null +++ b/net/sched/sch_ets.c +// spdx-license-identifier: gpl-2.0-only +/* + * net/sched/sch_ets.c enhanced transmission selection scheduler + * + * description + * ----------- + * + * the enhanced transmission selection scheduler is a classful queuing + * discipline that merges functionality of prio and drr qdiscs in one scheduler. + * ets makes it easy to configure a set of strict and bandwidth-sharing bands to + * implement the transmission selection described in 802.1qaz. + * + * although ets is technically classful, it's not possible to add and remove + * classes at will. instead one specifies number of classes, how many are + * prio-like and how many drr-like, and quanta for the latter. + * + * algorithm + * --------- + * + * the strict classes, if any, are tried for traffic first: first band 0, if it + * has no traffic then band 1, etc. + * + * when there is no traffic in any of the strict queues, the bandwidth-sharing + * ones are tried next. each band is assigned a deficit counter, initialized to + * "quantum" of that band. ets maintains a list of active bandwidth-sharing + * bands whose qdiscs are non-empty. a packet is dequeued from the band at the + * head of the list if the packet size is smaller or equal to the deficit + * counter. if the counter is too small, it is increased by "quantum" and the + * scheduler moves on to the next band in the active list. + */ + +#include <linux/module.h> +#include <net/gen_stats.h> +#include <net/netlink.h> +#include <net/pkt_cls.h> +#include <net/pkt_sched.h> +#include <net/sch_generic.h> + +struct ets_class { + struct list_head alist; /* in struct ets_sched.active. */ + struct qdisc *qdisc; + u32 quantum; + u32 deficit; + struct gnet_stats_basic_packed bstats; + struct gnet_stats_queue qstats; +}; + +struct ets_sched { + struct list_head active; + struct tcf_proto __rcu *filter_list; + struct tcf_block *block; + unsigned int nbands; + unsigned int nstrict; + u8 prio2band[tc_prio_max + 1]; + struct ets_class classes[tcq_ets_max_bands]; +}; + +static const struct nla_policy ets_policy[tca_ets_max + 1] = { + [tca_ets_nbands] = { .type = nla_u8 }, + [tca_ets_nstrict] = { .type = nla_u8 }, + [tca_ets_quanta] = { .type = nla_nested }, + [tca_ets_priomap] = { .type = nla_nested }, +}; + +static const struct nla_policy ets_priomap_policy[tca_ets_max + 1] = { + [tca_ets_priomap_band] = { .type = nla_u8 }, +}; + +static const struct nla_policy ets_quanta_policy[tca_ets_max + 1] = { + [tca_ets_quanta_band] = { .type = nla_u32 }, +}; + +static const struct nla_policy ets_class_policy[tca_ets_max + 1] = { + [tca_ets_quanta_band] = { .type = nla_u32 }, +}; + +static int ets_quantum_parse(struct qdisc *sch, const struct nlattr *attr, + unsigned int *quantum, + struct netlink_ext_ack *extack) +{ + *quantum = nla_get_u32(attr); + if (!*quantum) { + nl_set_err_msg(extack, "ets quantum cannot be zero"); + return -einval; + } + return 0; +} + +static struct ets_class * +ets_class_from_arg(struct qdisc *sch, unsigned long arg) +{ + struct ets_sched *q = qdisc_priv(sch); + + return &q->classes[arg - 1]; +} + +static u32 ets_class_id(struct qdisc *sch, const struct ets_class *cl) +{ + struct ets_sched *q = qdisc_priv(sch); + int band = cl - q->classes; + + return tc_h_make(sch->handle, band + 1); +} + +static bool ets_class_is_strict(struct ets_sched *q, const struct ets_class *cl) +{ + unsigned int band = cl - q->classes; + + return band < q->nstrict; +} + +static int ets_class_change(struct qdisc *sch, u32 classid, u32 parentid, + struct nlattr **tca, unsigned long *arg, + struct netlink_ext_ack *extack) +{ + struct ets_class *cl = ets_class_from_arg(sch, *arg); + struct ets_sched *q = qdisc_priv(sch); + struct nlattr *opt = tca[tca_options]; + struct nlattr *tb[tca_ets_max + 1]; + unsigned int quantum; + int err; + + /* classes can be added and removed only through qdisc_ops.change + * interface. + */ + if (!cl) { + nl_set_err_msg(extack, "fine-grained class addition and removal is not supported"); + return -eopnotsupp; + } + + if (!opt) { + nl_set_err_msg(extack, "ets options are required for this operation"); + return -einval; + } + + err = nla_parse_nested(tb, tca_ets_max, opt, ets_class_policy, extack); + if (err < 0) + return err; + + if (!tb[tca_ets_quanta_band]) + /* nothing to configure. */ + return 0; + + if (ets_class_is_strict(q, cl)) { + nl_set_err_msg(extack, "strict bands do not have a configurable quantum"); + return -einval; + } + + err = ets_quantum_parse(sch, tb[tca_ets_quanta_band], &quantum, + extack); + if (err) + return err; + + sch_tree_lock(sch); + cl->quantum = quantum; + sch_tree_unlock(sch); + return 0; +} + +static int ets_class_graft(struct qdisc *sch, unsigned long arg, + struct qdisc *new, struct qdisc **old, + struct netlink_ext_ack *extack) +{ + struct ets_class *cl = ets_class_from_arg(sch, arg); + + if (!new) { + new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + ets_class_id(sch, cl), null); + if (!new) + new = &noop_qdisc; + else + qdisc_hash_add(new, true); + } + + *old = qdisc_replace(sch, new, &cl->qdisc); + return 0; +} + +static struct qdisc *ets_class_leaf(struct qdisc *sch, unsigned long arg) +{ + struct ets_class *cl = ets_class_from_arg(sch, arg); + + return cl->qdisc; +} + +static unsigned long ets_class_find(struct qdisc *sch, u32 classid) +{ + unsigned long band = tc_h_min(classid); + struct ets_sched *q = qdisc_priv(sch); + + if (band - 1 >= q->nbands) + return 0; + return band; +} + +static void ets_class_qlen_notify(struct qdisc *sch, unsigned long arg) +{ + struct ets_class *cl = ets_class_from_arg(sch, arg); + struct ets_sched *q = qdisc_priv(sch); + + /* we get notified about zero-length child qdiscs as well if they are + * offloaded. those aren't on the active list though, so don't attempt + * to remove them. + */ + if (!ets_class_is_strict(q, cl) && sch->q.qlen) + list_del(&cl->alist); +} + +static int ets_class_dump(struct qdisc *sch, unsigned long arg, + struct sk_buff *skb, struct tcmsg *tcm) +{ + struct ets_class *cl = ets_class_from_arg(sch, arg); + struct ets_sched *q = qdisc_priv(sch); + struct nlattr *nest; + + tcm->tcm_parent = tc_h_root; + tcm->tcm_handle = ets_class_id(sch, cl); + tcm->tcm_info = cl->qdisc->handle; + + nest = nla_nest_start_noflag(skb, tca_options); + if (!nest) + goto nla_put_failure; + if (!ets_class_is_strict(q, cl)) { + if (nla_put_u32(skb, tca_ets_quanta_band, cl->quantum)) + goto nla_put_failure; + } + return nla_nest_end(skb, nest); + +nla_put_failure: + nla_nest_cancel(skb, nest); + return -emsgsize; +} + +static int ets_class_dump_stats(struct qdisc *sch, unsigned long arg, + struct gnet_dump *d) +{ + struct ets_class *cl = ets_class_from_arg(sch, arg); + struct qdisc *cl_q = cl->qdisc; + + if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), + d, null, &cl_q->bstats) < 0 || + qdisc_qstats_copy(d, cl_q) < 0) + return -1; + + return 0; +} + +static void ets_qdisc_walk(struct qdisc *sch, struct qdisc_walker *arg) +{ + struct ets_sched *q = qdisc_priv(sch); + int i; + + if (arg->stop) + return; + + for (i = 0; i < q->nbands; i++) { + if (arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, i + 1, arg) < 0) { + arg->stop = 1; + break; + } + arg->count++; + } +} + +static struct tcf_block * +ets_qdisc_tcf_block(struct qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) +{ + struct ets_sched *q = qdisc_priv(sch); + + if (cl) { + nl_set_err_msg(extack, "ets classid must be zero"); + return null; + } + + return q->block; +} + +static unsigned long ets_qdisc_bind_tcf(struct qdisc *sch, unsigned long parent, + u32 classid) +{ + return ets_class_find(sch, classid); +} + +static void ets_qdisc_unbind_tcf(struct qdisc *sch, unsigned long arg) +{ +} + +static struct ets_class *ets_classify(struct sk_buff *skb, struct qdisc *sch, + int *qerr) +{ + struct ets_sched *q = qdisc_priv(sch); + u32 band = skb->priority; + struct tcf_result res; + struct tcf_proto *fl; + int err; + + *qerr = net_xmit_success | __net_xmit_bypass; + if (tc_h_maj(skb->priority) != sch->handle) { + fl = rcu_dereference_bh(q->filter_list); + err = tcf_classify(skb, fl, &res, false); +#ifdef config_net_cls_act + switch (err) { + case tc_act_stolen: + case tc_act_queued: + case tc_act_trap: + *qerr = net_xmit_success | __net_xmit_stolen; + /* fall through */ + case tc_act_shot: + return null; + } +#endif + if (!fl || err < 0) { + if (tc_h_maj(band)) + band = 0; + return &q->classes[q->prio2band[band & tc_prio_max]]; + } + band = res.classid; + } + band = tc_h_min(band) - 1; + if (band >= q->nbands) + return &q->classes[q->prio2band[0]]; + return &q->classes[band]; +} + +static int ets_qdisc_enqueue(struct sk_buff *skb, struct qdisc *sch, + struct sk_buff **to_free) +{ + unsigned int len = qdisc_pkt_len(skb); + struct ets_sched *q = qdisc_priv(sch); + struct ets_class *cl; + int err = 0; + bool first; + + cl = ets_classify(skb, sch, &err); + if (!cl) { + if (err & __net_xmit_bypass) + qdisc_qstats_drop(sch); + __qdisc_drop(skb, to_free); + return err; + } + + first = !cl->qdisc->q.qlen; + err = qdisc_enqueue(skb, cl->qdisc, to_free); + if (unlikely(err != net_xmit_success)) { + if (net_xmit_drop_count(err)) { + cl->qstats.drops++; + qdisc_qstats_drop(sch); + } + return err; + } + + if (first && !ets_class_is_strict(q, cl)) { + list_add_tail(&cl->alist, &q->active); + cl->deficit = cl->quantum; + } + + sch->qstats.backlog += len; + sch->q.qlen++; + return err; +} + +static struct sk_buff * +ets_qdisc_dequeue_skb(struct qdisc *sch, struct sk_buff *skb) +{ + qdisc_bstats_update(sch, skb); + qdisc_qstats_backlog_dec(sch, skb); + sch->q.qlen--; + return skb; +} + +static struct sk_buff *ets_qdisc_dequeue(struct qdisc *sch) +{ + struct ets_sched *q = qdisc_priv(sch); + struct ets_class *cl; + struct sk_buff *skb; + unsigned int band; + unsigned int len; + + while (1) { + for (band = 0; band < q->nstrict; band++) { + cl = &q->classes[band]; + skb = qdisc_dequeue_peeked(cl->qdisc); + if (skb) + return ets_qdisc_dequeue_skb(sch, skb); + } + + if (list_empty(&q->active)) + goto out; + + cl = list_first_entry(&q->active, struct ets_class, alist); + skb = cl->qdisc->ops->peek(cl->qdisc); + if (!skb) { + qdisc_warn_nonwc(__func__, cl->qdisc); + goto out; + } + + len = qdisc_pkt_len(skb); + if (len <= cl->deficit) { + cl->deficit -= len; + skb = qdisc_dequeue_peeked(cl->qdisc); + if (unlikely(!skb)) + goto out; + if (cl->qdisc->q.qlen == 0) + list_del(&cl->alist); + return ets_qdisc_dequeue_skb(sch, skb); + } + + cl->deficit += cl->quantum; + list_move_tail(&cl->alist, &q->active); + } +out: + return null; +} + +static int ets_qdisc_priomap_parse(struct nlattr *priomap_attr, + unsigned int nbands, u8 *priomap, + struct netlink_ext_ack *extack) +{ + const struct nlattr *attr; + int prio = 0; + u8 band; + int rem; + int err; + + err = __nla_validate_nested(priomap_attr, tca_ets_max, + ets_priomap_policy, nl_validate_strict, + extack); + if (err) + return err; + + nla_for_each_nested(attr, priomap_attr, rem) { + switch (nla_type(attr)) { + case tca_ets_priomap_band: + if (prio > tc_prio_max) { + nl_set_err_msg_mod(extack, "too many priorities in ets priomap"); + return -einval; + } + band = nla_get_u8(attr); + if (band >= nbands) { + nl_set_err_msg_mod(extack, "invalid band number in ets priomap"); + return -einval; + } + priomap[prio++] = band; + break; + default: + warn_on_once(1); /* validate should have caught this. */ + return -einval; + } + } + + return 0; +} + +static int ets_qdisc_quanta_parse(struct qdisc *sch, struct nlattr *quanta_attr, + unsigned int nbands, unsigned int nstrict, + unsigned int *quanta, + struct netlink_ext_ack *extack) +{ + const struct nlattr *attr; + int band = nstrict; + int rem; + int err; + + err = __nla_validate_nested(quanta_attr, tca_ets_max, + ets_quanta_policy, nl_validate_strict, + extack); + if (err < 0) + return err; + + nla_for_each_nested(attr, quanta_attr, rem) { + switch (nla_type(attr)) { + case tca_ets_quanta_band: + if (band >= nbands) { + nl_set_err_msg_mod(extack, "ets quanta has more values than bands"); + return -einval; + } + err = ets_quantum_parse(sch, attr, &quanta[band++], + extack); + if (err) + return err; + break; + default: + warn_on_once(1); /* validate should have caught this. */ + return -einval; + } + } + + return 0; +} + +static int ets_qdisc_change(struct qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) +{ + unsigned int quanta[tcq_ets_max_bands] = {0}; + struct qdisc *queues[tcq_ets_max_bands]; + struct ets_sched *q = qdisc_priv(sch); + struct nlattr *tb[tca_ets_max + 1]; + unsigned int oldbands = q->nbands; + u8 priomap[tc_prio_max + 1]; + unsigned int nstrict = 0; + unsigned int nbands; + unsigned int i; + int err; + + if (!opt) { + nl_set_err_msg(extack, "ets options are required for this operation"); + return -einval; + } + + err = nla_parse_nested(tb, tca_ets_max, opt, ets_policy, extack); + if (err < 0) + return err; + + if (!tb[tca_ets_nbands]) { + nl_set_err_msg_mod(extack, "number of bands is a required argument"); + return -einval; + } + nbands = nla_get_u8(tb[tca_ets_nbands]); + if (nbands < 1 || nbands > tcq_ets_max_bands) { + nl_set_err_msg_mod(extack, "invalid number of bands"); + return -einval; + } + /* unless overridden, traffic goes to the last band. */ + memset(priomap, nbands - 1, sizeof(priomap)); + + if (tb[tca_ets_nstrict]) { + nstrict = nla_get_u8(tb[tca_ets_nstrict]); + if (nstrict > nbands) { + nl_set_err_msg_mod(extack, "invalid number of strict bands"); + return -einval; + } + } + + if (tb[tca_ets_priomap]) { + err = ets_qdisc_priomap_parse(tb[tca_ets_priomap], + nbands, priomap, extack); + if (err) + return err; + } + + if (tb[tca_ets_quanta]) { + err = ets_qdisc_quanta_parse(sch, tb[tca_ets_quanta], + nbands, nstrict, quanta, extack); + if (err) + return err; + } + /* if there are more bands than strict + quanta provided, the remaining + * ones are ets with quantum of mtu. initialize the missing values here. + */ + for (i = nstrict; i < nbands; i++) { + if (!quanta[i]) + quanta[i] = psched_mtu(qdisc_dev(sch)); + } + + /* before commit, make sure we can allocate all new qdiscs */ + for (i = oldbands; i < nbands; i++) { + queues[i] = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + ets_class_id(sch, &q->classes[i]), + extack); + if (!queues[i]) { + while (i > oldbands) + qdisc_put(queues[--i]); + return -enomem; + } + } + + sch_tree_lock(sch); + + q->nbands = nbands; + q->nstrict = nstrict; + memcpy(q->prio2band, priomap, sizeof(priomap)); + + for (i = q->nbands; i < oldbands; i++) + qdisc_tree_flush_backlog(q->classes[i].qdisc); + + for (i = 0; i < q->nbands; i++) + q->classes[i].quantum = quanta[i]; + + for (i = oldbands; i < q->nbands; i++) { + q->classes[i].qdisc = queues[i]; + if (q->classes[i].qdisc != &noop_qdisc) + qdisc_hash_add(q->classes[i].qdisc, true); + } + + sch_tree_unlock(sch); + + for (i = q->nbands; i < oldbands; i++) { + qdisc_put(q->classes[i].qdisc); + memset(&q->classes[i], 0, sizeof(q->classes[i])); + } + return 0; +} + +static int ets_qdisc_init(struct qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) +{ + struct ets_sched *q = qdisc_priv(sch); + int err; + + if (!opt) + return -einval; + + err = tcf_block_get(&q->block, &q->filter_list, sch, extack); + if (err) + return err; + + init_list_head(&q->active); + return ets_qdisc_change(sch, opt, extack); +} + +static void ets_qdisc_reset(struct qdisc *sch) +{ + struct ets_sched *q = qdisc_priv(sch); + int band; + + for (band = q->nstrict; band < q->nbands; band++) { + if (q->classes[band].qdisc->q.qlen) + list_del(&q->classes[band].alist); + } + for (band = 0; band < q->nbands; band++) + qdisc_reset(q->classes[band].qdisc); + sch->qstats.backlog = 0; + sch->q.qlen = 0; +} + +static void ets_qdisc_destroy(struct qdisc *sch) +{ + struct ets_sched *q = qdisc_priv(sch); + int band; + + tcf_block_put(q->block); + for (band = 0; band < q->nbands; band++) + qdisc_put(q->classes[band].qdisc); +} + +static int ets_qdisc_dump(struct qdisc *sch, struct sk_buff *skb) +{ + struct ets_sched *q = qdisc_priv(sch); + struct nlattr *opts; + struct nlattr *nest; + int band; + int prio; + + opts = nla_nest_start_noflag(skb, tca_options); + if (!opts) + goto nla_err; + + if (nla_put_u8(skb, tca_ets_nbands, q->nbands)) + goto nla_err; + + if (q->nstrict && + nla_put_u8(skb, tca_ets_nstrict, q->nstrict)) + goto nla_err; + + if (q->nbands > q->nstrict) { + nest = nla_nest_start(skb, tca_ets_quanta); + if (!nest) + goto nla_err; + + for (band = q->nstrict; band < q->nbands; band++) { + if (nla_put_u32(skb, tca_ets_quanta_band, + q->classes[band].quantum)) + goto nla_err; + } + + nla_nest_end(skb, nest); + } + + nest = nla_nest_start(skb, tca_ets_priomap); + if (!nest) + goto nla_err; + + for (prio = 0; prio <= tc_prio_max; prio++) { + if (nla_put_u8(skb, tca_ets_priomap_band, q->prio2band[prio])) + goto nla_err; + } + + nla_nest_end(skb, nest); + + return nla_nest_end(skb, opts); + +nla_err: + nla_nest_cancel(skb, opts); + return -emsgsize; +} + +static const struct qdisc_class_ops ets_class_ops = { + .change = ets_class_change, + .graft = ets_class_graft, + .leaf = ets_class_leaf, + .find = ets_class_find, + .qlen_notify = ets_class_qlen_notify, + .dump = ets_class_dump, + .dump_stats = ets_class_dump_stats, + .walk = ets_qdisc_walk, + .tcf_block = ets_qdisc_tcf_block, + .bind_tcf = ets_qdisc_bind_tcf, + .unbind_tcf = ets_qdisc_unbind_tcf, +}; + +static struct qdisc_ops ets_qdisc_ops __read_mostly = { + .cl_ops = &ets_class_ops, + .id = "ets", + .priv_size = sizeof(struct ets_sched), + .enqueue = ets_qdisc_enqueue, + .dequeue = ets_qdisc_dequeue, + .peek = qdisc_peek_dequeued, + .change = ets_qdisc_change, + .init = ets_qdisc_init, + .reset = ets_qdisc_reset, + .destroy = ets_qdisc_destroy, + .dump = ets_qdisc_dump, + .owner = this_module, +}; + +static int __init ets_init(void) +{ + return register_qdisc(&ets_qdisc_ops); +} + +static void __exit ets_exit(void) +{ + unregister_qdisc(&ets_qdisc_ops); +} + +module_init(ets_init); +module_exit(ets_exit); +module_license("gpl");
|
Networking
|
dcc68b4d8084e1ac9af0d4022d6b1aff6a139a33
|
petr machata
|
net
|
sched
|
linux
|
net: sch_ets: make the ets qdisc offloadable
|
add hooks at appropriate points to make it possible to offload the ets qdisc.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['h', 'c']
| 3
| 127
| 0
|
--- diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h + tc_setup_qdisc_ets, diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h +enum tc_ets_command { + tc_ets_replace, + tc_ets_destroy, + tc_ets_stats, + tc_ets_graft, +}; + +struct tc_ets_qopt_offload_replace_params { + unsigned int bands; + u8 priomap[tc_prio_max + 1]; + unsigned int quanta[tcq_ets_max_bands]; /* 0 for strict bands. */ + unsigned int weights[tcq_ets_max_bands]; + struct gnet_stats_queue *qstats; +}; + +struct tc_ets_qopt_offload_graft_params { + u8 band; + u32 child_handle; +}; + +struct tc_ets_qopt_offload { + enum tc_ets_command command; + u32 handle; + u32 parent; + union { + struct tc_ets_qopt_offload_replace_params replace_params; + struct tc_qopt_offload_stats stats; + struct tc_ets_qopt_offload_graft_params graft_params; + }; +}; + diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c --- a/net/sched/sch_ets.c +++ b/net/sched/sch_ets.c +static void ets_offload_change(struct qdisc *sch) +{ + struct net_device *dev = qdisc_dev(sch); + struct ets_sched *q = qdisc_priv(sch); + struct tc_ets_qopt_offload qopt; + unsigned int w_psum_prev = 0; + unsigned int q_psum = 0; + unsigned int q_sum = 0; + unsigned int quantum; + unsigned int w_psum; + unsigned int weight; + unsigned int i; + + if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) + return; + + qopt.command = tc_ets_replace; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + qopt.replace_params.bands = q->nbands; + qopt.replace_params.qstats = &sch->qstats; + memcpy(&qopt.replace_params.priomap, + q->prio2band, sizeof(q->prio2band)); + + for (i = 0; i < q->nbands; i++) + q_sum += q->classes[i].quantum; + + for (i = 0; i < q->nbands; i++) { + quantum = q->classes[i].quantum; + q_psum += quantum; + w_psum = quantum ? q_psum * 100 / q_sum : 0; + weight = w_psum - w_psum_prev; + w_psum_prev = w_psum; + + qopt.replace_params.quanta[i] = quantum; + qopt.replace_params.weights[i] = weight; + } + + dev->netdev_ops->ndo_setup_tc(dev, tc_setup_qdisc_ets, &qopt); +} + +static void ets_offload_destroy(struct qdisc *sch) +{ + struct net_device *dev = qdisc_dev(sch); + struct tc_ets_qopt_offload qopt; + + if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) + return; + + qopt.command = tc_ets_destroy; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + dev->netdev_ops->ndo_setup_tc(dev, tc_setup_qdisc_ets, &qopt); +} + +static void ets_offload_graft(struct qdisc *sch, struct qdisc *new, + struct qdisc *old, unsigned long arg, + struct netlink_ext_ack *extack) +{ + struct net_device *dev = qdisc_dev(sch); + struct tc_ets_qopt_offload qopt; + + qopt.command = tc_ets_graft; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + qopt.graft_params.band = arg - 1; + qopt.graft_params.child_handle = new->handle; + + qdisc_offload_graft_helper(dev, sch, new, old, tc_setup_qdisc_ets, + &qopt, extack); +} + +static int ets_offload_dump(struct qdisc *sch) +{ + struct tc_ets_qopt_offload qopt; + + qopt.command = tc_ets_stats; + qopt.handle = sch->handle; + qopt.parent = sch->parent; + qopt.stats.bstats = &sch->bstats; + qopt.stats.qstats = &sch->qstats; + + return qdisc_offload_dump_helper(sch, tc_setup_qdisc_ets, &qopt); +} + + + ets_offload_change(sch); + ets_offload_graft(sch, new, *old, arg, extack); + ets_offload_change(sch); + ets_offload_destroy(sch); + int err; + + err = ets_offload_dump(sch); + if (err) + return err;
|
Networking
|
d35eb52bd2ac7557b62bda52668f2e64dde2cf90
|
petr machata jiri pirko jiri mellanox com ido schimmel idosch mellanox com
|
net
|
sched
| |
mlxsw: spectrum_qdisc: generalize prio offload to support ets
|
thanks to the similarity between prio and ets it is possible to simply reuse most of the code for offloading prio qdisc. extract the common functionality into separate functions, making the current prio handlers thin api adapters.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c']
| 1
| 81
| 23
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c -mlxsw_sp_qdisc_prio_destroy(struct mlxsw_sp_port *mlxsw_sp_port, - struct mlxsw_sp_qdisc *mlxsw_sp_qdisc) +__mlxsw_sp_qdisc_ets_destroy(struct mlxsw_sp_port *mlxsw_sp_port) + mlxsw_sp_port_ets_set(mlxsw_sp_port, + mlxsw_reg_qeec_hr_subgroup, + i, 0, false, 0); -mlxsw_sp_qdisc_prio_check_params(struct mlxsw_sp_port *mlxsw_sp_port, - struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, - void *params) +mlxsw_sp_qdisc_prio_destroy(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc) - struct tc_prio_qopt_offload_params *p = params; + return __mlxsw_sp_qdisc_ets_destroy(mlxsw_sp_port); +} - if (p->bands > ieee_8021qaz_max_tcs) +static int +__mlxsw_sp_qdisc_ets_check_params(unsigned int nbands) +{ + if (nbands > ieee_8021qaz_max_tcs) -mlxsw_sp_qdisc_prio_replace(struct mlxsw_sp_port *mlxsw_sp_port, - struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, - void *params) +mlxsw_sp_qdisc_prio_check_params(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) + + return __mlxsw_sp_qdisc_ets_check_params(p->bands); +} + +static int +__mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port, + unsigned int nbands, + const unsigned int *quanta, + const unsigned int *weights, + const u8 *priomap) +{ - for (band = 0; band < p->bands; band++) { + for (band = 0; band < nbands; band++) { + + err = mlxsw_sp_port_ets_set(mlxsw_sp_port, + mlxsw_reg_qeec_hr_subgroup, + tclass, 0, !!quanta[band], + weights[band]); + if (err) + return err; + - if (p->priomap[i] == band) { + if (priomap[i] == band) { + mlxsw_sp_port_ets_set(mlxsw_sp_port, + mlxsw_reg_qeec_hr_subgroup, + tclass, 0, false, 0); +static int +mlxsw_sp_qdisc_prio_replace(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_prio_qopt_offload_params *p = params; + unsigned int zeroes[tcq_ets_max_bands] = {0}; + + return __mlxsw_sp_qdisc_ets_replace(mlxsw_sp_port, p->bands, + zeroes, zeroes, p->priomap); +} + +static void +__mlxsw_sp_qdisc_ets_unoffload(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + struct gnet_stats_queue *qstats) +{ + u64 backlog; + + backlog = mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp, + mlxsw_sp_qdisc->stats_base.backlog); + qstats->backlog -= backlog; +} + - u64 backlog; - backlog = mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp, - mlxsw_sp_qdisc->stats_base.backlog); - p->qstats->backlog -= backlog; + __mlxsw_sp_qdisc_ets_unoffload(mlxsw_sp_port, mlxsw_sp_qdisc, + p->qstats); -mlxsw_sp_qdisc_prio_graft(struct mlxsw_sp_port *mlxsw_sp_port, - struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, - struct tc_prio_qopt_offload_graft_params *p) +__mlxsw_sp_qdisc_ets_graft(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + u8 band, u32 child_handle) - int tclass_num = mlxsw_sp_prio_band_to_tclass(p->band); + int tclass_num = mlxsw_sp_prio_band_to_tclass(band); - if (p->band < ieee_8021qaz_max_tcs && - mlxsw_sp_port->tclass_qdiscs[tclass_num].handle == p->child_handle) + if (band < ieee_8021qaz_max_tcs && + mlxsw_sp_port->tclass_qdiscs[tclass_num].handle == child_handle) - p->child_handle); + child_handle); +static int +mlxsw_sp_qdisc_prio_graft(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + struct tc_prio_qopt_offload_graft_params *p) +{ + return __mlxsw_sp_qdisc_ets_graft(mlxsw_sp_port, mlxsw_sp_qdisc, + p->band, p->child_handle); +} +
|
Networking
|
7917f52ae188b87de627a892b57646abfe5a82bc
|
petr machata
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: spectrum_qdisc: support offloading of ets qdisc
|
handle tc_setup_qdisc_ets, add a new ops structure for the ets qdisc. invoke the extended prio handlers implemented in the previous patch. for stats ops, invoke directly the prio callbacks, which are not sensitive to differences between prio and ets.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['c', 'h']
| 3
| 88
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c + case tc_setup_qdisc_ets: + return mlxsw_sp_setup_tc_ets(mlxsw_sp_port, type_data); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port, + struct tc_ets_qopt_offload *p); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c + mlxsw_sp_qdisc_ets, +static int +mlxsw_sp_qdisc_ets_check_params(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_ets_qopt_offload_replace_params *p = params; + + return __mlxsw_sp_qdisc_ets_check_params(p->bands); +} + +static int +mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_ets_qopt_offload_replace_params *p = params; + + return __mlxsw_sp_qdisc_ets_replace(mlxsw_sp_port, p->bands, + p->quanta, p->weights, p->priomap); +} + +static void +mlxsw_sp_qdisc_ets_unoffload(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, + void *params) +{ + struct tc_ets_qopt_offload_replace_params *p = params; + + __mlxsw_sp_qdisc_ets_unoffload(mlxsw_sp_port, mlxsw_sp_qdisc, + p->qstats); +} + +static int +mlxsw_sp_qdisc_ets_destroy(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc) +{ + return __mlxsw_sp_qdisc_ets_destroy(mlxsw_sp_port); +} + +static struct mlxsw_sp_qdisc_ops mlxsw_sp_qdisc_ops_ets = { + .type = mlxsw_sp_qdisc_ets, + .check_params = mlxsw_sp_qdisc_ets_check_params, + .replace = mlxsw_sp_qdisc_ets_replace, + .unoffload = mlxsw_sp_qdisc_ets_unoffload, + .destroy = mlxsw_sp_qdisc_ets_destroy, + .get_stats = mlxsw_sp_qdisc_get_prio_stats, + .clean_stats = mlxsw_sp_setup_tc_qdisc_prio_clean_stats, +}; + +int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port, + struct tc_ets_qopt_offload *p) +{ + struct mlxsw_sp_qdisc *mlxsw_sp_qdisc; + + mlxsw_sp_qdisc = mlxsw_sp_qdisc_find(mlxsw_sp_port, p->parent, true); + if (!mlxsw_sp_qdisc) + return -eopnotsupp; + + if (p->command == tc_ets_replace) + return mlxsw_sp_qdisc_replace(mlxsw_sp_port, p->handle, + mlxsw_sp_qdisc, + &mlxsw_sp_qdisc_ops_ets, + &p->replace_params); + + if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, + mlxsw_sp_qdisc_ets)) + return -eopnotsupp; + + switch (p->command) { + case tc_ets_destroy: + return mlxsw_sp_qdisc_destroy(mlxsw_sp_port, mlxsw_sp_qdisc); + case tc_ets_stats: + return mlxsw_sp_qdisc_get_stats(mlxsw_sp_port, mlxsw_sp_qdisc, + &p->stats); + case tc_ets_graft: + return __mlxsw_sp_qdisc_ets_graft(mlxsw_sp_port, mlxsw_sp_qdisc, + p->graft_params.band, + p->graft_params.child_handle); + default: + return -eopnotsupp; + } +} +
|
Networking
|
19f405b988e7bdee75e4936d27d2909c11574a7c
|
petr machata jiri pirko jiri mellanox com ido schimmel idosch mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
selftests: forwarding: move start_/stop_traffic from mlxsw to lib.sh
|
these two functions are used for starting several streams of traffic, and then stopping them later. they will be handy for the test coverage of ets qdisc. move them from mlxsw-specific qos_lib.sh to the generic lib.sh.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 2
| 18
| 18
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh --- a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh -start_traffic() -{ - local h_in=$1; shift # where the traffic egresses the host - local sip=$1; shift - local dip=$1; shift - local dmac=$1; shift - - $mz $h_in -p 8000 -a $sip -b $dip -c 0 \ - -a own -b $dmac -t udp -q & - sleep 1 -} - -stop_traffic() -{ - # suppress noise from killing mausezahn. - { kill %% && wait %%; } 2>/dev/null -} - diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh + +start_traffic() +{ + local h_in=$1; shift # where the traffic egresses the host + local sip=$1; shift + local dip=$1; shift + local dmac=$1; shift + + $mz $h_in -p 8000 -a $sip -b $dip -c 0 \ + -a own -b $dmac -t udp -q & + sleep 1 +} + +stop_traffic() +{ + # suppress noise from killing mausezahn. + { kill %% && wait %%; } 2>/dev/null +}
|
Networking
|
4cf9b8f9929285b91f5f22652ad5175a2206303b
|
petr machata jiri pirko jiri mellanox com ido schimmel idosch mellanox com
|
tools
|
testing
|
drivers, forwarding, mlxsw, net, selftests
|
selftests: forwarding: sch_ets: add test coverage for ets qdisc
|
this tests the newly-added ets qdisc. it runs two to three streams of traffic, each with a different priority. ets qdisc is supposed to allocate bandwidth according to the drr algorithm and given weights. after running the traffic for a while, counters are compared for each stream to check that the expected ratio is in fact observed.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['sh']
| 5
| 666
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh --- a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh + +bail_on_lldpad() +{ + if systemctl is-active --quiet lldpad; then + + cat >/dev/stderr <<-eof + warning: lldpad is running + + lldpad will likely configure dcb, and this test will + configure qdiscs. mlxsw does not support both at the + same time, one of them is arbitrarily going to overwrite + the other. that will cause spurious failures (or, + unlikely, passes) of this test. + eof + + if [[ -z $allow_lldpad ]]; then + cat >/dev/stderr <<-eof + + if you want to run the test anyway, please set + an environment variable allow_lldpad to a + non-empty string. + eof + exit 1 + else + return + fi + fi +} diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +# a driver for the ets selftest that implements testing in offloaded datapath. +lib_dir=$(dirname $0)/../../../net/forwarding +source $lib_dir/sch_ets_core.sh +source $lib_dir/devlink_lib.sh +source qos_lib.sh + +all_tests=" + ping_ipv4 + priomap_mode + ets_test_strict + ets_test_mixed + ets_test_dwrr +" + +switch_create() +{ + ets_switch_create + + # create a bottleneck so that the dwrr process can kick in. + ethtool -s $h2 speed 1000 autoneg off + ethtool -s $swp2 speed 1000 autoneg off + + # set the ingress quota high and use the three egress tcs to limit the + # amount of traffic that is admitted to the shared buffers. this makes + # sure that there is always enough traffic of all types to select from + # for the dwrr process. + devlink_port_pool_th_set $swp1 0 12 + devlink_tc_bind_pool_th_set $swp1 0 ingress 0 12 + devlink_port_pool_th_set $swp2 4 12 + devlink_tc_bind_pool_th_set $swp2 7 egress 4 5 + devlink_tc_bind_pool_th_set $swp2 6 egress 4 5 + devlink_tc_bind_pool_th_set $swp2 5 egress 4 5 + + # note: sch_ets_core.sh uses vlan ingress-qos-map to assign packet + # priorities at $swp1 based on their 802.1p headers. ingress-qos-map is + # not offloaded by mlxsw as of this writing, but the mapping used is + # 1:1, which is the mapping currently hard-coded by the driver. +} + +switch_destroy() +{ + devlink_tc_bind_pool_th_restore $swp2 5 egress + devlink_tc_bind_pool_th_restore $swp2 6 egress + devlink_tc_bind_pool_th_restore $swp2 7 egress + devlink_port_pool_th_restore $swp2 4 + devlink_tc_bind_pool_th_restore $swp1 0 ingress + devlink_port_pool_th_restore $swp1 0 + + ethtool -s $swp2 autoneg on + ethtool -s $h2 autoneg on + + ets_switch_destroy +} + +# callback from sch_ets_tests.sh +get_stats() +{ + local band=$1; shift + + ethtool_stats_get "$h2" rx_octets_prio_$band +} + +bail_on_lldpad +ets_run diff --git a/tools/testing/selftests/net/forwarding/sch_ets.sh b/tools/testing/selftests/net/forwarding/sch_ets.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_ets.sh +#!/bin/bash +# spdx-license-identifier: gpl-2.0 + +# a driver for the ets selftest that implements testing in slowpath. +lib_dir=. +source sch_ets_core.sh + +all_tests=" + ping_ipv4 + priomap_mode + ets_test_strict + ets_test_mixed + ets_test_dwrr + classifier_mode + ets_test_strict + ets_test_mixed + ets_test_dwrr +" + +switch_create() +{ + ets_switch_create + + # create a bottleneck so that the dwrr process can kick in. + tc qdisc add dev $swp2 root handle 1: tbf \ + rate 1gbit burst 1mbit latency 100ms + parent="parent 1:" +} + +switch_destroy() +{ + ets_switch_destroy + tc qdisc del dev $swp2 root +} + +# callback from sch_ets_tests.sh +get_stats() +{ + local stream=$1; shift + + link_stats_get $h2.1$stream rx bytes +} + +ets_run diff --git a/tools/testing/selftests/net/forwarding/sch_ets_core.sh b/tools/testing/selftests/net/forwarding/sch_ets_core.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_ets_core.sh +# spdx-license-identifier: gpl-2.0 + +# this is a template for ets qdisc test. +# +# this test sends from h1 several traffic streams with 802.1p-tagged packets. +# the tags are used at $swp1 to prioritize the traffic. each stream is then +# queued at a different ets band according to the assigned priority. after +# runnig for a while, counters at h2 are consulted to determine whether the +# traffic scheduling was according to the ets configuration. +# +# this template is supposed to be embedded by a test driver, which implements +# statistics collection, any hw-specific stuff, and prominently configures the +# system to assure that there is overcommitment at $swp2. that is necessary so +# that the ets traffic selection algorithm kicks in and has to schedule some +# traffic at the expense of other. +# +# a driver for veth-based testing is in sch_ets.sh, an example of a driver for +# an offloaded data path is in selftests/drivers/net/mlxsw/sch_ets.sh. +# +# +---------------------------------------------------------------------+ +# | h1 | +# | + $h1.10 + $h1.11 + $h1.12 | +# | | 192.0.2.1/28 | 192.0.2.17/28 | 192.0.2.33/28 | +# | | egress-qos-map | egress-qos-map | egress-qos-map | +# | | 0:0 | 0:1 | 0:2 | +# | \____________________ | ____________________/ | +# | \|/ | +# | + $h1 | +# +---------------------------|-----------------------------------------+ +# | +# +---------------------------|-----------------------------------------+ +# | sw + $swp1 | +# | | >1gbps | +# | ____________________/|\____________________ | +# | / | \ | +# | +--|----------------+ +--|----------------+ +--|----------------+ | +# | | + $swp1.10 | | + $swp1.11 | | + $swp1.12 | | +# | | ingress-qos-map| | ingress-qos-map| | ingress-qos-map| | +# | | 0:0 1:1 2:2 | | 0:0 1:1 2:2 | | 0:0 1:1 2:2 | | +# | | | | | | | | +# | | br10 | | br11 | | br12 | | +# | | | | | | | | +# | | + $swp2.10 | | + $swp2.11 | | + $swp2.12 | | +# | +--|----------------+ +--|----------------+ +--|----------------+ | +# | \____________________ | ____________________/ | +# | \|/ | +# | + $swp2 | +# | | 1gbps (ethtool or htb qdisc) | +# | | qdisc ets quanta $w0 $w1 $w2 | +# | | priomap 0 1 2 | +# +---------------------------|-----------------------------------------+ +# | +# +---------------------------|-----------------------------------------+ +# | h2 + $h2 | +# | ____________________/|\____________________ | +# | / | \ | +# | + $h2.10 + $h2.11 + $h2.12 | +# | 192.0.2.2/28 192.0.2.18/28 192.0.2.34/28 | +# +---------------------------------------------------------------------+ + +num_netifs=4 +check_tc=yes +source $lib_dir/lib.sh +source $lib_dir/sch_ets_tests.sh + +parent=root +qdisc_dev= + +sip() +{ + echo 192.0.2.$((16 * $1 + 1)) +} + +dip() +{ + echo 192.0.2.$((16 * $1 + 2)) +} + +# callback from sch_ets_tests.sh +ets_start_traffic() +{ + local dst_mac=$(mac_get $h2) + local i=$1; shift + + start_traffic $h1.1$i $(sip $i) $(dip $i) $dst_mac +} + +ets_change_qdisc= + +priomap_mode() +{ + echo "running in priomap mode" + ets_delete_qdisc + ets_change_qdisc=ets_change_qdisc_priomap +} + +classifier_mode() +{ + echo "running in classifier mode" + ets_delete_qdisc + ets_change_qdisc=ets_change_qdisc_classifier +} + +ets_change_qdisc_priomap() +{ + local dev=$1; shift + local nstrict=$1; shift + local priomap=$1; shift + local quanta=("${@}") + + local op=$(if [[ -n $qdisc_dev ]]; then echo change; else echo add; fi) + + tc qdisc $op dev $dev $parent handle 10: ets \ + $(if ((nstrict)); then echo strict $nstrict; fi) \ + $(if ((${#quanta[@]})); then echo quanta ${quanta[@]}; fi) \ + priomap $priomap + qdisc_dev=$dev +} + +ets_change_qdisc_classifier() +{ + local dev=$1; shift + local nstrict=$1; shift + local priomap=$1; shift + local quanta=("${@}") + + local op=$(if [[ -n $qdisc_dev ]]; then echo change; else echo add; fi) + + tc qdisc $op dev $dev $parent handle 10: ets \ + $(if ((nstrict)); then echo strict $nstrict; fi) \ + $(if ((${#quanta[@]})); then echo quanta ${quanta[@]}; fi) + + if [[ $op == add ]]; then + local prio=0 + local band + + for band in $priomap; do + tc filter add dev $dev parent 10: basic \ + match "meta(priority eq $prio)" \ + flowid 10:$((band + 1)) + ((prio++)) + done + fi + qdisc_dev=$dev +} + +# callback from sch_ets_tests.sh +ets_change_qdisc() +{ + if [[ -z "$ets_change_qdisc" ]]; then + exit 1 + fi + $ets_change_qdisc "$@" +} + +ets_delete_qdisc() +{ + if [[ -n $qdisc_dev ]]; then + tc qdisc del dev $qdisc_dev $parent + qdisc_dev= + fi +} + +h1_create() +{ + local i; + + simple_if_init $h1 + mtu_set $h1 9900 + for i in {0..2}; do + vlan_create $h1 1$i v$h1 $(sip $i)/28 + ip link set dev $h1.1$i type vlan egress 0:$i + done +} + +h1_destroy() +{ + local i + + for i in {0..2}; do + vlan_destroy $h1 1$i + done + mtu_restore $h1 + simple_if_fini $h1 +} + +h2_create() +{ + local i + + simple_if_init $h2 + mtu_set $h2 9900 + for i in {0..2}; do + vlan_create $h2 1$i v$h2 $(dip $i)/28 + done +} + +h2_destroy() +{ + local i + + for i in {0..2}; do + vlan_destroy $h2 1$i + done + mtu_restore $h2 + simple_if_fini $h2 +} + +ets_switch_create() +{ + local i + + ip link set dev $swp1 up + mtu_set $swp1 9900 + + ip link set dev $swp2 up + mtu_set $swp2 9900 + + for i in {0..2}; do + vlan_create $swp1 1$i + ip link set dev $swp1.1$i type vlan ingress 0:0 1:1 2:2 + + vlan_create $swp2 1$i + + ip link add dev br1$i type bridge + ip link set dev $swp1.1$i master br1$i + ip link set dev $swp2.1$i master br1$i + + ip link set dev br1$i up + ip link set dev $swp1.1$i up + ip link set dev $swp2.1$i up + done +} + +ets_switch_destroy() +{ + local i + + ets_delete_qdisc + + for i in {0..2}; do + ip link del dev br1$i + vlan_destroy $swp2 1$i + vlan_destroy $swp1 1$i + done + + mtu_restore $swp2 + ip link set dev $swp2 down + + mtu_restore $swp1 + ip link set dev $swp1 down +} + +setup_prepare() +{ + h1=${netifs[p1]} + swp1=${netifs[p2]} + + swp2=${netifs[p3]} + h2=${netifs[p4]} + + put=$swp2 + hut=$h2 + + vrf_prepare + + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + + vrf_cleanup +} + +ping_ipv4() +{ + ping_test $h1.10 $(dip 0) " vlan 10" + ping_test $h1.11 $(dip 1) " vlan 11" + ping_test $h1.12 $(dip 2) " vlan 12" +} + +ets_run() +{ + trap cleanup exit + + setup_prepare + setup_wait + + tests_run + + exit $exit_status +} diff --git a/tools/testing/selftests/net/forwarding/sch_ets_tests.sh b/tools/testing/selftests/net/forwarding/sch_ets_tests.sh --- /dev/null +++ b/tools/testing/selftests/net/forwarding/sch_ets_tests.sh +# spdx-license-identifier: gpl-2.0 + +# global interface: +# $put -- port under test (e.g. $swp2) +# get_stats($band) -- a function to collect stats for band +# ets_start_traffic($band) -- start traffic for this band +# ets_change_qdisc($op, $dev, $nstrict, $quanta...) -- add or change qdisc + +# ws describes the qdisc configuration. it has one value per band (so the +# number of array elements indicates the number of bands). if the value is +# 0, it is a strict band, otherwise the it's a drr band and the value is +# that band's quantum. +declare -a ws + +qdisc_describe() +{ + local nbands=${#ws[@]} + local nstrict=0 + local i + + for ((i = 0; i < nbands; i++)); do + if ((!${ws[$i]})); then + : $((nstrict++)) + fi + done + + echo -n "ets bands $nbands" + if ((nstrict)); then + echo -n " strict $nstrict" + fi + if ((nstrict < nbands)); then + echo -n " quanta" + for ((i = nstrict; i < nbands; i++)); do + echo -n " ${ws[$i]}" + done + fi +} + +__strict_eval() +{ + local desc=$1; shift + local d=$1; shift + local total=$1; shift + local above=$1; shift + + ret=0 + + if ((! total)); then + check_err 1 "no traffic observed" + log_test "$desc" + return + fi + + local ratio=$(echo "scale=2; 100 * $d / $total" | bc -l) + if ((above)); then + test $(echo "$ratio > 95.0" | bc -l) -eq 1 + check_err $? "not enough traffic" + log_test "$desc" + log_info "expected ratio >95% measured ratio $ratio" + else + test $(echo "$ratio < 5" | bc -l) -eq 1 + check_err $? "too much traffic" + log_test "$desc" + log_info "expected ratio <5% measured ratio $ratio" + fi +} + +strict_eval() +{ + __strict_eval "$@" 1 +} + +notraf_eval() +{ + __strict_eval "$@" 0 +} + +__ets_dwrr_test() +{ + local -a streams=("$@") + + local low_stream=${streams[0]} + local seen_strict=0 + local -a t0 t1 d + local stream + local total + local i + + echo "testing $(qdisc_describe), streams ${streams[@]}" + + for stream in ${streams[@]}; do + ets_start_traffic $stream + done + + sleep 10 + + t0=($(for stream in ${streams[@]}; do + get_stats $stream + done)) + + sleep 10 + + t1=($(for stream in ${streams[@]}; do + get_stats $stream + done)) + d=($(for ((i = 0; i < ${#streams[@]}; i++)); do + echo $((${t1[$i]} - ${t0[$i]})) + done)) + total=$(echo ${d[@]} | sed 's/ /+/g' | bc) + + for ((i = 0; i < ${#streams[@]}; i++)); do + local stream=${streams[$i]} + if ((seen_strict)); then + notraf_eval "band $stream" ${d[$i]} $total + elif ((${ws[$stream]} == 0)); then + strict_eval "band $stream" ${d[$i]} $total + seen_strict=1 + elif ((stream == low_stream)); then + # low stream is used as dwrr evaluation reference. + continue + else + multipath_eval "bands $low_stream:$stream" \ + ${ws[$low_stream]} ${ws[$stream]} \ + ${d[0]} ${d[$i]} + fi + done + + for stream in ${streams[@]}; do + stop_traffic + done +} + +ets_dwrr_test_012() +{ + __ets_dwrr_test 0 1 2 +} + +ets_dwrr_test_01() +{ + __ets_dwrr_test 0 1 +} + +ets_dwrr_test_12() +{ + __ets_dwrr_test 1 2 +} + +ets_qdisc_setup() +{ + local dev=$1; shift + local nstrict=$1; shift + local -a quanta=("$@") + + local ndwrr=${#quanta[@]} + local nbands=$((nstrict + ndwrr)) + local nstreams=$(if ((nbands > 3)); then echo 3; else echo $nbands; fi) + local priomap=$(seq 0 $((nstreams - 1))) + local i + + ws=($( + for ((i = 0; i < nstrict; i++)); do + echo 0 + done + for ((i = 0; i < ndwrr; i++)); do + echo ${quanta[$i]} + done + )) + + ets_change_qdisc $dev $nstrict "$priomap" ${quanta[@]} +} + +ets_set_dwrr_uniform() +{ + ets_qdisc_setup $put 0 3300 3300 3300 +} + +ets_set_dwrr_varying() +{ + ets_qdisc_setup $put 0 5000 3500 1500 +} + +ets_set_strict() +{ + ets_qdisc_setup $put 3 +} + +ets_set_mixed() +{ + ets_qdisc_setup $put 1 5000 2500 1500 +} + +ets_change_quantum() +{ + tc class change dev $put classid 10:2 ets quantum 8000 + ws[1]=8000 +} + +ets_set_dwrr_two_bands() +{ + ets_qdisc_setup $put 0 5000 2500 +} + +ets_test_strict() +{ + ets_set_strict + ets_dwrr_test_01 + ets_dwrr_test_12 +} + +ets_test_mixed() +{ + ets_set_mixed + ets_dwrr_test_01 + ets_dwrr_test_12 +} + +ets_test_dwrr() +{ + ets_set_dwrr_uniform + ets_dwrr_test_012 + ets_set_dwrr_varying + ets_dwrr_test_012 + ets_change_quantum + ets_dwrr_test_012 + ets_set_dwrr_two_bands + ets_dwrr_test_01 +}
|
Networking
|
ddd3fd750ffee2c562fa88ea6ed1f90a02818303
|
petr machata
|
tools
|
testing
|
drivers, forwarding, mlxsw, net, selftests
|
selftests: qdiscs: add test coverage for ets qdisc
|
add tdc coverage for the new ets qdisc.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add a new qdisc, ets
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mlxsw ']
|
['json']
| 1
| 940
| 0
|
--- diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/ets.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/ets.json --- /dev/null +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/ets.json +[ + { + "id": "e90e", + "name": "add ets qdisc using bands", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 2", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .* bands 2", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "b059", + "name": "add ets qdisc using quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 1000 900 800 700", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 4 quanta 1000 900 800 700", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "e8e7", + "name": "add ets qdisc using strict", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 3", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 3 strict 3", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "233c", + "name": "add ets qdisc using bands + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 4 quanta 1000 900 800 700", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 4 quanta 1000 900 800 700 priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "3d35", + "name": "add ets qdisc using bands + strict", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 3 strict 3", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 3 strict 3 priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "7f3b", + "name": "add ets qdisc using strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 3 quanta 1500 750", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 5 strict 3 quanta 1500 750 priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "4593", + "name": "add ets qdisc using strict 0 + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 0 quanta 1500 750", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 2 quanta 1500 750 priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "8938", + "name": "add ets qdisc using bands + strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 5 strict 3 quanta 1500 750", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 5 .*strict 3 quanta 1500 750 priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "0782", + "name": "add ets qdisc with more bands than quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 2 quanta 1000", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 2 .*quanta 1000 [1-9][0-9]* priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "501b", + "name": "add ets qdisc with more bands than strict", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 3 strict 1", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 3 strict 1 quanta ([1-9][0-9]* ){2}priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "671a", + "name": "add ets qdisc with more bands than strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 3 strict 1 quanta 1000", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 3 strict 1 quanta 1000 [1-9][0-9]* priomap", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "2a23", + "name": "add ets qdisc with 16 bands", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 16", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .* bands 16", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "8daf", + "name": "add ets qdisc with 17 bands", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 17", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "7f95", + "name": "add ets qdisc with 17 strict", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 17", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "837a", + "name": "add ets qdisc with 16 quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .* bands 16", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "65b6", + "name": "add ets qdisc with 17 quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17", + "expexitcode": "2", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "b9e9", + "name": "add ets qdisc with 16 strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 8 quanta 1 2 3 4 5 6 7 8", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .* bands 16", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "9877", + "name": "add ets qdisc with 17 strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 9 quanta 1 2 3 4 5 6 7 8", + "expexitcode": "2", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "c696", + "name": "add ets qdisc with priomap", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 5 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "30c4", + "name": "add ets qdisc with quanta + priomap", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 1000 2000 3000 4000 5000 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*quanta 1000 2000 3000 4000 5000 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "e8ac", + "name": "add ets qdisc with strict + priomap", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 5 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*bands 5 strict 5 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "5a7e", + "name": "add ets qdisc with quanta + strict + priomap", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 2 quanta 1000 2000 3000 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*strict 2 quanta 1000 2000 3000 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "cb8b", + "name": "show ets class :1", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 4000 3000 2000", + "expexitcode": "0", + "verifycmd": "$tc class show dev $dummy classid 1:1", + "matchpattern": "class ets 1:1 root quantum 4000", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "1b4e", + "name": "show ets class :2", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 4000 3000 2000", + "expexitcode": "0", + "verifycmd": "$tc class show dev $dummy classid 1:2", + "matchpattern": "class ets 1:2 root quantum 3000", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "f642", + "name": "show ets class :3", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 4000 3000 2000", + "expexitcode": "0", + "verifycmd": "$tc class show dev $dummy classid 1:3", + "matchpattern": "class ets 1:3 root quantum 2000", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "0a5f", + "name": "show ets strict class", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 3", + "expexitcode": "0", + "verifycmd": "$tc class show dev $dummy classid 1:1", + "matchpattern": "class ets 1:1 root $", + "matchcount": "1", + "teardown": [ + "$tc qdisc del dev $dummy handle 1: root", + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "f7c8", + "name": "add ets qdisc with too many quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 2 quanta 1000 2000 3000", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "2389", + "name": "add ets qdisc with too many strict", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 2 strict 3", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "fe3c", + "name": "add ets qdisc with too many strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 4 strict 2 quanta 1000 2000 3000", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "cb04", + "name": "add ets qdisc with excess priomap elements", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 5 priomap 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "c32e", + "name": "add ets qdisc with priomap above bands", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 2 priomap 0 1 2", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "744c", + "name": "add ets qdisc with priomap above quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 1000 500 priomap 0 1 2", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "7b33", + "name": "add ets qdisc with priomap above strict", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 2 priomap 0 1 2", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "dbe6", + "name": "add ets qdisc with priomap above strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets strict 1 quanta 1000 500 priomap 0 1 2 3", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "bdb2", + "name": "add ets qdisc with priomap within bands with strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 4 strict 1 quanta 1000 500 priomap 0 1 2 3", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "39a3", + "name": "add ets qdisc with priomap above bands with strict + quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 4 strict 1 quanta 1000 500 priomap 0 1 2 3 4", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "557c", + "name": "unset priorities default to the last band", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 4 priomap 0 0 0 0", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets .*priomap 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "a347", + "name": "unset priorities default to the last band -- no priomap", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 4", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets .*priomap 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "39c4", + "name": "add ets qdisc with too few bands", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 0", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "930b", + "name": "add ets qdisc with too many bands", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets bands 17", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "406a", + "name": "add ets qdisc without parameters", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "e51a", + "name": "zero element in quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 1000 0 800 700", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "e7f2", + "name": "sole zero element in quanta", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta 0", + "expexitcode": "1", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "d6e6", + "name": "no values after the quanta keyword", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true" + ], + "cmdundertest": "$tc qdisc add dev $dummy handle 1: root ets quanta", + "expexitcode": "255", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets", + "matchcount": "0", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "28c6", + "name": "change ets band quantum", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true", + "$tc qdisc add dev $dummy handle 1: root ets quanta 1000 2000 3000" + ], + "cmdundertest": "$tc class change dev $dummy classid 1:1 ets quantum 1500", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*quanta 1500 2000 3000 priomap ", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "4714", + "name": "change ets band without quantum", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true", + "$tc qdisc add dev $dummy handle 1: root ets quanta 1000 2000 3000" + ], + "cmdundertest": "$tc class change dev $dummy classid 1:1 ets", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets 1: root .*quanta 1000 2000 3000 priomap ", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "6979", + "name": "change quantum of a strict ets band", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true", + "$tc qdisc add dev $dummy handle 1: root ets strict 5" + ], + "cmdundertest": "$tc class change dev $dummy classid 1:2 ets quantum 1500", + "expexitcode": "2", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets .*bands 5 .*strict 5", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + }, + { + "id": "9a7d", + "name": "change ets strict band without quantum", + "category": [ + "qdisc", + "ets" + ], + "setup": [ + "$ip link add dev $dummy type dummy || /bin/true", + "$tc qdisc add dev $dummy handle 1: root ets strict 5" + ], + "cmdundertest": "$tc class change dev $dummy classid 1:2 ets", + "expexitcode": "0", + "verifycmd": "$tc qdisc show dev $dummy", + "matchpattern": "qdisc ets .*bands 5 .*strict 5", + "matchcount": "1", + "teardown": [ + "$ip link del dev $dummy type dummy" + ] + } +]
|
Networking
|
82c664b69c8b3729dfcf33e9abfd952dad35fcca
|
petr machata ido schimmel idosch mellanox com
|
tools
|
testing
|
qdiscs, selftests, tc-testing, tc-tests
|
mv88e6xxx: add serdes rx statistics
|
if packet checker is enabled in the serdes, then rx counter registers start working, and no side effects have been detected.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add serdes rx statistics
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['mv88e6xxx']
|
['c', 'h']
| 3
| 109
| 3
|
--- diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c + .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, + .serdes_get_strings = mv88e6390_serdes_get_strings, + .serdes_get_stats = mv88e6390_serdes_get_stats, diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c +struct mv88e6390_serdes_hw_stat { + char string[eth_gstring_len]; + int reg; +}; + +static struct mv88e6390_serdes_hw_stat mv88e6390_serdes_hw_stats[] = { + { "serdes_rx_pkts", 0xf021 }, + { "serdes_rx_bytes", 0xf024 }, + { "serdes_rx_pkts_error", 0xf027 }, +}; + +int mv88e6390_serdes_get_sset_count(struct mv88e6xxx_chip *chip, int port) +{ + if (mv88e6390_serdes_get_lane(chip, port) == 0) + return 0; + + return array_size(mv88e6390_serdes_hw_stats); +} + +int mv88e6390_serdes_get_strings(struct mv88e6xxx_chip *chip, + int port, uint8_t *data) +{ + struct mv88e6390_serdes_hw_stat *stat; + int i; + + if (mv88e6390_serdes_get_lane(chip, port) == 0) + return 0; + + for (i = 0; i < array_size(mv88e6390_serdes_hw_stats); i++) { + stat = &mv88e6390_serdes_hw_stats[i]; + memcpy(data + i * eth_gstring_len, stat->string, + eth_gstring_len); + } + return array_size(mv88e6390_serdes_hw_stats); +} + +static uint64_t mv88e6390_serdes_get_stat(struct mv88e6xxx_chip *chip, int lane, + struct mv88e6390_serdes_hw_stat *stat) +{ + u16 reg[3]; + int err, i; + + for (i = 0; i < 3; i++) { + err = mv88e6390_serdes_read(chip, lane, mdio_mmd_phyxs, + stat->reg + i, ®[i]); + if (err) { + dev_err(chip->dev, "failed to read statistic "); + return 0; + } + } + + return reg[0] | ((u64)reg[1] << 16) | ((u64)reg[2] << 32); +} + +int mv88e6390_serdes_get_stats(struct mv88e6xxx_chip *chip, int port, + uint64_t *data) +{ + struct mv88e6390_serdes_hw_stat *stat; + int lane; + int i; + + lane = mv88e6390_serdes_get_lane(chip, port); + if (lane == 0) + return 0; + + for (i = 0; i < array_size(mv88e6390_serdes_hw_stats); i++) { + stat = &mv88e6390_serdes_hw_stats[i]; + data[i] = mv88e6390_serdes_get_stat(chip, lane, stat); + } + + return array_size(mv88e6390_serdes_hw_stats); +} + +static int mv88e6390_serdes_enable_checker(struct mv88e6xxx_chip *chip, u8 lane) +{ + u16 reg; + int err; + + err = mv88e6390_serdes_read(chip, lane, mdio_mmd_phyxs, + mv88e6390_pg_control, ®); + if (err) + return err; + + reg |= mv88e6390_pg_control_enable_pc; + return mv88e6390_serdes_write(chip, lane, mdio_mmd_phyxs, + mv88e6390_pg_control, reg); +} + + int err = 0; - return mv88e6390_serdes_power_sgmii(chip, lane, up); + err = mv88e6390_serdes_power_sgmii(chip, lane, up); + break; - return mv88e6390_serdes_power_10g(chip, lane, up); + err = mv88e6390_serdes_power_10g(chip, lane, up); + break; - return 0; + if (!err && up) + err = mv88e6390_serdes_enable_checker(chip, lane); + + return err; diff --git a/drivers/net/dsa/mv88e6xxx/serdes.h b/drivers/net/dsa/mv88e6xxx/serdes.h --- a/drivers/net/dsa/mv88e6xxx/serdes.h +++ b/drivers/net/dsa/mv88e6xxx/serdes.h +/* packet generator pad packet checker */ +#define mv88e6390_pg_control 0xf010 +#define mv88e6390_pg_control_enable_pc bit(0) + +int mv88e6390_serdes_get_sset_count(struct mv88e6xxx_chip *chip, int port); +int mv88e6390_serdes_get_strings(struct mv88e6xxx_chip *chip, + int port, uint8_t *data); +int mv88e6390_serdes_get_stats(struct mv88e6xxx_chip *chip, int port, + uint64_t *data);
|
Networking
|
0df952873636a6df4b7469a4eb4da1e477031e3a
|
nikita yushchenko
|
drivers
|
net
|
dsa, mv88e6xxx
|
netdevsim: fib: add dummy implementation for fib offload
|
implement dummy ipv4 and ipv6 fib "offload" in the driver by storing currently "programmed" routes in a hash table. each route in the hash table is marked with "trap" indication. the indication is cleared when the route is replaced or when the netdevsim instance is deleted.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add dummy implementation for fib offload
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['netdevsim', 'fib']
|
['c', 'kconfig']
| 2
| 663
| 9
|
--- diff --git a/drivers/net/kconfig b/drivers/net/kconfig --- a/drivers/net/kconfig +++ b/drivers/net/kconfig + depends on ipv6 || ipv6=n diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c --- a/drivers/net/netdevsim/fib.c +++ b/drivers/net/netdevsim/fib.c +#include <linux/in6.h> +#include <linux/kernel.h> +#include <linux/list.h> +#include <linux/rhashtable.h> +#include <linux/spinlock_types.h> +#include <linux/types.h> + struct rhashtable fib_rt_ht; + struct list_head fib_rt_list; + spinlock_t fib_lock; /* protects hashtable, list and accounting */ + struct devlink *devlink; +}; + +struct nsim_fib_rt_key { + unsigned char addr[sizeof(struct in6_addr)]; + unsigned char prefix_len; + int family; + u32 tb_id; +}; + +struct nsim_fib_rt { + struct nsim_fib_rt_key key; + struct rhash_head ht_node; + struct list_head list; /* member of fib_rt_list */ +}; + +struct nsim_fib4_rt { + struct nsim_fib_rt common; + struct fib_info *fi; + u8 tos; + u8 type; +}; + +struct nsim_fib6_rt { + struct nsim_fib_rt common; + struct list_head nh_list; + unsigned int nhs; +}; + +struct nsim_fib6_rt_nh { + struct list_head list; /* member of nh_list */ + struct fib6_info *rt; +}; + +static const struct rhashtable_params nsim_fib_rt_ht_params = { + .key_offset = offsetof(struct nsim_fib_rt, key), + .head_offset = offsetof(struct nsim_fib_rt, ht_node), + .key_len = sizeof(struct nsim_fib_rt_key), + .automatic_shrinking = true, +static void nsim_fib_rt_init(struct nsim_fib_data *data, + struct nsim_fib_rt *fib_rt, const void *addr, + size_t addr_len, unsigned int prefix_len, + int family, u32 tb_id) +{ + memcpy(fib_rt->key.addr, addr, addr_len); + fib_rt->key.prefix_len = prefix_len; + fib_rt->key.family = family; + fib_rt->key.tb_id = tb_id; + list_add(&fib_rt->list, &data->fib_rt_list); +} + +static void nsim_fib_rt_fini(struct nsim_fib_rt *fib_rt) +{ + list_del(&fib_rt->list); +} + +static struct nsim_fib_rt *nsim_fib_rt_lookup(struct rhashtable *fib_rt_ht, + const void *addr, size_t addr_len, + unsigned int prefix_len, + int family, u32 tb_id) +{ + struct nsim_fib_rt_key key; + + memset(&key, 0, sizeof(key)); + memcpy(key.addr, addr, addr_len); + key.prefix_len = prefix_len; + key.family = family; + key.tb_id = tb_id; + + return rhashtable_lookup_fast(fib_rt_ht, &key, nsim_fib_rt_ht_params); +} + +static struct nsim_fib4_rt * +nsim_fib4_rt_create(struct nsim_fib_data *data, + struct fib_entry_notifier_info *fen_info) +{ + struct nsim_fib4_rt *fib4_rt; + + fib4_rt = kzalloc(sizeof(*fib4_rt), gfp_atomic); + if (!fib4_rt) + return null; + + nsim_fib_rt_init(data, &fib4_rt->common, &fen_info->dst, sizeof(u32), + fen_info->dst_len, af_inet, fen_info->tb_id); + + fib4_rt->fi = fen_info->fi; + fib_info_hold(fib4_rt->fi); + fib4_rt->tos = fen_info->tos; + fib4_rt->type = fen_info->type; + + return fib4_rt; +} + +static void nsim_fib4_rt_destroy(struct nsim_fib4_rt *fib4_rt) +{ + fib_info_put(fib4_rt->fi); + nsim_fib_rt_fini(&fib4_rt->common); + kfree(fib4_rt); +} + +static struct nsim_fib4_rt * +nsim_fib4_rt_lookup(struct rhashtable *fib_rt_ht, + const struct fib_entry_notifier_info *fen_info) +{ + struct nsim_fib_rt *fib_rt; + + fib_rt = nsim_fib_rt_lookup(fib_rt_ht, &fen_info->dst, sizeof(u32), + fen_info->dst_len, af_inet, + fen_info->tb_id); + if (!fib_rt) + return null; + + return container_of(fib_rt, struct nsim_fib4_rt, common); +} + +static void nsim_fib4_rt_hw_flags_set(struct net *net, + const struct nsim_fib4_rt *fib4_rt, + bool trap) +{ + u32 *p_dst = (u32 *) fib4_rt->common.key.addr; + int dst_len = fib4_rt->common.key.prefix_len; + struct fib_rt_info fri; + + fri.fi = fib4_rt->fi; + fri.tb_id = fib4_rt->common.key.tb_id; + fri.dst = cpu_to_be32(*p_dst); + fri.dst_len = dst_len; + fri.tos = fib4_rt->tos; + fri.type = fib4_rt->type; + fri.offload = false; + fri.trap = trap; + fib_alias_hw_flags_set(net, &fri); +} + +static int nsim_fib4_rt_add(struct nsim_fib_data *data, + struct nsim_fib4_rt *fib4_rt, + struct netlink_ext_ack *extack) +{ + struct net *net = devlink_net(data->devlink); + int err; + + err = nsim_fib_account(&data->ipv4.fib, true, extack); + if (err) + return err; + + err = rhashtable_insert_fast(&data->fib_rt_ht, + &fib4_rt->common.ht_node, + nsim_fib_rt_ht_params); + if (err) { + nl_set_err_msg_mod(extack, "failed to insert ipv4 route"); + goto err_fib_dismiss; + } + + nsim_fib4_rt_hw_flags_set(net, fib4_rt, true); + + return 0; + +err_fib_dismiss: + nsim_fib_account(&data->ipv4.fib, false, extack); + return err; +} + +static int nsim_fib4_rt_replace(struct nsim_fib_data *data, + struct nsim_fib4_rt *fib4_rt, + struct nsim_fib4_rt *fib4_rt_old, + struct netlink_ext_ack *extack) +{ + struct net *net = devlink_net(data->devlink); + int err; + + /* we are replacing a route, so no need to change the accounting. */ + err = rhashtable_replace_fast(&data->fib_rt_ht, + &fib4_rt_old->common.ht_node, + &fib4_rt->common.ht_node, + nsim_fib_rt_ht_params); + if (err) { + nl_set_err_msg_mod(extack, "failed to replace ipv4 route"); + return err; + } + + nsim_fib4_rt_hw_flags_set(net, fib4_rt, true); + + nsim_fib4_rt_hw_flags_set(net, fib4_rt_old, false); + nsim_fib4_rt_destroy(fib4_rt_old); + + return 0; +} + +static int nsim_fib4_rt_insert(struct nsim_fib_data *data, + struct fib_entry_notifier_info *fen_info) +{ + struct netlink_ext_ack *extack = fen_info->info.extack; + struct nsim_fib4_rt *fib4_rt, *fib4_rt_old; + int err; + + fib4_rt = nsim_fib4_rt_create(data, fen_info); + if (!fib4_rt) + return -enomem; + + fib4_rt_old = nsim_fib4_rt_lookup(&data->fib_rt_ht, fen_info); + if (!fib4_rt_old) + err = nsim_fib4_rt_add(data, fib4_rt, extack); + else + err = nsim_fib4_rt_replace(data, fib4_rt, fib4_rt_old, extack); + + if (err) + nsim_fib4_rt_destroy(fib4_rt); + + return err; +} + +static void nsim_fib4_rt_remove(struct nsim_fib_data *data, + const struct fib_entry_notifier_info *fen_info) +{ + struct netlink_ext_ack *extack = fen_info->info.extack; + struct nsim_fib4_rt *fib4_rt; + + fib4_rt = nsim_fib4_rt_lookup(&data->fib_rt_ht, fen_info); + if (warn_on_once(!fib4_rt)) + return; + + rhashtable_remove_fast(&data->fib_rt_ht, &fib4_rt->common.ht_node, + nsim_fib_rt_ht_params); + nsim_fib_account(&data->ipv4.fib, false, extack); + nsim_fib4_rt_destroy(fib4_rt); +} + +static int nsim_fib4_event(struct nsim_fib_data *data, + struct fib_notifier_info *info, + unsigned long event) +{ + struct fib_entry_notifier_info *fen_info; + int err = 0; + + fen_info = container_of(info, struct fib_entry_notifier_info, info); + + if (fen_info->fi->nh) { + nl_set_err_msg_mod(info->extack, "ipv4 route with nexthop objects is not supported"); + return 0; + } + + switch (event) { + case fib_event_entry_replace: + err = nsim_fib4_rt_insert(data, fen_info); + break; + case fib_event_entry_del: + nsim_fib4_rt_remove(data, fen_info); + break; + default: + break; + } + + return err; +} + +static struct nsim_fib6_rt_nh * +nsim_fib6_rt_nh_find(const struct nsim_fib6_rt *fib6_rt, + const struct fib6_info *rt) +{ + struct nsim_fib6_rt_nh *fib6_rt_nh; + + list_for_each_entry(fib6_rt_nh, &fib6_rt->nh_list, list) { + if (fib6_rt_nh->rt == rt) + return fib6_rt_nh; + } + + return null; +} + +static int nsim_fib6_rt_nh_add(struct nsim_fib6_rt *fib6_rt, + struct fib6_info *rt) +{ + struct nsim_fib6_rt_nh *fib6_rt_nh; + + fib6_rt_nh = kzalloc(sizeof(*fib6_rt_nh), gfp_atomic); + if (!fib6_rt_nh) + return -enomem; + + fib6_info_hold(rt); + fib6_rt_nh->rt = rt; + list_add_tail(&fib6_rt_nh->list, &fib6_rt->nh_list); + fib6_rt->nhs++; + + return 0; +} + +static void nsim_fib6_rt_nh_del(struct nsim_fib6_rt *fib6_rt, + const struct fib6_info *rt) +{ + struct nsim_fib6_rt_nh *fib6_rt_nh; + + fib6_rt_nh = nsim_fib6_rt_nh_find(fib6_rt, rt); + if (warn_on_once(!fib6_rt_nh)) + return; + + fib6_rt->nhs--; + list_del(&fib6_rt_nh->list); +#if is_enabled(config_ipv6) + fib6_info_release(fib6_rt_nh->rt); +#endif + kfree(fib6_rt_nh); +} + +static struct nsim_fib6_rt * +nsim_fib6_rt_create(struct nsim_fib_data *data, + struct fib6_entry_notifier_info *fen6_info) +{ + struct fib6_info *iter, *rt = fen6_info->rt; + struct nsim_fib6_rt *fib6_rt; + int i = 0; + int err; + + fib6_rt = kzalloc(sizeof(*fib6_rt), gfp_atomic); + if (!fib6_rt) + return null; + + nsim_fib_rt_init(data, &fib6_rt->common, &rt->fib6_dst.addr, + sizeof(rt->fib6_dst.addr), rt->fib6_dst.plen, af_inet6, + rt->fib6_table->tb6_id); + + /* we consider a multipath ipv6 route as one entry, but it can be made + * up from several fib6_info structs (one for each nexthop), so we + * add them all to the same list under the entry. + */ + init_list_head(&fib6_rt->nh_list); + + err = nsim_fib6_rt_nh_add(fib6_rt, rt); + if (err) + goto err_fib_rt_fini; + + if (!fen6_info->nsiblings) + return fib6_rt; + + list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) { + if (i == fen6_info->nsiblings) + break; + + err = nsim_fib6_rt_nh_add(fib6_rt, iter); + if (err) + goto err_fib6_rt_nh_del; + i++; + } + warn_on_once(i != fen6_info->nsiblings); + + return fib6_rt; + +err_fib6_rt_nh_del: + list_for_each_entry_continue_reverse(iter, &rt->fib6_siblings, + fib6_siblings) + nsim_fib6_rt_nh_del(fib6_rt, iter); + nsim_fib6_rt_nh_del(fib6_rt, rt); +err_fib_rt_fini: + nsim_fib_rt_fini(&fib6_rt->common); + kfree(fib6_rt); + return err_ptr(err); +} + +static void nsim_fib6_rt_destroy(struct nsim_fib6_rt *fib6_rt) +{ + struct nsim_fib6_rt_nh *iter, *tmp; + + list_for_each_entry_safe(iter, tmp, &fib6_rt->nh_list, list) + nsim_fib6_rt_nh_del(fib6_rt, iter->rt); + warn_on_once(!list_empty(&fib6_rt->nh_list)); + nsim_fib_rt_fini(&fib6_rt->common); + kfree(fib6_rt); +} + +static struct nsim_fib6_rt * +nsim_fib6_rt_lookup(struct rhashtable *fib_rt_ht, const struct fib6_info *rt) +{ + struct nsim_fib_rt *fib_rt; + + fib_rt = nsim_fib_rt_lookup(fib_rt_ht, &rt->fib6_dst.addr, + sizeof(rt->fib6_dst.addr), + rt->fib6_dst.plen, af_inet6, + rt->fib6_table->tb6_id); + if (!fib_rt) + return null; + + return container_of(fib_rt, struct nsim_fib6_rt, common); +} + +static int nsim_fib6_rt_append(struct nsim_fib_data *data, + struct fib6_entry_notifier_info *fen6_info) +{ + struct fib6_info *iter, *rt = fen6_info->rt; + struct nsim_fib6_rt *fib6_rt; + int i = 0; + int err; + + fib6_rt = nsim_fib6_rt_lookup(&data->fib_rt_ht, rt); + if (warn_on_once(!fib6_rt)) + return -einval; + + err = nsim_fib6_rt_nh_add(fib6_rt, rt); + if (err) + return err; + rt->trap = true; + + if (!fen6_info->nsiblings) + return 0; + + list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) { + if (i == fen6_info->nsiblings) + break; + + err = nsim_fib6_rt_nh_add(fib6_rt, iter); + if (err) + goto err_fib6_rt_nh_del; + iter->trap = true; + i++; + } + warn_on_once(i != fen6_info->nsiblings); + + return 0; + +err_fib6_rt_nh_del: + list_for_each_entry_continue_reverse(iter, &rt->fib6_siblings, + fib6_siblings) { + iter->trap = false; + nsim_fib6_rt_nh_del(fib6_rt, iter); + } + rt->trap = false; + nsim_fib6_rt_nh_del(fib6_rt, rt); + return err; +} + +static void nsim_fib6_rt_hw_flags_set(const struct nsim_fib6_rt *fib6_rt, + bool trap) +{ + struct nsim_fib6_rt_nh *fib6_rt_nh; + + list_for_each_entry(fib6_rt_nh, &fib6_rt->nh_list, list) + fib6_info_hw_flags_set(fib6_rt_nh->rt, false, trap); +} + +static int nsim_fib6_rt_add(struct nsim_fib_data *data, + struct nsim_fib6_rt *fib6_rt, + struct netlink_ext_ack *extack) +{ + int err; + + err = nsim_fib_account(&data->ipv6.fib, true, extack); + if (err) + return err; + + err = rhashtable_insert_fast(&data->fib_rt_ht, + &fib6_rt->common.ht_node, + nsim_fib_rt_ht_params); + if (err) { + nl_set_err_msg_mod(extack, "failed to insert ipv6 route"); + goto err_fib_dismiss; + } + + nsim_fib6_rt_hw_flags_set(fib6_rt, true); + + return 0; + +err_fib_dismiss: + nsim_fib_account(&data->ipv6.fib, false, extack); + return err; +} + +static int nsim_fib6_rt_replace(struct nsim_fib_data *data, + struct nsim_fib6_rt *fib6_rt, + struct nsim_fib6_rt *fib6_rt_old, + struct netlink_ext_ack *extack) +{ + int err; + + /* we are replacing a route, so no need to change the accounting. */ + err = rhashtable_replace_fast(&data->fib_rt_ht, + &fib6_rt_old->common.ht_node, + &fib6_rt->common.ht_node, + nsim_fib_rt_ht_params); + if (err) { + nl_set_err_msg_mod(extack, "failed to replace ipv6 route"); + return err; + } + + nsim_fib6_rt_hw_flags_set(fib6_rt, true); + + nsim_fib6_rt_hw_flags_set(fib6_rt_old, false); + nsim_fib6_rt_destroy(fib6_rt_old); + + return 0; +} + +static int nsim_fib6_rt_insert(struct nsim_fib_data *data, + struct fib6_entry_notifier_info *fen6_info) +{ + struct netlink_ext_ack *extack = fen6_info->info.extack; + struct nsim_fib6_rt *fib6_rt, *fib6_rt_old; + int err; + + fib6_rt = nsim_fib6_rt_create(data, fen6_info); + if (!fib6_rt) + return -enomem; + + fib6_rt_old = nsim_fib6_rt_lookup(&data->fib_rt_ht, fen6_info->rt); + if (!fib6_rt_old) + err = nsim_fib6_rt_add(data, fib6_rt, extack); + else + err = nsim_fib6_rt_replace(data, fib6_rt, fib6_rt_old, extack); + + if (err) + nsim_fib6_rt_destroy(fib6_rt); + + return err; +} + +static void +nsim_fib6_rt_remove(struct nsim_fib_data *data, + const struct fib6_entry_notifier_info *fen6_info) +{ + struct netlink_ext_ack *extack = fen6_info->info.extack; + struct nsim_fib6_rt *fib6_rt; + + /* multipath routes are first added to the fib trie and only then + * notified. if we vetoed the addition, we will get a delete + * notification for a route we do not have. therefore, do not warn if + * route was not found. + */ + fib6_rt = nsim_fib6_rt_lookup(&data->fib_rt_ht, fen6_info->rt); + if (!fib6_rt) + return; + + /* if not all the nexthops are deleted, then only reduce the nexthop + * group. + */ + if (fen6_info->nsiblings + 1 != fib6_rt->nhs) { + nsim_fib6_rt_nh_del(fib6_rt, fen6_info->rt); + return; + } + + rhashtable_remove_fast(&data->fib_rt_ht, &fib6_rt->common.ht_node, + nsim_fib_rt_ht_params); + nsim_fib_account(&data->ipv6.fib, false, extack); + nsim_fib6_rt_destroy(fib6_rt); +} + +static int nsim_fib6_event(struct nsim_fib_data *data, + struct fib_notifier_info *info, + unsigned long event) +{ + struct fib6_entry_notifier_info *fen6_info; + int err = 0; + + fen6_info = container_of(info, struct fib6_entry_notifier_info, info); + + if (fen6_info->rt->nh) { + nl_set_err_msg_mod(info->extack, "ipv6 route with nexthop objects is not supported"); + return 0; + } + + if (fen6_info->rt->fib6_src.plen) { + nl_set_err_msg_mod(info->extack, "ipv6 source-specific route is not supported"); + return 0; + } + + switch (event) { + case fib_event_entry_replace: + err = nsim_fib6_rt_insert(data, fen6_info); + break; + case fib_event_entry_append: + err = nsim_fib6_rt_append(data, fen6_info); + break; + case fib_event_entry_del: + nsim_fib6_rt_remove(data, fen6_info); + break; + default: + break; + } + + return err; +} + - struct fib_notifier_info *info, bool add) + struct fib_notifier_info *info, unsigned long event) - struct netlink_ext_ack *extack = info->extack; - err = nsim_fib_account(&data->ipv4.fib, add, extack); + err = nsim_fib4_event(data, info, event); - err = nsim_fib_account(&data->ipv6.fib, add, extack); + err = nsim_fib6_event(data, info, event); + /* ipv6 routes can be added via ras from softirq. */ + spin_lock_bh(&data->fib_lock); + + case fib_event_entry_append: /* fall through */ - err = nsim_fib_event(data, info, event != fib_event_entry_del); + err = nsim_fib_event(data, info, event); + spin_unlock_bh(&data->fib_lock); + +static void nsim_fib4_rt_free(struct nsim_fib_rt *fib_rt, + struct nsim_fib_data *data) +{ + struct devlink *devlink = data->devlink; + struct nsim_fib4_rt *fib4_rt; + + fib4_rt = container_of(fib_rt, struct nsim_fib4_rt, common); + nsim_fib4_rt_hw_flags_set(devlink_net(devlink), fib4_rt, false); + nsim_fib_account(&data->ipv4.fib, false, null); + nsim_fib4_rt_destroy(fib4_rt); +} + +static void nsim_fib6_rt_free(struct nsim_fib_rt *fib_rt, + struct nsim_fib_data *data) +{ + struct nsim_fib6_rt *fib6_rt; + + fib6_rt = container_of(fib_rt, struct nsim_fib6_rt, common); + nsim_fib6_rt_hw_flags_set(fib6_rt, false); + nsim_fib_account(&data->ipv6.fib, false, null); + nsim_fib6_rt_destroy(fib6_rt); +} + +static void nsim_fib_rt_free(void *ptr, void *arg) +{ + struct nsim_fib_rt *fib_rt = ptr; + struct nsim_fib_data *data = arg; + + switch (fib_rt->key.family) { + case af_inet: + nsim_fib4_rt_free(fib_rt, data); + break; + case af_inet6: + nsim_fib6_rt_free(fib_rt, data); + break; + default: + warn_on_once(1); + } +} + + struct nsim_fib_rt *fib_rt, *fib_rt_tmp; + + /* the notifier block is still not registered, so we do not need to + * take any locks here. + */ + list_for_each_entry_safe(fib_rt, fib_rt_tmp, &data->fib_rt_list, list) { + rhashtable_remove_fast(&data->fib_rt_ht, &fib_rt->ht_node, + nsim_fib_rt_ht_params); + nsim_fib_rt_free(fib_rt, data); + } - data->ipv4.fib.num = 0ull; - data->ipv6.fib.num = 0ull; + data->devlink = devlink; + + spin_lock_init(&data->fib_lock); + init_list_head(&data->fib_rt_list); + err = rhashtable_init(&data->fib_rt_ht, &nsim_fib_rt_ht_params); + if (err) + goto err_data_free; - goto err_out; + goto err_rhashtable_destroy; -err_out: +err_rhashtable_destroy: + rhashtable_free_and_destroy(&data->fib_rt_ht, nsim_fib_rt_free, + data); +err_data_free: + rhashtable_free_and_destroy(&data->fib_rt_ht, nsim_fib_rt_free, + data); + warn_on_once(!list_empty(&data->fib_rt_list));
|
Networking
|
48bb9eb47b2708bd3ded16684ddd258e53bd402c
|
ido schimmel
|
drivers
|
net
|
netdevsim
|
nfp: add support for tlv device stats
|
device stats are currently hard coded in the pci bar0 layout. add a ability to read them from the tlv area instead. names for the stats are maintained by the driver, and their meaning documented. this allows us to more easily add and remove device stats.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for tlv device stats
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c', 'h', 'rst']
| 4
| 242
| 7
|
--- diff --git a/documentation/networking/device_drivers/netronome/nfp.rst b/documentation/networking/device_drivers/netronome/nfp.rst --- a/documentation/networking/device_drivers/netronome/nfp.rst +++ b/documentation/networking/device_drivers/netronome/nfp.rst + +statistics +========== + +following device statistics are available through the ''ethtool -s'' interface: + +.. flat-table:: nfp device statistics + :header-rows: 1 + :widths: 3 1 11 + + * - name + - id + - meaning + + * - dev_rx_discards + - 1 + - packet can be discarded on the rx path for one of the following reasons: + + * the nic is not in promisc mode, and the destination mac address + doesn't match the interfaces' mac address. + * the received packet is larger than the max buffer size on the host. + i.e. it exceeds the layer 3 mru. + * there is no freelist descriptor available on the host for the packet. + it is likely that the nic couldn't cache one in time. + * a bpf program discarded the packet. + * the datapath drop action was executed. + * the mac discarded the packet due to lack of ingress buffer space + on the nic. + + * - dev_rx_errors + - 2 + - a packet can be counted (and dropped) as rx error for the following + reasons: + + * a problem with the veb lookup (only when sr-iov is used). + * a physical layer problem that causes ethernet errors, like fcs or + alignment errors. the cause is usually faulty cables or sfps. + + * - dev_rx_bytes + - 3 + - total number of bytes received. + + * - dev_rx_uc_bytes + - 4 + - unicast bytes received. + + * - dev_rx_mc_bytes + - 5 + - multicast bytes received. + + * - dev_rx_bc_bytes + - 6 + - broadcast bytes received. + + * - dev_rx_pkts + - 7 + - total number of packets received. + + * - dev_rx_mc_pkts + - 8 + - multicast packets received. + + * - dev_rx_bc_pkts + - 9 + - broadcast packets received. + + * - dev_tx_discards + - 10 + - a packet can be discarded in the tx direction if the mac is + being flow controlled and the nic runs out of tx queue space. + + * - dev_tx_errors + - 11 + - a packet can be counted as tx error (and dropped) for one for the + following reasons: + + * the packet is an lso segment, but the layer 3 or layer 4 offset + could not be determined. therefore lso could not continue. + * an invalid packet descriptor was received over pcie. + * the packet layer 3 length exceeds the device mtu. + * an error on the mac/physical layer. usually due to faulty cables or + sfps. + * a ctm buffer could not be allocated. + * the packet offset was incorrect and could not be fixed by the nic. + + * - dev_tx_bytes + - 12 + - total number of bytes transmitted. + + * - dev_tx_uc_bytes + - 13 + - unicast bytes transmitted. + + * - dev_tx_mc_bytes + - 14 + - multicast bytes transmitted. + + * - dev_tx_bc_bytes + - 15 + - broadcast bytes transmitted. + + * - dev_tx_pkts + - 16 + - total number of packets transmitted. + + * - dev_tx_mc_pkts + - 17 + - multicast packets transmitted. + + * - dev_tx_bc_pkts + - 18 + - broadcast packets transmitted. + +note that statistics unknown to the driver will be displayed as +''dev_unknown_stat$id'', where ''$id'' refers to the second column +above. diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.c --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.c + case nfp_net_cfg_tlv_type_vnic_stats: + if ((data - ctrl_mem) % 8) { + dev_warn(dev, "vnic stats tlv misaligned, ignoring offset:%u len:%u ", + offset, length); + break; + } + caps->vnic_stats_off = data - ctrl_mem; + caps->vnic_stats_cnt = length / 10; + break; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h b/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h + * + * %nfp_net_cfg_tlv_type_vnic_stats: + * variable, per-vnic statistics, data should be 8b aligned (fw should insert + * zero-length reserved tlv to pad). + * tlv data has two sections. first is an array of statistics' ids (2b each). + * second 8b statistics themselves. statistics are 8b aligned, meaning there + * may be a padding between sections. + * number of statistics can be determined as floor(tlv.length / (2 + 8)). + * this tlv overwrites %nfp_net_cfg_stats_* values (statistics in this tlv + * duplicate the old ones, so driver should be careful not to unnecessarily + * render both). +#define nfp_net_cfg_tlv_type_vnic_stats 12 + * @vnic_stats_off: offset of vnic stats area + * @vnic_stats_cnt: number of vnic stats + unsigned int vnic_stats_off; + unsigned int vnic_stats_cnt; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +static const char nfp_tlv_stat_names[][eth_gstring_len] = { + [1] = "dev_rx_discards", + [2] = "dev_rx_errors", + [3] = "dev_rx_bytes", + [4] = "dev_rx_uc_bytes", + [5] = "dev_rx_mc_bytes", + [6] = "dev_rx_bc_bytes", + [7] = "dev_rx_pkts", + [8] = "dev_rx_mc_pkts", + [9] = "dev_rx_bc_pkts", + + [10] = "dev_tx_discards", + [11] = "dev_tx_errors", + [12] = "dev_tx_bytes", + [13] = "dev_tx_uc_bytes", + [14] = "dev_tx_mc_bytes", + [15] = "dev_tx_bc_bytes", + [16] = "dev_tx_pkts", + [17] = "dev_tx_mc_pkts", + [18] = "dev_tx_bc_pkts", +}; + +static unsigned int nfp_vnic_get_tlv_stats_count(struct nfp_net *nn) +{ + return nn->tlv_caps.vnic_stats_cnt + nn->max_r_vecs * 4; +} + +static u8 *nfp_vnic_get_tlv_stats_strings(struct nfp_net *nn, u8 *data) +{ + unsigned int i, id; + u8 __iomem *mem; + u64 id_word = 0; + + mem = nn->dp.ctrl_bar + nn->tlv_caps.vnic_stats_off; + for (i = 0; i < nn->tlv_caps.vnic_stats_cnt; i++) { + if (!(i % 4)) + id_word = readq(mem + i * 2); + + id = (u16)id_word; + id_word >>= 16; + + if (id < array_size(nfp_tlv_stat_names) && + nfp_tlv_stat_names[id][0]) { + memcpy(data, nfp_tlv_stat_names[id], eth_gstring_len); + data += eth_gstring_len; + } else { + data = nfp_pr_et(data, "dev_unknown_stat%u", id); + } + } + + for (i = 0; i < nn->max_r_vecs; i++) { + data = nfp_pr_et(data, "rxq_%u_pkts", i); + data = nfp_pr_et(data, "rxq_%u_bytes", i); + data = nfp_pr_et(data, "txq_%u_pkts", i); + data = nfp_pr_et(data, "txq_%u_bytes", i); + } + + return data; +} + +static u64 *nfp_vnic_get_tlv_stats(struct nfp_net *nn, u64 *data) +{ + u8 __iomem *mem; + unsigned int i; + + mem = nn->dp.ctrl_bar + nn->tlv_caps.vnic_stats_off; + mem += roundup(2 * nn->tlv_caps.vnic_stats_cnt, 8); + for (i = 0; i < nn->tlv_caps.vnic_stats_cnt; i++) + *data++ = readq(mem + i * 8); + + mem = nn->dp.ctrl_bar; + for (i = 0; i < nn->max_r_vecs; i++) { + *data++ = readq(mem + nfp_net_cfg_rxr_stats(i)); + *data++ = readq(mem + nfp_net_cfg_rxr_stats(i) + 8); + *data++ = readq(mem + nfp_net_cfg_txr_stats(i)); + *data++ = readq(mem + nfp_net_cfg_txr_stats(i) + 8); + } + + return data; +} + - data = nfp_vnic_get_hw_stats_strings(data, nn->max_r_vecs, - false); + if (!nn->tlv_caps.vnic_stats_off) + data = nfp_vnic_get_hw_stats_strings(data, + nn->max_r_vecs, + false); + else + data = nfp_vnic_get_tlv_stats_strings(nn, data); - data = nfp_vnic_get_hw_stats(data, nn->dp.ctrl_bar, nn->max_r_vecs); + if (!nn->tlv_caps.vnic_stats_off) + data = nfp_vnic_get_hw_stats(data, nn->dp.ctrl_bar, + nn->max_r_vecs); + else + data = nfp_vnic_get_tlv_stats(nn, data); + unsigned int cnt; - return nfp_vnic_get_sw_stats_count(netdev) + - nfp_vnic_get_hw_stats_count(nn->max_r_vecs) + - nfp_mac_get_stats_count(netdev) + - nfp_app_port_get_stats_count(nn->port); + cnt = nfp_vnic_get_sw_stats_count(netdev); + if (!nn->tlv_caps.vnic_stats_off) + cnt += nfp_vnic_get_hw_stats_count(nn->max_r_vecs); + else + cnt += nfp_vnic_get_tlv_stats_count(nn); + cnt += nfp_mac_get_stats_count(netdev); + cnt += nfp_app_port_get_stats_count(nn->port); + return cnt;
|
Networking
|
ca866ee825911cb70e64ad5b33ac73d4ab924c1f
|
jakub kicinski
|
documentation
|
networking
|
device_drivers, ethernet, netronome, nfp
|
nfp: flower: pass flow rule pointer directly to match functions
|
in kernel 5.1, the flow offload api was introduced along with a helper function to extract the flow_rule from the tc offload struct. each of the match helper functions are passed the offload struct and extract the flow rule to a local variable.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c']
| 1
| 27
| 49
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c - struct flow_cls_offload *flow, u8 key_type) + struct flow_rule *rule, u8 key_type) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - struct nfp_flower_mac_mpls *msk, - struct flow_cls_offload *flow) + struct nfp_flower_mac_mpls *msk, struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - struct flow_cls_offload *flow) + struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - struct nfp_flower_ip_ext *msk, - struct flow_cls_offload *flow) + struct nfp_flower_ip_ext *msk, struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - struct nfp_flower_ipv4 *msk, - struct flow_cls_offload *flow) + struct nfp_flower_ipv4 *msk, struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, flow); + nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); - struct nfp_flower_ipv6 *msk, - struct flow_cls_offload *flow) + struct nfp_flower_ipv6 *msk, struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, flow); + nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); -nfp_flower_compile_geneve_opt(void *ext, void *msk, - struct flow_cls_offload *flow) +nfp_flower_compile_geneve_opt(void *ext, void *msk, struct flow_rule *rule) - flow_rule_match_enc_opts(flow->rule, &match); + flow_rule_match_enc_opts(rule, &match); - struct flow_cls_offload *flow) + struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - struct flow_cls_offload *flow) + struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - struct flow_cls_offload *flow) + struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, flow); - nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, flow); + nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, rule); + nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); - struct flow_cls_offload *flow) + struct flow_rule *rule) - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - - nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, flow); - nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, flow); + nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, rule); + nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); - flow, key_ls->key_layer); + rule, key_ls->key_layer); - flow); + rule); - flow); + rule); - flow); + rule); - flow); + rule); - nfp_flower_compile_ipv4_gre_tun((void *)ext, (void *)msk, flow); + nfp_flower_compile_ipv4_gre_tun((void *)ext, (void *)msk, rule); - nfp_flower_compile_ipv4_udp_tun((void *)ext, (void *)msk, flow); + nfp_flower_compile_ipv4_udp_tun((void *)ext, (void *)msk, rule); - err = nfp_flower_compile_geneve_opt(ext, msk, flow); + err = nfp_flower_compile_geneve_opt(ext, msk, rule);
|
Networking
|
31c491e56ad1ad769e09f6971d267834bfc9bc39
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: move udp tunnel key match compilation to helper function
|
ipv4 udp and gre tunnel match rule compile helpers share functions for compiling fields such as ip addresses. however, they handle fields such tunnel ids differently.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c']
| 1
| 35
| 22
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c +static void +nfp_flower_compile_tun_udp_key(__be32 *key, __be32 *key_msk, + struct flow_rule *rule) +{ + if (flow_rule_match_key(rule, flow_dissector_key_enc_keyid)) { + struct flow_match_enc_keyid match; + u32 vni; + + flow_rule_match_enc_keyid(rule, &match); + vni = be32_to_cpu(match.key->keyid) << nfp_fl_tun_vni_offset; + *key = cpu_to_be32(vni); + vni = be32_to_cpu(match.mask->keyid) << nfp_fl_tun_vni_offset; + *key_msk = cpu_to_be32(vni); + } +} + +static void +nfp_flower_compile_tun_gre_key(__be32 *key, __be32 *key_msk, __be16 *flags, + __be16 *flags_msk, struct flow_rule *rule) +{ + if (flow_rule_match_key(rule, flow_dissector_key_enc_keyid)) { + struct flow_match_enc_keyid match; + + flow_rule_match_enc_keyid(rule, &match); + *key = match.key->keyid; + *key_msk = match.mask->keyid; + + *flags = cpu_to_be16(nfp_fl_gre_flag_key); + *flags_msk = cpu_to_be16(nfp_fl_gre_flag_key); + } +} + - if (flow_rule_match_key(rule, flow_dissector_key_enc_keyid)) { - struct flow_match_enc_keyid match; - - flow_rule_match_enc_keyid(rule, &match); - ext->tun_key = match.key->keyid; - msk->tun_key = match.mask->keyid; - - ext->tun_flags = cpu_to_be16(nfp_fl_gre_flag_key); - msk->tun_flags = cpu_to_be16(nfp_fl_gre_flag_key); - } - + nfp_flower_compile_tun_gre_key(&ext->tun_key, &msk->tun_key, + &ext->tun_flags, &msk->tun_flags, rule); - if (flow_rule_match_key(rule, flow_dissector_key_enc_keyid)) { - struct flow_match_enc_keyid match; - u32 temp_vni; - - flow_rule_match_enc_keyid(rule, &match); - temp_vni = be32_to_cpu(match.key->keyid) << nfp_fl_tun_vni_offset; - ext->tun_id = cpu_to_be32(temp_vni); - temp_vni = be32_to_cpu(match.mask->keyid) << nfp_fl_tun_vni_offset; - msk->tun_id = cpu_to_be32(temp_vni); - } - + nfp_flower_compile_tun_udp_key(&ext->tun_id, &msk->tun_id, rule);
|
Networking
|
77a5f73a8b337c22ccadefbed30d2a36425388d1
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: compile match for ipv6 tunnels
|
ipv6 tunnel matches are now supported by firmware. modify the nfp driver to compile these match rules. ipv6 matches are handled similar to ipv4 tunnels with the difference the address length. the type of tunnel is indicated by the same bitmap that is used in ipv4 with an extra bit signifying that the ipv6 variation should be used.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['h', 'c']
| 4
| 246
| 51
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +#define nfp_flower_layer2_tun_ipv6 bit(7) +#define nfp_fl_max_geneve_opt_key_v6 8 +struct nfp_flower_tun_ipv6 { + struct in6_addr src; + struct in6_addr dst; +}; + +/* flow frame ipv6 udp tunnel --> tunnel details (11w/44b) + * ----------------------------------------------------------------- + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 31 - 0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 63 - 32 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 95 - 64 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 127 - 96 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 31 - 0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 63 - 32 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 95 - 64 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 127 - 96 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved | tos | ttl | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | vni | reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_ipv6_udp_tun { + struct nfp_flower_tun_ipv6 ipv6; + __be16 reserved1; + struct nfp_flower_tun_ip_ext ip_ext; + __be32 reserved2; + __be32 tun_id; +}; + +/* flow frame gre tunnel v6 --> tunnel details (12w/48b) + * ----------------------------------------------------------------- + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 31 - 0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 63 - 32 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 95 - 64 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_src, 127 - 96 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 31 - 0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 63 - 32 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 95 - 64 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_addr_dst, 127 - 96 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | tun_flags | tos | ttl | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved | ethertype | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | key | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_ipv6_gre_tun { + struct nfp_flower_tun_ipv6 ipv6; + __be16 tun_flags; + struct nfp_flower_tun_ip_ext ip_ext; + __be16 reserved1; + __be16 ethertype; + __be32 tun_key; + __be32 reserved2; +}; + diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h +#define nfp_fl_feats_ipv6_tun bit(7) diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c +static void +nfp_flower_compile_tun_ipv6_addrs(struct nfp_flower_tun_ipv6 *ext, + struct nfp_flower_tun_ipv6 *msk, + struct flow_rule *rule) +{ + if (flow_rule_match_key(rule, flow_dissector_key_enc_ipv6_addrs)) { + struct flow_match_ipv6_addrs match; + + flow_rule_match_enc_ipv6_addrs(rule, &match); + ext->src = match.key->src; + ext->dst = match.key->dst; + msk->src = match.mask->src; + msk->dst = match.mask->dst; + } +} + +static void +nfp_flower_compile_ipv6_udp_tun(struct nfp_flower_ipv6_udp_tun *ext, + struct nfp_flower_ipv6_udp_tun *msk, + struct flow_rule *rule) +{ + memset(ext, 0, sizeof(struct nfp_flower_ipv6_udp_tun)); + memset(msk, 0, sizeof(struct nfp_flower_ipv6_udp_tun)); + + nfp_flower_compile_tun_ipv6_addrs(&ext->ipv6, &msk->ipv6, rule); + nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); + nfp_flower_compile_tun_udp_key(&ext->tun_id, &msk->tun_id, rule); +} + +static void +nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext, + struct nfp_flower_ipv6_gre_tun *msk, + struct flow_rule *rule) +{ + memset(ext, 0, sizeof(struct nfp_flower_ipv6_gre_tun)); + memset(msk, 0, sizeof(struct nfp_flower_ipv6_gre_tun)); + + /* nvgre is the only supported gre tunnel type */ + ext->ethertype = cpu_to_be16(eth_p_teb); + msk->ethertype = cpu_to_be16(~0); + + nfp_flower_compile_tun_ipv6_addrs(&ext->ipv6, &msk->ipv6, rule); + nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); + nfp_flower_compile_tun_gre_key(&ext->tun_key, &msk->tun_key, + &ext->tun_flags, &msk->tun_flags, rule); +} + - __be32 tun_dst; - - nfp_flower_compile_ipv4_gre_tun((void *)ext, (void *)msk, rule); - tun_dst = ((struct nfp_flower_ipv4_gre_tun *)ext)->ipv4.dst; - ext += sizeof(struct nfp_flower_ipv4_gre_tun); - msk += sizeof(struct nfp_flower_ipv4_gre_tun); - - /* store the tunnel destination in the rule data. - * this must be present and be an exact match. - */ - nfp_flow->nfp_tun_ipv4_addr = tun_dst; - nfp_tunnel_add_ipv4_off(app, tun_dst); + if (key_ls->key_layer_two & nfp_flower_layer2_tun_ipv6) { + nfp_flower_compile_ipv6_gre_tun((void *)ext, + (void *)msk, rule); + ext += sizeof(struct nfp_flower_ipv6_gre_tun); + msk += sizeof(struct nfp_flower_ipv6_gre_tun); + } else { + __be32 dst; + + nfp_flower_compile_ipv4_gre_tun((void *)ext, + (void *)msk, rule); + dst = ((struct nfp_flower_ipv4_gre_tun *)ext)->ipv4.dst; + ext += sizeof(struct nfp_flower_ipv4_gre_tun); + msk += sizeof(struct nfp_flower_ipv4_gre_tun); + + /* store the tunnel destination in the rule data. + * this must be present and be an exact match. + */ + nfp_flow->nfp_tun_ipv4_addr = dst; + nfp_tunnel_add_ipv4_off(app, dst); + } - __be32 tun_dst; - - nfp_flower_compile_ipv4_udp_tun((void *)ext, (void *)msk, rule); - tun_dst = ((struct nfp_flower_ipv4_udp_tun *)ext)->ipv4.dst; - ext += sizeof(struct nfp_flower_ipv4_udp_tun); - msk += sizeof(struct nfp_flower_ipv4_udp_tun); - - /* store the tunnel destination in the rule data. - * this must be present and be an exact match. - */ - nfp_flow->nfp_tun_ipv4_addr = tun_dst; - nfp_tunnel_add_ipv4_off(app, tun_dst); + if (key_ls->key_layer_two & nfp_flower_layer2_tun_ipv6) { + nfp_flower_compile_ipv6_udp_tun((void *)ext, + (void *)msk, rule); + ext += sizeof(struct nfp_flower_ipv6_udp_tun); + msk += sizeof(struct nfp_flower_ipv6_udp_tun); + } else { + __be32 dst; + + nfp_flower_compile_ipv4_udp_tun((void *)ext, + (void *)msk, rule); + dst = ((struct nfp_flower_ipv4_udp_tun *)ext)->ipv4.dst; + ext += sizeof(struct nfp_flower_ipv4_udp_tun); + msk += sizeof(struct nfp_flower_ipv4_udp_tun); + + /* store the tunnel destination in the rule data. + * this must be present and be an exact match. + */ + nfp_flow->nfp_tun_ipv4_addr = dst; + nfp_tunnel_add_ipv4_off(app, dst); + } diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c +#define nfp_flower_whitelist_tun_dissector_v6_r \ + (bit(flow_dissector_key_enc_control) | \ + bit(flow_dissector_key_enc_ipv6_addrs)) + - u32 *key_layer_two, int *key_size, + u32 *key_layer_two, int *key_size, bool ipv6, - if (enc_opts->len > nfp_fl_max_geneve_opt_key) { + if (enc_opts->len > nfp_fl_max_geneve_opt_key || + (ipv6 && enc_opts->len > nfp_fl_max_geneve_opt_key_v6)) { - enum nfp_flower_tun_type *tun_type, + enum nfp_flower_tun_type *tun_type, bool ipv6, - *key_size += sizeof(struct nfp_flower_ipv4_udp_tun); + + if (ipv6) { + *key_layer |= nfp_flower_layer_ext_meta; + *key_size += sizeof(struct nfp_flower_ext_meta); + *key_layer_two |= nfp_flower_layer2_tun_ipv6; + *key_size += sizeof(struct nfp_flower_ipv6_udp_tun); + } else { + *key_size += sizeof(struct nfp_flower_ipv4_udp_tun); + } - *key_size += sizeof(struct nfp_flower_ipv4_udp_tun); + + if (ipv6) { + *key_layer_two |= nfp_flower_layer2_tun_ipv6; + *key_size += sizeof(struct nfp_flower_ipv6_udp_tun); + } else { + *key_size += sizeof(struct nfp_flower_ipv4_udp_tun); + } - err = nfp_flower_calc_opt_layer(enc_op, key_layer_two, - key_size, extack); + err = nfp_flower_calc_opt_layer(enc_op, key_layer_two, key_size, + ipv6, extack); + (dissector->used_keys & nfp_flower_whitelist_tun_dissector_v6_r) + != nfp_flower_whitelist_tun_dissector_v6_r && + struct flow_match_ipv6_addrs ipv6_addrs; + bool ipv6_tun = false; - if (enc_ctl.key->addr_type != flow_dissector_key_ipv4_addrs) { - nl_set_err_msg_mod(extack, "unsupported offload: only ipv4 tunnels are supported"); + + ipv6_tun = enc_ctl.key->addr_type == + flow_dissector_key_ipv6_addrs; + if (ipv6_tun && + !(priv->flower_ext_feats & nfp_fl_feats_ipv6_tun)) { + nl_set_err_msg_mod(extack, "unsupported offload: firmware does not support ipv6 tunnels"); - /* these fields are already verified as used. */ - flow_rule_match_enc_ipv4_addrs(rule, &ipv4_addrs); - if (ipv4_addrs.mask->dst != cpu_to_be32(~0)) { - nl_set_err_msg_mod(extack, "unsupported offload: only an exact match ipv4 destination address is supported"); + if (!ipv6_tun && + enc_ctl.key->addr_type != flow_dissector_key_ipv4_addrs) { + nl_set_err_msg_mod(extack, "unsupported offload: tunnel address type not ipv4 or ipv6"); + if (ipv6_tun) { + flow_rule_match_enc_ipv6_addrs(rule, &ipv6_addrs); + if (memchr_inv(&ipv6_addrs.mask->dst, 0xff, + sizeof(ipv6_addrs.mask->dst))) { + nl_set_err_msg_mod(extack, "unsupported offload: only an exact match ipv6 destination address is supported"); + return -eopnotsupp; + } + } else { + flow_rule_match_enc_ipv4_addrs(rule, &ipv4_addrs); + if (ipv4_addrs.mask->dst != cpu_to_be32(~0)) { + nl_set_err_msg_mod(extack, "unsupported offload: only an exact match ipv4 destination address is supported"); + return -eopnotsupp; + } + } + - - if (netif_is_gretap(netdev)) { - *tun_type = nfp_fl_tunnel_gre; - key_layer |= nfp_flower_layer_ext_meta; - key_size += sizeof(struct nfp_flower_ext_meta); - key_layer_two |= nfp_flower_layer2_gre; - key_size += - sizeof(struct nfp_flower_ipv4_gre_tun); + if (!netif_is_gretap(netdev)) { + nl_set_err_msg_mod(extack, "unsupported offload: an exact match on l4 destination port is required for non-gre tunnels"); + return -eopnotsupp; + } - if (enc_op.key) { - nl_set_err_msg_mod(extack, "unsupported offload: encap options not supported on gre tunnels"); - return -eopnotsupp; - } + *tun_type = nfp_fl_tunnel_gre; + key_layer |= nfp_flower_layer_ext_meta; + key_size += sizeof(struct nfp_flower_ext_meta); + key_layer_two |= nfp_flower_layer2_gre; + + if (ipv6_tun) { + key_layer_two |= nfp_flower_layer2_tun_ipv6; + key_size += + sizeof(struct nfp_flower_ipv6_udp_tun); - nl_set_err_msg_mod(extack, "unsupported offload: an exact match on l4 destination port is required for non-gre tunnels"); + key_size += + sizeof(struct nfp_flower_ipv4_udp_tun); + } + + if (enc_op.key) { + nl_set_err_msg_mod(extack, "unsupported offload: encap options not supported on gre tunnels"); - tun_type, extack); + tun_type, ipv6_tun, + extack);
|
Networking
|
78a722af4ad9cb2d82f230f697220af5aa6723c1
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: offload list of ipv6 tunnel endpoint addresses
|
fw requires a list of ipv6 addresses that are used as tunnel endpoints to enable correct decap of tunneled packets.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['h', 'c']
| 5
| 141
| 1
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h + nfp_flower_cmsg_type_tun_ips_v6 = 22, diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h + * @ipv6_off_list: list of ipv6 addresses to offload + * @ipv6_off_lock: lock for the ipv6 address list + struct list_head ipv6_off_list; + struct mutex ipv6_off_lock; +/** + * struct nfp_ipv6_addr_entry - cached ipv6 addresses + * @ipv6_addr: ip address + * @ref_count: number of rules currently using this ip + * @list: list pointer + */ +struct nfp_ipv6_addr_entry { + struct in6_addr ipv6_addr; + int ref_count; + struct list_head list; +}; + + struct nfp_ipv6_addr_entry *nfp_tun_ipv6; +void +nfp_tunnel_put_ipv6_off(struct nfp_app *app, struct nfp_ipv6_addr_entry *entry); +struct nfp_ipv6_addr_entry * +nfp_tunnel_add_ipv6_off(struct nfp_app *app, struct in6_addr *ipv6); diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c + struct nfp_flower_ipv6_gre_tun *gre_match; + struct nfp_ipv6_addr_entry *entry; + struct in6_addr *dst; + + gre_match = (struct nfp_flower_ipv6_gre_tun *)ext; + dst = &gre_match->ipv6.dst; + + entry = nfp_tunnel_add_ipv6_off(app, dst); + if (!entry) + return -eopnotsupp; + + nfp_flow->nfp_tun_ipv6 = entry; + struct nfp_flower_ipv6_udp_tun *udp_match; + struct nfp_ipv6_addr_entry *entry; + struct in6_addr *dst; + + udp_match = (struct nfp_flower_ipv6_udp_tun *)ext; + dst = &udp_match->ipv6.dst; + + entry = nfp_tunnel_add_ipv6_off(app, dst); + if (!entry) + return -eopnotsupp; + + nfp_flow->nfp_tun_ipv6 = entry; diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c + flow_pay->nfp_tun_ipv6 = null; + if (flow_pay->nfp_tun_ipv6) + nfp_tunnel_put_ipv6_off(app, flow_pay->nfp_tun_ipv6); + if (nfp_flow->nfp_tun_ipv6) + nfp_tunnel_put_ipv6_off(app, nfp_flow->nfp_tun_ipv6); + diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +#define nfp_fl_ipv6_addrs_max 4 + +/** + * struct nfp_tun_ipv6_addr - set the ip address list on the nfp + * @count: number of ips populated in the array + * @ipv6_addr: array of ipv6_addrs_max 128 bit ipv6 addresses + */ +struct nfp_tun_ipv6_addr { + __be32 count; + struct in6_addr ipv6_addr[nfp_fl_ipv6_addrs_max]; +}; + +static void nfp_tun_write_ipv6_list(struct nfp_app *app) +{ + struct nfp_flower_priv *priv = app->priv; + struct nfp_ipv6_addr_entry *entry; + struct nfp_tun_ipv6_addr payload; + int count = 0; + + memset(&payload, 0, sizeof(struct nfp_tun_ipv6_addr)); + mutex_lock(&priv->tun.ipv6_off_lock); + list_for_each_entry(entry, &priv->tun.ipv6_off_list, list) { + if (count >= nfp_fl_ipv6_addrs_max) { + nfp_flower_cmsg_warn(app, "too many ipv6 tunnel endpoint addresses, some cannot be offloaded. "); + break; + } + payload.ipv6_addr[count++] = entry->ipv6_addr; + } + mutex_unlock(&priv->tun.ipv6_off_lock); + payload.count = cpu_to_be32(count); + + nfp_flower_xmit_tun_conf(app, nfp_flower_cmsg_type_tun_ips_v6, + sizeof(struct nfp_tun_ipv6_addr), + &payload, gfp_kernel); +} + +struct nfp_ipv6_addr_entry * +nfp_tunnel_add_ipv6_off(struct nfp_app *app, struct in6_addr *ipv6) +{ + struct nfp_flower_priv *priv = app->priv; + struct nfp_ipv6_addr_entry *entry; + + mutex_lock(&priv->tun.ipv6_off_lock); + list_for_each_entry(entry, &priv->tun.ipv6_off_list, list) + if (!memcmp(&entry->ipv6_addr, ipv6, sizeof(*ipv6))) { + entry->ref_count++; + mutex_unlock(&priv->tun.ipv6_off_lock); + return entry; + } + + entry = kmalloc(sizeof(*entry), gfp_kernel); + if (!entry) { + mutex_unlock(&priv->tun.ipv6_off_lock); + nfp_flower_cmsg_warn(app, "mem error when offloading ip address. "); + return null; + } + entry->ipv6_addr = *ipv6; + entry->ref_count = 1; + list_add_tail(&entry->list, &priv->tun.ipv6_off_list); + mutex_unlock(&priv->tun.ipv6_off_lock); + + nfp_tun_write_ipv6_list(app); + + return entry; +} + +void +nfp_tunnel_put_ipv6_off(struct nfp_app *app, struct nfp_ipv6_addr_entry *entry) +{ + struct nfp_flower_priv *priv = app->priv; + bool freed = false; + + mutex_lock(&priv->tun.ipv6_off_lock); + if (!--entry->ref_count) { + list_del(&entry->list); + kfree(entry); + freed = true; + } + mutex_unlock(&priv->tun.ipv6_off_lock); + + if (freed) + nfp_tun_write_ipv6_list(app); +} + - /* initialise priv data for ipv4 offloading. */ + /* initialise priv data for ipv4/v6 offloading. */ + mutex_init(&priv->tun.ipv6_off_lock); + init_list_head(&priv->tun.ipv6_off_list); + mutex_destroy(&priv->tun.ipv6_off_lock); +
|
Networking
|
cfa189934231a2c7922ad9e15561b5b01ea5e82e
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: modify pre-tunnel and set tunnel action for ipv6
|
the ipv4 set tunnel action allows the setting of tunnel metadata such as the ttl and tos values. the pre-tunnel action includes the destination ip address and is used to calculate the next hop from from the neighbour table.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c', 'h']
| 3
| 62
| 30
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c -#define nfp_fl_supported_tunnel_info_flags ip_tunnel_info_tx -#define nfp_fl_supported_ipv4_udp_tun_flags (nfp_fl_tunnel_csum | \ +#define nfp_fl_supported_tunnel_info_flags (ip_tunnel_info_tx | \ + ip_tunnel_info_ipv6) +#define nfp_fl_supported_udp_tun_flags (nfp_fl_tunnel_csum | \ -nfp_fl_set_ipv4_tun(struct nfp_app *app, struct nfp_fl_set_ipv4_tun *set_tun, - const struct flow_action_entry *act, - struct nfp_fl_pre_tunnel *pre_tun, - enum nfp_flower_tun_type tun_type, - struct net_device *netdev, struct netlink_ext_ack *extack) +nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun, + const struct flow_action_entry *act, + struct nfp_fl_pre_tunnel *pre_tun, + enum nfp_flower_tun_type tun_type, + struct net_device *netdev, struct netlink_ext_ack *extack) - size_t act_size = sizeof(struct nfp_fl_set_ipv4_tun); + bool ipv6 = ip_tunnel_info_af(ip_tun) == af_inet6; + size_t act_size = sizeof(struct nfp_fl_set_tun); + if (!is_enabled(config_ipv6) && ipv6) + return -eopnotsupp; + + if (ipv6 && !(priv->flower_ext_feats & nfp_fl_feats_ipv6_tun)) + return -eopnotsupp; + - set_tun->head.jump_id = nfp_fl_action_opcode_set_ipv4_tunnel; + set_tun->head.jump_id = nfp_fl_action_opcode_set_tunnel; - field_prep(nfp_fl_ipv4_tunnel_type, tun_type) | - field_prep(nfp_fl_ipv4_pre_tun_index, pretun_idx); + field_prep(nfp_fl_tunnel_type, tun_type) | + field_prep(nfp_fl_pre_tun_index, pretun_idx); +#ifdef config_ipv6 + } else if (ipv6) { + struct net *net = dev_net(netdev); + struct flowi6 flow = {}; + struct dst_entry *dst; + + flow.daddr = ip_tun->key.u.ipv6.dst; + flow.flowi4_proto = ipproto_udp; + dst = ipv6_stub->ipv6_dst_lookup_flow(net, null, &flow, null); + if (!is_err(dst)) { + set_tun->ttl = ip6_dst_hoplimit(dst); + dst_release(dst); + } else { + set_tun->ttl = net->ipv6.devconf_all->hop_limit; + } +#endif - ip_tun->key.tun_flags & ~nfp_fl_supported_ipv4_udp_tun_flags) { + ip_tun->key.tun_flags & ~nfp_fl_supported_udp_tun_flags) { - pre_tun->ipv4_dst = ip_tun->key.u.ipv4.dst; + if (ipv6) { + pre_tun->flags |= cpu_to_be16(nfp_fl_pre_tun_ipv6); + pre_tun->ipv6_dst = ip_tun->key.u.ipv6.dst; + } else { + pre_tun->ipv4_dst = ip_tun->key.u.ipv4.dst; + } - struct nfp_fl_set_ipv4_tun *set_tun; + struct nfp_fl_set_tun *set_tun; - sizeof(struct nfp_fl_set_ipv4_tun) > nfp_fl_max_a_siz) { + sizeof(struct nfp_fl_set_tun) > nfp_fl_max_a_siz) { - err = nfp_fl_set_ipv4_tun(app, set_tun, act, pre_tun, - *tun_type, netdev, extack); + err = nfp_fl_set_tun(app, set_tun, act, pre_tun, *tun_type, + netdev, extack); - *a_len += sizeof(struct nfp_fl_set_ipv4_tun); + *a_len += sizeof(struct nfp_fl_set_tun); diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h -#define nfp_fl_action_opcode_set_ipv4_tunnel 6 +#define nfp_fl_action_opcode_set_tunnel 6 -#define nfp_fl_ipv4_tunnel_type genmask(7, 4) -#define nfp_fl_ipv4_pre_tun_index genmask(2, 0) +#define nfp_fl_tunnel_type genmask(7, 4) +#define nfp_fl_pre_tun_index genmask(2, 0) - __be16 reserved; - __be32 ipv4_dst; - /* reserved for use with ipv6 addresses */ - __be32 extra[3]; + __be16 flags; + union { + __be32 ipv4_dst; + struct in6_addr ipv6_dst; + }; -struct nfp_fl_set_ipv4_tun { +#define nfp_fl_pre_tun_ipv6 bit(0) + +struct nfp_fl_set_tun { diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c - case nfp_fl_action_opcode_set_ipv4_tunnel: + case nfp_fl_action_opcode_set_tunnel: - struct nfp_fl_set_ipv4_tun *tun; + struct nfp_fl_set_tun *tun; - if (a->jump_id == nfp_fl_action_opcode_set_ipv4_tunnel) { - tun = (struct nfp_fl_set_ipv4_tun *)a; + if (a->jump_id == nfp_fl_action_opcode_set_tunnel) { + tun = (struct nfp_fl_set_tun *)a;
|
Networking
|
1922c9a4e273fd0934f82d9d80c69d53658a1c9d
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: handle ipv6 tunnel no neigh request
|
when fw does not know the next hop for an ipv6 tunnel, it sends a request to the driver.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c', 'h']
| 4
| 116
| 8
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c - nfp_tunnel_request_route(app, skb); + nfp_tunnel_request_route_v4(app, skb); + break; + case nfp_flower_cmsg_type_no_neigh_v6: + nfp_tunnel_request_route_v6(app, skb); - } else if (cmsg_hdr->type == nfp_flower_cmsg_type_tun_neigh) { + } else if (cmsg_hdr->type == nfp_flower_cmsg_type_tun_neigh || + cmsg_hdr->type == nfp_flower_cmsg_type_tun_neigh_v6) { diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h + nfp_flower_cmsg_type_no_neigh_v6 = 23, + nfp_flower_cmsg_type_tun_neigh_v6 = 24, diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h -void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb); +void nfp_tunnel_request_route_v4(struct nfp_app *app, struct sk_buff *skb); +void nfp_tunnel_request_route_v6(struct nfp_app *app, struct sk_buff *skb); diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +/** + * struct nfp_tun_neigh_v6 - neighbour/route entry on the nfp + * @dst_ipv6: destination ipv6 address + * @src_ipv6: source ipv6 address + * @dst_addr: destination mac address + * @src_addr: source mac address + * @port_id: nfp port to output packet on - associated with source ipv6 + */ +struct nfp_tun_neigh_v6 { + struct in6_addr dst_ipv6; + struct in6_addr src_ipv6; + u8 dst_addr[eth_alen]; + u8 src_addr[eth_alen]; + __be32 port_id; +}; + +/** + * struct nfp_tun_req_route_ipv6 - nfp requests an ipv6 route/neighbour lookup + * @ingress_port: ingress port of packet that signalled request + * @ipv6_addr: destination ipv6 address for route + */ +struct nfp_tun_req_route_ipv6 { + __be32 ingress_port; + struct in6_addr ipv6_addr; +}; + -nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app, - struct flowi4 *flow, struct neighbour *neigh, gfp_t flag) +nfp_tun_write_neigh_v4(struct net_device *netdev, struct nfp_app *app, + struct flowi4 *flow, struct neighbour *neigh, gfp_t flag) +static void +nfp_tun_write_neigh_v6(struct net_device *netdev, struct nfp_app *app, + struct flowi6 *flow, struct neighbour *neigh, gfp_t flag) +{ + struct nfp_tun_neigh_v6 payload; + u32 port_id; + + port_id = nfp_flower_get_port_id_from_netdev(app, netdev); + if (!port_id) + return; + + memset(&payload, 0, sizeof(struct nfp_tun_neigh_v6)); + payload.dst_ipv6 = flow->daddr; + + /* if entry has expired send dst ip with all other fields 0. */ + if (!(neigh->nud_state & nud_valid) || neigh->dead) { + /* trigger probe to verify invalid neighbour state. */ + neigh_event_send(neigh, null); + goto send_msg; + } + + /* have a valid neighbour so populate rest of entry. */ + payload.src_ipv6 = flow->saddr; + ether_addr_copy(payload.src_addr, netdev->dev_addr); + neigh_ha_snapshot(payload.dst_addr, neigh, netdev); + payload.port_id = cpu_to_be32(port_id); + +send_msg: + nfp_flower_xmit_tun_conf(app, nfp_flower_cmsg_type_tun_neigh_v6, + sizeof(struct nfp_tun_neigh_v6), + (unsigned char *)&payload, flag); +} + - nfp_tun_write_neigh(n->dev, app, &flow, n, gfp_atomic); + nfp_tun_write_neigh_v4(n->dev, app, &flow, n, gfp_atomic); -void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb) +void nfp_tunnel_request_route_v4(struct nfp_app *app, struct sk_buff *skb) - nfp_tun_write_neigh(n->dev, app, &flow, n, gfp_atomic); + nfp_tun_write_neigh_v4(n->dev, app, &flow, n, gfp_atomic); +void nfp_tunnel_request_route_v6(struct nfp_app *app, struct sk_buff *skb) +{ + struct nfp_tun_req_route_ipv6 *payload; + struct net_device *netdev; + struct flowi6 flow = {}; + struct dst_entry *dst; + struct neighbour *n; + + payload = nfp_flower_cmsg_get_data(skb); + + rcu_read_lock(); + netdev = nfp_app_dev_get(app, be32_to_cpu(payload->ingress_port), null); + if (!netdev) + goto fail_rcu_unlock; + + flow.daddr = payload->ipv6_addr; + flow.flowi6_proto = ipproto_udp; + +#if is_enabled(config_inet) && is_enabled(config_ipv6) + dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(netdev), null, &flow, + null); + if (is_err(dst)) + goto fail_rcu_unlock; +#else + goto fail_rcu_unlock; +#endif + + n = dst_neigh_lookup(dst, &flow.daddr); + dst_release(dst); + if (!n) + goto fail_rcu_unlock; + + nfp_tun_write_neigh_v6(n->dev, app, &flow, n, gfp_atomic); + neigh_release(n); + rcu_read_unlock(); + return; + +fail_rcu_unlock: + rcu_read_unlock(); + nfp_flower_cmsg_warn(app, "requested ipv6 route not found. "); +} +
|
Networking
|
50b1c86ab0a07509fd65c92acacf281fb72a285b
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: handle notifiers for ipv6 route changes
|
a notifier is used to track route changes in the kernel. if a change is made to a route that is offloaded to fw then an update is sent to the nic. the driver tracks all routes that are offloaded to determine if a kernel change is of interest.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['h', 'c']
| 2
| 181
| 68
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h - * @neigh_off_list: list of neighbour offloads + * @neigh_off_list_v4: list of ipv4 neighbour offloads + * @neigh_off_list_v6: list of ipv6 neighbour offloads - * @neigh_off_lock: lock for the neighbour address list + * @neigh_off_lock_v4: lock for the ipv4 neighbour address list + * @neigh_off_lock_v6: lock for the ipv6 neighbour address list - struct list_head neigh_off_list; + struct list_head neigh_off_list_v4; + struct list_head neigh_off_list_v6; - spinlock_t neigh_off_lock; + spinlock_t neigh_off_lock_v4; + spinlock_t neigh_off_lock_v6; diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c - * struct nfp_ipv4_route_entry - routes that are offloaded to the nfp - * @ipv4_addr: destination of route + * struct nfp_offloaded_route - routes that are offloaded to the nfp + * @ip_add: destination of route - can be ipv4 or ipv6 -struct nfp_ipv4_route_entry { - __be32 ipv4_addr; +struct nfp_offloaded_route { + u8 ip_add[]; -static bool nfp_tun_has_route(struct nfp_app *app, __be32 ipv4_addr) +static bool +__nfp_tun_has_route(struct list_head *route_list, spinlock_t *list_lock, + void *add, int add_len) - struct nfp_flower_priv *priv = app->priv; - struct nfp_ipv4_route_entry *entry; - struct list_head *ptr, *storage; + struct nfp_offloaded_route *entry; - spin_lock_bh(&priv->tun.neigh_off_lock); - list_for_each_safe(ptr, storage, &priv->tun.neigh_off_list) { - entry = list_entry(ptr, struct nfp_ipv4_route_entry, list); - if (entry->ipv4_addr == ipv4_addr) { - spin_unlock_bh(&priv->tun.neigh_off_lock); + spin_lock_bh(list_lock); + list_for_each_entry(entry, route_list, list) + if (!memcmp(entry->ip_add, add, add_len)) { + spin_unlock_bh(list_lock); - } - spin_unlock_bh(&priv->tun.neigh_off_lock); + spin_unlock_bh(list_lock); -static void nfp_tun_add_route_to_cache(struct nfp_app *app, __be32 ipv4_addr) +static int +__nfp_tun_add_route_to_cache(struct list_head *route_list, + spinlock_t *list_lock, void *add, int add_len) - struct nfp_flower_priv *priv = app->priv; - struct nfp_ipv4_route_entry *entry; - struct list_head *ptr, *storage; + struct nfp_offloaded_route *entry; - spin_lock_bh(&priv->tun.neigh_off_lock); - list_for_each_safe(ptr, storage, &priv->tun.neigh_off_list) { - entry = list_entry(ptr, struct nfp_ipv4_route_entry, list); - if (entry->ipv4_addr == ipv4_addr) { - spin_unlock_bh(&priv->tun.neigh_off_lock); - return; + spin_lock_bh(list_lock); + list_for_each_entry(entry, route_list, list) + if (!memcmp(entry->ip_add, add, add_len)) { + spin_unlock_bh(list_lock); + return 0; - } - entry = kmalloc(sizeof(*entry), gfp_atomic); + + entry = kmalloc(sizeof(*entry) + add_len, gfp_atomic); - spin_unlock_bh(&priv->tun.neigh_off_lock); - nfp_flower_cmsg_warn(app, "mem error when storing new route. "); - return; + spin_unlock_bh(list_lock); + return -enomem; - entry->ipv4_addr = ipv4_addr; - list_add_tail(&entry->list, &priv->tun.neigh_off_list); - spin_unlock_bh(&priv->tun.neigh_off_lock); + memcpy(entry->ip_add, add, add_len); + list_add_tail(&entry->list, route_list); + spin_unlock_bh(list_lock); + + return 0; -static void nfp_tun_del_route_from_cache(struct nfp_app *app, __be32 ipv4_addr) +static void +__nfp_tun_del_route_from_cache(struct list_head *route_list, + spinlock_t *list_lock, void *add, int add_len) - struct nfp_flower_priv *priv = app->priv; - struct nfp_ipv4_route_entry *entry; - struct list_head *ptr, *storage; + struct nfp_offloaded_route *entry; - spin_lock_bh(&priv->tun.neigh_off_lock); - list_for_each_safe(ptr, storage, &priv->tun.neigh_off_list) { - entry = list_entry(ptr, struct nfp_ipv4_route_entry, list); - if (entry->ipv4_addr == ipv4_addr) { + spin_lock_bh(list_lock); + list_for_each_entry(entry, route_list, list) + if (!memcmp(entry->ip_add, add, add_len)) { - } - spin_unlock_bh(&priv->tun.neigh_off_lock); + spin_unlock_bh(list_lock); +} + +static bool nfp_tun_has_route_v4(struct nfp_app *app, __be32 *ipv4_addr) +{ + struct nfp_flower_priv *priv = app->priv; + + return __nfp_tun_has_route(&priv->tun.neigh_off_list_v4, + &priv->tun.neigh_off_lock_v4, ipv4_addr, + sizeof(*ipv4_addr)); +} + +static bool +nfp_tun_has_route_v6(struct nfp_app *app, struct in6_addr *ipv6_addr) +{ + struct nfp_flower_priv *priv = app->priv; + + return __nfp_tun_has_route(&priv->tun.neigh_off_list_v6, + &priv->tun.neigh_off_lock_v6, ipv6_addr, + sizeof(*ipv6_addr)); +} + +static void +nfp_tun_add_route_to_cache_v4(struct nfp_app *app, __be32 *ipv4_addr) +{ + struct nfp_flower_priv *priv = app->priv; + + __nfp_tun_add_route_to_cache(&priv->tun.neigh_off_list_v4, + &priv->tun.neigh_off_lock_v4, ipv4_addr, + sizeof(*ipv4_addr)); +} + +static void +nfp_tun_add_route_to_cache_v6(struct nfp_app *app, struct in6_addr *ipv6_addr) +{ + struct nfp_flower_priv *priv = app->priv; + + __nfp_tun_add_route_to_cache(&priv->tun.neigh_off_list_v6, + &priv->tun.neigh_off_lock_v6, ipv6_addr, + sizeof(*ipv6_addr)); +} + +static void +nfp_tun_del_route_from_cache_v4(struct nfp_app *app, __be32 *ipv4_addr) +{ + struct nfp_flower_priv *priv = app->priv; + + __nfp_tun_del_route_from_cache(&priv->tun.neigh_off_list_v4, + &priv->tun.neigh_off_lock_v4, ipv4_addr, + sizeof(*ipv4_addr)); +} + +static void +nfp_tun_del_route_from_cache_v6(struct nfp_app *app, struct in6_addr *ipv6_addr) +{ + struct nfp_flower_priv *priv = app->priv; + + __nfp_tun_del_route_from_cache(&priv->tun.neigh_off_list_v6, + &priv->tun.neigh_off_lock_v6, ipv6_addr, + sizeof(*ipv6_addr)); - nfp_tun_del_route_from_cache(app, payload.dst_ipv4); + nfp_tun_del_route_from_cache_v4(app, &payload.dst_ipv4); - nfp_tun_add_route_to_cache(app, payload.dst_ipv4); + nfp_tun_add_route_to_cache_v4(app, &payload.dst_ipv4); + nfp_tun_del_route_from_cache_v6(app, &payload.dst_ipv6); + /* add destination of new route to nfp cache. */ + nfp_tun_add_route_to_cache_v6(app, &payload.dst_ipv6); - struct flowi4 flow = {}; + struct flowi4 flow4 = {}; + struct flowi6 flow6 = {}; + bool ipv6 = false; - flow.daddr = *(__be32 *)n->primary_key; + if (n->tbl->family == af_inet6) + ipv6 = true; + + if (ipv6) + flow6.daddr = *(struct in6_addr *)n->primary_key; + else + flow4.daddr = *(__be32 *)n->primary_key; - if (!nfp_tun_has_route(app, flow.daddr)) + if ((ipv6 && !nfp_tun_has_route_v6(app, &flow6.daddr)) || + (!ipv6 && !nfp_tun_has_route_v4(app, &flow4.daddr))) - /* do a route lookup to populate flow data. */ - rt = ip_route_output_key(dev_net(n->dev), &flow); - err = ptr_err_or_zero(rt); - if (err) + if (ipv6) { +#if is_enabled(config_ipv6) + struct dst_entry *dst; + + dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(n->dev), null, + &flow6, null); + if (is_err(dst)) + return notify_done; + + dst_release(dst); + flow6.flowi6_proto = ipproto_udp; + nfp_tun_write_neigh_v6(n->dev, app, &flow6, n, gfp_atomic); +#else +#endif /* config_ipv6 */ + } else { + /* do a route lookup to populate flow data. */ + rt = ip_route_output_key(dev_net(n->dev), &flow4); + err = ptr_err_or_zero(rt); + if (err) + return notify_done; - ip_rt_put(rt); + ip_rt_put(rt); + + flow4.flowi4_proto = ipproto_udp; + nfp_tun_write_neigh_v4(n->dev, app, &flow4, n, gfp_atomic); + } -#endif - - flow.flowi4_proto = ipproto_udp; - nfp_tun_write_neigh_v4(n->dev, app, &flow, n, gfp_atomic); +#endif /* config_inet */ - spin_lock_init(&priv->tun.neigh_off_lock); - init_list_head(&priv->tun.neigh_off_list); + spin_lock_init(&priv->tun.neigh_off_lock_v4); + init_list_head(&priv->tun.neigh_off_list_v4); + spin_lock_init(&priv->tun.neigh_off_lock_v6); + init_list_head(&priv->tun.neigh_off_list_v6); + struct nfp_offloaded_route *route_entry, *temp; - struct nfp_ipv4_route_entry *route_entry; + struct nfp_tun_neigh_v6 ipv6_route; + struct nfp_tun_neigh ipv4_route; - /* free any memory that may be occupied by the route list. */ - list_for_each_safe(ptr, storage, &priv->tun.neigh_off_list) { - route_entry = list_entry(ptr, struct nfp_ipv4_route_entry, - list); + /* free memory in the route list and remove entries from fw cache. */ + list_for_each_entry_safe(route_entry, temp, + &priv->tun.neigh_off_list_v4, list) { + memset(&ipv4_route, 0, sizeof(ipv4_route)); + memcpy(&ipv4_route.dst_ipv4, &route_entry->ip_add, + sizeof(ipv4_route.dst_ipv4)); + + nfp_flower_xmit_tun_conf(app, nfp_flower_cmsg_type_tun_neigh, + sizeof(struct nfp_tun_neigh), + (unsigned char *)&ipv4_route, + gfp_kernel); + } + + list_for_each_entry_safe(route_entry, temp, + &priv->tun.neigh_off_list_v6, list) { + memset(&ipv6_route, 0, sizeof(ipv6_route)); + memcpy(&ipv6_route.dst_ipv6, &route_entry->ip_add, + sizeof(ipv6_route.dst_ipv6)); + list_del(&route_entry->list); + kfree(route_entry); + + nfp_flower_xmit_tun_conf(app, nfp_flower_cmsg_type_tun_neigh_v6, + sizeof(struct nfp_tun_neigh), + (unsigned char *)&ipv6_route, + gfp_kernel);
|
Networking
|
6c463a059f626bc2115b17bee97f014f59dd844a
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: support ipv6 tunnel keep-alive messages from fw
|
fw sends an update of ipv6 tunnels that are active in a given period. use this information to update the kernel table so that neighbour entries do not time out when active on the nic.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c', 'h']
| 4
| 67
| 0
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c + case nfp_flower_cmsg_type_active_tuns_v6: + nfp_tunnel_keep_alive_v6(app, skb); + break; diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h + nfp_flower_cmsg_type_active_tuns_v6 = 25, diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h +void nfp_tunnel_keep_alive_v6(struct nfp_app *app, struct sk_buff *skb); diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +/** + * struct nfp_tun_active_tuns_v6 - periodic message of active ipv6 tunnels + * @seq: sequence number of the message + * @count: number of tunnels report in message + * @flags: options part of the request + * @tun_info.ipv6: dest ipv6 address of active route + * @tun_info.egress_port: port the encapsulated packet egressed + * @tun_info: tunnels that have sent traffic in reported period + */ +struct nfp_tun_active_tuns_v6 { + __be32 seq; + __be32 count; + __be32 flags; + struct route_ip_info_v6 { + struct in6_addr ipv6; + __be32 egress_port; + } tun_info[]; +}; + +void nfp_tunnel_keep_alive_v6(struct nfp_app *app, struct sk_buff *skb) +{ +#if is_enabled(config_ipv6) + struct nfp_tun_active_tuns_v6 *payload; + struct net_device *netdev; + int count, i, pay_len; + struct neighbour *n; + void *ipv6_add; + u32 port; + + payload = nfp_flower_cmsg_get_data(skb); + count = be32_to_cpu(payload->count); + if (count > nfp_fl_ipv6_addrs_max) { + nfp_flower_cmsg_warn(app, "ipv6 tunnel keep-alive request exceeds max routes. "); + return; + } + + pay_len = nfp_flower_cmsg_get_data_len(skb); + if (pay_len != struct_size(payload, tun_info, count)) { + nfp_flower_cmsg_warn(app, "corruption in tunnel keep-alive message. "); + return; + } + + rcu_read_lock(); + for (i = 0; i < count; i++) { + ipv6_add = &payload->tun_info[i].ipv6; + port = be32_to_cpu(payload->tun_info[i].egress_port); + netdev = nfp_app_dev_get(app, port, null); + if (!netdev) + continue; + + n = neigh_lookup(&nd_tbl, ipv6_add, netdev); + if (!n) + continue; + + /* update the used timestamp of neighbour */ + neigh_event_send(n, null); + neigh_release(n); + } + rcu_read_unlock(); +#endif +} +
|
Networking
|
9ea9bfa12240650feba7648dbb7f334dac8ba757
|
john hurley simon horman simon horman netronome com jakub kicinski jakub kicinski netronome com
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
nfp: flower: update flow merge code to support ipv6 tunnels
|
both pre-tunnel match rules and flow merge functions parse compiled match/action fields for validation.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add ipv6 tunnel support to nfp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['nfp ']
|
['c']
| 1
| 23
| 5
|
--- diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c - nfp_flower_layer_ipv4) + nfp_flower_layer_ipv4 | \ + nfp_flower_layer_ipv6) + struct nfp_fl_pre_tunnel *pre_tun; + bool ipv6_tun = false; - memset(&merge->ipv4, 0xff, - sizeof(struct nfp_flower_ipv4)); + if (ipv6_tun) + memset(&merge->ipv6, 0xff, + sizeof(struct nfp_flower_ipv6)); + else + memset(&merge->ipv4, 0xff, + sizeof(struct nfp_flower_ipv4)); + pre_tun = (struct nfp_fl_pre_tunnel *)a; + ipv6_tun = be16_to_cpu(pre_tun->flags) & + nfp_fl_pre_tun_ipv6; + break; - if (key_layer & nfp_flower_layer_ipv4) { + if (key_layer & nfp_flower_layer_ipv4 || + key_layer & nfp_flower_layer_ipv6) { + /* flags and proto fields have same offset in ipv4 and ipv6. */ + int size; + size = key_layer & nfp_flower_layer_ipv4 ? + sizeof(struct nfp_flower_ipv4) : + sizeof(struct nfp_flower_ipv6); + - for (i = 0; i < sizeof(struct nfp_flower_ipv4); i++) + for (i = 0; i < size; i++)
|
Networking
|
783461604f7e3c7b4df9c653bf3db165cb9e3326
|
john hurley
|
drivers
|
net
|
ethernet, flower, netronome, nfp
|
octeontx2-pf: add marvell octeontx2 nic driver
|
this patch adds template for the marvell's octeontx2 network controller's physical function driver. just the probe, pci specific initialization and netdev registration.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['h', 'kconfig', 'c', 'makefile']
| 6
| 362
| 0
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/kconfig b/drivers/net/ethernet/marvell/octeontx2/kconfig --- a/drivers/net/ethernet/marvell/octeontx2/kconfig +++ b/drivers/net/ethernet/marvell/octeontx2/kconfig + +config octeontx2_pf + tristate "marvell octeontx2 nic physical function driver" + select octeontx2_mbox + depends on (64bit && compile_test) || arm64 + depends on pci + help + this driver supports marvell's octeontx2 nic physical function. diff --git a/drivers/net/ethernet/marvell/octeontx2/makefile b/drivers/net/ethernet/marvell/octeontx2/makefile --- a/drivers/net/ethernet/marvell/octeontx2/makefile +++ b/drivers/net/ethernet/marvell/octeontx2/makefile +obj-$(config_octeontx2_mbox) += af/ +obj-$(config_octeontx2_pf) += nic/ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/makefile b/drivers/net/ethernet/marvell/octeontx2/nic/makefile --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/makefile +# spdx-license-identifier: gpl-2.0 +# +# makefile for marvell's octeontx2 ethernet device drivers +# + +obj-$(config_octeontx2_pf) += octeontx2_nicpf.o + +octeontx2_nicpf-y := otx2_pf.o + +ccflags-y += -i$(srctree)/drivers/net/ethernet/marvell/octeontx2/af diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +/* spdx-license-identifier: gpl-2.0 */ +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#ifndef otx2_common_h +#define otx2_common_h + +#include <linux/pci.h> + +#include "otx2_reg.h" + +/* pci device ids */ +#define pci_devid_octeontx2_rvu_pf 0xa063 + +/* pci bar nos */ +#define pci_cfg_reg_bar_num 2 + +struct otx2_hw { + struct pci_dev *pdev; + u16 rx_queues; + u16 tx_queues; + u16 max_queues; +}; + +struct otx2_nic { + void __iomem *reg_base; + struct net_device *netdev; + + struct otx2_hw hw; + struct pci_dev *pdev; + struct device *dev; +}; + +/* register read/write apis */ +static inline void __iomem *otx2_get_regaddr(struct otx2_nic *nic, u64 offset) +{ + u64 blkaddr; + + switch ((offset >> rvu_func_blkaddr_shift) & rvu_func_blkaddr_mask) { + case blktype_nix: + blkaddr = blkaddr_nix0; + break; + case blktype_npa: + blkaddr = blkaddr_npa; + break; + default: + blkaddr = blkaddr_rvum; + break; + }; + + offset &= ~(rvu_func_blkaddr_mask << rvu_func_blkaddr_shift); + offset |= (blkaddr << rvu_func_blkaddr_shift); + + return nic->reg_base + offset; +} + +static inline void otx2_write64(struct otx2_nic *nic, u64 offset, u64 val) +{ + void __iomem *addr = otx2_get_regaddr(nic, offset); + + writeq(val, addr); +} + +static inline u64 otx2_read64(struct otx2_nic *nic, u64 offset) +{ + void __iomem *addr = otx2_get_regaddr(nic, offset); + + return readq(addr); +} + +#endif /* otx2_common_h */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +// spdx-license-identifier: gpl-2.0 +/* marvell octeontx2 rvu physcial function ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#include <linux/module.h> +#include <linux/interrupt.h> +#include <linux/pci.h> +#include <linux/etherdevice.h> +#include <linux/of.h> +#include <linux/if_vlan.h> +#include <linux/iommu.h> +#include <net/ip.h> + +#include "otx2_common.h" + +#define drv_name "octeontx2-nicpf" +#define drv_string "marvell octeontx2 nic physical function driver" +#define drv_version "1.0" + +/* supported devices */ +static const struct pci_device_id otx2_pf_id_table[] = { + { pci_device(pci_vendor_id_cavium, pci_devid_octeontx2_rvu_pf) }, + { 0, } /* end of table */ +}; + +module_author("marvell international ltd."); +module_description(drv_string); +module_license("gpl v2"); +module_version(drv_version); +module_device_table(pci, otx2_pf_id_table); + +static int otx2_set_real_num_queues(struct net_device *netdev, + int tx_queues, int rx_queues) +{ + int err; + + err = netif_set_real_num_tx_queues(netdev, tx_queues); + if (err) { + netdev_err(netdev, + "failed to set no of tx queues: %d ", tx_queues); + return err; + } + + err = netif_set_real_num_rx_queues(netdev, rx_queues); + if (err) + netdev_err(netdev, + "failed to set no of rx queues: %d ", rx_queues); + return err; +} + +static int otx2_open(struct net_device *netdev) +{ + netif_carrier_off(netdev); + + return 0; +} + +static int otx2_stop(struct net_device *netdev) +{ + return 0; +} + +static const struct net_device_ops otx2_netdev_ops = { + .ndo_open = otx2_open, + .ndo_stop = otx2_stop, +}; + +static int otx2_check_pf_usable(struct otx2_nic *nic) +{ + u64 rev; + + rev = otx2_read64(nic, rvu_pf_block_addrx_disc(blkaddr_rvum)); + rev = (rev >> 12) & 0xff; + /* check if af has setup revision for rvum block, + * otherwise this driver probe should be deferred + * until af driver comes up. + */ + if (!rev) { + dev_warn(nic->dev, + "af is not initialized, deferring probe "); + return -eprobe_defer; + } + return 0; +} + +static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct device *dev = &pdev->dev; + struct net_device *netdev; + struct otx2_nic *pf; + struct otx2_hw *hw; + int err, qcount; + + err = pcim_enable_device(pdev); + if (err) { + dev_err(dev, "failed to enable pci device "); + return err; + } + + err = pci_request_regions(pdev, drv_name); + if (err) { + dev_err(dev, "pci request regions failed 0x%x ", err); + return err; + } + + err = dma_set_mask_and_coherent(dev, dma_bit_mask(48)); + if (err) { + dev_err(dev, "dma mask config failed, abort "); + goto err_release_regions; + } + + pci_set_master(pdev); + + /* set number of queues */ + qcount = min_t(int, num_online_cpus(), num_online_cpus()); + + netdev = alloc_etherdev_mqs(sizeof(*pf), qcount, qcount); + if (!netdev) { + err = -enomem; + goto err_release_regions; + } + + pci_set_drvdata(pdev, netdev); + set_netdev_dev(netdev, &pdev->dev); + pf = netdev_priv(netdev); + pf->netdev = netdev; + pf->pdev = pdev; + pf->dev = dev; + + hw = &pf->hw; + hw->pdev = pdev; + hw->rx_queues = qcount; + hw->tx_queues = qcount; + hw->max_queues = qcount; + + /* map csrs */ + pf->reg_base = pcim_iomap(pdev, pci_cfg_reg_bar_num, 0); + if (!pf->reg_base) { + dev_err(dev, "unable to map physical function csrs, aborting "); + err = -enomem; + goto err_free_netdev; + } + + err = otx2_check_pf_usable(pf); + if (err) + goto err_free_netdev; + + err = otx2_set_real_num_queues(netdev, hw->tx_queues, hw->rx_queues); + if (err) + goto err_free_netdev; + + netdev->netdev_ops = &otx2_netdev_ops; + + err = register_netdev(netdev); + if (err) { + dev_err(dev, "failed to register netdevice "); + goto err_free_netdev; + } + + return 0; + +err_free_netdev: + pci_set_drvdata(pdev, null); + free_netdev(netdev); +err_release_regions: + pci_release_regions(pdev); + return err; +} + +static void otx2_remove(struct pci_dev *pdev) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + struct otx2_nic *pf; + + if (!netdev) + return; + + pf = netdev_priv(netdev); + + unregister_netdev(netdev); + pci_free_irq_vectors(pf->pdev); + pci_set_drvdata(pdev, null); + free_netdev(netdev); + pci_release_regions(pdev); +} + +static struct pci_driver otx2_pf_driver = { + .name = drv_name, + .id_table = otx2_pf_id_table, + .probe = otx2_probe, + .shutdown = otx2_remove, + .remove = otx2_remove, +}; + +static int __init otx2_rvupf_init_module(void) +{ + pr_info("%s: %s ", drv_name, drv_string); + + return pci_register_driver(&otx2_pf_driver); +} + +static void __exit otx2_rvupf_cleanup_module(void) +{ + pci_unregister_driver(&otx2_pf_driver); +} + +module_init(otx2_rvupf_init_module); +module_exit(otx2_rvupf_cleanup_module); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h +/* spdx-license-identifier: gpl-2.0 */ +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#ifndef otx2_reg_h +#define otx2_reg_h + +#include <rvu_struct.h> + +/* rvu pf registers */ +#define rvu_pf_vfx_pfvf_mbox0 (0x00000) +#define rvu_pf_vfx_pfvf_mbox1 (0x00008) +#define rvu_pf_vfx_pfvf_mboxx(a, b) (0x0 | (a) << 12 | (b) << 3) +#define rvu_pf_vf_bar4_addr (0x10) +#define rvu_pf_block_addrx_disc(a) (0x200 | (a) << 3) +#define rvu_pf_vfme_statusx(a) (0x800 | (a) << 3) +#define rvu_pf_vftrpendx(a) (0x820 | (a) << 3) +#define rvu_pf_vftrpend_w1sx(a) (0x840 | (a) << 3) +#define rvu_pf_vfpf_mbox_intx(a) (0x880 | (a) << 3) +#define rvu_pf_vfpf_mbox_int_w1sx(a) (0x8a0 | (a) << 3) +#define rvu_pf_vfpf_mbox_int_ena_w1sx(a) (0x8c0 | (a) << 3) +#define rvu_pf_vfpf_mbox_int_ena_w1cx(a) (0x8e0 | (a) << 3) +#define rvu_pf_vfflr_intx(a) (0x900 | (a) << 3) +#define rvu_pf_vfflr_int_w1sx(a) (0x920 | (a) << 3) +#define rvu_pf_vfflr_int_ena_w1sx(a) (0x940 | (a) << 3) +#define rvu_pf_vfflr_int_ena_w1cx(a) (0x960 | (a) << 3) +#define rvu_pf_vfme_intx(a) (0x980 | (a) << 3) +#define rvu_pf_vfme_int_w1sx(a) (0x9a0 | (a) << 3) +#define rvu_pf_vfme_int_ena_w1sx(a) (0x9c0 | (a) << 3) +#define rvu_pf_vfme_int_ena_w1cx(a) (0x9e0 | (a) << 3) +#define rvu_pf_pfaf_mbox0 (0xc00) +#define rvu_pf_pfaf_mbox1 (0xc08) +#define rvu_pf_pfaf_mboxx(a) (0xc00 | (a) << 3) +#define rvu_pf_int (0xc20) +#define rvu_pf_int_w1s (0xc28) +#define rvu_pf_int_ena_w1s (0xc30) +#define rvu_pf_int_ena_w1c (0xc38) +#define rvu_pf_msix_vecx_addr(a) (0x000 | (a) << 4) +#define rvu_pf_msix_vecx_ctl(a) (0x008 | (a) << 4) +#define rvu_pf_msix_pbax(a) (0xf0000 | (a) << 3) + +#define rvu_func_blkaddr_shift 20 +#define rvu_func_blkaddr_mask 0x1full + +#endif /* otx2_reg_h */
|
Networking
|
165475779ba1d4758429f48d65960473df9dc35a
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: mailbox communication with af
|
in the resource virtualization unit (rvu) each of the pf and af (admin function) share a 64kb of reserved memory region for communication. this patch initializes pf <=> af mailbox irqs, registers handlers for processing these communication messages. also adds support to process these messages in both directions ie responses to pf initiated down (pf => af) messages and af initiated up messages (af => pf).
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'makefile', 'h']
| 4
| 552
| 3
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/makefile b/drivers/net/ethernet/marvell/octeontx2/nic/makefile --- a/drivers/net/ethernet/marvell/octeontx2/nic/makefile +++ b/drivers/net/ethernet/marvell/octeontx2/nic/makefile -octeontx2_nicpf-y := otx2_pf.o +octeontx2_nicpf-y := otx2_pf.o otx2_common.o diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +// spdx-license-identifier: gpl-2.0 +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#include <linux/interrupt.h> +#include <linux/pci.h> + +#include "otx2_reg.h" +#include "otx2_common.h" + +#define m(_name, _id, _fn_name, _req_type, _rsp_type) \ +int __weak \ +otx2_mbox_up_handler_ ## _fn_name(struct otx2_nic *pfvf, \ + struct _req_type *req, \ + struct _rsp_type *rsp) \ +{ \ + /* nothing to do here */ \ + return 0; \ +} \ +export_symbol(otx2_mbox_up_handler_ ## _fn_name); +mbox_up_cgx_messages +#undef m diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +#include <mbox.h> +#define pci_mbox_bar_num 4 + +#define name_size 32 + +struct mbox { + struct otx2_mbox mbox; + struct work_struct mbox_wrk; + struct otx2_mbox mbox_up; + struct work_struct mbox_up_wrk; + struct otx2_nic *pfvf; + void *bbuf_base; /* bounce buffer for mbox memory */ + struct mutex lock; /* serialize mailbox access */ + int num_msgs; /* mbox number of messages */ + int up_num_msgs; /* mbox_up number of messages */ +}; + + /* msi-x */ + char *irq_name; + cpumask_var_t *affinity_mask; + + /* mbox */ + struct mbox mbox; + struct workqueue_struct *mbox_wq; + + u16 pcifunc; /* rvu pf_func */ +/* mbox bounce buffer apis */ +static inline int otx2_mbox_bbuf_init(struct mbox *mbox, struct pci_dev *pdev) +{ + struct otx2_mbox *otx2_mbox; + struct otx2_mbox_dev *mdev; + + mbox->bbuf_base = devm_kmalloc(&pdev->dev, mbox_size, gfp_kernel); + if (!mbox->bbuf_base) + return -enomem; + + /* overwrite mbox mbase to point to bounce buffer, so that pf/vf + * prepare all mbox messages in bounce buffer instead of directly + * in hw mbox memory. + */ + otx2_mbox = &mbox->mbox; + mdev = &otx2_mbox->dev[0]; + mdev->mbase = mbox->bbuf_base; + + otx2_mbox = &mbox->mbox_up; + mdev = &otx2_mbox->dev[0]; + mdev->mbase = mbox->bbuf_base; + return 0; +} + +static inline void otx2_sync_mbox_bbuf(struct otx2_mbox *mbox, int devid) +{ + u16 msgs_offset = align(sizeof(struct mbox_hdr), mbox_msg_align); + void *hw_mbase = mbox->hwbase + (devid * mbox_size); + struct otx2_mbox_dev *mdev = &mbox->dev[devid]; + struct mbox_hdr *hdr; + u64 msg_size; + + if (mdev->mbase == hw_mbase) + return; + + hdr = hw_mbase + mbox->rx_start; + msg_size = hdr->msg_size; + + if (msg_size > mbox->rx_size - msgs_offset) + msg_size = mbox->rx_size - msgs_offset; + + /* copy mbox messages from mbox memory to bounce buffer */ + memcpy(mdev->mbase + mbox->rx_start, + hw_mbase + mbox->rx_start, msg_size + msgs_offset); +} + +static inline void otx2_mbox_lock_init(struct mbox *mbox) +{ + mutex_init(&mbox->lock); +} + +static inline void otx2_mbox_lock(struct mbox *mbox) +{ + mutex_lock(&mbox->lock); +} + +static inline void otx2_mbox_unlock(struct mbox *mbox) +{ + mutex_unlock(&mbox->lock); +} + +/* mbox apis */ +static inline int otx2_sync_mbox_msg(struct mbox *mbox) +{ + int err; + + if (!otx2_mbox_nonempty(&mbox->mbox, 0)) + return 0; + otx2_mbox_msg_send(&mbox->mbox, 0); + err = otx2_mbox_wait_for_rsp(&mbox->mbox, 0); + if (err) + return err; + + return otx2_mbox_check_rsp_msgs(&mbox->mbox, 0); +} + +static inline int otx2_sync_mbox_up_msg(struct mbox *mbox, int devid) +{ + int err; + + if (!otx2_mbox_nonempty(&mbox->mbox_up, devid)) + return 0; + otx2_mbox_msg_send(&mbox->mbox_up, devid); + err = otx2_mbox_wait_for_rsp(&mbox->mbox_up, devid); + if (err) + return err; + + return otx2_mbox_check_rsp_msgs(&mbox->mbox_up, devid); +} + +/* use this api to send mbox msgs in atomic context + * where sleeping is not allowed + */ +static inline int otx2_sync_mbox_msg_busy_poll(struct mbox *mbox) +{ + int err; + + if (!otx2_mbox_nonempty(&mbox->mbox, 0)) + return 0; + otx2_mbox_msg_send(&mbox->mbox, 0); + err = otx2_mbox_busy_poll_for_rsp(&mbox->mbox, 0); + if (err) + return err; + + return otx2_mbox_check_rsp_msgs(&mbox->mbox, 0); +} + +#define m(_name, _id, _fn_name, _req_type, _rsp_type) \ +static struct _req_type __maybe_unused \ +*otx2_mbox_alloc_msg_ ## _fn_name(struct mbox *mbox) \ +{ \ + struct _req_type *req; \ + \ + req = (struct _req_type *)otx2_mbox_alloc_msg_rsp( \ + &mbox->mbox, 0, sizeof(struct _req_type), \ + sizeof(struct _rsp_type)); \ + if (!req) \ + return null; \ + req->hdr.sig = otx2_mbox_req_sig; \ + req->hdr.id = _id; \ + return req; \ +} + +mbox_messages +#undef m + +#define m(_name, _id, _fn_name, _req_type, _rsp_type) \ +int \ +otx2_mbox_up_handler_ ## _fn_name(struct otx2_nic *pfvf, \ + struct _req_type *req, \ + struct _rsp_type *rsp); \ + +mbox_up_cgx_messages +#undef m + +#define rvu_pfvf_pf_shift 10 +#define rvu_pfvf_pf_mask 0x3f +#define rvu_pfvf_func_shift 0 +#define rvu_pfvf_func_mask 0x3ff + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +enum { + type_pfaf, + type_pfvf, +}; + +static void otx2_queue_work(struct mbox *mw, struct workqueue_struct *mbox_wq, + int first, int mdevs, u64 intr, int type) +{ + struct otx2_mbox_dev *mdev; + struct otx2_mbox *mbox; + struct mbox_hdr *hdr; + int i; + + for (i = first; i < mdevs; i++) { + /* start from 0 */ + if (!(intr & bit_ull(i - first))) + continue; + + mbox = &mw->mbox; + mdev = &mbox->dev[i]; + if (type == type_pfaf) + otx2_sync_mbox_bbuf(mbox, i); + hdr = mdev->mbase + mbox->rx_start; + /* the hdr->num_msgs is set to zero immediately in the interrupt + * handler to ensure that it holds a correct value next time + * when the interrupt handler is called. + * pf->mbox.num_msgs holds the data for use in pfaf_mbox_handler + * pf>mbox.up_num_msgs holds the data for use in + * pfaf_mbox_up_handler. + */ + if (hdr->num_msgs) { + mw[i].num_msgs = hdr->num_msgs; + hdr->num_msgs = 0; + if (type == type_pfaf) + memset(mbox->hwbase + mbox->rx_start, 0, + align(sizeof(struct mbox_hdr), + sizeof(u64))); + + queue_work(mbox_wq, &mw[i].mbox_wrk); + } + + mbox = &mw->mbox_up; + mdev = &mbox->dev[i]; + if (type == type_pfaf) + otx2_sync_mbox_bbuf(mbox, i); + hdr = mdev->mbase + mbox->rx_start; + if (hdr->num_msgs) { + mw[i].up_num_msgs = hdr->num_msgs; + hdr->num_msgs = 0; + if (type == type_pfaf) + memset(mbox->hwbase + mbox->rx_start, 0, + align(sizeof(struct mbox_hdr), + sizeof(u64))); + + queue_work(mbox_wq, &mw[i].mbox_up_wrk); + } + } +} + +static void otx2_process_pfaf_mbox_msg(struct otx2_nic *pf, + struct mbox_msghdr *msg) +{ + if (msg->id >= mbox_msg_max) { + dev_err(pf->dev, + "mbox msg with unknown id 0x%x ", msg->id); + return; + } + + if (msg->sig != otx2_mbox_rsp_sig) { + dev_err(pf->dev, + "mbox msg with wrong signature %x, id 0x%x ", + msg->sig, msg->id); + return; + } + + switch (msg->id) { + case mbox_msg_ready: + pf->pcifunc = msg->pcifunc; + break; + default: + if (msg->rc) + dev_err(pf->dev, + "mbox msg response has err %d, id 0x%x ", + msg->rc, msg->id); + break; + } +} + +static void otx2_pfaf_mbox_handler(struct work_struct *work) +{ + struct otx2_mbox_dev *mdev; + struct mbox_hdr *rsp_hdr; + struct mbox_msghdr *msg; + struct otx2_mbox *mbox; + struct mbox *af_mbox; + struct otx2_nic *pf; + int offset, id; + + af_mbox = container_of(work, struct mbox, mbox_wrk); + mbox = &af_mbox->mbox; + mdev = &mbox->dev[0]; + rsp_hdr = (struct mbox_hdr *)(mdev->mbase + mbox->rx_start); + + offset = mbox->rx_start + align(sizeof(*rsp_hdr), mbox_msg_align); + pf = af_mbox->pfvf; + + for (id = 0; id < af_mbox->num_msgs; id++) { + msg = (struct mbox_msghdr *)(mdev->mbase + offset); + otx2_process_pfaf_mbox_msg(pf, msg); + offset = mbox->rx_start + msg->next_msgoff; + mdev->msgs_acked++; + } + + otx2_mbox_reset(mbox, 0); +} + +static int otx2_process_mbox_msg_up(struct otx2_nic *pf, + struct mbox_msghdr *req) +{ + /* check if valid, if not reply with a invalid msg */ + if (req->sig != otx2_mbox_req_sig) { + otx2_reply_invalid_msg(&pf->mbox.mbox_up, 0, 0, req->id); + return -enodev; + } + + switch (req->id) { +#define m(_name, _id, _fn_name, _req_type, _rsp_type) \ + case _id: { \ + struct _rsp_type *rsp; \ + int err; \ + \ + rsp = (struct _rsp_type *)otx2_mbox_alloc_msg( \ + &pf->mbox.mbox_up, 0, \ + sizeof(struct _rsp_type)); \ + if (!rsp) \ + return -enomem; \ + \ + rsp->hdr.id = _id; \ + rsp->hdr.sig = otx2_mbox_rsp_sig; \ + rsp->hdr.pcifunc = 0; \ + rsp->hdr.rc = 0; \ + \ + err = otx2_mbox_up_handler_ ## _fn_name( \ + pf, (struct _req_type *)req, rsp); \ + return err; \ + } +mbox_up_cgx_messages +#undef m + break; + default: + otx2_reply_invalid_msg(&pf->mbox.mbox_up, 0, 0, req->id); + return -enodev; + } + return 0; +} + +static void otx2_pfaf_mbox_up_handler(struct work_struct *work) +{ + struct mbox *af_mbox = container_of(work, struct mbox, mbox_up_wrk); + struct otx2_mbox *mbox = &af_mbox->mbox_up; + struct otx2_mbox_dev *mdev = &mbox->dev[0]; + struct otx2_nic *pf = af_mbox->pfvf; + int offset, id, devid = 0; + struct mbox_hdr *rsp_hdr; + struct mbox_msghdr *msg; + + rsp_hdr = (struct mbox_hdr *)(mdev->mbase + mbox->rx_start); + + offset = mbox->rx_start + align(sizeof(*rsp_hdr), mbox_msg_align); + + for (id = 0; id < af_mbox->up_num_msgs; id++) { + msg = (struct mbox_msghdr *)(mdev->mbase + offset); + + devid = msg->pcifunc & rvu_pfvf_func_mask; + /* skip processing vf's messages */ + if (!devid) + otx2_process_mbox_msg_up(pf, msg); + offset = mbox->rx_start + msg->next_msgoff; + } + + otx2_mbox_msg_send(mbox, 0); +} + +static irqreturn_t otx2_pfaf_mbox_intr_handler(int irq, void *pf_irq) +{ + struct otx2_nic *pf = (struct otx2_nic *)pf_irq; + struct mbox *mbox; + + /* clear the irq */ + otx2_write64(pf, rvu_pf_int, bit_ull(0)); + + mbox = &pf->mbox; + otx2_queue_work(mbox, pf->mbox_wq, 0, 1, 1, type_pfaf); + + return irq_handled; +} + +static void otx2_disable_mbox_intr(struct otx2_nic *pf) +{ + int vector = pci_irq_vector(pf->pdev, rvu_pf_int_vec_afpf_mbox); + + /* disable af => pf mailbox irq */ + otx2_write64(pf, rvu_pf_int_ena_w1c, bit_ull(0)); + free_irq(vector, pf); +} + +static int otx2_register_mbox_intr(struct otx2_nic *pf, bool probe_af) +{ + struct otx2_hw *hw = &pf->hw; + struct msg_req *req; + char *irq_name; + int err; + + /* register mailbox interrupt handler */ + irq_name = &hw->irq_name[rvu_pf_int_vec_afpf_mbox * name_size]; + snprintf(irq_name, name_size, "rvupfaf mbox"); + err = request_irq(pci_irq_vector(pf->pdev, rvu_pf_int_vec_afpf_mbox), + otx2_pfaf_mbox_intr_handler, 0, irq_name, pf); + if (err) { + dev_err(pf->dev, + "rvupf: irq registration failed for pfaf mbox irq "); + return err; + } + + /* enable mailbox interrupt for msgs coming from af. + * first clear to avoid spurious interrupts, if any. + */ + otx2_write64(pf, rvu_pf_int, bit_ull(0)); + otx2_write64(pf, rvu_pf_int_ena_w1s, bit_ull(0)); + + if (!probe_af) + return 0; + + /* check mailbox communication with af */ + req = otx2_mbox_alloc_msg_ready(&pf->mbox); + if (!req) { + otx2_disable_mbox_intr(pf); + return -enomem; + } + err = otx2_sync_mbox_msg(&pf->mbox); + if (err) { + dev_warn(pf->dev, + "af not responding to mailbox, deferring probe "); + otx2_disable_mbox_intr(pf); + return -eprobe_defer; + } + + return 0; +} + +static void otx2_pfaf_mbox_destroy(struct otx2_nic *pf) +{ + struct mbox *mbox = &pf->mbox; + + if (pf->mbox_wq) { + flush_workqueue(pf->mbox_wq); + destroy_workqueue(pf->mbox_wq); + pf->mbox_wq = null; + } + + if (mbox->mbox.hwbase) + iounmap((void __iomem *)mbox->mbox.hwbase); + + otx2_mbox_destroy(&mbox->mbox); + otx2_mbox_destroy(&mbox->mbox_up); +} + +static int otx2_pfaf_mbox_init(struct otx2_nic *pf) +{ + struct mbox *mbox = &pf->mbox; + void __iomem *hwbase; + int err; + + mbox->pfvf = pf; + pf->mbox_wq = alloc_workqueue("otx2_pfaf_mailbox", + wq_unbound | wq_highpri | + wq_mem_reclaim, 1); + if (!pf->mbox_wq) + return -enomem; + + /* mailbox is a reserved memory (in ram) region shared between + * admin function (i.e af) and this pf, shouldn't be mapped as + * device memory to allow unaligned accesses. + */ + hwbase = ioremap_wc(pci_resource_start(pf->pdev, pci_mbox_bar_num), + pci_resource_len(pf->pdev, pci_mbox_bar_num)); + if (!hwbase) { + dev_err(pf->dev, "unable to map pfaf mailbox region "); + err = -enomem; + goto exit; + } + + err = otx2_mbox_init(&mbox->mbox, hwbase, pf->pdev, pf->reg_base, + mbox_dir_pfaf, 1); + if (err) + goto exit; + + err = otx2_mbox_init(&mbox->mbox_up, hwbase, pf->pdev, pf->reg_base, + mbox_dir_pfaf_up, 1); + if (err) + goto exit; + + err = otx2_mbox_bbuf_init(mbox, pf->pdev); + if (err) + goto exit; + + init_work(&mbox->mbox_wrk, otx2_pfaf_mbox_handler); + init_work(&mbox->mbox_up_wrk, otx2_pfaf_mbox_up_handler); + otx2_mbox_lock_init(&pf->mbox); + + return 0; +exit: + otx2_pfaf_mbox_destroy(pf); + return err; +} + + int num_vec; + num_vec = pci_msix_vec_count(pdev); + hw->irq_name = devm_kmalloc_array(&hw->pdev->dev, num_vec, name_size, + gfp_kernel); + if (!hw->irq_name) + goto err_free_netdev; + + hw->affinity_mask = devm_kcalloc(&hw->pdev->dev, num_vec, + sizeof(cpumask_var_t), gfp_kernel); + if (!hw->affinity_mask) + goto err_free_netdev; + + err = pci_alloc_irq_vectors(hw->pdev, rvu_pf_int_vec_cnt, + rvu_pf_int_vec_cnt, pci_irq_msix); + if (err < 0) { + dev_err(dev, "%s: failed to alloc %d irq vectors ", + __func__, num_vec); + goto err_free_netdev; + } + + /* init pf <=> af mailbox stuff */ + err = otx2_pfaf_mbox_init(pf); + if (err) + goto err_free_irq_vectors; + + /* register mailbox interrupt */ + err = otx2_register_mbox_intr(pf, true); + if (err) + goto err_mbox_destroy; + - goto err_free_netdev; + goto err_disable_mbox_intr; - goto err_free_netdev; + goto err_disable_mbox_intr; +err_disable_mbox_intr: + otx2_disable_mbox_intr(pf); +err_mbox_destroy: + otx2_pfaf_mbox_destroy(pf); +err_free_irq_vectors: + pci_free_irq_vectors(hw->pdev); + otx2_disable_mbox_intr(pf); + otx2_pfaf_mbox_destroy(pf); +
|
Networking
|
5a6d7c9daef392370d873f8a626bb525629cdd6a
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: attach nix and npa block lfs
|
for a pf to function as a nic, npa (for rx buffers, tx descriptors etc) and nix (for rcv, send and completion queues) are the minimum resources needed. so request admin function (af) to attach one each of nix and npa block lfs (local functions).
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 4
| 286
| 4
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +#include "otx2_struct.h" + +int otx2_config_nix(struct otx2_nic *pfvf) +{ + struct nix_lf_alloc_req *nixlf; + struct nix_lf_alloc_rsp *rsp; + int err; + + pfvf->qset.xqe_size = nix_xqesz_w16 ? 128 : 512; + + /* get memory to put this msg */ + nixlf = otx2_mbox_alloc_msg_nix_lf_alloc(&pfvf->mbox); + if (!nixlf) + return -enomem; + + /* set rq/sq/cq counts */ + nixlf->rq_cnt = pfvf->hw.rx_queues; + nixlf->sq_cnt = pfvf->hw.tx_queues; + nixlf->cq_cnt = pfvf->qset.cq_cnt; + nixlf->xqe_sz = nix_xqesz_w16; + /* we don't know absolute npa lf idx attached. + * af will replace 'rvu_default_pf_func' with + * npa lf attached to this rvu pf/vf. + */ + nixlf->npa_func = rvu_default_pf_func; + /* disable alignment pad, enable l2 length check, + * enable l4 tcp/udp checksum verification. + */ + nixlf->rx_cfg = bit_ull(33) | bit_ull(35) | bit_ull(37); + + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) + return err; + + rsp = (struct nix_lf_alloc_rsp *)otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, + &nixlf->hdr); + if (is_err(rsp)) + return ptr_err(rsp); + + if (rsp->qints < 1) + return -enxio; + + return rsp->hdr.rc; +} + +int otx2_config_npa(struct otx2_nic *pfvf) +{ + struct otx2_qset *qset = &pfvf->qset; + struct npa_lf_alloc_req *npalf; + struct otx2_hw *hw = &pfvf->hw; + int aura_cnt; + + /* pool - stack of free buffer pointers + * aura - alloc/frees pointers from/to pool for nix dma. + */ + + if (!hw->pool_cnt) + return -einval; + + qset->pool = devm_kzalloc(pfvf->dev, sizeof(struct otx2_pool) * + hw->pool_cnt, gfp_kernel); + if (!qset->pool) + return -enomem; + + /* get memory to put this msg */ + npalf = otx2_mbox_alloc_msg_npa_lf_alloc(&pfvf->mbox); + if (!npalf) + return -enomem; + + /* set aura and pool counts */ + npalf->nr_pools = hw->pool_cnt; + aura_cnt = ilog2(roundup_pow_of_two(hw->pool_cnt)); + npalf->aura_sz = (aura_cnt >= ilog2(128)) ? (aura_cnt - 6) : 1; + + return otx2_sync_mbox_msg(&pfvf->mbox); +} + +int otx2_detach_resources(struct mbox *mbox) +{ + struct rsrc_detach *detach; + + otx2_mbox_lock(mbox); + detach = otx2_mbox_alloc_msg_detach_resources(mbox); + if (!detach) { + otx2_mbox_unlock(mbox); + return -enomem; + } + + /* detach all */ + detach->partial = false; + + /* send detach request to af */ + otx2_mbox_msg_send(&mbox->mbox, 0); + otx2_mbox_unlock(mbox); + return 0; +} + +int otx2_attach_npa_nix(struct otx2_nic *pfvf) +{ + struct rsrc_attach *attach; + struct msg_req *msix; + int err; + + otx2_mbox_lock(&pfvf->mbox); + /* get memory to put this msg */ + attach = otx2_mbox_alloc_msg_attach_resources(&pfvf->mbox); + if (!attach) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + attach->npalf = true; + attach->nixlf = true; + + /* send attach request to af */ + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) { + otx2_mbox_unlock(&pfvf->mbox); + return err; + } + + /* get npa and nix msix vector offsets */ + msix = otx2_mbox_alloc_msg_msix_offset(&pfvf->mbox); + if (!msix) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) { + otx2_mbox_unlock(&pfvf->mbox); + return err; + } + otx2_mbox_unlock(&pfvf->mbox); + + if (pfvf->hw.npa_msixoff == msix_vector_invalid || + pfvf->hw.nix_msixoff == msix_vector_invalid) { + dev_err(pfvf->dev, + "rvupf: invalid msix vector offset for npa/nix "); + return -einval; + } + + return 0; +} + +/* mbox message handlers */ +void mbox_handler_npa_lf_alloc(struct otx2_nic *pfvf, + struct npa_lf_alloc_rsp *rsp) +{ + pfvf->hw.stack_pg_ptrs = rsp->stack_pg_ptrs; + pfvf->hw.stack_pg_bytes = rsp->stack_pg_bytes; +} + +void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf, + struct nix_lf_alloc_rsp *rsp) +{ + pfvf->hw.sqb_size = rsp->sqb_size; + pfvf->hw.rx_chan_base = rsp->rx_chan_base; + pfvf->hw.tx_chan_base = rsp->tx_chan_base; +} + +void mbox_handler_msix_offset(struct otx2_nic *pfvf, + struct msix_offset_rsp *rsp) +{ + pfvf->hw.npa_msixoff = rsp->npa_msixoff; + pfvf->hw.nix_msixoff = rsp->nix_msixoff; +} diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +struct otx2_pool { + struct qmem *stack; +}; + +struct otx2_qset { +#define otx2_max_cq_cnt 64 + u16 cq_cnt; + u16 xqe_size; /* size of cqe i.e 128 or 512 bytes */ + struct otx2_pool *pool; +}; + + u16 pool_cnt; + + /* npa */ + u32 stack_pg_ptrs; /* no of ptrs per stack page */ + u32 stack_pg_bytes; /* size of stack page */ + u16 sqb_size; + + u16 rx_chan_base; + u16 tx_chan_base; + u16 npa_msixoff; /* offset of npa vectors */ + u16 nix_msixoff; /* offset of nix vectors */ + struct otx2_qset qset; +/* rvu block related apis */ +int otx2_attach_npa_nix(struct otx2_nic *pfvf); +int otx2_detach_resources(struct mbox *mbox); +int otx2_config_npa(struct otx2_nic *pfvf); +int otx2_config_nix(struct otx2_nic *pfvf); + +/* mbox handlers */ +void mbox_handler_msix_offset(struct otx2_nic *pfvf, + struct msix_offset_rsp *rsp); +void mbox_handler_npa_lf_alloc(struct otx2_nic *pfvf, + struct npa_lf_alloc_rsp *rsp); +void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf, + struct nix_lf_alloc_rsp *rsp); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + case mbox_msg_msix_offset: + mbox_handler_msix_offset(pf, (struct msix_offset_rsp *)msg); + break; + case mbox_msg_npa_lf_alloc: + mbox_handler_npa_lf_alloc(pf, (struct npa_lf_alloc_rsp *)msg); + break; + case mbox_msg_nix_lf_alloc: + mbox_handler_nix_lf_alloc(pf, (struct nix_lf_alloc_rsp *)msg); + break; + struct otx2_nic *pf = netdev_priv(netdev); + int err = 0; + - return 0; + pf->qset.cq_cnt = pf->hw.rx_queues + pf->hw.tx_queues; + + /* npa init */ + err = otx2_config_npa(pf); + if (err) + return err; + + /* nix init */ + return otx2_config_nix(pf); +static int otx2_realloc_msix_vectors(struct otx2_nic *pf) +{ + struct otx2_hw *hw = &pf->hw; + int num_vec, err; + + /* npa interrupts are inot registered, so alloc only + * upto nix vector offset. + */ + num_vec = hw->nix_msixoff; +#define nix_lf_cint_vec_start 0x40 + num_vec += nix_lf_cint_vec_start + hw->max_queues; + + otx2_disable_mbox_intr(pf); + pci_free_irq_vectors(hw->pdev); + pci_free_irq_vectors(hw->pdev); + err = pci_alloc_irq_vectors(hw->pdev, num_vec, num_vec, pci_irq_msix); + if (err < 0) { + dev_err(pf->dev, "%s: failed to realloc %d irq vectors ", + __func__, num_vec); + return err; + } + + return otx2_register_mbox_intr(pf, false); +} + - qcount = min_t(int, num_online_cpus(), num_online_cpus()); + qcount = min_t(int, num_online_cpus(), otx2_max_cq_cnt); - err = otx2_set_real_num_queues(netdev, hw->tx_queues, hw->rx_queues); + /* request af to attach npa and nix lfs to this pf. + * nix and npa lfs are needed for this pf to function as a nic. + */ + err = otx2_attach_npa_nix(pf); + err = otx2_realloc_msix_vectors(pf); + if (err) + goto err_detach_rsrc; + + err = otx2_set_real_num_queues(netdev, hw->tx_queues, hw->rx_queues); + if (err) + goto err_detach_rsrc; + - goto err_disable_mbox_intr; + goto err_detach_rsrc; +err_detach_rsrc: + otx2_detach_resources(&pf->mbox); + otx2_detach_resources(&pf->mbox); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +/* spdx-license-identifier: gpl-2.0 */ +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#ifndef otx2_struct_h +#define otx2_struct_h + +/* nix wqe/cqe size 128 byte or 512 byte */ +enum nix_cqesz_e { + nix_xqesz_w64 = 0x0, + nix_xqesz_w16 = 0x1, +}; + +#endif /* otx2_struct_h */
|
Networking
|
05fcc9e08955b7c04afb7f53402902f4a86e553c
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: initialize and config queues
|
this patch does the initialization of all queues ie the receive buffer pools, receive and transmit queues, completion or notification queues etc. allocates all required resources (eg transmit schedulers, receive buffers etc) and configures them for proper functioning of queues. also sets up receive queue's red dropping levels.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['h', 'c']
| 7
| 1,290
| 17
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h b/drivers/net/ethernet/marvell/octeontx2/af/common.h --- a/drivers/net/ethernet/marvell/octeontx2/af/common.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h -#define txsch_tl1_dflt_rr_qtm ((1 << 24) - 1) -#define txsch_tl1_dflt_rr_prio (0x1ull) +#define txsch_rr_qtm_max ((1 << 24) - 1) +#define txsch_tl1_dflt_rr_qtm txsch_rr_qtm_max +#define txsch_tl1_dflt_rr_prio (0x1ull) +#define max_sched_weight 0xff +#define dflt_rr_weight 71 +#define dflt_rr_qtm ((dflt_rr_weight * txsch_rr_qtm_max) \ + / max_sched_weight) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +dma_addr_t otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool, + gfp_t gfp) +{ + dma_addr_t iova; + + /* check if request can be accommodated in previous allocated page */ + if (pool->page && ((pool->page_offset + pool->rbsize) <= + (page_size << pool->rbpage_order))) { + pool->pageref++; + goto ret; + } + + otx2_get_page(pool); + + /* allocate a new page */ + pool->page = alloc_pages(gfp | __gfp_comp | __gfp_nowarn, + pool->rbpage_order); + if (unlikely(!pool->page)) + return -enomem; + + pool->page_offset = 0; +ret: + iova = (u64)otx2_dma_map_page(pfvf, pool->page, pool->page_offset, + pool->rbsize, dma_from_device); + if (!iova) { + if (!pool->page_offset) + __free_pages(pool->page, pool->rbpage_order); + pool->page = null; + return -enomem; + } + pool->page_offset += pool->rbsize; + return iova; +} + +static int otx2_get_link(struct otx2_nic *pfvf) +{ + int link = 0; + u16 map; + + /* cgx lmac link */ + if (pfvf->hw.tx_chan_base >= cgx_chan_base) { + map = pfvf->hw.tx_chan_base & 0x7ff; + link = 4 * ((map >> 8) & 0xf) + ((map >> 4) & 0xf); + } + /* lbk channel */ + if (pfvf->hw.tx_chan_base < sdp_chan_base) + link = 12; + + return link; +} + +int otx2_txschq_config(struct otx2_nic *pfvf, int lvl) +{ + struct otx2_hw *hw = &pfvf->hw; + struct nix_txschq_config *req; + u64 schq, parent; + + req = otx2_mbox_alloc_msg_nix_txschq_cfg(&pfvf->mbox); + if (!req) + return -enomem; + + req->lvl = lvl; + req->num_regs = 1; + + schq = hw->txschq_list[lvl][0]; + /* set topology e.t.c configuration */ + if (lvl == nix_txsch_lvl_smq) { + req->reg[0] = nix_af_smqx_cfg(schq); + req->regval[0] |= (0x20ull << 51) | (0x80ull << 39) | + (0x2ull << 36); + req->num_regs++; + /* mdq config */ + parent = hw->txschq_list[nix_txsch_lvl_tl4][0]; + req->reg[1] = nix_af_mdqx_parent(schq); + req->regval[1] = parent << 16; + req->num_regs++; + /* set dwrr quantum */ + req->reg[2] = nix_af_mdqx_schedule(schq); + req->regval[2] = dflt_rr_qtm; + } else if (lvl == nix_txsch_lvl_tl4) { + parent = hw->txschq_list[nix_txsch_lvl_tl3][0]; + req->reg[0] = nix_af_tl4x_parent(schq); + req->regval[0] = parent << 16; + req->num_regs++; + req->reg[1] = nix_af_tl4x_schedule(schq); + req->regval[1] = dflt_rr_qtm; + } else if (lvl == nix_txsch_lvl_tl3) { + parent = hw->txschq_list[nix_txsch_lvl_tl2][0]; + req->reg[0] = nix_af_tl3x_parent(schq); + req->regval[0] = parent << 16; + req->num_regs++; + req->reg[1] = nix_af_tl3x_schedule(schq); + req->regval[1] = dflt_rr_qtm; + } else if (lvl == nix_txsch_lvl_tl2) { + parent = hw->txschq_list[nix_txsch_lvl_tl1][0]; + req->reg[0] = nix_af_tl2x_parent(schq); + req->regval[0] = parent << 16; + + req->num_regs++; + req->reg[1] = nix_af_tl2x_schedule(schq); + req->regval[1] = txsch_tl1_dflt_rr_prio << 24 | dflt_rr_qtm; + + req->num_regs++; + req->reg[2] = nix_af_tl3_tl2x_linkx_cfg(schq, + otx2_get_link(pfvf)); + /* enable this queue and backpressure */ + req->regval[2] = bit_ull(13) | bit_ull(12); + + } else if (lvl == nix_txsch_lvl_tl1) { + /* default config for tl1. + * for vf this is always ignored. + */ + + /* set dwrr quantum */ + req->reg[0] = nix_af_tl1x_schedule(schq); + req->regval[0] = txsch_tl1_dflt_rr_qtm; + + req->num_regs++; + req->reg[1] = nix_af_tl1x_topology(schq); + req->regval[1] = (txsch_tl1_dflt_rr_prio << 1); + + req->num_regs++; + req->reg[2] = nix_af_tl1x_cir(schq); + req->regval[2] = 0; + } + + return otx2_sync_mbox_msg(&pfvf->mbox); +} + +int otx2_txsch_alloc(struct otx2_nic *pfvf) +{ + struct nix_txsch_alloc_req *req; + int lvl; + + /* get memory to put this msg */ + req = otx2_mbox_alloc_msg_nix_txsch_alloc(&pfvf->mbox); + if (!req) + return -enomem; + + /* request one schq per level */ + for (lvl = 0; lvl < nix_txsch_lvl_cnt; lvl++) + req->schq[lvl] = 1; + + return otx2_sync_mbox_msg(&pfvf->mbox); +} + +int otx2_txschq_stop(struct otx2_nic *pfvf) +{ + struct nix_txsch_free_req *free_req; + int lvl, schq, err; + + otx2_mbox_lock(&pfvf->mbox); + /* free the transmit schedulers */ + free_req = otx2_mbox_alloc_msg_nix_txsch_free(&pfvf->mbox); + if (!free_req) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + free_req->flags = txschq_free_all; + err = otx2_sync_mbox_msg(&pfvf->mbox); + otx2_mbox_unlock(&pfvf->mbox); + + /* clear the txschq list */ + for (lvl = 0; lvl < nix_txsch_lvl_cnt; lvl++) { + for (schq = 0; schq < max_txschq_per_func; schq++) + pfvf->hw.txschq_list[lvl][schq] = 0; + } + return err; +} + +void otx2_sqb_flush(struct otx2_nic *pfvf) +{ + int qidx, sqe_tail, sqe_head; + u64 incr, *ptr, val; + + ptr = (u64 *)otx2_get_regaddr(pfvf, nix_lf_sq_op_status); + for (qidx = 0; qidx < pfvf->hw.tx_queues; qidx++) { + incr = (u64)qidx << 32; + while (1) { + val = otx2_atomic64_add(incr, ptr); + sqe_head = (val >> 20) & 0x3f; + sqe_tail = (val >> 28) & 0x3f; + if (sqe_head == sqe_tail) + break; + usleep_range(1, 3); + } + } +} + +/* red and drop levels of cq on packet reception. + * for cq level is measure of emptiness ( 0x0 = full, 255 = empty). + */ +#define rq_pass_lvl_cq(skid, qsize) ((((skid) + 16) * 256) / (qsize)) +#define rq_drop_lvl_cq(skid, qsize) (((skid) * 256) / (qsize)) + +/* red and drop levels of aura for packet reception. + * for aura level is measure of fullness (0x0 = empty, 255 = full). + * eg: for rq length 1k, for pass/drop level 204/230. + * red accepts pkts if free pointers > 102 & <= 205. + * drops pkts if free pointers < 102. + */ +#define rq_pass_lvl_aura (255 - ((95 * 256) / 100)) /* red when 95% is full */ +#define rq_drop_lvl_aura (255 - ((99 * 256) / 100)) /* drop when 99% is full */ + +/* send skid of 2000 packets required for cq size of 4k cqes. */ +#define send_cq_skid 2000 + +static int otx2_rq_init(struct otx2_nic *pfvf, u16 qidx, u16 lpb_aura) +{ + struct otx2_qset *qset = &pfvf->qset; + struct nix_aq_enq_req *aq; + + /* get memory to put this msg */ + aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox); + if (!aq) + return -enomem; + + aq->rq.cq = qidx; + aq->rq.ena = 1; + aq->rq.pb_caching = 1; + aq->rq.lpb_aura = lpb_aura; /* use large packet buffer aura */ + aq->rq.lpb_sizem1 = (dma_buffer_len(pfvf->rbsize) / 8) - 1; + aq->rq.xqe_imm_size = 0; /* copying of packet to cqe not needed */ + aq->rq.flow_tagw = 32; /* copy full 32bit flow_tag to cqe header */ + aq->rq.lpb_drop_ena = 1; /* enable red dropping for aura */ + aq->rq.xqe_drop_ena = 1; /* enable red dropping for cq/sso */ + aq->rq.xqe_pass = rq_pass_lvl_cq(pfvf->hw.rq_skid, qset->rqe_cnt); + aq->rq.xqe_drop = rq_drop_lvl_cq(pfvf->hw.rq_skid, qset->rqe_cnt); + aq->rq.lpb_aura_pass = rq_pass_lvl_aura; + aq->rq.lpb_aura_drop = rq_drop_lvl_aura; + + /* fill aq info */ + aq->qidx = qidx; + aq->ctype = nix_aq_ctype_rq; + aq->op = nix_aq_instop_init; + + return otx2_sync_mbox_msg(&pfvf->mbox); +} + +static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura) +{ + struct otx2_qset *qset = &pfvf->qset; + struct otx2_snd_queue *sq; + struct nix_aq_enq_req *aq; + struct otx2_pool *pool; + int err; + + pool = &pfvf->qset.pool[sqb_aura]; + sq = &qset->sq[qidx]; + sq->sqe_size = nix_sqesz_w16 ? 64 : 128; + sq->sqe_cnt = qset->sqe_cnt; + + err = qmem_alloc(pfvf->dev, &sq->sqe, 1, sq->sqe_size); + if (err) + return err; + + sq->sqe_base = sq->sqe->base; + + sq->sqe_per_sqb = (pfvf->hw.sqb_size / sq->sqe_size) - 1; + sq->num_sqbs = (qset->sqe_cnt + sq->sqe_per_sqb) / sq->sqe_per_sqb; + sq->aura_id = sqb_aura; + sq->aura_fc_addr = pool->fc_addr->base; + sq->lmt_addr = (__force u64 *)(pfvf->reg_base + lmt_lf_lmtlinex(qidx)); + sq->io_addr = (__force u64)otx2_get_regaddr(pfvf, nix_lf_op_sendx(0)); + + /* get memory to put this msg */ + aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox); + if (!aq) + return -enomem; + + aq->sq.cq = pfvf->hw.rx_queues + qidx; + aq->sq.max_sqe_size = nix_maxsqesz_w16; /* 128 byte */ + aq->sq.cq_ena = 1; + aq->sq.ena = 1; + /* only one smq is allocated, map all sq's to that smq */ + aq->sq.smq = pfvf->hw.txschq_list[nix_txsch_lvl_smq][0]; + aq->sq.smq_rr_quantum = dflt_rr_qtm; + aq->sq.default_chan = pfvf->hw.tx_chan_base; + aq->sq.sqe_stype = nix_stype_stf; /* cache sqb */ + aq->sq.sqb_aura = sqb_aura; + /* due pipelining impact minimum 2000 unused sq cqe's + * need to maintain to avoid cq overflow. + */ + aq->sq.cq_limit = ((send_cq_skid * 256) / (sq->sqe_cnt)); + + /* fill aq info */ + aq->qidx = qidx; + aq->ctype = nix_aq_ctype_sq; + aq->op = nix_aq_instop_init; + + return otx2_sync_mbox_msg(&pfvf->mbox); +} + +static int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) +{ + struct otx2_qset *qset = &pfvf->qset; + struct nix_aq_enq_req *aq; + struct otx2_cq_queue *cq; + int err, pool_id; + + cq = &qset->cq[qidx]; + cq->cq_idx = qidx; + if (qidx < pfvf->hw.rx_queues) { + cq->cq_type = cq_rx; + cq->cqe_cnt = qset->rqe_cnt; + } else { + cq->cq_type = cq_tx; + cq->cqe_cnt = qset->sqe_cnt; + } + cq->cqe_size = pfvf->qset.xqe_size; + + /* allocate memory for cqes */ + err = qmem_alloc(pfvf->dev, &cq->cqe, cq->cqe_cnt, cq->cqe_size); + if (err) + return err; + + /* save cqe cpu base for faster reference */ + cq->cqe_base = cq->cqe->base; + /* in case where all rqs auras point to single pool, + * all cqs receive buffer pool also point to same pool. + */ + pool_id = ((cq->cq_type == cq_rx) && + (pfvf->hw.rqpool_cnt != pfvf->hw.rx_queues)) ? 0 : qidx; + cq->rbpool = &qset->pool[pool_id]; + + /* get memory to put this msg */ + aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox); + if (!aq) + return -enomem; + + aq->cq.ena = 1; + aq->cq.qsize = q_size(cq->cqe_cnt, 4); + aq->cq.caching = 1; + aq->cq.base = cq->cqe->iova; + aq->cq.avg_level = 255; + + if (qidx < pfvf->hw.rx_queues) { + aq->cq.drop = rq_drop_lvl_cq(pfvf->hw.rq_skid, cq->cqe_cnt); + aq->cq.drop_ena = 1; + } + + /* fill aq info */ + aq->qidx = qidx; + aq->ctype = nix_aq_ctype_cq; + aq->op = nix_aq_instop_init; + + return otx2_sync_mbox_msg(&pfvf->mbox); +} + +int otx2_config_nix_queues(struct otx2_nic *pfvf) +{ + int qidx, err; + + /* initialize rx queues */ + for (qidx = 0; qidx < pfvf->hw.rx_queues; qidx++) { + u16 lpb_aura = otx2_get_pool_idx(pfvf, aura_nix_rq, qidx); + + err = otx2_rq_init(pfvf, qidx, lpb_aura); + if (err) + return err; + } + + /* initialize tx queues */ + for (qidx = 0; qidx < pfvf->hw.tx_queues; qidx++) { + u16 sqb_aura = otx2_get_pool_idx(pfvf, aura_nix_sq, qidx); + + err = otx2_sq_init(pfvf, qidx, sqb_aura); + if (err) + return err; + } + + /* initialize completion queues */ + for (qidx = 0; qidx < pfvf->qset.cq_cnt; qidx++) { + err = otx2_cq_init(pfvf, qidx); + if (err) + return err; + } + + return 0; +} + +void otx2_sq_free_sqbs(struct otx2_nic *pfvf) +{ + struct otx2_qset *qset = &pfvf->qset; + struct otx2_hw *hw = &pfvf->hw; + struct otx2_snd_queue *sq; + int sqb, qidx; + u64 iova, pa; + + for (qidx = 0; qidx < hw->tx_queues; qidx++) { + sq = &qset->sq[qidx]; + if (!sq->sqb_ptrs) + continue; + for (sqb = 0; sqb < sq->sqb_count; sqb++) { + if (!sq->sqb_ptrs[sqb]) + continue; + iova = sq->sqb_ptrs[sqb]; + pa = otx2_iova_to_phys(pfvf->iommu_domain, iova); + dma_unmap_page_attrs(pfvf->dev, iova, hw->sqb_size, + dma_from_device, + dma_attr_skip_cpu_sync); + put_page(virt_to_page(phys_to_virt(pa))); + } + sq->sqb_count = 0; + } +} + +void otx2_free_aura_ptr(struct otx2_nic *pfvf, int type) +{ + int pool_id, pool_start = 0, pool_end = 0, size = 0; + u64 iova, pa; + + if (type == aura_nix_sq) { + pool_start = otx2_get_pool_idx(pfvf, type, 0); + pool_end = pool_start + pfvf->hw.sqpool_cnt; + size = pfvf->hw.sqb_size; + } + if (type == aura_nix_rq) { + pool_start = otx2_get_pool_idx(pfvf, type, 0); + pool_end = pfvf->hw.rqpool_cnt; + size = pfvf->rbsize; + } + + /* free sqb and rqb pointers from the aura pool */ + for (pool_id = pool_start; pool_id < pool_end; pool_id++) { + iova = otx2_aura_allocptr(pfvf, pool_id); + while (iova) { + if (type == aura_nix_rq) + iova -= otx2_head_room; + + pa = otx2_iova_to_phys(pfvf->iommu_domain, iova); + dma_unmap_page_attrs(pfvf->dev, iova, size, + dma_from_device, + dma_attr_skip_cpu_sync); + put_page(virt_to_page(phys_to_virt(pa))); + iova = otx2_aura_allocptr(pfvf, pool_id); + } + } +} + +void otx2_aura_pool_free(struct otx2_nic *pfvf) +{ + struct otx2_pool *pool; + int pool_id; + + if (!pfvf->qset.pool) + return; + + for (pool_id = 0; pool_id < pfvf->hw.pool_cnt; pool_id++) { + pool = &pfvf->qset.pool[pool_id]; + qmem_free(pfvf->dev, pool->stack); + qmem_free(pfvf->dev, pool->fc_addr); + } + devm_kfree(pfvf->dev, pfvf->qset.pool); +} + +static int otx2_aura_init(struct otx2_nic *pfvf, int aura_id, + int pool_id, int numptrs) +{ + struct npa_aq_enq_req *aq; + struct otx2_pool *pool; + int err; + + pool = &pfvf->qset.pool[pool_id]; + + /* allocate memory for hw to update aura count. + * alloc one cache line, so that it fits all fc_stype modes. + */ + if (!pool->fc_addr) { + err = qmem_alloc(pfvf->dev, &pool->fc_addr, 1, otx2_align); + if (err) + return err; + } + + /* initialize this aura's context via af */ + aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox); + if (!aq) { + /* shared mbox memory buffer is full, flush it and retry */ + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) + return err; + aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox); + if (!aq) + return -enomem; + } + + aq->aura_id = aura_id; + /* will be filled by af with correct pool context address */ + aq->aura.pool_addr = pool_id; + aq->aura.pool_caching = 1; + aq->aura.shift = ilog2(numptrs) - 8; + aq->aura.count = numptrs; + aq->aura.limit = numptrs; + aq->aura.avg_level = 255; + aq->aura.ena = 1; + aq->aura.fc_ena = 1; + aq->aura.fc_addr = pool->fc_addr->iova; + aq->aura.fc_hyst_bits = 0; /* store count on all updates */ + + /* fill aq info */ + aq->ctype = npa_aq_ctype_aura; + aq->op = npa_aq_instop_init; + + return 0; +} + +static int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id, + int stack_pages, int numptrs, int buf_size) +{ + struct npa_aq_enq_req *aq; + struct otx2_pool *pool; + int err; + + pool = &pfvf->qset.pool[pool_id]; + /* alloc memory for stack which is used to store buffer pointers */ + err = qmem_alloc(pfvf->dev, &pool->stack, + stack_pages, pfvf->hw.stack_pg_bytes); + if (err) + return err; + + pool->rbsize = buf_size; + pool->rbpage_order = get_order(buf_size); + + /* initialize this pool's context via af */ + aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox); + if (!aq) { + /* shared mbox memory buffer is full, flush it and retry */ + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) { + qmem_free(pfvf->dev, pool->stack); + return err; + } + aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox); + if (!aq) { + qmem_free(pfvf->dev, pool->stack); + return -enomem; + } + } + + aq->aura_id = pool_id; + aq->pool.stack_base = pool->stack->iova; + aq->pool.stack_caching = 1; + aq->pool.ena = 1; + aq->pool.buf_size = buf_size / 128; + aq->pool.stack_max_pages = stack_pages; + aq->pool.shift = ilog2(numptrs) - 8; + aq->pool.ptr_start = 0; + aq->pool.ptr_end = ~0ull; + + /* fill aq info */ + aq->ctype = npa_aq_ctype_pool; + aq->op = npa_aq_instop_init; + + return 0; +} + +int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) +{ + int qidx, pool_id, stack_pages, num_sqbs; + struct otx2_qset *qset = &pfvf->qset; + struct otx2_hw *hw = &pfvf->hw; + struct otx2_snd_queue *sq; + struct otx2_pool *pool; + int err, ptr; + s64 bufptr; + + /* calculate number of sqbs needed. + * + * for a 128byte sqe, and 4k size sqb, 31 sqes will fit in one sqb. + * last sqe is used for pointing to next sqb. + */ + num_sqbs = (hw->sqb_size / 128) - 1; + num_sqbs = (qset->sqe_cnt + num_sqbs) / num_sqbs; + + /* get no of stack pages needed */ + stack_pages = + (num_sqbs + hw->stack_pg_ptrs - 1) / hw->stack_pg_ptrs; + + for (qidx = 0; qidx < hw->tx_queues; qidx++) { + pool_id = otx2_get_pool_idx(pfvf, aura_nix_sq, qidx); + /* initialize aura context */ + err = otx2_aura_init(pfvf, pool_id, pool_id, num_sqbs); + if (err) + goto fail; + + /* initialize pool context */ + err = otx2_pool_init(pfvf, pool_id, stack_pages, + num_sqbs, hw->sqb_size); + if (err) + goto fail; + } + + /* flush accumulated messages */ + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) + goto fail; + + /* allocate pointers and free them to aura/pool */ + for (qidx = 0; qidx < hw->tx_queues; qidx++) { + pool_id = otx2_get_pool_idx(pfvf, aura_nix_sq, qidx); + pool = &pfvf->qset.pool[pool_id]; + + sq = &qset->sq[qidx]; + sq->sqb_count = 0; + sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(u64 *), gfp_kernel); + if (!sq->sqb_ptrs) + return -enomem; + + for (ptr = 0; ptr < num_sqbs; ptr++) { + bufptr = otx2_alloc_rbuf(pfvf, pool, gfp_kernel); + if (bufptr <= 0) + return bufptr; + otx2_aura_freeptr(pfvf, pool_id, bufptr); + sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr; + } + otx2_get_page(pool); + } + + return 0; +fail: + otx2_mbox_reset(&pfvf->mbox.mbox, 0); + otx2_aura_pool_free(pfvf); + return err; +} + +int otx2_rq_aura_pool_init(struct otx2_nic *pfvf) +{ + struct otx2_hw *hw = &pfvf->hw; + int stack_pages, pool_id, rq; + struct otx2_pool *pool; + int err, ptr, num_ptrs; + s64 bufptr; + + num_ptrs = pfvf->qset.rqe_cnt; + + stack_pages = + (num_ptrs + hw->stack_pg_ptrs - 1) / hw->stack_pg_ptrs; + + for (rq = 0; rq < hw->rx_queues; rq++) { + pool_id = otx2_get_pool_idx(pfvf, aura_nix_rq, rq); + /* initialize aura context */ + err = otx2_aura_init(pfvf, pool_id, pool_id, num_ptrs); + if (err) + goto fail; + } + for (pool_id = 0; pool_id < hw->rqpool_cnt; pool_id++) { + err = otx2_pool_init(pfvf, pool_id, stack_pages, + num_ptrs, pfvf->rbsize); + if (err) + goto fail; + } + + /* flush accumulated messages */ + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) + goto fail; + + /* allocate pointers and free them to aura/pool */ + for (pool_id = 0; pool_id < hw->rqpool_cnt; pool_id++) { + pool = &pfvf->qset.pool[pool_id]; + for (ptr = 0; ptr < num_ptrs; ptr++) { + bufptr = otx2_alloc_rbuf(pfvf, pool, gfp_kernel); + if (bufptr <= 0) + return bufptr; + otx2_aura_freeptr(pfvf, pool_id, + bufptr + otx2_head_room); + } + otx2_get_page(pool); + } + + return 0; +fail: + otx2_mbox_reset(&pfvf->mbox.mbox, 0); + otx2_aura_pool_free(pfvf); + return err; +} + + pfvf->nix_blkaddr = blkaddr_nix0; + + /* if the platform has two nix blocks then lf may be + * allocated from nix1. + */ + if (otx2_read64(pfvf, rvu_pf_block_addrx_disc(blkaddr_nix1)) & 0x1ffull) + pfvf->nix_blkaddr = blkaddr_nix1; + +void otx2_ctx_disable(struct mbox *mbox, int type, bool npa) +{ + struct hwctx_disable_req *req; + + otx2_mbox_lock(mbox); + /* request aq to disable this context */ + if (npa) + req = otx2_mbox_alloc_msg_npa_hwctx_disable(mbox); + else + req = otx2_mbox_alloc_msg_nix_hwctx_disable(mbox); + + if (!req) { + otx2_mbox_unlock(mbox); + return; + } + + req->ctype = type; + + if (otx2_sync_mbox_msg(mbox)) + dev_err(mbox->pfvf->dev, "%s failed to disable context ", + __func__); + + otx2_mbox_unlock(mbox); +} + +void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf, + struct nix_txsch_alloc_rsp *rsp) +{ + int lvl, schq; + + /* setup transmit scheduler list */ + for (lvl = 0; lvl < nix_txsch_lvl_cnt; lvl++) + for (schq = 0; schq < rsp->schq[lvl]; schq++) + pf->hw.txschq_list[lvl][schq] = + rsp->schq_list[lvl][schq]; +} + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +#include <linux/iommu.h> +#include "otx2_txrx.h" -struct otx2_pool { - struct qmem *stack; -}; - -struct otx2_qset { -#define otx2_max_cq_cnt 64 - u16 cq_cnt; - u16 xqe_size; /* size of cqe i.e 128 or 512 bytes */ - struct otx2_pool *pool; +enum arua_mapped_qtypes { + aura_nix_rq, + aura_nix_sq, + u16 rqpool_cnt; + u16 sqpool_cnt; + /* nix */ + u16 txschq_list[nix_txsch_lvl_cnt][max_txschq_per_func]; + + /* hw settings, coalescing etc */ + u16 rq_skid; + void *iommu_domain; + u16 rbsize; /* receive buffer size */ + + /* block address of nix either blkaddr_nix0 or blkaddr_nix1 */ + int nix_blkaddr; - blkaddr = blkaddr_nix0; + blkaddr = nic->nix_blkaddr; +/* with the absence of api for 128-bit io memory access for arm64, + * implement required operations at place. + */ +#if defined(config_arm64) +static inline void otx2_write128(u64 lo, u64 hi, void __iomem *addr) +{ + __asm__ volatile("stp %x[x0], %x[x1], [%x[p1],#0]!" + ::[x0]"r"(lo), [x1]"r"(hi), [p1]"r"(addr)); +} + +static inline u64 otx2_atomic64_add(u64 incr, u64 *ptr) +{ + u64 result; + + __asm__ volatile(".cpu generic+lse " + "ldadd %x[i], %x[r], [%[b]]" + : [r]"=r"(result), "+m"(*ptr) + : [i]"r"(incr), [b]"r"(ptr) + : "memory"); + return result; +} + +#else +#define otx2_write128(lo, hi, addr) +#define otx2_atomic64_add(incr, ptr) ({ *ptr += incr; }) +#endif + +/* alloc pointer from pool/aura */ +static inline u64 otx2_aura_allocptr(struct otx2_nic *pfvf, int aura) +{ + u64 *ptr = (u64 *)otx2_get_regaddr(pfvf, + npa_lf_aura_op_allocx(0)); + u64 incr = (u64)aura | bit_ull(63); + + return otx2_atomic64_add(incr, ptr); +} + +/* free pointer to a pool/aura */ +static inline void otx2_aura_freeptr(struct otx2_nic *pfvf, + int aura, s64 buf) +{ + otx2_write128((u64)buf, (u64)aura | bit_ull(63), + otx2_get_regaddr(pfvf, npa_lf_aura_op_free0)); +} + +/* update page ref count */ +static inline void otx2_get_page(struct otx2_pool *pool) +{ + if (!pool->page) + return; + + if (pool->pageref) + page_ref_add(pool->page, pool->pageref); + pool->pageref = 0; + pool->page = null; +} + +static inline int otx2_get_pool_idx(struct otx2_nic *pfvf, int type, int idx) +{ + if (type == aura_nix_sq) + return pfvf->hw.rqpool_cnt + idx; + + /* aura_nix_rq */ + return idx; +} + +static inline dma_addr_t otx2_dma_map_page(struct otx2_nic *pfvf, + struct page *page, + size_t offset, size_t size, + enum dma_data_direction dir) +{ + dma_addr_t iova; + + iova = dma_map_page_attrs(pfvf->dev, page, + offset, size, dir, dma_attr_skip_cpu_sync); + if (unlikely(dma_mapping_error(pfvf->dev, iova))) + return (dma_addr_t)null; + return iova; +} + +static inline void otx2_dma_unmap_page(struct otx2_nic *pfvf, + dma_addr_t addr, size_t size, + enum dma_data_direction dir) +{ + dma_unmap_page_attrs(pfvf->dev, addr, size, + dir, dma_attr_skip_cpu_sync); +} + +int otx2_sq_aura_pool_init(struct otx2_nic *pfvf); +int otx2_rq_aura_pool_init(struct otx2_nic *pfvf); +void otx2_aura_pool_free(struct otx2_nic *pfvf); +void otx2_free_aura_ptr(struct otx2_nic *pfvf, int type); +void otx2_sq_free_sqbs(struct otx2_nic *pfvf); +int otx2_config_nix_queues(struct otx2_nic *pfvf); +int otx2_txschq_config(struct otx2_nic *pfvf, int lvl); +int otx2_txsch_alloc(struct otx2_nic *pfvf); +int otx2_txschq_stop(struct otx2_nic *pfvf); +void otx2_sqb_flush(struct otx2_nic *pfvf); +dma_addr_t otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool, + gfp_t gfp); +void otx2_ctx_disable(struct mbox *mbox, int type, bool npa); +void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf, + struct nix_txsch_alloc_rsp *rsp); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +#include "otx2_reg.h" +#include "otx2_txrx.h" +#include "otx2_struct.h" + case mbox_msg_nix_txsch_alloc: + mbox_handler_nix_txsch_alloc(pf, + (struct nix_txsch_alloc_rsp *)msg); + break; +static void otx2_free_cq_res(struct otx2_nic *pf) +{ + struct otx2_qset *qset = &pf->qset; + struct otx2_cq_queue *cq; + int qidx; + + /* disable cqs */ + otx2_ctx_disable(&pf->mbox, nix_aq_ctype_cq, false); + for (qidx = 0; qidx < qset->cq_cnt; qidx++) { + cq = &qset->cq[qidx]; + qmem_free(pf->dev, cq->cqe); + } +} + +static void otx2_free_sq_res(struct otx2_nic *pf) +{ + struct otx2_qset *qset = &pf->qset; + struct otx2_snd_queue *sq; + int qidx; + + /* disable sqs */ + otx2_ctx_disable(&pf->mbox, nix_aq_ctype_sq, false); + /* free sqb pointers */ + otx2_sq_free_sqbs(pf); + for (qidx = 0; qidx < pf->hw.tx_queues; qidx++) { + sq = &qset->sq[qidx]; + qmem_free(pf->dev, sq->sqe); + kfree(sq->sqb_ptrs); + } +} + +static int otx2_init_hw_resources(struct otx2_nic *pf) +{ + struct mbox *mbox = &pf->mbox; + struct otx2_hw *hw = &pf->hw; + struct msg_req *req; + int err = 0, lvl; + + /* set required npa lf's pool counts + * auras and pools are used in a 1:1 mapping, + * so, aura count = pool count. + */ + hw->rqpool_cnt = hw->rx_queues; + hw->sqpool_cnt = hw->tx_queues; + hw->pool_cnt = hw->rqpool_cnt + hw->sqpool_cnt; + + /* get the size of receive buffers to allocate */ + pf->rbsize = rcv_frag_len(pf->netdev->mtu); + + otx2_mbox_lock(mbox); + /* npa init */ + err = otx2_config_npa(pf); + if (err) + goto exit; + + /* nix init */ + err = otx2_config_nix(pf); + if (err) + goto err_free_npa_lf; + + /* init auras and pools used by nix rq, for free buffer ptrs */ + err = otx2_rq_aura_pool_init(pf); + if (err) { + otx2_mbox_unlock(mbox); + goto err_free_nix_lf; + } + /* init auras and pools used by nix sq, for queueing sqes */ + err = otx2_sq_aura_pool_init(pf); + if (err) { + otx2_mbox_unlock(mbox); + goto err_free_rq_ptrs; + } + + err = otx2_txsch_alloc(pf); + if (err) { + otx2_mbox_unlock(mbox); + goto err_free_sq_ptrs; + } + + err = otx2_config_nix_queues(pf); + if (err) { + otx2_mbox_unlock(mbox); + goto err_free_txsch; + } + for (lvl = 0; lvl < nix_txsch_lvl_cnt; lvl++) { + err = otx2_txschq_config(pf, lvl); + if (err) { + otx2_mbox_unlock(mbox); + goto err_free_nix_queues; + } + } + otx2_mbox_unlock(mbox); + return err; + +err_free_nix_queues: + otx2_free_sq_res(pf); + otx2_free_cq_res(pf); + otx2_ctx_disable(mbox, nix_aq_ctype_rq, false); +err_free_txsch: + if (otx2_txschq_stop(pf)) + dev_err(pf->dev, "%s failed to stop tx schedulers ", __func__); +err_free_sq_ptrs: + otx2_sq_free_sqbs(pf); +err_free_rq_ptrs: + otx2_free_aura_ptr(pf, aura_nix_rq); + otx2_ctx_disable(mbox, npa_aq_ctype_pool, true); + otx2_ctx_disable(mbox, npa_aq_ctype_aura, true); + otx2_aura_pool_free(pf); +err_free_nix_lf: + otx2_mbox_lock(mbox); + req = otx2_mbox_alloc_msg_nix_lf_free(mbox); + if (req) { + if (otx2_sync_mbox_msg(mbox)) + dev_err(pf->dev, "%s failed to free nixlf ", __func__); + } +err_free_npa_lf: + /* reset npa lf */ + req = otx2_mbox_alloc_msg_npa_lf_free(mbox); + if (req) { + if (otx2_sync_mbox_msg(mbox)) + dev_err(pf->dev, "%s failed to free npalf ", __func__); + } +exit: + otx2_mbox_unlock(mbox); + return err; +} + +static void otx2_free_hw_resources(struct otx2_nic *pf) +{ + struct mbox *mbox = &pf->mbox; + struct msg_req *req; + int err; + + /* ensure all sqe are processed */ + otx2_sqb_flush(pf); + + /* stop transmission */ + err = otx2_txschq_stop(pf); + if (err) + dev_err(pf->dev, "rvupf: failed to stop/free tx schedulers "); + + /* disable rqs */ + otx2_ctx_disable(mbox, nix_aq_ctype_rq, false); + + otx2_free_sq_res(pf); + + /* free rq buffer pointers*/ + otx2_free_aura_ptr(pf, aura_nix_rq); + + otx2_free_cq_res(pf); + + otx2_mbox_lock(mbox); + /* reset nix lf */ + req = otx2_mbox_alloc_msg_nix_lf_free(mbox); + if (req) { + if (otx2_sync_mbox_msg(mbox)) + dev_err(pf->dev, "%s failed to free nixlf ", __func__); + } + otx2_mbox_unlock(mbox); + + /* disable npa pool and aura hw context */ + otx2_ctx_disable(mbox, npa_aq_ctype_pool, true); + otx2_ctx_disable(mbox, npa_aq_ctype_aura, true); + otx2_aura_pool_free(pf); + + otx2_mbox_lock(mbox); + /* reset npa lf */ + req = otx2_mbox_alloc_msg_npa_lf_free(mbox); + if (req) { + if (otx2_sync_mbox_msg(mbox)) + dev_err(pf->dev, "%s failed to free npalf ", __func__); + } + otx2_mbox_unlock(mbox); +} + + struct otx2_qset *qset = &pf->qset; - /* npa init */ - err = otx2_config_npa(pf); + /* cq size of rq */ + qset->rqe_cnt = qset->rqe_cnt ? qset->rqe_cnt : q_count(q_size_256); + /* cq size of sq */ + qset->sqe_cnt = qset->sqe_cnt ? qset->sqe_cnt : q_count(q_size_4k); + + err = -enomem; + qset->cq = kcalloc(pf->qset.cq_cnt, + sizeof(struct otx2_cq_queue), gfp_kernel); + if (!qset->cq) + goto err_free_mem; + + qset->sq = kcalloc(pf->hw.tx_queues, + sizeof(struct otx2_snd_queue), gfp_kernel); + if (!qset->sq) + goto err_free_mem; + + err = otx2_init_hw_resources(pf); - return err; + goto err_free_mem; - /* nix init */ - return otx2_config_nix(pf); + return 0; +err_free_mem: + kfree(qset->sq); + kfree(qset->cq); + return err; + struct otx2_nic *pf = netdev_priv(netdev); + struct otx2_qset *qset = &pf->qset; + + otx2_free_hw_resources(pf); + + kfree(qset->sq); + kfree(qset->cq); + + /* do not clear rq/sq ringsize settings */ + memset((void *)qset + offsetof(struct otx2_qset, sqe_cnt), 0, + sizeof(*qset) - offsetof(struct otx2_qset, sqe_cnt)); + /* npa's pool is a stack to which sw frees buffer pointers via aura. + * hw allocates buffer pointer from stack and uses it for dma'ing + * ingress packet. in some scenarios hw can free back allocated buffer + * pointers to pool. this makes it impossible for sw to maintain a + * parallel list where physical addresses of buffer pointers (iovas) + * given to hw can be saved for later reference. + * + * so the only way to convert rx packet's buffer address is to use + * iommu's iova_to_phys() handler which translates the address by + * walking through the translation tables. + */ + pf->iommu_domain = iommu_get_domain_for_dev(dev); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_reg.h +/* npa lf registers */ +#define npa_lfbase (blktype_npa << rvu_func_blkaddr_shift) +#define npa_lf_aura_op_allocx(a) (npa_lfbase | 0x10 | (a) << 3) +#define npa_lf_aura_op_free0 (npa_lfbase | 0x20) +#define npa_lf_aura_op_free1 (npa_lfbase | 0x28) +#define npa_lf_aura_op_cnt (npa_lfbase | 0x30) +#define npa_lf_aura_op_limit (npa_lfbase | 0x50) +#define npa_lf_aura_op_int (npa_lfbase | 0x60) +#define npa_lf_aura_op_thresh (npa_lfbase | 0x70) +#define npa_lf_pool_op_pc (npa_lfbase | 0x100) +#define npa_lf_pool_op_available (npa_lfbase | 0x110) +#define npa_lf_pool_op_ptr_start0 (npa_lfbase | 0x120) +#define npa_lf_pool_op_ptr_start1 (npa_lfbase | 0x128) +#define npa_lf_pool_op_ptr_end0 (npa_lfbase | 0x130) +#define npa_lf_pool_op_ptr_end1 (npa_lfbase | 0x138) +#define npa_lf_pool_op_int (npa_lfbase | 0x160) +#define npa_lf_pool_op_thresh (npa_lfbase | 0x170) +#define npa_lf_err_int (npa_lfbase | 0x200) +#define npa_lf_err_int_w1s (npa_lfbase | 0x208) +#define npa_lf_err_int_ena_w1c (npa_lfbase | 0x210) +#define npa_lf_err_int_ena_w1s (npa_lfbase | 0x218) +#define npa_lf_ras (npa_lfbase | 0x220) +#define npa_lf_ras_w1s (npa_lfbase | 0x228) +#define npa_lf_ras_ena_w1c (npa_lfbase | 0x230) +#define npa_lf_ras_ena_w1s (npa_lfbase | 0x238) +#define npa_lf_qintx_cnt(a) (npa_lfbase | 0x300 | (a) << 12) +#define npa_lf_qintx_int(a) (npa_lfbase | 0x310 | (a) << 12) +#define npa_lf_qintx_int_w1s(a) (npa_lfbase | 0x318 | (a) << 12) +#define npa_lf_qintx_ena_w1s(a) (npa_lfbase | 0x320 | (a) << 12) +#define npa_lf_qintx_ena_w1c(a) (npa_lfbase | 0x330 | (a) << 12) + +/* nix lf registers */ +#define nix_lfbase (blktype_nix << rvu_func_blkaddr_shift) +#define nix_lf_rx_secretx(a) (nix_lfbase | 0x0 | (a) << 3) +#define nix_lf_cfg (nix_lfbase | 0x100) +#define nix_lf_gint (nix_lfbase | 0x200) +#define nix_lf_gint_w1s (nix_lfbase | 0x208) +#define nix_lf_gint_ena_w1c (nix_lfbase | 0x210) +#define nix_lf_gint_ena_w1s (nix_lfbase | 0x218) +#define nix_lf_err_int (nix_lfbase | 0x220) +#define nix_lf_err_int_w1s (nix_lfbase | 0x228) +#define nix_lf_err_int_ena_w1c (nix_lfbase | 0x230) +#define nix_lf_err_int_ena_w1s (nix_lfbase | 0x238) +#define nix_lf_ras (nix_lfbase | 0x240) +#define nix_lf_ras_w1s (nix_lfbase | 0x248) +#define nix_lf_ras_ena_w1c (nix_lfbase | 0x250) +#define nix_lf_ras_ena_w1s (nix_lfbase | 0x258) +#define nix_lf_sq_op_err_dbg (nix_lfbase | 0x260) +#define nix_lf_mnq_err_dbg (nix_lfbase | 0x270) +#define nix_lf_send_err_dbg (nix_lfbase | 0x280) +#define nix_lf_tx_statx(a) (nix_lfbase | 0x300 | (a) << 3) +#define nix_lf_rx_statx(a) (nix_lfbase | 0x400 | (a) << 3) +#define nix_lf_op_sendx(a) (nix_lfbase | 0x800 | (a) << 3) +#define nix_lf_rq_op_int (nix_lfbase | 0x900) +#define nix_lf_rq_op_octs (nix_lfbase | 0x910) +#define nix_lf_rq_op_pkts (nix_lfbase | 0x920) +#define nix_lf_op_ipsec_dyno_cn (nix_lfbase | 0x980) +#define nix_lf_sq_op_int (nix_lfbase | 0xa00) +#define nix_lf_sq_op_octs (nix_lfbase | 0xa10) +#define nix_lf_sq_op_pkts (nix_lfbase | 0xa20) +#define nix_lf_sq_op_status (nix_lfbase | 0xa30) +#define nix_lf_cq_op_int (nix_lfbase | 0xb00) +#define nix_lf_cq_op_door (nix_lfbase | 0xb30) +#define nix_lf_cq_op_status (nix_lfbase | 0xb40) +#define nix_lf_qintx_cnt(a) (nix_lfbase | 0xc00 | (a) << 12) +#define nix_lf_qintx_int(a) (nix_lfbase | 0xc10 | (a) << 12) +#define nix_lf_qintx_int_w1s(a) (nix_lfbase | 0xc18 | (a) << 12) +#define nix_lf_qintx_ena_w1s(a) (nix_lfbase | 0xc20 | (a) << 12) +#define nix_lf_qintx_ena_w1c(a) (nix_lfbase | 0xc30 | (a) << 12) +#define nix_lf_cintx_cnt(a) (nix_lfbase | 0xd00 | (a) << 12) +#define nix_lf_cintx_wait(a) (nix_lfbase | 0xd10 | (a) << 12) +#define nix_lf_cintx_int(a) (nix_lfbase | 0xd20 | (a) << 12) +#define nix_lf_cintx_int_w1s(a) (nix_lfbase | 0xd30 | (a) << 12) +#define nix_lf_cintx_ena_w1s(a) (nix_lfbase | 0xd40 | (a) << 12) +#define nix_lf_cintx_ena_w1c(a) (nix_lfbase | 0xd50 | (a) << 12) + +/* nix af transmit scheduler registers */ +#define nix_af_smqx_cfg(a) (0x700 | (a) << 16) +#define nix_af_tl1x_schedule(a) (0xc00 | (a) << 16) +#define nix_af_tl1x_cir(a) (0xc20 | (a) << 16) +#define nix_af_tl1x_topology(a) (0xc80 | (a) << 16) +#define nix_af_tl2x_parent(a) (0xe88 | (a) << 16) +#define nix_af_tl2x_schedule(a) (0xe00 | (a) << 16) +#define nix_af_tl3x_parent(a) (0x1088 | (a) << 16) +#define nix_af_tl3x_schedule(a) (0x1000 | (a) << 16) +#define nix_af_tl4x_parent(a) (0x1288 | (a) << 16) +#define nix_af_tl4x_schedule(a) (0x1200 | (a) << 16) +#define nix_af_mdqx_schedule(a) (0x1400 | (a) << 16) +#define nix_af_mdqx_parent(a) (0x1480 | (a) << 16) +#define nix_af_tl3_tl2x_linkx_cfg(a, b) (0x1700 | (a) << 16 | (b) << 3) + +/* lmt lf registers */ +#define lmt_lfbase bit_ull(rvu_func_blkaddr_shift) +#define lmt_lf_lmtlinex(a) (lmt_lfbase | 0x000 | (a) << 12) +#define lmt_lf_lmtcancel (lmt_lfbase | 0x400) + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +enum nix_sqes_e { + nix_sqesz_w16 = 0x0, + nix_sqesz_w8 = 0x1, +}; + +enum nix_send_ldtype { + nix_send_ldtype_ldd = 0x0, + nix_send_ldtype_ldt = 0x1, + nix_send_ldtype_ldwb = 0x2, +}; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +/* spdx-license-identifier: gpl-2.0 */ +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#ifndef otx2_txrx_h +#define otx2_txrx_h + +#include <linux/etherdevice.h> +#include <linux/iommu.h> +#include <linux/if_vlan.h> + +#define lbk_chan_base 0x000 +#define sdp_chan_base 0x700 +#define cgx_chan_base 0x800 + +#define otx2_data_align(x) align(x, otx2_align) +#define otx2_head_room otx2_align + +/* rx buffer size should be in multiples of 128bytes */ +#define rcv_frag_len1(x) \ + ((otx2_head_room + otx2_data_align(x)) + \ + otx2_data_align(sizeof(struct skb_shared_info))) + +/* prefer 2048 byte buffers for better last level cache + * utilization or data distribution across regions. + */ +#define rcv_frag_len(x) \ + ((rcv_frag_len1(x) < 2048) ? 2048 : rcv_frag_len1(x)) + +#define dma_buffer_len(x) \ + ((x) - otx2_head_room - \ + otx2_data_align(sizeof(struct skb_shared_info))) + +struct otx2_snd_queue { + u8 aura_id; + u16 sqe_size; + u32 sqe_cnt; + u16 num_sqbs; + u8 sqe_per_sqb; + u64 io_addr; + u64 *aura_fc_addr; + u64 *lmt_addr; + void *sqe_base; + struct qmem *sqe; + u16 sqb_count; + u64 *sqb_ptrs; +} ____cacheline_aligned_in_smp; + +struct otx2_pool { + struct qmem *stack; + struct qmem *fc_addr; + u8 rbpage_order; + u16 rbsize; + u32 page_offset; + u16 pageref; + struct page *page; +}; + +enum cq_type { + cq_rx, + cq_tx, + cqs_per_cint = 2, /* rq + sq */ +}; + +struct otx2_cq_queue { + u8 cq_idx; + u8 cq_type; + u16 cqe_size; + u16 pool_ptrs; + u32 cqe_cnt; + void *cqe_base; + struct qmem *cqe; + struct otx2_pool *rbpool; +} ____cacheline_aligned_in_smp; + +struct otx2_qset { + u32 rqe_cnt; + u32 sqe_cnt; /* keep these two at top */ +#define otx2_max_cq_cnt 64 + u16 cq_cnt; + u16 xqe_size; + struct otx2_pool *pool; + struct otx2_cq_queue *cq; + struct otx2_snd_queue *sq; +}; + +/* translate iova to physical address */ +static inline u64 otx2_iova_to_phys(void *iommu_domain, dma_addr_t dma_addr) +{ + /* translation is installed only when iommu is present */ + if (likely(iommu_domain)) + return iommu_iova_to_phys(iommu_domain, dma_addr); + return dma_addr; +} + +#endif /* otx2_txrx_h */
|
Networking
|
caa2da34fd25a37e9fd43343b6966fb9d730a6d5
|
sunil goutham
|
drivers
|
net
|
af, ethernet, marvell, nic, octeontx2
|
octeontx2-pf: setup interrupts and napi handler
|
completion queue (cq) is the one with which hw notifies sw on a packet reception or transmission. each of the rq and sq are mapped to a unique cq and again both cqs are mapped to same interrupt ie the cint. so that each core has one interrupt source in whose handler both rx and tx notifications are processed.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'makefile', 'h']
| 6
| 332
| 10
|
- registered a napi handler for the cint. - setup coalescing parameters. - irq affinity hints etc --- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/makefile b/drivers/net/ethernet/marvell/octeontx2/nic/makefile --- a/drivers/net/ethernet/marvell/octeontx2/nic/makefile +++ b/drivers/net/ethernet/marvell/octeontx2/nic/makefile -octeontx2_nicpf-y := otx2_pf.o otx2_common.o +octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +void otx2_config_irq_coalescing(struct otx2_nic *pfvf, int qidx) +{ + /* configure cqe interrupt coalescing parameters + * + * hw triggers an irq when ecount > cq_ecount_wait, hence + * set 1 less than cq_ecount_wait. and cq_time_wait is in + * usecs, convert that to 100ns count. + */ + otx2_write64(pfvf, nix_lf_cintx_wait(qidx), + ((u64)(pfvf->hw.cq_time_wait * 10) << 48) | + ((u64)pfvf->hw.cq_qcount_wait << 32) | + (pfvf->hw.cq_ecount_wait - 1)); +} + +void otx2_free_cints(struct otx2_nic *pfvf, int n) +{ + struct otx2_qset *qset = &pfvf->qset; + struct otx2_hw *hw = &pfvf->hw; + int irq, qidx; + + for (qidx = 0, irq = hw->nix_msixoff + nix_lf_cint_vec_start; + qidx < n; + qidx++, irq++) { + int vector = pci_irq_vector(pfvf->pdev, irq); + + irq_set_affinity_hint(vector, null); + free_cpumask_var(hw->affinity_mask[irq]); + free_irq(vector, &qset->napi[qidx]); + } +} + +void otx2_set_cints_affinity(struct otx2_nic *pfvf) +{ + struct otx2_hw *hw = &pfvf->hw; + int vec, cpu, irq, cint; + + vec = hw->nix_msixoff + nix_lf_cint_vec_start; + cpu = cpumask_first(cpu_online_mask); + + /* cq interrupts */ + for (cint = 0; cint < pfvf->hw.cint_cnt; cint++, vec++) { + if (!alloc_cpumask_var(&hw->affinity_mask[vec], gfp_kernel)) + return; + + cpumask_set_cpu(cpu, hw->affinity_mask[vec]); + + irq = pci_irq_vector(pfvf->pdev, vec); + irq_set_affinity_hint(irq, hw->affinity_mask[vec]); + + cpu = cpumask_next(cpu, cpu_online_mask); + if (unlikely(cpu >= nr_cpu_ids)) + cpu = 0; + } +} + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +#define pci_subsys_devid_96xx_rvu_pfvf 0xb200 + +/* nix lf interrupts range*/ +#define nix_lf_qint_vec_start 0x00 +#define nix_lf_cint_vec_start 0x40 +#define nix_lf_gint_vec 0x80 +#define nix_lf_err_vec 0x81 +#define nix_lf_poison_vec 0x82 + + u16 cq_qcount_wait; + u16 cq_ecount_wait; + u8 cq_time_wait; + u8 cint_cnt; /* cq interrupt count */ +static inline bool is_96xx_a0(struct pci_dev *pdev) +{ + return (pdev->revision == 0x00) && + (pdev->subsystem_device == pci_subsys_devid_96xx_rvu_pfvf); +} + +static inline bool is_96xx_b0(struct pci_dev *pdev) +{ + return (pdev->revision == 0x01) && + (pdev->subsystem_device == pci_subsys_devid_96xx_rvu_pfvf); +} + +static inline void otx2_setup_dev_hw_settings(struct otx2_nic *pfvf) +{ + pfvf->hw.cq_time_wait = cq_timer_thresh_default; + pfvf->hw.cq_ecount_wait = cq_cqe_thresh_default; + pfvf->hw.cq_qcount_wait = cq_qcount_default; + + if (is_96xx_a0(pfvf->pdev)) { + /* time based irq coalescing is not supported */ + pfvf->hw.cq_qcount_wait = 0x0; + + /* due to hw issue previous silicons required minimum + * 600 unused cqe to avoid cq overflow. + */ + pfvf->hw.rq_skid = 600; + pfvf->qset.rqe_cnt = q_count(q_size_1k); + } +} + +static inline int rvu_get_pf(u16 pcifunc) +{ + return (pcifunc >> rvu_pfvf_pf_shift) & rvu_pfvf_pf_mask; +} + +/* msi-x apis */ +void otx2_free_cints(struct otx2_nic *pfvf, int n); +void otx2_set_cints_affinity(struct otx2_nic *pfvf); + +void otx2_config_irq_coalescing(struct otx2_nic *pfvf, int qidx); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +static irqreturn_t otx2_cq_intr_handler(int irq, void *cq_irq) +{ + struct otx2_cq_poll *cq_poll = (struct otx2_cq_poll *)cq_irq; + struct otx2_nic *pf = (struct otx2_nic *)cq_poll->dev; + int qidx = cq_poll->cint_idx; + + /* disable interrupts. + * + * completion interrupts behave in a level-triggered interrupt + * fashion, and hence have to be cleared only after it is serviced. + */ + otx2_write64(pf, nix_lf_cintx_ena_w1c(qidx), bit_ull(0)); + + /* schedule napi */ + napi_schedule_irqoff(&cq_poll->napi); + + return irq_handled; +} + +static void otx2_disable_napi(struct otx2_nic *pf) +{ + struct otx2_qset *qset = &pf->qset; + struct otx2_cq_poll *cq_poll; + int qidx; + + for (qidx = 0; qidx < pf->hw.cint_cnt; qidx++) { + cq_poll = &qset->napi[qidx]; + napi_disable(&cq_poll->napi); + netif_napi_del(&cq_poll->napi); + } +} + + struct otx2_cq_poll *cq_poll = null; - int err = 0; + int err = 0, qidx, vec; + char *irq_name; + /* rq and sqs are mapped to different cqs, + * so find out max cq irqs (i.e cints) needed. + */ + pf->hw.cint_cnt = max(pf->hw.rx_queues, pf->hw.tx_queues); + qset->napi = kcalloc(pf->hw.cint_cnt, sizeof(*cq_poll), gfp_kernel); + if (!qset->napi) + return -enomem; + /* register napi handler */ + for (qidx = 0; qidx < pf->hw.cint_cnt; qidx++) { + cq_poll = &qset->napi[qidx]; + cq_poll->cint_idx = qidx; + /* rq0 & sq0 are mapped to cint0 and so on.. + * 'cq_ids[0]' points to rq's cq and + * 'cq_ids[1]' points to sq's cq and + */ + cq_poll->cq_ids[cq_rx] = + (qidx < pf->hw.rx_queues) ? qidx : cint_invalid_cq; + cq_poll->cq_ids[cq_tx] = (qidx < pf->hw.tx_queues) ? + qidx + pf->hw.rx_queues : cint_invalid_cq; + cq_poll->dev = (void *)pf; + netif_napi_add(netdev, &cq_poll->napi, + otx2_napi_handler, napi_poll_weight); + napi_enable(&cq_poll->napi); + } + + /* register cq irq handlers */ + vec = pf->hw.nix_msixoff + nix_lf_cint_vec_start; + for (qidx = 0; qidx < pf->hw.cint_cnt; qidx++) { + irq_name = &pf->hw.irq_name[vec * name_size]; + + snprintf(irq_name, name_size, "%s-rxtx-%d", pf->netdev->name, + qidx); + + err = request_irq(pci_irq_vector(pf->pdev, vec), + otx2_cq_intr_handler, 0, irq_name, + &qset->napi[qidx]); + if (err) { + dev_err(pf->dev, + "rvupf%d: irq registration failed for cq%d ", + rvu_get_pf(pf->pcifunc), qidx); + goto err_free_cints; + } + vec++; + + otx2_config_irq_coalescing(pf, qidx); + + /* enable cq irq */ + otx2_write64(pf, nix_lf_cintx_int(qidx), bit_ull(0)); + otx2_write64(pf, nix_lf_cintx_ena_w1s(qidx), bit_ull(0)); + } + + otx2_set_cints_affinity(pf); + + +err_free_cints: + otx2_free_cints(pf, qidx); + otx2_disable_napi(pf); + otx2_free_hw_resources(pf); + kfree(qset->napi); + struct otx2_cq_poll *cq_poll = null; + int qidx, vec; + + netif_carrier_off(netdev); + netif_tx_stop_all_queues(netdev); + + /* cleanup cq napi and irq */ + vec = pf->hw.nix_msixoff + nix_lf_cint_vec_start; + for (qidx = 0; qidx < pf->hw.cint_cnt; qidx++) { + /* disable interrupt */ + otx2_write64(pf, nix_lf_cintx_ena_w1c(qidx), bit_ull(0)); + + synchronize_irq(pci_irq_vector(pf->pdev, vec)); + + cq_poll = &qset->napi[qidx]; + napi_synchronize(&cq_poll->napi); + vec++; + } + + netif_tx_disable(netdev); + otx2_free_cints(pf, pf->hw.cint_cnt); + otx2_disable_napi(pf); + + for (qidx = 0; qidx < netdev->num_tx_queues; qidx++) + netdev_tx_reset_queue(netdev_get_tx_queue(netdev, qidx)); - + kfree(qset->napi); -#define nix_lf_cint_vec_start 0x40 + otx2_setup_dev_hw_settings(pf); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +// spdx-license-identifier: gpl-2.0 +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#include <linux/etherdevice.h> +#include <net/ip.h> + +#include "otx2_reg.h" +#include "otx2_common.h" +#include "otx2_struct.h" +#include "otx2_txrx.h" + +static int otx2_rx_napi_handler(struct otx2_nic *pfvf, + struct napi_struct *napi, + struct otx2_cq_queue *cq, int budget) +{ + /* nothing to do, for now */ + return 0; +} + +static int otx2_tx_napi_handler(struct otx2_nic *pfvf, + struct otx2_cq_queue *cq, int budget) +{ + /* nothing to do, for now */ + return 0; +} + +int otx2_napi_handler(struct napi_struct *napi, int budget) +{ + struct otx2_cq_poll *cq_poll; + int workdone = 0, cq_idx, i; + struct otx2_cq_queue *cq; + struct otx2_qset *qset; + struct otx2_nic *pfvf; + + cq_poll = container_of(napi, struct otx2_cq_poll, napi); + pfvf = (struct otx2_nic *)cq_poll->dev; + qset = &pfvf->qset; + + for (i = cqs_per_cint - 1; i >= 0; i--) { + cq_idx = cq_poll->cq_ids[i]; + if (unlikely(cq_idx == cint_invalid_cq)) + continue; + cq = &qset->cq[cq_idx]; + if (cq->cq_type == cq_rx) { + workdone += otx2_rx_napi_handler(pfvf, napi, + cq, budget); + } else { + workdone += otx2_tx_napi_handler(pfvf, cq, budget); + } + } + + /* clear the irq */ + otx2_write64(pfvf, nix_lf_cintx_int(cq_poll->cint_idx), bit_ull(0)); + + if (workdone < budget && napi_complete_done(napi, workdone)) { + /* re-enable interrupts */ + otx2_write64(pfvf, nix_lf_cintx_ena_w1s(cq_poll->cint_idx), + bit_ull(0)); + } + return workdone; +} diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +/* irq triggered when nix_lf_cintx_cnt[ecount] + * is equal to this value. + */ +#define cq_cqe_thresh_default 10 + +/* irq triggered when nix_lf_cintx_cnt[ecount] + * is nonzero and this much time elapses after that. + */ +#define cq_timer_thresh_default 1 /* 1 usec */ +#define cq_timer_thresh_max 25 /* 25 usec */ + +/* min number of cqs (of the ones mapped to this cint) + * with valid cqes. + */ +#define cq_qcount_default 1 + +enum cq_type { + cq_rx, + cq_tx, + cqs_per_cint = 2, /* rq + sq */ +}; + +struct otx2_cq_poll { + void *dev; +#define cint_invalid_cq 255 + u8 cint_idx; + u8 cq_ids[cqs_per_cint]; + struct napi_struct napi; +}; + -enum cq_type { - cq_rx, - cq_tx, - cqs_per_cint = 2, /* rq + sq */ -}; - + struct otx2_cq_poll *napi; +int otx2_napi_handler(struct napi_struct *napi, int budget);
|
Networking
|
04a21ef303df74737259190d7d7cf77a129bb56a
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: receive packet handling support
|
added receive packet handling (napi) support, error stats, rx_all capability config option to passon error pkts to stack upon user request.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 6
| 349
| 3
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c + cq->cint_idx = qidx; + aq->cq.cint_idx = cq->cint_idx; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +/* nix (or npc) rx errors */ +enum otx2_errlvl { + npc_errlvl_re, + npc_errlvl_lid_la, + npc_errlvl_lid_lb, + npc_errlvl_lid_lc, + npc_errlvl_lid_ld, + npc_errlvl_lid_le, + npc_errlvl_lid_lf, + npc_errlvl_lid_lg, + npc_errlvl_lid_lh, + npc_errlvl_nix = 0x0f, +}; + +enum otx2_errcodes_re { + /* npc_errlvl_re errcodes */ + errcode_fcs = 0x7, + errcode_fcs_rcv = 0x8, + errcode_undersize = 0x10, + errcode_oversize = 0x11, + errcode_ol2_len_mismatch = 0x12, + /* npc_errlvl_nix errcodes */ + errcode_ol3_len = 0x10, + errcode_ol4_len = 0x11, + errcode_ol4_csum = 0x12, + errcode_il3_len = 0x20, + errcode_il4_len = 0x21, + errcode_il4_csum = 0x22, +}; + +/* driver counted stats */ +struct otx2_drv_stats { + atomic_t rx_fcs_errs; + atomic_t rx_oversize_errs; + atomic_t rx_undersize_errs; + atomic_t rx_csum_errs; + atomic_t rx_len_errs; + atomic_t rx_other_errs; +}; + + + /* stats */ + struct otx2_drv_stats drv_stats; +void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + struct otx2_qset *qset = &pf->qset; + struct otx2_cq_queue *cq; - int err; + int qidx, err; + /*dequeue all cqes */ + for (qidx = 0; qidx < qset->cq_cnt; qidx++) { + cq = &qset->cq[qidx]; + if (cq->cq_type == cq_rx) + otx2_cleanup_rx_cqes(pf, cq); + } + + netdev->hw_features = netif_f_rxcsum; + netdev->features |= netdev->hw_features; + + netdev->hw_features |= netif_f_rxall; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +/* nix wqe/cqe types */ +enum nix_xqe_type { + nix_xqe_type_invalid = 0x0, + nix_xqe_type_rx = 0x1, + nix_xqe_type_rx_ipsecs = 0x2, + nix_xqe_type_rx_ipsech = 0x3, + nix_xqe_type_rx_ipsecd = 0x4, + nix_xqe_type_send = 0x8, +}; + +/* nix cqe/sqe subdescriptor types */ +enum nix_subdc { + nix_subdc_nop = 0x0, + nix_subdc_ext = 0x1, + nix_subdc_crc = 0x2, + nix_subdc_imm = 0x3, + nix_subdc_sg = 0x4, + nix_subdc_mem = 0x5, + nix_subdc_jump = 0x6, + nix_subdc_work = 0x7, + nix_subdc_sod = 0xf, +}; + +/* nix cqe header structure */ +struct nix_cqe_hdr_s { + u64 flow_tag : 32; + u64 q : 20; + u64 reserved_52_57 : 6; + u64 node : 2; + u64 cqe_type : 4; +}; + +/* nix cqe rx parse structure */ +struct nix_rx_parse_s { + u64 chan : 12; + u64 desc_sizem1 : 5; + u64 rsvd_17 : 1; + u64 express : 1; + u64 wqwd : 1; + u64 errlev : 4; + u64 errcode : 8; + u64 latype : 4; + u64 lbtype : 4; + u64 lctype : 4; + u64 ldtype : 4; + u64 letype : 4; + u64 lftype : 4; + u64 lgtype : 4; + u64 lhtype : 4; + u64 pkt_lenm1 : 16; /* w1 */ + u64 l2m : 1; + u64 l2b : 1; + u64 l3m : 1; + u64 l3b : 1; + u64 vtag0_valid : 1; + u64 vtag0_gone : 1; + u64 vtag1_valid : 1; + u64 vtag1_gone : 1; + u64 pkind : 6; + u64 rsvd_95_94 : 2; + u64 vtag0_tci : 16; + u64 vtag1_tci : 16; + u64 laflags : 8; /* w2 */ + u64 lbflags : 8; + u64 lcflags : 8; + u64 ldflags : 8; + u64 leflags : 8; + u64 lfflags : 8; + u64 lgflags : 8; + u64 lhflags : 8; + u64 eoh_ptr : 8; /* w3 */ + u64 wqe_aura : 20; + u64 pb_aura : 20; + u64 match_id : 16; + u64 laptr : 8; /* w4 */ + u64 lbptr : 8; + u64 lcptr : 8; + u64 ldptr : 8; + u64 leptr : 8; + u64 lfptr : 8; + u64 lgptr : 8; + u64 lhptr : 8; + u64 vtag0_ptr : 8; /* w5 */ + u64 vtag1_ptr : 8; + u64 flow_key_alg : 5; + u64 rsvd_383_341 : 43; + u64 rsvd_447_384; /* w6 */ +}; + +/* nix cqe rx scatter/gather subdescriptor structure */ +struct nix_rx_sg_s { + u64 seg_size : 16; /* w0 */ + u64 seg2_size : 16; + u64 seg3_size : 16; + u64 segs : 2; + u64 rsvd_59_50 : 10; + u64 subdc : 4; + u64 seg_addr; + u64 seg2_addr; + u64 seg3_addr; +}; + +struct nix_cqe_rx_s { + struct nix_cqe_hdr_s hdr; + struct nix_rx_parse_s parse; + struct nix_rx_sg_s sg; +}; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +#define cqe_addr(cq, idx) ((cq)->cqe_base + ((cq)->cqe_size * (idx))) + +static struct nix_cqe_hdr_s *otx2_get_next_cqe(struct otx2_cq_queue *cq) +{ + struct nix_cqe_hdr_s *cqe_hdr; + + cqe_hdr = (struct nix_cqe_hdr_s *)cqe_addr(cq, cq->cq_head); + if (cqe_hdr->cqe_type == nix_xqe_type_invalid) + return null; + + cq->cq_head++; + cq->cq_head &= (cq->cqe_cnt - 1); + + return cqe_hdr; +} + +static void otx2_skb_add_frag(struct otx2_nic *pfvf, struct sk_buff *skb, + u64 iova, int len) +{ + struct page *page; + void *va; + + va = phys_to_virt(otx2_iova_to_phys(pfvf->iommu_domain, iova)); + page = virt_to_page(va); + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, + va - page_address(page), len, pfvf->rbsize); + + otx2_dma_unmap_page(pfvf, iova - otx2_head_room, + pfvf->rbsize, dma_from_device); +} + +static bool otx2_check_rcv_errors(struct otx2_nic *pfvf, + struct nix_cqe_rx_s *cqe, int qidx) +{ + struct otx2_drv_stats *stats = &pfvf->hw.drv_stats; + struct nix_rx_parse_s *parse = &cqe->parse; + + if (parse->errlev == npc_errlvl_re) { + switch (parse->errcode) { + case errcode_fcs: + case errcode_fcs_rcv: + atomic_inc(&stats->rx_fcs_errs); + break; + case errcode_undersize: + atomic_inc(&stats->rx_undersize_errs); + break; + case errcode_oversize: + atomic_inc(&stats->rx_oversize_errs); + break; + case errcode_ol2_len_mismatch: + atomic_inc(&stats->rx_len_errs); + break; + default: + atomic_inc(&stats->rx_other_errs); + break; + } + } else if (parse->errlev == npc_errlvl_nix) { + switch (parse->errcode) { + case errcode_ol3_len: + case errcode_ol4_len: + case errcode_il3_len: + case errcode_il4_len: + atomic_inc(&stats->rx_len_errs); + break; + case errcode_ol4_csum: + case errcode_il4_csum: + atomic_inc(&stats->rx_csum_errs); + break; + default: + atomic_inc(&stats->rx_other_errs); + break; + } + } else { + atomic_inc(&stats->rx_other_errs); + /* for now ignore all the npc parser errors and + * pass the packets to stack. + */ + return false; + } + + /* if rxall is enabled pass on packets to stack. */ + if (cqe->sg.segs && (pfvf->netdev->features & netif_f_rxall)) + return false; + + /* free buffer back to pool */ + if (cqe->sg.segs) + otx2_aura_freeptr(pfvf, qidx, cqe->sg.seg_addr & ~0x07ull); + return true; +} + +static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf, + struct napi_struct *napi, + struct otx2_cq_queue *cq, + struct nix_cqe_rx_s *cqe) +{ + struct nix_rx_parse_s *parse = &cqe->parse; + struct sk_buff *skb = null; + + if (unlikely(parse->errlev || parse->errcode)) { + if (otx2_check_rcv_errors(pfvf, cqe, cq->cq_idx)) + return; + } + + skb = napi_get_frags(napi); + if (unlikely(!skb)) + return; + + otx2_skb_add_frag(pfvf, skb, cqe->sg.seg_addr, cqe->sg.seg_size); + cq->pool_ptrs++; + + skb_record_rx_queue(skb, cq->cq_idx); + if (pfvf->netdev->features & netif_f_rxcsum) + skb->ip_summed = checksum_unnecessary; + + napi_gro_frags(napi); +} + - /* nothing to do, for now */ - return 0; + struct nix_cqe_rx_s *cqe; + int processed_cqe = 0; + s64 bufptr; + + while (likely(processed_cqe < budget)) { + cqe = (struct nix_cqe_rx_s *)cqe_addr(cq, cq->cq_head); + if (cqe->hdr.cqe_type == nix_xqe_type_invalid || + !cqe->sg.seg_addr) { + if (!processed_cqe) + return 0; + break; + } + cq->cq_head++; + cq->cq_head &= (cq->cqe_cnt - 1); + + otx2_rcv_pkt_handler(pfvf, napi, cq, cqe); + + cqe->hdr.cqe_type = nix_xqe_type_invalid; + cqe->sg.seg_addr = 0x00; + processed_cqe++; + } + + /* free cqes to hw */ + otx2_write64(pfvf, nix_lf_cq_op_door, + ((u64)cq->cq_idx << 32) | processed_cqe); + + if (unlikely(!cq->pool_ptrs)) + return 0; + + /* refill pool with new buffers */ + while (cq->pool_ptrs) { + bufptr = otx2_alloc_rbuf(pfvf, cq->rbpool, gfp_atomic); + if (unlikely(bufptr <= 0)) + break; + otx2_aura_freeptr(pfvf, cq->cq_idx, bufptr + otx2_head_room); + cq->pool_ptrs--; + } + otx2_get_page(cq->rbpool); + + return processed_cqe; + +void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq) +{ + struct nix_cqe_rx_s *cqe; + int processed_cqe = 0; + u64 iova, pa; + + while ((cqe = (struct nix_cqe_rx_s *)otx2_get_next_cqe(cq))) { + if (!cqe->sg.subdc) + continue; + iova = cqe->sg.seg_addr - otx2_head_room; + pa = otx2_iova_to_phys(pfvf->iommu_domain, iova); + otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize, dma_from_device); + put_page(virt_to_page(phys_to_virt(pa))); + processed_cqe++; + } + + /* free cqes to hw */ + otx2_write64(pfvf, nix_lf_cq_op_door, + ((u64)cq->cq_idx << 32) | processed_cqe); +} diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h + u8 cint_idx; /* cq interrupt id */ + u32 cq_head;
|
Networking
|
abe0254333124598d1e7452c19e9e753c6bfaada
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: add packet transmission support
|
this patch adds the packet transmission support. for a given skb prepares send queue descriptors (sqes) and pushes them to hw. here driver doesn't maintain it's own sq rings, sqes are pushed to hw using a silicon specific operations called lmtst. from the instuction hw derives the transmit queue number and queues the sqe to that queue. these lmtst instructions are designed to avoid queue maintenance in sw and lockless behavior ie when multiple cores are trying to add sqes to same queue then hw will takecare of serialization, no need for sw to hold locks.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 6
| 470
| 2
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c + sq->sg = kcalloc(qset->sqe_cnt, sizeof(struct sg_list), gfp_kernel); + if (!sq->sg) + return -enomem; + sq->head = 0; + /* set sqe threshold to 10% of total sqes */ + sq->sqe_thresh = ((sq->num_sqbs * sq->sqe_per_sqb) * 10) / 100; + cq->cint_idx = qidx - pfvf->hw.rx_queues; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +static inline u64 otx2_lmt_flush(uint64_t addr) +{ + u64 result = 0; + + __asm__ volatile(".cpu generic+lse " + "ldeor xzr,%x[rf],[%[rs]]" + : [rf]"=r"(result) + : [rs]"r"(addr)); + return result; +} + +#define otx2_lmt_flush(addr) ({ 0; }) +void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + kfree(sq->sg); + else + otx2_cleanup_tx_cqes(pf, cq); +static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev) +{ + struct otx2_nic *pf = netdev_priv(netdev); + int qidx = skb_get_queue_mapping(skb); + struct otx2_snd_queue *sq; + struct netdev_queue *txq; + + /* check for minimum packet length */ + if (skb->len <= eth_hlen) { + dev_kfree_skb(skb); + return netdev_tx_ok; + } + + sq = &pf->qset.sq[qidx]; + txq = netdev_get_tx_queue(netdev, qidx); + + if (!otx2_sq_append_skb(netdev, sq, skb, qidx)) { + netif_tx_stop_queue(txq); + + /* check again, incase sqbs got freed up */ + smp_mb(); + if (((sq->num_sqbs - *sq->aura_fc_addr) * sq->sqe_per_sqb) + > sq->sqe_thresh) + netif_tx_wake_queue(txq); + + return netdev_tx_busy; + } + + return netdev_tx_ok; +} + + .ndo_start_xmit = otx2_xmit, - netdev->hw_features = netif_f_rxcsum; + netdev->hw_features = (netif_f_rxcsum | netif_f_ip_csum | + netif_f_ipv6_csum | netif_f_sg); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +/* csum offload */ +enum nix_sendl3type { + nix_sendl3type_none = 0x0, + nix_sendl3type_ip4 = 0x2, + nix_sendl3type_ip4_cksum = 0x3, + nix_sendl3type_ip6 = 0x4, +}; + +enum nix_sendl4type { + nix_sendl4type_none, + nix_sendl4type_tcp_cksum, + nix_sendl4type_sctp_cksum, + nix_sendl4type_udp_cksum, +}; + +/* algorithm for nix_sqe_mem_s header (value of the 'alg' field) */ +enum nix_sendmemalg { + nix_sendmemalg_e_set = 0x0, + nix_sendmemalg_e_settstmp = 0x1, + nix_sendmemalg_e_setrslt = 0x2, + nix_sendmemalg_e_add = 0x8, + nix_sendmemalg_e_sub = 0x9, + nix_sendmemalg_e_addlen = 0xa, + nix_sendmemalg_e_sublen = 0xb, + nix_sendmemalg_e_addmbuf = 0xc, + nix_sendmemalg_e_submbuf = 0xd, + nix_sendmemalg_e_enum_last = 0xe, +}; + +struct nix_send_comp_s { + u64 status : 8; + u64 sqe_id : 16; + u64 rsvd_24_63 : 40; +}; + +struct nix_cqe_tx_s { + struct nix_cqe_hdr_s hdr; + struct nix_send_comp_s comp; +}; + +/* nix sqe header structure */ +struct nix_sqe_hdr_s { + u64 total : 18; /* w0 */ + u64 reserved_18 : 1; + u64 df : 1; + u64 aura : 20; + u64 sizem1 : 3; + u64 pnc : 1; + u64 sq : 20; + u64 ol3ptr : 8; /* w1 */ + u64 ol4ptr : 8; + u64 il3ptr : 8; + u64 il4ptr : 8; + u64 ol3type : 4; + u64 ol4type : 4; + u64 il3type : 4; + u64 il4type : 4; + u64 sqe_id : 16; + +}; + +/* nix send extended header subdescriptor structure */ +struct nix_sqe_ext_s { + u64 lso_mps : 14; /* w0 */ + u64 lso : 1; + u64 tstmp : 1; + u64 lso_sb : 8; + u64 lso_format : 5; + u64 rsvd_31_29 : 3; + u64 shp_chg : 9; + u64 shp_dis : 1; + u64 shp_ra : 2; + u64 markptr : 8; + u64 markform : 7; + u64 mark_en : 1; + u64 subdc : 4; + u64 vlan0_ins_ptr : 8; /* w1 */ + u64 vlan0_ins_tci : 16; + u64 vlan1_ins_ptr : 8; + u64 vlan1_ins_tci : 16; + u64 vlan0_ins_ena : 1; + u64 vlan1_ins_ena : 1; + u64 rsvd_127_114 : 14; +}; + +struct nix_sqe_sg_s { + u64 seg1_size : 16; + u64 seg2_size : 16; + u64 seg3_size : 16; + u64 segs : 2; + u64 rsvd_54_50 : 5; + u64 i1 : 1; + u64 i2 : 1; + u64 i3 : 1; + u64 ld_type : 2; + u64 subdc : 4; +}; + +/* nix send memory subdescriptor structure */ +struct nix_sqe_mem_s { + u64 offset : 16; /* w0 */ + u64 rsvd_52_16 : 37; + u64 wmem : 1; + u64 dsz : 2; + u64 alg : 4; + u64 subdc : 4; + u64 addr; /* w1 */ +}; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +static unsigned int frag_num(unsigned int i) +{ +#ifdef __big_endian + return (i & ~3) + 3 - (i & 3); +#else + return i; +#endif +} + +static dma_addr_t otx2_dma_map_skb_frag(struct otx2_nic *pfvf, + struct sk_buff *skb, int seg, int *len) +{ + const skb_frag_t *frag; + struct page *page; + int offset; + + /* first segment is always skb->data */ + if (!seg) { + page = virt_to_page(skb->data); + offset = offset_in_page(skb->data); + *len = skb_headlen(skb); + } else { + frag = &skb_shinfo(skb)->frags[seg - 1]; + page = skb_frag_page(frag); + offset = skb_frag_off(frag); + *len = skb_frag_size(frag); + } + return otx2_dma_map_page(pfvf, page, offset, *len, dma_to_device); +} + +static void otx2_dma_unmap_skb_frags(struct otx2_nic *pfvf, struct sg_list *sg) +{ + int seg; + + for (seg = 0; seg < sg->num_segs; seg++) { + otx2_dma_unmap_page(pfvf, sg->dma_addr[seg], + sg->size[seg], dma_to_device); + } + sg->num_segs = 0; +} + +static void otx2_snd_pkt_handler(struct otx2_nic *pfvf, + struct otx2_cq_queue *cq, + struct otx2_snd_queue *sq, + struct nix_cqe_tx_s *cqe, + int budget, int *tx_pkts, int *tx_bytes) +{ + struct nix_send_comp_s *snd_comp = &cqe->comp; + struct sk_buff *skb = null; + struct sg_list *sg; + + if (unlikely(snd_comp->status)) + net_err_ratelimited("%s: tx%d: error in send cq status:%x ", + pfvf->netdev->name, cq->cint_idx, + snd_comp->status); + + sg = &sq->sg[snd_comp->sqe_id]; + skb = (struct sk_buff *)sg->skb; + if (unlikely(!skb)) + return; + + *tx_bytes += skb->len; + (*tx_pkts)++; + otx2_dma_unmap_skb_frags(pfvf, sg); + napi_consume_skb(skb, budget); + sg->skb = (u64)null; +} + - /* nothing to do, for now */ + int tx_pkts = 0, tx_bytes = 0; + struct nix_cqe_tx_s *cqe; + int processed_cqe = 0; + + while (likely(processed_cqe < budget)) { + cqe = (struct nix_cqe_tx_s *)otx2_get_next_cqe(cq); + if (unlikely(!cqe)) { + if (!processed_cqe) + return 0; + break; + } + otx2_snd_pkt_handler(pfvf, cq, &pfvf->qset.sq[cq->cint_idx], + cqe, budget, &tx_pkts, &tx_bytes); + + cqe->hdr.cqe_type = nix_xqe_type_invalid; + processed_cqe++; + } + + /* free cqes to hw */ + otx2_write64(pfvf, nix_lf_cq_op_door, + ((u64)cq->cq_idx << 32) | processed_cqe); + + if (likely(tx_pkts)) { + struct netdev_queue *txq; + + txq = netdev_get_tx_queue(pfvf->netdev, cq->cint_idx); + netdev_tx_completed_queue(txq, tx_pkts, tx_bytes); + /* check if queue was stopped earlier due to ring full */ + smp_mb(); + if (netif_tx_queue_stopped(txq) && + netif_carrier_ok(pfvf->netdev)) + netif_tx_wake_queue(txq); + } +static void otx2_sqe_flush(struct otx2_snd_queue *sq, int size) +{ + u64 status; + + /* packet data stores should finish before sqe is flushed to hw */ + dma_wmb(); + + do { + memcpy(sq->lmt_addr, sq->sqe_base, size); + status = otx2_lmt_flush(sq->io_addr); + } while (status == 0); + + sq->head++; + sq->head &= (sq->sqe_cnt - 1); +} + +#define max_segs_per_sg 3 +/* add sqe scatter/gather subdescriptor structure */ +static bool otx2_sqe_add_sg(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, + struct sk_buff *skb, int num_segs, int *offset) +{ + struct nix_sqe_sg_s *sg = null; + u64 dma_addr, *iova = null; + u16 *sg_lens = null; + int seg, len; + + sq->sg[sq->head].num_segs = 0; + + for (seg = 0; seg < num_segs; seg++) { + if ((seg % max_segs_per_sg) == 0) { + sg = (struct nix_sqe_sg_s *)(sq->sqe_base + *offset); + sg->ld_type = nix_send_ldtype_ldd; + sg->subdc = nix_subdc_sg; + sg->segs = 0; + sg_lens = (void *)sg; + iova = (void *)sg + sizeof(*sg); + /* next subdc always starts at a 16byte boundary. + * so if sg->segs is whether 2 or 3, offset += 16bytes. + */ + if ((num_segs - seg) >= (max_segs_per_sg - 1)) + *offset += sizeof(*sg) + (3 * sizeof(u64)); + else + *offset += sizeof(*sg) + sizeof(u64); + } + dma_addr = otx2_dma_map_skb_frag(pfvf, skb, seg, &len); + if (dma_mapping_error(pfvf->dev, dma_addr)) + return false; + + sg_lens[frag_num(seg % max_segs_per_sg)] = len; + sg->segs++; + *iova++ = dma_addr; + + /* save dma mapping info for later unmapping */ + sq->sg[sq->head].dma_addr[seg] = dma_addr; + sq->sg[sq->head].size[seg] = len; + sq->sg[sq->head].num_segs++; + } + + sq->sg[sq->head].skb = (u64)skb; + return true; +} + +/* add sqe header subdescriptor structure */ +static void otx2_sqe_add_hdr(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, + struct nix_sqe_hdr_s *sqe_hdr, + struct sk_buff *skb, u16 qidx) +{ + int proto = 0; + + /* check if sqe was framed before, if yes then no need to + * set these constants again and again. + */ + if (!sqe_hdr->total) { + /* don't free tx buffers to aura */ + sqe_hdr->df = 1; + sqe_hdr->aura = sq->aura_id; + /* post a cqe tx after pkt transmission */ + sqe_hdr->pnc = 1; + sqe_hdr->sq = qidx; + } + sqe_hdr->total = skb->len; + /* set sqe identifier which will be used later for freeing skb */ + sqe_hdr->sqe_id = sq->head; + + /* offload tcp/udp checksum to hw */ + if (skb->ip_summed == checksum_partial) { + sqe_hdr->ol3ptr = skb_network_offset(skb); + sqe_hdr->ol4ptr = skb_transport_offset(skb); + /* get vlan protocol ethertype */ + if (eth_type_vlan(skb->protocol)) + skb->protocol = vlan_get_protocol(skb); + + if (skb->protocol == htons(eth_p_ip)) { + proto = ip_hdr(skb)->protocol; + /* in case of tso, hw needs this to be explicitly set. + * so set this always, instead of adding a check. + */ + sqe_hdr->ol3type = nix_sendl3type_ip4_cksum; + } else if (skb->protocol == htons(eth_p_ipv6)) { + proto = ipv6_hdr(skb)->nexthdr; + } + + if (proto == ipproto_tcp) + sqe_hdr->ol4type = nix_sendl4type_tcp_cksum; + else if (proto == ipproto_udp) + sqe_hdr->ol4type = nix_sendl4type_udp_cksum; + } +} + +bool otx2_sq_append_skb(struct net_device *netdev, struct otx2_snd_queue *sq, + struct sk_buff *skb, u16 qidx) +{ + struct netdev_queue *txq = netdev_get_tx_queue(netdev, qidx); + struct otx2_nic *pfvf = netdev_priv(netdev); + int offset, num_segs, free_sqe; + struct nix_sqe_hdr_s *sqe_hdr; + + /* check if there is room for new sqe. + * 'num of sqbs freed to sq's pool - sq's aura count' + * will give free sqe count. + */ + free_sqe = (sq->num_sqbs - *sq->aura_fc_addr) * sq->sqe_per_sqb; + + if (!free_sqe || free_sqe < sq->sqe_thresh) + return false; + + num_segs = skb_shinfo(skb)->nr_frags + 1; + + /* if skb doesn't fit in a single sqe, linearize it. + * todo: consider adding jump descriptor instead. + */ + if (unlikely(num_segs > otx2_max_frags_in_sqe)) { + if (__skb_linearize(skb)) { + dev_kfree_skb_any(skb); + return true; + } + num_segs = skb_shinfo(skb)->nr_frags + 1; + } + + /* set sqe's send_hdr. + * do not clear the first 64bit as it contains constant info. + */ + memset(sq->sqe_base + 8, 0, sq->sqe_size - 8); + sqe_hdr = (struct nix_sqe_hdr_s *)(sq->sqe_base); + otx2_sqe_add_hdr(pfvf, sq, sqe_hdr, skb, qidx); + offset = sizeof(*sqe_hdr); + + /* add sg subdesc with data frags */ + if (!otx2_sqe_add_sg(pfvf, sq, skb, num_segs, &offset)) { + otx2_dma_unmap_skb_frags(pfvf, &sq->sg[sq->head]); + return false; + } + + sqe_hdr->sizem1 = (offset / 16) - 1; + + netdev_tx_sent_queue(txq, skb->len); + + /* flush sqe to hw */ + otx2_sqe_flush(sq, offset); + + return true; +} + + +void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq) +{ + struct sk_buff *skb = null; + struct otx2_snd_queue *sq; + struct nix_cqe_tx_s *cqe; + int processed_cqe = 0; + struct sg_list *sg; + + sq = &pfvf->qset.sq[cq->cint_idx]; + + while ((cqe = (struct nix_cqe_tx_s *)otx2_get_next_cqe(cq))) { + sg = &sq->sg[cqe->comp.sqe_id]; + skb = (struct sk_buff *)sg->skb; + if (skb) { + otx2_dma_unmap_skb_frags(pfvf, sg); + dev_kfree_skb_any(skb); + sg->skb = (u64)null; + } + processed_cqe++; + } + + /* free cqes to hw */ + otx2_write64(pfvf, nix_lf_cq_op_door, + ((u64)cq->cq_idx << 32) | processed_cqe); +} diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +#define otx2_max_frags_in_sqe 9 + +struct sg_list { + u16 num_segs; + u64 skb; + u64 size[otx2_max_frags_in_sqe]; + u64 dma_addr[otx2_max_frags_in_sqe]; +}; + + u16 head; + u16 sqe_thresh; + struct sg_list *sg; +bool otx2_sq_append_skb(struct net_device *netdev, struct otx2_snd_queue *sq, + struct sk_buff *skb, u16 qidx);
|
Networking
|
3ca6c4c882a7f34085b170d93cf0d0e843aa00e6
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: register and handle link notifications
|
pf and af (admin function) shares 64kb of reserved memory region for communication. this region is shared for - messages sent by pf and responses sent by af. - notifications sent by af and acks sent by pf.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['h', 'c']
| 3
| 109
| 0
|
- messages sent by pf and responses sent by af. - notifications sent by af and acks sent by pf. --- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +#define otx2_flag_intf_down bit_ull(2) + u64 flags; + + struct cgx_link_user_info linfo; +int otx2_rxtx_enable(struct otx2_nic *pfvf, bool enable); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +static void otx2_handle_link_event(struct otx2_nic *pf) +{ + struct cgx_link_user_info *linfo = &pf->linfo; + struct net_device *netdev = pf->netdev; + + pr_info("%s nic link is %s %d mbps %s duplex ", netdev->name, + linfo->link_up ? "up" : "down", linfo->speed, + linfo->full_duplex ? "full" : "half"); + if (linfo->link_up) { + netif_carrier_on(netdev); + netif_tx_start_all_queues(netdev); + } else { + netif_tx_stop_all_queues(netdev); + netif_carrier_off(netdev); + } +} + +int otx2_mbox_up_handler_cgx_link_event(struct otx2_nic *pf, + struct cgx_link_info_msg *msg, + struct msg_rsp *rsp) +{ + /* copy the link info sent by af */ + pf->linfo = msg->link_info; + + /* interface has not been fully configured yet */ + if (pf->flags & otx2_flag_intf_down) + return 0; + + otx2_handle_link_event(pf); + return 0; +} + +static int otx2_cgx_config_linkevents(struct otx2_nic *pf, bool enable) +{ + struct msg_req *msg; + int err; + + otx2_mbox_lock(&pf->mbox); + if (enable) + msg = otx2_mbox_alloc_msg_cgx_start_linkevents(&pf->mbox); + else + msg = otx2_mbox_alloc_msg_cgx_stop_linkevents(&pf->mbox); + + if (!msg) { + otx2_mbox_unlock(&pf->mbox); + return -enomem; + } + + err = otx2_sync_mbox_msg(&pf->mbox); + otx2_mbox_unlock(&pf->mbox); + return err; +} + + pf->flags &= ~otx2_flag_intf_down; + /* 'intf_down' may be checked on any cpu */ + smp_wmb(); + + /* we have already received link status notification */ + if (pf->linfo.link_up && !(pf->pcifunc & rvu_pfvf_func_mask)) + otx2_handle_link_event(pf); + + err = otx2_rxtx_enable(pf, true); + if (err) + goto err_free_cints; + + pf->flags |= otx2_flag_intf_down; + /* 'intf_down' may be checked on any cpu */ + smp_wmb(); + + /* first stop packet rx/tx */ + otx2_rxtx_enable(pf, false); + + pf->flags |= otx2_flag_intf_down; + /* enable link notifications */ + otx2_cgx_config_linkevents(pf, true); + + /* disable link notifications */ + otx2_cgx_config_linkevents(pf, false); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c + /* if interface is going down, don't re-enable irq */ + if (pfvf->flags & otx2_flag_intf_down) + return workdone; + + +int otx2_rxtx_enable(struct otx2_nic *pfvf, bool enable) +{ + struct msg_req *msg; + int err; + + otx2_mbox_lock(&pfvf->mbox); + if (enable) + msg = otx2_mbox_alloc_msg_nix_lf_start_rx(&pfvf->mbox); + else + msg = otx2_mbox_alloc_msg_nix_lf_stop_rx(&pfvf->mbox); + + if (!msg) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + err = otx2_sync_mbox_msg(&pfvf->mbox); + otx2_mbox_unlock(&pfvf->mbox); + return err; +}
|
Networking
|
50fe6c02e5ad50727fb1069bb31099385fb59883
|
linu cherian
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: mtu, mac and rx mode config support
|
this patch addes support to change interface mtu, mac address retrieval and config, rx mode ie unicast, multicast and promiscuous. also added link loopback support
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['h', 'c']
| 6
| 242
| 6
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h -m(nix_rxvlan_alloc, 0x8012, nix_rxvlan_alloc, msg_req, msg_rsp) +m(nix_rxvlan_alloc, 0x8012, nix_rxvlan_alloc, msg_req, msg_rsp) \ +m(nix_get_mac_addr, 0x8018, nix_get_mac_addr, msg_req, nix_get_mac_addr_rsp) \ +struct nix_get_mac_addr_rsp { + struct mbox_msghdr hdr; + u8 mac_addr[eth_alen]; +}; + diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +int rvu_mbox_handler_nix_get_mac_addr(struct rvu *rvu, + struct msg_req *req, + struct nix_get_mac_addr_rsp *rsp) +{ + u16 pcifunc = req->hdr.pcifunc; + struct rvu_pfvf *pfvf; + + if (!is_nixlf_attached(rvu, pcifunc)) + return nix_af_err_af_lf_invalid; + + pfvf = rvu_get_pfvf(rvu, pcifunc); + + ether_addr_copy(rsp->mac_addr, pfvf->mac_addr); + + return 0; +} + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +/* sync mac address with rvu af */ +static int otx2_hw_set_mac_addr(struct otx2_nic *pfvf, u8 *mac) +{ + struct nix_set_mac_addr *req; + int err; + + otx2_mbox_lock(&pfvf->mbox); + req = otx2_mbox_alloc_msg_nix_set_mac_addr(&pfvf->mbox); + if (!req) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + ether_addr_copy(req->mac_addr, mac); + + err = otx2_sync_mbox_msg(&pfvf->mbox); + otx2_mbox_unlock(&pfvf->mbox); + return err; +} + +static int otx2_hw_get_mac_addr(struct otx2_nic *pfvf, + struct net_device *netdev) +{ + struct nix_get_mac_addr_rsp *rsp; + struct mbox_msghdr *msghdr; + struct msg_req *req; + int err; + + otx2_mbox_lock(&pfvf->mbox); + req = otx2_mbox_alloc_msg_nix_get_mac_addr(&pfvf->mbox); + if (!req) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + err = otx2_sync_mbox_msg(&pfvf->mbox); + if (err) { + otx2_mbox_unlock(&pfvf->mbox); + return err; + } + + msghdr = otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr); + if (!msghdr) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + rsp = (struct nix_get_mac_addr_rsp *)msghdr; + ether_addr_copy(netdev->dev_addr, rsp->mac_addr); + otx2_mbox_unlock(&pfvf->mbox); + + return 0; +} + +int otx2_set_mac_address(struct net_device *netdev, void *p) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct sockaddr *addr = p; + + if (!is_valid_ether_addr(addr->sa_data)) + return -eaddrnotavail; + + if (!otx2_hw_set_mac_addr(pfvf, addr->sa_data)) + memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); + else + return -eperm; + + return 0; +} + +int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu) +{ + struct nix_frs_cfg *req; + int err; + + otx2_mbox_lock(&pfvf->mbox); + req = otx2_mbox_alloc_msg_nix_set_hw_frs(&pfvf->mbox); + if (!req) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + + /* smq config limits maximum pkt size that can be transmitted */ + req->update_smq = true; + pfvf->max_frs = mtu + otx2_eth_hlen; + req->maxlen = pfvf->max_frs; + + err = otx2_sync_mbox_msg(&pfvf->mbox); + otx2_mbox_unlock(&pfvf->mbox); + return err; +} + +void otx2_get_mac_from_af(struct net_device *netdev) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + int err; + + err = otx2_hw_get_mac_addr(pfvf, netdev); + if (err) + dev_warn(pfvf->dev, "failed to read mac from hardware "); + + /* if af doesn't provide a valid mac, generate a random one */ + if (!is_valid_ether_addr(netdev->dev_addr)) + eth_hw_addr_random(netdev); +} + + req->regval[0] = ((pfvf->netdev->mtu + otx2_eth_hlen) << 8) | + otx2_min_mtu; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h + u16 max_frs; - +int otx2_set_mac_address(struct net_device *netdev, void *p); +int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu); +void otx2_get_mac_from_af(struct net_device *netdev); + +int otx2_open(struct net_device *netdev); +int otx2_stop(struct net_device *netdev); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +static int otx2_change_mtu(struct net_device *netdev, int new_mtu) +{ + bool if_up = netif_running(netdev); + int err = 0; + + if (if_up) + otx2_stop(netdev); + + netdev_info(netdev, "changing mtu from %d to %d ", + netdev->mtu, new_mtu); + netdev->mtu = new_mtu; + + if (if_up) + err = otx2_open(netdev); + + return err; +} + +static int otx2_cgx_config_loopback(struct otx2_nic *pf, bool enable) +{ + struct msg_req *msg; + int err; + + otx2_mbox_lock(&pf->mbox); + if (enable) + msg = otx2_mbox_alloc_msg_cgx_intlbk_enable(&pf->mbox); + else + msg = otx2_mbox_alloc_msg_cgx_intlbk_disable(&pf->mbox); + + if (!msg) { + otx2_mbox_unlock(&pf->mbox); + return -enomem; + } + + err = otx2_sync_mbox_msg(&pf->mbox); + otx2_mbox_unlock(&pf->mbox); + return err; +} + - pf->rbsize = rcv_frag_len(pf->netdev->mtu); + pf->rbsize = rcv_frag_len(pf->netdev->mtu + otx2_eth_hlen); -static int otx2_open(struct net_device *netdev) +int otx2_open(struct net_device *netdev) + /* set maximum frame size allowed in hw */ + err = otx2_hw_set_mtu(pf, netdev->mtu); + if (err) + goto err_disable_napi; + +err_disable_napi: -static int otx2_stop(struct net_device *netdev) +int otx2_stop(struct net_device *netdev) +static void otx2_set_rx_mode(struct net_device *netdev) +{ + struct otx2_nic *pf = netdev_priv(netdev); + struct nix_rx_mode *req; + + if (!(netdev->flags & iff_up)) + return; + + otx2_mbox_lock(&pf->mbox); + req = otx2_mbox_alloc_msg_nix_set_rx_mode(&pf->mbox); + if (!req) { + otx2_mbox_unlock(&pf->mbox); + return; + } + + req->mode = nix_rx_mode_ucast; + + /* we don't support mac address filtering yet */ + if (netdev->flags & iff_promisc) + req->mode |= nix_rx_mode_promisc; + else if (netdev->flags & (iff_allmulti | iff_multicast)) + req->mode |= nix_rx_mode_allmulti; + + otx2_sync_mbox_msg(&pf->mbox); + otx2_mbox_unlock(&pf->mbox); +} + +static int otx2_set_features(struct net_device *netdev, + netdev_features_t features) +{ + netdev_features_t changed = features ^ netdev->features; + struct otx2_nic *pf = netdev_priv(netdev); + + if ((changed & netif_f_loopback) && netif_running(netdev)) + return otx2_cgx_config_loopback(pf, + features & netif_f_loopback); + return 0; +} + + .ndo_set_mac_address = otx2_set_mac_address, + .ndo_change_mtu = otx2_change_mtu, + .ndo_set_rx_mode = otx2_set_rx_mode, + .ndo_set_features = otx2_set_features, + /* assign default mac address */ + otx2_get_mac_from_af(netdev); + - netdev->hw_features |= netif_f_rxall; + netdev->hw_features |= netif_f_loopback | netif_f_rxall; + /* mtu range: 64 - 9190 */ + netdev->min_mtu = otx2_min_mtu; + netdev->max_mtu = otx2_max_mtu; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +#define otx2_eth_hlen (vlan_eth_hlen + vlan_hlen) +#define otx2_min_mtu 64 +#define otx2_max_mtu (9212 - otx2_eth_hlen) +
|
Networking
|
34bfe0ebedb76aeb964341d96cf7c5135d14e1bf
|
sunil goutham
|
drivers
|
net
|
af, ethernet, marvell, nic, octeontx2
|
octeontx2-pf: error handling support
|
hw reports many errors on the receive and transmit paths. such as incorrect queue configuration, pkt transmission errors, lmtst instruction errors, transmit queue full etc. these are reported via qint interrupt. most of the errors are fatal and needs reinitialization.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 6
| 255
| 3
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +void otx2_tx_timeout(struct net_device *netdev, unsigned int txq) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + + schedule_work(&pfvf->reset_task); +} + + aq->rq.qint_idx = 0; + aq->sq.sq_int_ena = nix_sqint_bits; + aq->sq.qint_idx = 0; + cq->refill_task_sched = false; + aq->cq.cq_err_int_ena = nix_cqerrint_bits; + aq->cq.qint_idx = 0; +static void otx2_pool_refill_task(struct work_struct *work) +{ + struct otx2_cq_queue *cq; + struct otx2_pool *rbpool; + struct refill_work *wrk; + int qidx, free_ptrs = 0; + struct otx2_nic *pfvf; + s64 bufptr; + + wrk = container_of(work, struct refill_work, pool_refill_work.work); + pfvf = wrk->pf; + qidx = wrk - pfvf->refill_wrk; + cq = &pfvf->qset.cq[qidx]; + rbpool = cq->rbpool; + free_ptrs = cq->pool_ptrs; + + while (cq->pool_ptrs) { + bufptr = otx2_alloc_rbuf(pfvf, rbpool, gfp_kernel); + if (bufptr <= 0) { + /* schedule a wq if we fails to free atleast half of the + * pointers else enable napi for this rq. + */ + if (!((free_ptrs - cq->pool_ptrs) > free_ptrs / 2)) { + struct delayed_work *dwork; + + dwork = &wrk->pool_refill_work; + schedule_delayed_work(dwork, + msecs_to_jiffies(100)); + } else { + cq->refill_task_sched = false; + } + return; + } + otx2_aura_freeptr(pfvf, qidx, bufptr + otx2_head_room); + cq->pool_ptrs--; + } + cq->refill_task_sched = false; +} + + /* initialize work queue for receive buffer refill */ + pfvf->refill_wrk = devm_kcalloc(pfvf->dev, pfvf->qset.cq_cnt, + sizeof(struct refill_work), gfp_kernel); + if (!pfvf->refill_wrk) + return -enomem; + + for (qidx = 0; qidx < pfvf->qset.cq_cnt; qidx++) { + pfvf->refill_wrk[qidx].pf = pfvf; + init_delayed_work(&pfvf->refill_wrk[qidx].pool_refill_work, + otx2_pool_refill_task); + } diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +struct refill_work { + struct delayed_work pool_refill_work; + struct otx2_nic *pf; +}; + + u64 reset_count; + struct work_struct reset_task; + struct refill_work *refill_wrk; + +/* time to wait before watchdog kicks off */ +#define otx2_tx_timeout (100 * hz) + +void otx2_tx_timeout(struct net_device *netdev, unsigned int txq); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +static irqreturn_t otx2_q_intr_handler(int irq, void *data) +{ + struct otx2_nic *pf = data; + u64 val, *ptr; + u64 qidx = 0; + + /* cq */ + for (qidx = 0; qidx < pf->qset.cq_cnt; qidx++) { + ptr = otx2_get_regaddr(pf, nix_lf_cq_op_int); + val = otx2_atomic64_add((qidx << 44), ptr); + + otx2_write64(pf, nix_lf_cq_op_int, (qidx << 44) | + (val & nix_cqerrint_bits)); + if (!(val & (nix_cqerrint_bits | bit_ull(42)))) + continue; + + if (val & bit_ull(42)) { + netdev_err(pf->netdev, "cq%lld: error reading nix_lf_cq_op_int, nix_lf_err_int 0x%llx ", + qidx, otx2_read64(pf, nix_lf_err_int)); + } else { + if (val & bit_ull(nix_cqerrint_door_err)) + netdev_err(pf->netdev, "cq%lld: doorbell error", + qidx); + if (val & bit_ull(nix_cqerrint_cqe_fault)) + netdev_err(pf->netdev, "cq%lld: memory fault on cqe write to llc/dram", + qidx); + } + + schedule_work(&pf->reset_task); + } + + /* sq */ + for (qidx = 0; qidx < pf->hw.tx_queues; qidx++) { + ptr = otx2_get_regaddr(pf, nix_lf_sq_op_int); + val = otx2_atomic64_add((qidx << 44), ptr); + otx2_write64(pf, nix_lf_sq_op_int, (qidx << 44) | + (val & nix_sqint_bits)); + + if (!(val & (nix_sqint_bits | bit_ull(42)))) + continue; + + if (val & bit_ull(42)) { + netdev_err(pf->netdev, "sq%lld: error reading nix_lf_sq_op_int, nix_lf_err_int 0x%llx ", + qidx, otx2_read64(pf, nix_lf_err_int)); + } else { + if (val & bit_ull(nix_sqint_lmt_err)) { + netdev_err(pf->netdev, "sq%lld: lmt store error nix_lf_sq_op_err_dbg:0x%llx", + qidx, + otx2_read64(pf, + nix_lf_sq_op_err_dbg)); + otx2_write64(pf, nix_lf_sq_op_err_dbg, + bit_ull(44)); + } + if (val & bit_ull(nix_sqint_mnq_err)) { + netdev_err(pf->netdev, "sq%lld: meta-descriptor enqueue error nix_lf_mnq_err_dgb:0x%llx ", + qidx, + otx2_read64(pf, nix_lf_mnq_err_dbg)); + otx2_write64(pf, nix_lf_mnq_err_dbg, + bit_ull(44)); + } + if (val & bit_ull(nix_sqint_send_err)) { + netdev_err(pf->netdev, "sq%lld: send error, nix_lf_send_err_dbg 0x%llx", + qidx, + otx2_read64(pf, + nix_lf_send_err_dbg)); + otx2_write64(pf, nix_lf_send_err_dbg, + bit_ull(44)); + } + if (val & bit_ull(nix_sqint_sqb_alloc_fail)) + netdev_err(pf->netdev, "sq%lld: sqb allocation failed", + qidx); + } + + schedule_work(&pf->reset_task); + } + + return irq_handled; +} + + /* register queue irq handlers */ + vec = pf->hw.nix_msixoff + nix_lf_qint_vec_start; + irq_name = &pf->hw.irq_name[vec * name_size]; + + snprintf(irq_name, name_size, "%s-qerr", pf->netdev->name); + + err = request_irq(pci_irq_vector(pf->pdev, vec), + otx2_q_intr_handler, 0, irq_name, pf); + if (err) { + dev_err(pf->dev, + "rvupf%d: irq registration failed for qerr ", + rvu_get_pf(pf->pcifunc)); + goto err_disable_napi; + } + + /* enable qint irq */ + otx2_write64(pf, nix_lf_qintx_ena_w1s(0), bit_ull(0)); + + vec = pci_irq_vector(pf->pdev, + pf->hw.nix_msixoff + nix_lf_qint_vec_start); + otx2_write64(pf, nix_lf_qintx_ena_w1c(0), bit_ull(0)); + synchronize_irq(vec); + free_irq(vec, pf); - int qidx, vec; + int qidx, vec, wrk; + /* cleanup queue irq */ + vec = pci_irq_vector(pf->pdev, + pf->hw.nix_msixoff + nix_lf_qint_vec_start); + otx2_write64(pf, nix_lf_qintx_ena_w1c(0), bit_ull(0)); + synchronize_irq(vec); + free_irq(vec, pf); + + for (wrk = 0; wrk < pf->qset.cq_cnt; wrk++) + cancel_delayed_work_sync(&pf->refill_wrk[wrk].pool_refill_work); + devm_kfree(pf->dev, pf->refill_wrk); + +static void otx2_reset_task(struct work_struct *work) +{ + struct otx2_nic *pf = container_of(work, struct otx2_nic, reset_task); + + if (!netif_running(pf->netdev)) + return; + + otx2_stop(pf->netdev); + pf->reset_count++; + otx2_open(pf->netdev); + netif_trans_update(pf->netdev); +} + + .ndo_tx_timeout = otx2_tx_timeout, + netdev->watchdog_timeo = otx2_tx_timeout; + + init_work(&pf->reset_task, otx2_reset_task); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_struct.h +enum nix_cqerrint_e { + nix_cqerrint_door_err = 0, + nix_cqerrint_wr_full = 1, + nix_cqerrint_cqe_fault = 2, +}; + +#define nix_cqerrint_bits (bit_ull(nix_cqerrint_door_err) | \ + bit_ull(nix_cqerrint_cqe_fault)) + +enum nix_rqint_e { + nix_rqint_drop = 0, + nix_rqint_red = 1, +}; + +#define nix_rqint_bits (bit_ull(nix_rqint_drop) | bit_ull(nix_rqint_red)) + +enum nix_sqint_e { + nix_sqint_lmt_err = 0, + nix_sqint_mnq_err = 1, + nix_sqint_send_err = 2, + nix_sqint_sqb_alloc_fail = 3, +}; + +#define nix_sqint_bits (bit_ull(nix_sqint_lmt_err) | \ + bit_ull(nix_sqint_mnq_err) | \ + bit_ull(nix_sqint_send_err) | \ + bit_ull(nix_sqint_sqb_alloc_fail)) + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c - if (unlikely(bufptr <= 0)) + if (unlikely(bufptr <= 0)) { + struct refill_work *work; + struct delayed_work *dwork; + + work = &pfvf->refill_wrk[cq->cq_idx]; + dwork = &work->pool_refill_work; + /* schedule a task if no other task is running */ + if (!cq->refill_task_sched) { + cq->refill_task_sched = true; + schedule_delayed_work(dwork, + msecs_to_jiffies(100)); + } + } - otx2_get_page(cq->rbpool); + /* if the rq refill wq task is running, skip napi + * scheduler for this queue. + */ + if (cq->refill_task_sched) + continue; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h + u8 refill_task_sched;
|
Networking
|
4ff7d1488a8496fddcfdf40c42489eaa64892f3e
|
geetha sowjanya
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: receive side scaling support
|
adds receive side scaling (rss) support to distribute pkts/flows across multiple queues. sets up key, indirection table etc. also added extraction of hw calculated rxhash and adding to same to skb ie netif_f_rxhash offload support.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 4
| 167
| 1
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +static int otx2_set_flowkey_cfg(struct otx2_nic *pfvf) +{ + struct otx2_rss_info *rss = &pfvf->hw.rss_info; + struct nix_rss_flowkey_cfg *req; + int err; + + otx2_mbox_lock(&pfvf->mbox); + req = otx2_mbox_alloc_msg_nix_rss_flowkey_cfg(&pfvf->mbox); + if (!req) { + otx2_mbox_unlock(&pfvf->mbox); + return -enomem; + } + req->mcam_index = -1; /* default or reserved index */ + req->flowkey_cfg = rss->flowkey_cfg; + req->group = default_rss_context_group; + + err = otx2_sync_mbox_msg(&pfvf->mbox); + otx2_mbox_unlock(&pfvf->mbox); + return err; +} + +static int otx2_set_rss_table(struct otx2_nic *pfvf) +{ + struct otx2_rss_info *rss = &pfvf->hw.rss_info; + struct mbox *mbox = &pfvf->mbox; + struct nix_aq_enq_req *aq; + int idx, err; + + otx2_mbox_lock(mbox); + /* get memory to put this msg */ + for (idx = 0; idx < rss->rss_size; idx++) { + aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox); + if (!aq) { + /* the shared memory buffer can be full. + * flush it and retry + */ + err = otx2_sync_mbox_msg(mbox); + if (err) { + otx2_mbox_unlock(mbox); + return err; + } + aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox); + if (!aq) { + otx2_mbox_unlock(mbox); + return -enomem; + } + } + + aq->rss.rq = rss->ind_tbl[idx]; + + /* fill aq info */ + aq->qidx = idx; + aq->ctype = nix_aq_ctype_rss; + aq->op = nix_aq_instop_init; + } + err = otx2_sync_mbox_msg(mbox); + otx2_mbox_unlock(mbox); + return err; +} + +static void otx2_set_rss_key(struct otx2_nic *pfvf) +{ + struct otx2_rss_info *rss = &pfvf->hw.rss_info; + u64 *key = (u64 *)&rss->key[4]; + int idx; + + /* 352bit or 44byte key needs to be configured as below + * nix_lf_rx_secretx0 = key<351:288> + * nix_lf_rx_secretx1 = key<287:224> + * nix_lf_rx_secretx2 = key<223:160> + * nix_lf_rx_secretx3 = key<159:96> + * nix_lf_rx_secretx4 = key<95:32> + * nix_lf_rx_secretx5<63:32> = key<31:0> + */ + otx2_write64(pfvf, nix_lf_rx_secretx(5), + (u64)(*((u32 *)&rss->key)) << 32); + idx = sizeof(rss->key) / sizeof(u64); + while (idx > 0) { + idx--; + otx2_write64(pfvf, nix_lf_rx_secretx(idx), *key++); + } +} + +int otx2_rss_init(struct otx2_nic *pfvf) +{ + struct otx2_rss_info *rss = &pfvf->hw.rss_info; + int idx, ret = 0; + + rss->rss_size = sizeof(rss->ind_tbl); + + /* init rss key if it is not setup already */ + if (!rss->enable) + netdev_rss_key_fill(rss->key, sizeof(rss->key)); + otx2_set_rss_key(pfvf); + + if (!netif_is_rxfh_configured(pfvf->netdev)) { + /* default indirection table */ + for (idx = 0; idx < rss->rss_size; idx++) + rss->ind_tbl[idx] = + ethtool_rxfh_indir_default(idx, + pfvf->hw.rx_queues); + } + ret = otx2_set_rss_table(pfvf); + if (ret) + return ret; + + /* flowkey or hash config to be used for generating flow tag */ + rss->flowkey_cfg = rss->enable ? rss->flowkey_cfg : + nix_flow_key_type_ipv4 | nix_flow_key_type_ipv6 | + nix_flow_key_type_tcp | nix_flow_key_type_udp | + nix_flow_key_type_sctp; + + ret = otx2_set_flowkey_cfg(pfvf); + if (ret) + return ret; + + rss->enable = true; + return 0; +} + + nixlf->rss_sz = max_rss_indir_tbl_size; + nixlf->rss_grps = 1; /* single rss indir table supported, for now */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +/* rss configuration */ +struct otx2_rss_info { + u8 enable; + u32 flowkey_cfg; + u16 rss_size; + u8 ind_tbl[max_rss_indir_tbl_size]; +#define rss_hash_key_size 44 /* 352 bit key */ + u8 key[rss_hash_key_size]; +}; + + struct otx2_rss_info rss_info; +/* rss configuration apis*/ +int otx2_rss_init(struct otx2_nic *pfvf); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + /* initialize rss */ + err = otx2_rss_init(pf); + if (err) + goto err_disable_napi; + - netif_f_ipv6_csum | netif_f_sg); + netif_f_ipv6_csum | netif_f_rxhash | + netif_f_sg); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +static void otx2_set_rxhash(struct otx2_nic *pfvf, + struct nix_cqe_rx_s *cqe, struct sk_buff *skb) +{ + enum pkt_hash_types hash_type = pkt_hash_type_none; + struct otx2_rss_info *rss; + u32 hash = 0; + + if (!(pfvf->netdev->features & netif_f_rxhash)) + return; + + rss = &pfvf->hw.rss_info; + if (rss->flowkey_cfg) { + if (rss->flowkey_cfg & + ~(nix_flow_key_type_ipv4 | nix_flow_key_type_ipv6)) + hash_type = pkt_hash_type_l4; + else + hash_type = pkt_hash_type_l3; + hash = cqe->hdr.flow_tag; + } + skb_set_hash(skb, hash, hash_type); +} + + otx2_set_rxhash(pfvf, cqe, skb); +
|
Networking
|
85069e95e53161f8bcc1aa266f47c60c1f3e4ec3
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: tcp segmentation offload support
|
adds tcp segmentation offload (tso) support. first version of the silicon didn't support tso offload, for this driver level tso support is added.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 5
| 273
| 4
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +#include <net/tso.h> + err = qmem_alloc(pfvf->dev, &sq->tso_hdrs, qset->sqe_cnt, + tso_header_size); + if (err) + return err; + + pfvf->hw.lso_tsov4_idx = rsp->lso_tsov4_idx; + pfvf->hw.lso_tsov6_idx = rsp->lso_tsov6_idx; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h + /* for tso segmentation */ + u8 lso_tsov4_idx; + u8 lso_tsov6_idx; + u8 hw_tso; + + struct otx2_hw *hw = &pfvf->hw; + + hw->hw_tso = true; + + hw->hw_tso = false; + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + qmem_free(pf->dev, sq->tso_hdrs); - /* check for minimum packet length */ - if (skb->len <= eth_hlen) { + /* check for minimum and maximum packet length */ + if (skb->len <= eth_hlen || + (!skb_shinfo(skb)->gso_size && skb->len > pf->max_frs)) { - netif_f_sg); + netif_f_sg | netif_f_tso | netif_f_tso6); + netdev->gso_max_segs = otx2_max_gso_segs; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +#include <net/tso.h> +/* add sqe extended header subdescriptor */ +static void otx2_sqe_add_ext(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, + struct sk_buff *skb, int *offset) +{ + struct nix_sqe_ext_s *ext; + + ext = (struct nix_sqe_ext_s *)(sq->sqe_base + *offset); + ext->subdc = nix_subdc_ext; + if (skb_shinfo(skb)->gso_size) { + ext->lso = 1; + ext->lso_sb = skb_transport_offset(skb) + tcp_hdrlen(skb); + ext->lso_mps = skb_shinfo(skb)->gso_size; + + /* only tsov4 and tsov6 gso offloads are supported */ + if (skb_shinfo(skb)->gso_type & skb_gso_tcpv4) { + ext->lso_format = pfvf->hw.lso_tsov4_idx; + + /* hw adds payload size to 'ip_hdr->tot_len' while + * sending tso segment, hence set payload length + * in ip header of the packet to just header length. + */ + ip_hdr(skb)->tot_len = + htons(ext->lso_sb - skb_network_offset(skb)); + } else { + ext->lso_format = pfvf->hw.lso_tsov6_idx; + ipv6_hdr(skb)->payload_len = + htons(ext->lso_sb - skb_network_offset(skb)); + } + } + *offset += sizeof(*ext); +} + +static int otx2_dma_map_tso_skb(struct otx2_nic *pfvf, + struct otx2_snd_queue *sq, + struct sk_buff *skb, int sqe, int hdr_len) +{ + int num_segs = skb_shinfo(skb)->nr_frags + 1; + struct sg_list *sg = &sq->sg[sqe]; + u64 dma_addr; + int seg, len; + + sg->num_segs = 0; + + /* get payload length at skb->data */ + len = skb_headlen(skb) - hdr_len; + + for (seg = 0; seg < num_segs; seg++) { + /* skip skb->data, if there is no payload */ + if (!seg && !len) + continue; + dma_addr = otx2_dma_map_skb_frag(pfvf, skb, seg, &len); + if (dma_mapping_error(pfvf->dev, dma_addr)) + goto unmap; + + /* save dma mapping info for later unmapping */ + sg->dma_addr[sg->num_segs] = dma_addr; + sg->size[sg->num_segs] = len; + sg->num_segs++; + } + return 0; +unmap: + otx2_dma_unmap_skb_frags(pfvf, sg); + return -einval; +} + +static u64 otx2_tso_frag_dma_addr(struct otx2_snd_queue *sq, + struct sk_buff *skb, int seg, + u64 seg_addr, int hdr_len, int sqe) +{ + struct sg_list *sg = &sq->sg[sqe]; + const skb_frag_t *frag; + int offset; + + if (seg < 0) + return sg->dma_addr[0] + (seg_addr - (u64)skb->data); + + frag = &skb_shinfo(skb)->frags[seg]; + offset = seg_addr - (u64)skb_frag_address(frag); + if (skb_headlen(skb) - hdr_len) + seg++; + return sg->dma_addr[seg] + offset; +} + +static void otx2_sqe_tso_add_sg(struct otx2_snd_queue *sq, + struct sg_list *list, int *offset) +{ + struct nix_sqe_sg_s *sg = null; + u16 *sg_lens = null; + u64 *iova = null; + int seg; + + /* add sg descriptors with buffer addresses */ + for (seg = 0; seg < list->num_segs; seg++) { + if ((seg % max_segs_per_sg) == 0) { + sg = (struct nix_sqe_sg_s *)(sq->sqe_base + *offset); + sg->ld_type = nix_send_ldtype_ldd; + sg->subdc = nix_subdc_sg; + sg->segs = 0; + sg_lens = (void *)sg; + iova = (void *)sg + sizeof(*sg); + /* next subdc always starts at a 16byte boundary. + * so if sg->segs is whether 2 or 3, offset += 16bytes. + */ + if ((list->num_segs - seg) >= (max_segs_per_sg - 1)) + *offset += sizeof(*sg) + (3 * sizeof(u64)); + else + *offset += sizeof(*sg) + sizeof(u64); + } + sg_lens[frag_num(seg % max_segs_per_sg)] = list->size[seg]; + *iova++ = list->dma_addr[seg]; + sg->segs++; + } +} + +static void otx2_sq_append_tso(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, + struct sk_buff *skb, u16 qidx) +{ + struct netdev_queue *txq = netdev_get_tx_queue(pfvf->netdev, qidx); + int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); + int tcp_data, seg_len, pkt_len, offset; + struct nix_sqe_hdr_s *sqe_hdr; + int first_sqe = sq->head; + struct sg_list list; + struct tso_t tso; + + /* map skb's fragments to dma. + * it's done here to avoid mapping for every tso segment's packet. + */ + if (otx2_dma_map_tso_skb(pfvf, sq, skb, first_sqe, hdr_len)) { + dev_kfree_skb_any(skb); + return; + } + + netdev_tx_sent_queue(txq, skb->len); + + tso_start(skb, &tso); + tcp_data = skb->len - hdr_len; + while (tcp_data > 0) { + char *hdr; + + seg_len = min_t(int, skb_shinfo(skb)->gso_size, tcp_data); + tcp_data -= seg_len; + + /* set sqe's send_hdr */ + memset(sq->sqe_base, 0, sq->sqe_size); + sqe_hdr = (struct nix_sqe_hdr_s *)(sq->sqe_base); + otx2_sqe_add_hdr(pfvf, sq, sqe_hdr, skb, qidx); + offset = sizeof(*sqe_hdr); + + /* add tso segment's pkt header */ + hdr = sq->tso_hdrs->base + (sq->head * tso_header_size); + tso_build_hdr(skb, hdr, &tso, seg_len, tcp_data == 0); + list.dma_addr[0] = + sq->tso_hdrs->iova + (sq->head * tso_header_size); + list.size[0] = hdr_len; + list.num_segs = 1; + + /* add tso segment's payload data fragments */ + pkt_len = hdr_len; + while (seg_len > 0) { + int size; + + size = min_t(int, tso.size, seg_len); + + list.size[list.num_segs] = size; + list.dma_addr[list.num_segs] = + otx2_tso_frag_dma_addr(sq, skb, + tso.next_frag_idx - 1, + (u64)tso.data, hdr_len, + first_sqe); + list.num_segs++; + pkt_len += size; + seg_len -= size; + tso_build_data(skb, &tso, size); + } + sqe_hdr->total = pkt_len; + otx2_sqe_tso_add_sg(sq, &list, &offset); + + /* dma mappings and skb needs to be freed only after last + * tso segment is transmitted out. so set 'pnc' only for + * last segment. also point last segment's sqe_id to first + * segment's sqe index where skb address and dma mappings + * are saved. + */ + if (!tcp_data) { + sqe_hdr->pnc = 1; + sqe_hdr->sqe_id = first_sqe; + sq->sg[first_sqe].skb = (u64)skb; + } else { + sqe_hdr->pnc = 0; + } + + sqe_hdr->sizem1 = (offset / 16) - 1; + + /* flush sqe to hw */ + otx2_sqe_flush(sq, offset); + } +} + +static bool is_hw_tso_supported(struct otx2_nic *pfvf, + struct sk_buff *skb) +{ + int payload_len, last_seg_size; + + if (!pfvf->hw.hw_tso) + return false; + + /* hw has an issue due to which when the payload of the last lso + * segment is shorter than 16 bytes, some header fields may not + * be correctly modified, hence don't offload such tso segments. + */ + if (!is_96xx_b0(pfvf->pdev)) + return true; + + payload_len = skb->len - (skb_transport_offset(skb) + tcp_hdrlen(skb)); + last_seg_size = payload_len % skb_shinfo(skb)->gso_size; + if (last_seg_size && last_seg_size < 16) + return false; + + return true; +} + +static int otx2_get_sqe_count(struct otx2_nic *pfvf, struct sk_buff *skb) +{ + if (!skb_shinfo(skb)->gso_size) + return 1; + + /* hw tso */ + if (is_hw_tso_supported(pfvf, skb)) + return 1; + + /* sw tso */ + return skb_shinfo(skb)->gso_segs; +} + - if (!free_sqe || free_sqe < sq->sqe_thresh) + if (free_sqe < sq->sqe_thresh || + free_sqe < otx2_get_sqe_count(pfvf, skb)) + if (skb_shinfo(skb)->gso_size && !is_hw_tso_supported(pfvf, skb)) { + otx2_sq_append_tso(pfvf, sq, skb, qidx); + return true; + } + + /* add extended header if needed */ + otx2_sqe_add_ext(pfvf, sq, skb, &offset); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +#define otx2_max_gso_segs 255 + struct qmem *tso_hdrs;
|
Networking
|
86d7476078b87874ce5dee39cbbd094055c73d49
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: add ndo_get_stats64
|
added ndo_get_stats64 which returns stats maintained by hw.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 3
| 97
| 0
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +void otx2_get_dev_stats(struct otx2_nic *pfvf) +{ + struct otx2_dev_stats *dev_stats = &pfvf->hw.dev_stats; + +#define otx2_get_rx_stats(reg) \ + otx2_read64(pfvf, nix_lf_rx_statx(reg)) +#define otx2_get_tx_stats(reg) \ + otx2_read64(pfvf, nix_lf_tx_statx(reg)) + + dev_stats->rx_bytes = otx2_get_rx_stats(rx_octs); + dev_stats->rx_drops = otx2_get_rx_stats(rx_drop); + dev_stats->rx_bcast_frames = otx2_get_rx_stats(rx_bcast); + dev_stats->rx_mcast_frames = otx2_get_rx_stats(rx_mcast); + dev_stats->rx_ucast_frames = otx2_get_rx_stats(rx_ucast); + dev_stats->rx_frames = dev_stats->rx_bcast_frames + + dev_stats->rx_mcast_frames + + dev_stats->rx_ucast_frames; + + dev_stats->tx_bytes = otx2_get_tx_stats(tx_octs); + dev_stats->tx_drops = otx2_get_tx_stats(tx_drop); + dev_stats->tx_bcast_frames = otx2_get_tx_stats(tx_bcast); + dev_stats->tx_mcast_frames = otx2_get_tx_stats(tx_mcast); + dev_stats->tx_ucast_frames = otx2_get_tx_stats(tx_ucast); + dev_stats->tx_frames = dev_stats->tx_bcast_frames + + dev_stats->tx_mcast_frames + + dev_stats->tx_ucast_frames; +} + +void otx2_get_stats64(struct net_device *netdev, + struct rtnl_link_stats64 *stats) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct otx2_dev_stats *dev_stats; + + otx2_get_dev_stats(pfvf); + + dev_stats = &pfvf->hw.dev_stats; + stats->rx_bytes = dev_stats->rx_bytes; + stats->rx_packets = dev_stats->rx_frames; + stats->rx_dropped = dev_stats->rx_drops; + stats->multicast = dev_stats->rx_mcast_frames; + + stats->tx_bytes = dev_stats->tx_bytes; + stats->tx_packets = dev_stats->tx_frames; + stats->tx_dropped = dev_stats->tx_drops; +} + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +/* nix tx stats */ +enum nix_stat_lf_tx { + tx_ucast = 0x0, + tx_bcast = 0x1, + tx_mcast = 0x2, + tx_drop = 0x3, + tx_octs = 0x4, + tx_stats_enum_last, +}; + +/* nix rx stats */ +enum nix_stat_lf_rx { + rx_octs = 0x0, + rx_ucast = 0x1, + rx_bcast = 0x2, + rx_mcast = 0x3, + rx_drop = 0x4, + rx_drop_octs = 0x5, + rx_fcs = 0x6, + rx_err = 0x7, + rx_drp_bcast = 0x8, + rx_drp_mcast = 0x9, + rx_drp_l3bcast = 0xa, + rx_drp_l3mcast = 0xb, + rx_stats_enum_last, +}; + +struct otx2_dev_stats { + u64 rx_bytes; + u64 rx_frames; + u64 rx_ucast_frames; + u64 rx_bcast_frames; + u64 rx_mcast_frames; + u64 rx_drops; + + u64 tx_bytes; + u64 tx_frames; + u64 tx_ucast_frames; + u64 tx_bcast_frames; + u64 tx_mcast_frames; + u64 tx_drops; +}; + + struct otx2_dev_stats dev_stats; +/* device stats apis */ +void otx2_get_dev_stats(struct otx2_nic *pfvf); +void otx2_get_stats64(struct net_device *netdev, + struct rtnl_link_stats64 *stats); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + .ndo_get_stats64 = otx2_get_stats64,
|
Networking
|
e239d0c78c42e49558ea2c0e5857c4f9ca064f48
|
geetha sowjanya
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: add basic ethtool support
|
this patch adds ethtool support for - driver stats, tx/rx perqueue and cgx lmac stats - set/show rx/tx queue count - set/show rx/tx ring sizes - set/show irq coalescing parameters
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'makefile', 'h']
| 6
| 525
| 4
|
- driver stats, tx/rx perqueue and cgx lmac stats - set/show rx/tx queue count - set/show rx/tx ring sizes - set/show irq coalescing parameters --- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/makefile b/drivers/net/ethernet/marvell/octeontx2/nic/makefile --- a/drivers/net/ethernet/marvell/octeontx2/nic/makefile +++ b/drivers/net/ethernet/marvell/octeontx2/nic/makefile -octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o +octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +static void otx2_nix_rq_op_stats(struct queue_stats *stats, + struct otx2_nic *pfvf, int qidx) +{ + u64 incr = (u64)qidx << 32; + u64 *ptr; + + ptr = (u64 *)otx2_get_regaddr(pfvf, nix_lf_rq_op_octs); + stats->bytes = otx2_atomic64_add(incr, ptr); + + ptr = (u64 *)otx2_get_regaddr(pfvf, nix_lf_rq_op_pkts); + stats->pkts = otx2_atomic64_add(incr, ptr); +} + +static void otx2_nix_sq_op_stats(struct queue_stats *stats, + struct otx2_nic *pfvf, int qidx) +{ + u64 incr = (u64)qidx << 32; + u64 *ptr; + + ptr = (u64 *)otx2_get_regaddr(pfvf, nix_lf_sq_op_octs); + stats->bytes = otx2_atomic64_add(incr, ptr); + + ptr = (u64 *)otx2_get_regaddr(pfvf, nix_lf_sq_op_pkts); + stats->pkts = otx2_atomic64_add(incr, ptr); +} + +void otx2_update_lmac_stats(struct otx2_nic *pfvf) +{ + struct msg_req *req; + + if (!netif_running(pfvf->netdev)) + return; + + otx2_mbox_lock(&pfvf->mbox); + req = otx2_mbox_alloc_msg_cgx_stats(&pfvf->mbox); + if (!req) { + otx2_mbox_unlock(&pfvf->mbox); + return; + } + + otx2_sync_mbox_msg(&pfvf->mbox); + otx2_mbox_unlock(&pfvf->mbox); +} + +int otx2_update_rq_stats(struct otx2_nic *pfvf, int qidx) +{ + struct otx2_rcv_queue *rq = &pfvf->qset.rq[qidx]; + + if (!pfvf->qset.rq) + return 0; + + otx2_nix_rq_op_stats(&rq->stats, pfvf, qidx); + return 1; +} + +int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx) +{ + struct otx2_snd_queue *sq = &pfvf->qset.sq[qidx]; + + if (!pfvf->qset.sq) + return 0; + + otx2_nix_sq_op_stats(&sq->stats, pfvf, qidx); + return 1; +} + + sq->stats.bytes = 0; + sq->stats.pkts = 0; + +/* mbox message handlers */ +void mbox_handler_cgx_stats(struct otx2_nic *pfvf, + struct cgx_stats_rsp *rsp) +{ + int id; + + for (id = 0; id < cgx_rx_stats_count; id++) + pfvf->hw.cgx_rx_stats[id] = rsp->rx_stats[id]; + for (id = 0; id < cgx_tx_stats_count; id++) + pfvf->hw.cgx_tx_stats[id] = rsp->tx_stats[id]; +} + -/* mbox message handlers */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h + u64 cgx_rx_stats[cgx_rx_stats_count]; + u64 cgx_tx_stats[cgx_tx_stats_count]; +void mbox_handler_cgx_stats(struct otx2_nic *pfvf, + struct cgx_stats_rsp *rsp); +void otx2_update_lmac_stats(struct otx2_nic *pfvf); +int otx2_update_rq_stats(struct otx2_nic *pfvf, int qidx); +int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx); +void otx2_set_ethtool_ops(struct net_device *netdev); +int otx2_set_real_num_queues(struct net_device *netdev, + int tx_queues, int rx_queues); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c --- /dev/null +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +// spdx-license-identifier: gpl-2.0 +/* marvell octeontx2 rvu ethernet driver + * + * copyright (c) 2020 marvell international ltd. + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of the gnu general public license version 2 as + * published by the free software foundation. + */ + +#include <linux/pci.h> +#include <linux/ethtool.h> +#include <linux/stddef.h> +#include <linux/etherdevice.h> +#include <linux/log2.h> + +#include "otx2_common.h" + +#define drv_name "octeontx2-nicpf" + +struct otx2_stat { + char name[eth_gstring_len]; + unsigned int index; +}; + +/* hw device stats */ +#define otx2_dev_stat(stat) { \ + .name = #stat, \ + .index = offsetof(struct otx2_dev_stats, stat) / sizeof(u64), \ +} + +static const struct otx2_stat otx2_dev_stats[] = { + otx2_dev_stat(rx_ucast_frames), + otx2_dev_stat(rx_bcast_frames), + otx2_dev_stat(rx_mcast_frames), + + otx2_dev_stat(tx_ucast_frames), + otx2_dev_stat(tx_bcast_frames), + otx2_dev_stat(tx_mcast_frames), +}; + +/* driver level stats */ +#define otx2_drv_stat(stat) { \ + .name = #stat, \ + .index = offsetof(struct otx2_drv_stats, stat) / sizeof(atomic_t), \ +} + +static const struct otx2_stat otx2_drv_stats[] = { + otx2_drv_stat(rx_fcs_errs), + otx2_drv_stat(rx_oversize_errs), + otx2_drv_stat(rx_undersize_errs), + otx2_drv_stat(rx_csum_errs), + otx2_drv_stat(rx_len_errs), + otx2_drv_stat(rx_other_errs), +}; + +static const struct otx2_stat otx2_queue_stats[] = { + { "bytes", 0 }, + { "frames", 1 }, +}; + +static const unsigned int otx2_n_dev_stats = array_size(otx2_dev_stats); +static const unsigned int otx2_n_drv_stats = array_size(otx2_drv_stats); +static const unsigned int otx2_n_queue_stats = array_size(otx2_queue_stats); + +static void otx2_dev_open(struct net_device *netdev) +{ + otx2_open(netdev); +} + +static void otx2_dev_stop(struct net_device *netdev) +{ + otx2_stop(netdev); +} + +static void otx2_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *info) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + + strlcpy(info->driver, drv_name, sizeof(info->driver)); + strlcpy(info->bus_info, pci_name(pfvf->pdev), sizeof(info->bus_info)); +} + +static void otx2_get_qset_strings(struct otx2_nic *pfvf, u8 **data, int qset) +{ + int start_qidx = qset * pfvf->hw.rx_queues; + int qidx, stats; + + for (qidx = 0; qidx < pfvf->hw.rx_queues; qidx++) { + for (stats = 0; stats < otx2_n_queue_stats; stats++) { + sprintf(*data, "rxq%d: %s", qidx + start_qidx, + otx2_queue_stats[stats].name); + *data += eth_gstring_len; + } + } + for (qidx = 0; qidx < pfvf->hw.tx_queues; qidx++) { + for (stats = 0; stats < otx2_n_queue_stats; stats++) { + sprintf(*data, "txq%d: %s", qidx + start_qidx, + otx2_queue_stats[stats].name); + *data += eth_gstring_len; + } + } +} + +static void otx2_get_strings(struct net_device *netdev, u32 sset, u8 *data) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + int stats; + + if (sset != eth_ss_stats) + return; + + for (stats = 0; stats < otx2_n_dev_stats; stats++) { + memcpy(data, otx2_dev_stats[stats].name, eth_gstring_len); + data += eth_gstring_len; + } + + for (stats = 0; stats < otx2_n_drv_stats; stats++) { + memcpy(data, otx2_drv_stats[stats].name, eth_gstring_len); + data += eth_gstring_len; + } + + otx2_get_qset_strings(pfvf, &data, 0); + + for (stats = 0; stats < cgx_rx_stats_count; stats++) { + sprintf(data, "cgx_rxstat%d: ", stats); + data += eth_gstring_len; + } + + for (stats = 0; stats < cgx_tx_stats_count; stats++) { + sprintf(data, "cgx_txstat%d: ", stats); + data += eth_gstring_len; + } + + strcpy(data, "reset_count"); + data += eth_gstring_len; +} + +static void otx2_get_qset_stats(struct otx2_nic *pfvf, + struct ethtool_stats *stats, u64 **data) +{ + int stat, qidx; + + if (!pfvf) + return; + for (qidx = 0; qidx < pfvf->hw.rx_queues; qidx++) { + if (!otx2_update_rq_stats(pfvf, qidx)) { + for (stat = 0; stat < otx2_n_queue_stats; stat++) + *((*data)++) = 0; + continue; + } + for (stat = 0; stat < otx2_n_queue_stats; stat++) + *((*data)++) = ((u64 *)&pfvf->qset.rq[qidx].stats) + [otx2_queue_stats[stat].index]; + } + + for (qidx = 0; qidx < pfvf->hw.tx_queues; qidx++) { + if (!otx2_update_sq_stats(pfvf, qidx)) { + for (stat = 0; stat < otx2_n_queue_stats; stat++) + *((*data)++) = 0; + continue; + } + for (stat = 0; stat < otx2_n_queue_stats; stat++) + *((*data)++) = ((u64 *)&pfvf->qset.sq[qidx].stats) + [otx2_queue_stats[stat].index]; + } +} + +/* get device and per queue statistics */ +static void otx2_get_ethtool_stats(struct net_device *netdev, + struct ethtool_stats *stats, u64 *data) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + int stat; + + otx2_get_dev_stats(pfvf); + for (stat = 0; stat < otx2_n_dev_stats; stat++) + *(data++) = ((u64 *)&pfvf->hw.dev_stats) + [otx2_dev_stats[stat].index]; + + for (stat = 0; stat < otx2_n_drv_stats; stat++) + *(data++) = atomic_read(&((atomic_t *)&pfvf->hw.drv_stats) + [otx2_drv_stats[stat].index]); + + otx2_get_qset_stats(pfvf, stats, &data); + otx2_update_lmac_stats(pfvf); + for (stat = 0; stat < cgx_rx_stats_count; stat++) + *(data++) = pfvf->hw.cgx_rx_stats[stat]; + for (stat = 0; stat < cgx_tx_stats_count; stat++) + *(data++) = pfvf->hw.cgx_tx_stats[stat]; + *(data++) = pfvf->reset_count; +} + +static int otx2_get_sset_count(struct net_device *netdev, int sset) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + int qstats_count; + + if (sset != eth_ss_stats) + return -einval; + + qstats_count = otx2_n_queue_stats * + (pfvf->hw.rx_queues + pfvf->hw.tx_queues); + + return otx2_n_dev_stats + otx2_n_drv_stats + qstats_count + + cgx_rx_stats_count + cgx_tx_stats_count + 1; +} + +/* get no of queues device supports and current queue count */ +static void otx2_get_channels(struct net_device *dev, + struct ethtool_channels *channel) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + + channel->max_rx = pfvf->hw.max_queues; + channel->max_tx = pfvf->hw.max_queues; + + channel->rx_count = pfvf->hw.rx_queues; + channel->tx_count = pfvf->hw.tx_queues; +} + +/* set no of tx, rx queues to be used */ +static int otx2_set_channels(struct net_device *dev, + struct ethtool_channels *channel) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + bool if_up = netif_running(dev); + int err = 0; + + if (!channel->rx_count || !channel->tx_count) + return -einval; + + if (if_up) + otx2_dev_stop(dev); + + err = otx2_set_real_num_queues(dev, channel->tx_count, + channel->rx_count); + if (err) + goto fail; + + pfvf->hw.rx_queues = channel->rx_count; + pfvf->hw.tx_queues = channel->tx_count; + pfvf->qset.cq_cnt = pfvf->hw.tx_queues + pfvf->hw.rx_queues; + +fail: + if (if_up) + otx2_dev_open(dev); + + netdev_info(dev, "setting num tx rings to %d, rx rings to %d success ", + pfvf->hw.tx_queues, pfvf->hw.rx_queues); + + return err; +} + +static void otx2_get_ringparam(struct net_device *netdev, + struct ethtool_ringparam *ring) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct otx2_qset *qs = &pfvf->qset; + + ring->rx_max_pending = q_count(q_size_max); + ring->rx_pending = qs->rqe_cnt ? qs->rqe_cnt : q_count(q_size_256); + ring->tx_max_pending = q_count(q_size_max); + ring->tx_pending = qs->sqe_cnt ? qs->sqe_cnt : q_count(q_size_4k); +} + +static int otx2_set_ringparam(struct net_device *netdev, + struct ethtool_ringparam *ring) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + bool if_up = netif_running(netdev); + struct otx2_qset *qs = &pfvf->qset; + u32 rx_count, tx_count; + + if (ring->rx_mini_pending || ring->rx_jumbo_pending) + return -einval; + + /* permitted lengths are 16 64 256 1k 4k 16k 64k 256k 1m */ + rx_count = ring->rx_pending; + /* on some silicon variants a skid or reserved cqes are + * needed to avoid cq overflow. + */ + if (rx_count < pfvf->hw.rq_skid) + rx_count = pfvf->hw.rq_skid; + rx_count = q_count(q_size(rx_count, 3)); + + /* due pipelining impact minimum 2000 unused sq cqe's + * need to be maintained to avoid cq overflow, hence the + * minimum 4k size. + */ + tx_count = clamp_t(u32, ring->tx_pending, + q_count(q_size_4k), q_count(q_size_max)); + tx_count = q_count(q_size(tx_count, 3)); + + if (tx_count == qs->sqe_cnt && rx_count == qs->rqe_cnt) + return 0; + + if (if_up) + otx2_dev_stop(netdev); + + /* assigned to the nearest possible exponent. */ + qs->sqe_cnt = tx_count; + qs->rqe_cnt = rx_count; + + if (if_up) + otx2_dev_open(netdev); + return 0; +} + +static int otx2_get_coalesce(struct net_device *netdev, + struct ethtool_coalesce *cmd) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct otx2_hw *hw = &pfvf->hw; + + cmd->rx_coalesce_usecs = hw->cq_time_wait; + cmd->rx_max_coalesced_frames = hw->cq_ecount_wait; + cmd->tx_coalesce_usecs = hw->cq_time_wait; + cmd->tx_max_coalesced_frames = hw->cq_ecount_wait; + + return 0; +} + +static int otx2_set_coalesce(struct net_device *netdev, + struct ethtool_coalesce *ec) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct otx2_hw *hw = &pfvf->hw; + int qidx; + + if (ec->use_adaptive_rx_coalesce || ec->use_adaptive_tx_coalesce || + ec->rx_coalesce_usecs_irq || ec->rx_max_coalesced_frames_irq || + ec->tx_coalesce_usecs_irq || ec->tx_max_coalesced_frames_irq || + ec->stats_block_coalesce_usecs || ec->pkt_rate_low || + ec->rx_coalesce_usecs_low || ec->rx_max_coalesced_frames_low || + ec->tx_coalesce_usecs_low || ec->tx_max_coalesced_frames_low || + ec->pkt_rate_high || ec->rx_coalesce_usecs_high || + ec->rx_max_coalesced_frames_high || ec->tx_coalesce_usecs_high || + ec->tx_max_coalesced_frames_high || ec->rate_sample_interval) + return -eopnotsupp; + + if (!ec->rx_max_coalesced_frames || !ec->tx_max_coalesced_frames) + return 0; + + /* 'cq_time_wait' is 8bit and is in multiple of 100ns, + * so clamp the user given value to the range of 1 to 25usec. + */ + ec->rx_coalesce_usecs = clamp_t(u32, ec->rx_coalesce_usecs, + 1, cq_timer_thresh_max); + ec->tx_coalesce_usecs = clamp_t(u32, ec->tx_coalesce_usecs, + 1, cq_timer_thresh_max); + + /* rx and tx are mapped to same cq, check which one + * is changed, if both then choose the min. + */ + if (hw->cq_time_wait == ec->rx_coalesce_usecs) + hw->cq_time_wait = ec->tx_coalesce_usecs; + else if (hw->cq_time_wait == ec->tx_coalesce_usecs) + hw->cq_time_wait = ec->rx_coalesce_usecs; + else + hw->cq_time_wait = min_t(u8, ec->rx_coalesce_usecs, + ec->tx_coalesce_usecs); + + /* max ecount_wait supported is 16bit, + * so clamp the user given value to the range of 1 to 64k. + */ + ec->rx_max_coalesced_frames = clamp_t(u32, ec->rx_max_coalesced_frames, + 1, u16_max); + ec->tx_max_coalesced_frames = clamp_t(u32, ec->tx_max_coalesced_frames, + 1, u16_max); + + /* rx and tx are mapped to same cq, check which one + * is changed, if both then choose the min. + */ + if (hw->cq_ecount_wait == ec->rx_max_coalesced_frames) + hw->cq_ecount_wait = ec->tx_max_coalesced_frames; + else if (hw->cq_ecount_wait == ec->tx_max_coalesced_frames) + hw->cq_ecount_wait = ec->rx_max_coalesced_frames; + else + hw->cq_ecount_wait = min_t(u16, ec->rx_max_coalesced_frames, + ec->tx_max_coalesced_frames); + + if (netif_running(netdev)) { + for (qidx = 0; qidx < pfvf->hw.cint_cnt; qidx++) + otx2_config_irq_coalescing(pfvf, qidx); + } + + return 0; +} + +static const struct ethtool_ops otx2_ethtool_ops = { + .get_drvinfo = otx2_get_drvinfo, + .get_strings = otx2_get_strings, + .get_ethtool_stats = otx2_get_ethtool_stats, + .get_sset_count = otx2_get_sset_count, + .set_channels = otx2_set_channels, + .get_channels = otx2_get_channels, + .get_ringparam = otx2_get_ringparam, + .set_ringparam = otx2_set_ringparam, + .get_coalesce = otx2_get_coalesce, + .set_coalesce = otx2_set_coalesce, +}; + +void otx2_set_ethtool_ops(struct net_device *netdev) +{ + netdev->ethtool_ops = &otx2_ethtool_ops; +} diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c + case mbox_msg_cgx_stats: + mbox_handler_cgx_stats(pf, (struct cgx_stats_rsp *)msg); + break; -static int otx2_set_real_num_queues(struct net_device *netdev, - int tx_queues, int rx_queues) +int otx2_set_real_num_queues(struct net_device *netdev, + int tx_queues, int rx_queues) + qset->rq = kcalloc(pf->hw.rx_queues, + sizeof(struct otx2_rcv_queue), gfp_kernel); + if (!qset->rq) + goto err_free_mem; + + kfree(qset->rq); + kfree(qset->rq); + otx2_set_ethtool_ops(netdev); + diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +struct queue_stats { + u64 bytes; + u64 pkts; +}; + +struct otx2_rcv_queue { + struct queue_stats stats; +}; + + struct queue_stats stats; + struct otx2_rcv_queue *rq;
|
Networking
|
d45d8979840d9c9ac93d3fe8cfc8e794b7228445
|
christina jacob
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
octeontx2-pf: ethtool rss config support
|
added support to show or configure rss hash key, indirection table, 2,4 tuple via ethtool. also added debug msg_level support to dump messages when hw reports errors in packet received or transmitted.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['c', 'h']
| 4
| 269
| 4
|
--- diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c -static int otx2_set_flowkey_cfg(struct otx2_nic *pfvf) +int otx2_set_flowkey_cfg(struct otx2_nic *pfvf) -static int otx2_set_rss_table(struct otx2_nic *pfvf) +int otx2_set_rss_table(struct otx2_nic *pfvf) -static void otx2_set_rss_key(struct otx2_nic *pfvf) +void otx2_set_rss_key(struct otx2_nic *pfvf) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h + /* ethtool stuff */ + u32 msg_enable; + +int otx2_set_flowkey_cfg(struct otx2_nic *pfvf); +void otx2_set_rss_key(struct otx2_nic *pfvf); +int otx2_set_rss_table(struct otx2_nic *pfvf); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +static int otx2_get_rss_hash_opts(struct otx2_nic *pfvf, + struct ethtool_rxnfc *nfc) +{ + struct otx2_rss_info *rss = &pfvf->hw.rss_info; + + if (!(rss->flowkey_cfg & + (nix_flow_key_type_ipv4 | nix_flow_key_type_ipv6))) + return 0; + + /* mimimum is ipv4 and ipv6, sip/dip */ + nfc->data = rxh_ip_src | rxh_ip_dst; + + switch (nfc->flow_type) { + case tcp_v4_flow: + case tcp_v6_flow: + if (rss->flowkey_cfg & nix_flow_key_type_tcp) + nfc->data |= rxh_l4_b_0_1 | rxh_l4_b_2_3; + break; + case udp_v4_flow: + case udp_v6_flow: + if (rss->flowkey_cfg & nix_flow_key_type_udp) + nfc->data |= rxh_l4_b_0_1 | rxh_l4_b_2_3; + break; + case sctp_v4_flow: + case sctp_v6_flow: + if (rss->flowkey_cfg & nix_flow_key_type_sctp) + nfc->data |= rxh_l4_b_0_1 | rxh_l4_b_2_3; + break; + case ah_esp_v4_flow: + case ah_v4_flow: + case esp_v4_flow: + case ipv4_flow: + case ah_esp_v6_flow: + case ah_v6_flow: + case esp_v6_flow: + case ipv6_flow: + break; + default: + return -einval; + } + return 0; +} + +static int otx2_set_rss_hash_opts(struct otx2_nic *pfvf, + struct ethtool_rxnfc *nfc) +{ + struct otx2_rss_info *rss = &pfvf->hw.rss_info; + u32 rxh_l4 = rxh_l4_b_0_1 | rxh_l4_b_2_3; + u32 rss_cfg = rss->flowkey_cfg; + + if (!rss->enable) { + netdev_err(pfvf->netdev, + "rss is disabled, cannot change settings "); + return -eio; + } + + /* mimimum is ipv4 and ipv6, sip/dip */ + if (!(nfc->data & rxh_ip_src) || !(nfc->data & rxh_ip_dst)) + return -einval; + + switch (nfc->flow_type) { + case tcp_v4_flow: + case tcp_v6_flow: + /* different config for v4 and v6 is not supported. + * both of them have to be either 4-tuple or 2-tuple. + */ + switch (nfc->data & rxh_l4) { + case 0: + rss_cfg &= ~nix_flow_key_type_tcp; + break; + case (rxh_l4_b_0_1 | rxh_l4_b_2_3): + rss_cfg |= nix_flow_key_type_tcp; + break; + default: + return -einval; + } + break; + case udp_v4_flow: + case udp_v6_flow: + switch (nfc->data & rxh_l4) { + case 0: + rss_cfg &= ~nix_flow_key_type_udp; + break; + case (rxh_l4_b_0_1 | rxh_l4_b_2_3): + rss_cfg |= nix_flow_key_type_udp; + break; + default: + return -einval; + } + break; + case sctp_v4_flow: + case sctp_v6_flow: + switch (nfc->data & rxh_l4) { + case 0: + rss_cfg &= ~nix_flow_key_type_sctp; + break; + case (rxh_l4_b_0_1 | rxh_l4_b_2_3): + rss_cfg |= nix_flow_key_type_sctp; + break; + default: + return -einval; + } + break; + case ipv4_flow: + case ipv6_flow: + rss_cfg = nix_flow_key_type_ipv4 | nix_flow_key_type_ipv6; + break; + default: + return -einval; + } + + rss->flowkey_cfg = rss_cfg; + otx2_set_flowkey_cfg(pfvf); + return 0; +} + +static int otx2_get_rxnfc(struct net_device *dev, + struct ethtool_rxnfc *nfc, u32 *rules) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + int ret = -eopnotsupp; + + switch (nfc->cmd) { + case ethtool_grxrings: + nfc->data = pfvf->hw.rx_queues; + ret = 0; + break; + case ethtool_grxfh: + return otx2_get_rss_hash_opts(pfvf, nfc); + default: + break; + } + return ret; +} + +static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + int ret = -eopnotsupp; + + switch (nfc->cmd) { + case ethtool_srxfh: + ret = otx2_set_rss_hash_opts(pfvf, nfc); + break; + default: + break; + } + + return ret; +} + +static u32 otx2_get_rxfh_key_size(struct net_device *netdev) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct otx2_rss_info *rss; + + rss = &pfvf->hw.rss_info; + + return sizeof(rss->key); +} + +static u32 otx2_get_rxfh_indir_size(struct net_device *dev) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + + return pfvf->hw.rss_info.rss_size; +} + +/* get rss configuration */ +static int otx2_get_rxfh(struct net_device *dev, u32 *indir, + u8 *hkey, u8 *hfunc) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + struct otx2_rss_info *rss; + int idx; + + rss = &pfvf->hw.rss_info; + + if (indir) { + for (idx = 0; idx < rss->rss_size; idx++) + indir[idx] = rss->ind_tbl[idx]; + } + + if (hkey) + memcpy(hkey, rss->key, sizeof(rss->key)); + + if (hfunc) + *hfunc = eth_rss_hash_top; + + return 0; +} + +/* configure rss table and hash key */ +static int otx2_set_rxfh(struct net_device *dev, const u32 *indir, + const u8 *hkey, const u8 hfunc) +{ + struct otx2_nic *pfvf = netdev_priv(dev); + struct otx2_rss_info *rss; + int idx; + + if (hfunc != eth_rss_hash_no_change && hfunc != eth_rss_hash_top) + return -eopnotsupp; + + rss = &pfvf->hw.rss_info; + + if (!rss->enable) { + netdev_err(dev, "rss is disabled, cannot change settings "); + return -eio; + } + + if (indir) { + for (idx = 0; idx < rss->rss_size; idx++) + rss->ind_tbl[idx] = indir[idx]; + } + + if (hkey) { + memcpy(rss->key, hkey, sizeof(rss->key)); + otx2_set_rss_key(pfvf); + } + + otx2_set_rss_table(pfvf); + return 0; +} + +static u32 otx2_get_msglevel(struct net_device *netdev) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + + return pfvf->msg_enable; +} + +static void otx2_set_msglevel(struct net_device *netdev, u32 val) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + + pfvf->msg_enable = val; +} + +static u32 otx2_get_link(struct net_device *netdev) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + + return pfvf->linfo.link_up; +} + + .get_link = otx2_get_link, + .get_rxnfc = otx2_get_rxnfc, + .set_rxnfc = otx2_set_rxnfc, + .get_rxfh_key_size = otx2_get_rxfh_key_size, + .get_rxfh_indir_size = otx2_get_rxfh_indir_size, + .get_rxfh = otx2_get_rxfh, + .set_rxfh = otx2_set_rxfh, + .get_msglevel = otx2_get_msglevel, + .set_msglevel = otx2_set_msglevel, diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c - if (unlikely(snd_comp->status)) + if (unlikely(snd_comp->status) && netif_msg_tx_err(pfvf)) + if (netif_msg_rx_err(pfvf)) + netdev_err(pfvf->netdev, + "rq%d: error pkt with errlev:0x%x errcode:0x%x ", + qidx, parse->errlev, parse->errcode); +
|
Networking
|
6e92d71bf88208ddcbd48b3c831c0e394d0f56e2
|
sunil goutham
|
drivers
|
net
|
ethernet, marvell, nic, octeontx2
|
documentation: net: octeontx2: add rvu hw and drivers overview
|
added high level overview of octeontx2 rvu hw and functionality of various drivers which will be upstreamed.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['maintainers', 'rst']
| 3
| 161
| 0
|
--- diff --git a/documentation/networking/device_drivers/index.rst b/documentation/networking/device_drivers/index.rst --- a/documentation/networking/device_drivers/index.rst +++ b/documentation/networking/device_drivers/index.rst + marvell/octeontx2 diff --git a/documentation/networking/device_drivers/marvell/octeontx2.rst b/documentation/networking/device_drivers/marvell/octeontx2.rst --- /dev/null +++ b/documentation/networking/device_drivers/marvell/octeontx2.rst +.. spdx-license-identifier: (gpl-2.0-only or bsd-2-clause) + +==================================== +marvell octeontx2 rvu kernel drivers +==================================== + +copyright (c) 2020 marvell international ltd. + +contents +======== + +- 'overview'_ +- 'drivers'_ +- 'basic packet flow'_ + +overview +======== + +resource virtualization unit (rvu) on marvell's octeontx2 soc maps hw +resources from the network, crypto and other functional blocks into +pci-compatible physical and virtual functions. each functional block +again has multiple local functions (lfs) for provisioning to pci devices. +rvu supports multiple pcie sriov physical functions (pfs) and virtual +functions (vfs). pf0 is called the administrative / admin function (af) +and has privileges to provision rvu functional block's lfs to each of the +pf/vf. + +rvu managed networking functional blocks + - network pool or buffer allocator (npa) + - network interface controller (nix) + - network parser cam (npc) + - schedule/synchronize/order unit (sso) + - loopback interface (lbk) + +rvu managed non-networking functional blocks + - crypto accelerator (cpt) + - scheduled timers unit (tim) + - schedule/synchronize/order unit (sso) + used for both networking and non networking usecases + +resource provisioning examples + - a pf/vf with nix-lf & npa-lf resources works as a pure network device + - a pf/vf with cpt-lf resource works as a pure crypto offload device. + +rvu functional blocks are highly configurable as per software requirements. + +firmware setups following stuff before kernel boots + - enables required number of rvu pfs based on number of physical links. + - number of vfs per pf are either static or configurable at compile time. + based on config, firmware assigns vfs to each of the pfs. + - also assigns msix vectors to each of pf and vfs. + - these are not changed after kernel boot. + +drivers +======= + +linux kernel will have multiple drivers registering to different pf and vfs +of rvu. wrt networking there will be 3 flavours of drivers. + +admin function driver +--------------------- + +as mentioned above rvu pf0 is called the admin function (af), this driver +supports resource provisioning and configuration of functional blocks. +doesn't handle any i/o. it sets up few basic stuff but most of the +funcionality is achieved via configuration requests from pfs and vfs. + +pf/vfs communicates with af via a shared memory region (mailbox). upon +receiving requests af does resource provisioning and other hw configuration. +af is always attached to host kernel, but pfs and their vfs may be used by host +kernel itself, or attached to vms or to userspace applications like +dpdk etc. so af has to handle provisioning/configuration requests sent +by any device from any domain. + +af driver also interacts with underlying firmware to + - manage physical ethernet links ie cgx lmacs. + - retrieve information like speed, duplex, autoneg etc + - retrieve phy eeprom and stats. + - configure fec, pam modes + - etc + +from pure networking side af driver supports following functionality. + - map a physical link to a rvu pf to which a netdev is registered. + - attach nix and npa block lfs to rvu pf/vf which provide buffer pools, rqs, sqs + for regular networking functionality. + - flow control (pause frames) enable/disable/config. + - hw ptp timestamping related config. + - npc parser profile config, basically how to parse pkt and what info to extract. + - npc extract profile config, what to extract from the pkt to match data in mcam entries. + - manage npc mcam entries, upon request can frame and install requested packet forwarding rules. + - defines receive side scaling (rss) algorithms. + - defines segmentation offload algorithms (eg tso) + - vlan stripping, capture and insertion config. + - sso and tim blocks config which provide packet scheduling support. + - debugfs support, to check current resource provising, current status of + npa pools, nix rq, sq and cqs, various stats etc which helps in debugging issues. + - and many more. + +physical function driver +------------------------ + +this rvu pf handles io, is mapped to a physical ethernet link and this +driver registers a netdev. this supports sr-iov. as said above this driver +communicates with af with a mailbox. to retrieve information from physical +links this driver talks to af and af gets that info from firmware and responds +back ie cannot talk to firmware directly. + +supports ethtool for configuring links, rss, queue count, queue size, +flow control, ntuple filters, dump phy eeprom, config fec etc. + +virtual function driver +----------------------- + +there are two types vfs, vfs that share the physical link with their parent +sr-iov pf and the vfs which work in pairs using internal hw loopback channels (lbk). + +type1: + - these vfs and their parent pf share a physical link and used for outside communication. + - vfs cannot communicate with af directly, they send mbox message to pf and pf + forwards that to af. af after processing, responds back to pf and pf forwards + the reply to vf. + - from functionality point of view there is no difference between pf and vf as same type + hw resources are attached to both. but user would be able to configure few stuff only + from pf as pf is treated as owner/admin of the link. + +type2: + - rvu pf0 ie admin function creates these vfs and maps them to loopback block's channels. + - a set of two vfs (vf0 & vf1, vf2 & vf3 .. so on) works as a pair ie pkts sent out of + vf0 will be received by vf1 and viceversa. + - these vfs can be used by applications or virtual machines to communicate between them + without sending traffic outside. there is no switch present in hw, hence the support + for loopback vfs. + - these communicate directly with af (pf0) via mbox. + +except for the io channels or links used for packet reception and transmission there is +no other difference between these vf types. af driver takes care of io channel mapping, +hence same vf driver works for both types of devices. + +basic packet flow +================= + +ingress +------- + +1. cgx lmac receives packet. +2. forwards the packet to the nix block. +3. then submitted to npc block for parsing and then mcam lookup to get the destination rvu device. +4. nix lf attached to the destination rvu device allocates a buffer from rq mapped buffer pool of npa block lf. +5. rq may be selected by rss or by configuring mcam rule with a rq number. +6. packet is dma'ed and driver is notified. + +egress +------ + +1. driver prepares a send descriptor and submits to sq for transmission. +2. the sq is already configured (by af) to transmit on a specific link/channel. +3. the sq descriptor ring is maintained in buffers allocated from sq mapped pool of npa block lf. +4. nix block transmits the pkt on the designated channel. +5. npc mcam entries can be installed to divert pkt onto a different channel. diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +f: documentation/networking/device_drivers/marvell/octeontx2.rst
|
Networking
|
493aeb26e12ad4f0f7ad7f320b5706b6902e6eed
|
sunil goutham
|
documentation
|
networking
|
device_drivers, marvell
|
maintainers: add entry for marvell octeontx2 physical function driver
|
added maintainers entry for marvell octeontx2 soc's physical function nic driver.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add network driver for physical function
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['octeontx2-pf']
|
['maintainers']
| 1
| 9
| 0
|
--- diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +marvell octeontx2 physical function driver +m: sunil goutham <sgoutham@marvell.com> +m: geetha sowjanya <gakula@marvell.com> +m: subbaraya sundeep <sbhatta@marvell.com> +m: hariprasad <hkelam@marvell.com> +l: netdev@vger.kernel.org +s: supported +f: drivers/net/ethernet/marvell/octeontx2/nic/ +
|
Networking
|
688b3e829d60a290c9a0a2c8b0b99f816ed37a8c
|
sunil goutham
| |||
net: phy: dp83822: add support for additional dp83825 devices
|
add phy ids for the dp83825cs, dp83825cm and the dp83825s devices to the dp83822 driver.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for additional dp83825 devices
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['phy ', 'dp83822']
|
['c', 'kconfig']
| 2
| 12
| 3
|
--- diff --git a/drivers/net/phy/kconfig b/drivers/net/phy/kconfig --- a/drivers/net/phy/kconfig +++ b/drivers/net/phy/kconfig ---help--- - supports the dp83822, dp83825i, dp83826c and dp83826nc phys. + supports the dp83822, dp83825i, dp83825cm, dp83825cs, dp83825s, + dp83826c and dp83826nc phys. diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c -/* - * driver for the texas instruments dp83822 phy +/* driver for the texas instruments dp83822, dp83825 and dp83826 phys. +#define dp83825s_phy_id 0x2000a140 +#define dp83825cm_phy_id 0x2000a160 +#define dp83825cs_phy_id 0x2000a170 + dp83822_phy_driver(dp83825s_phy_id, "ti dp83825s"), + dp83822_phy_driver(dp83825cm_phy_id, "ti dp83825m"), + dp83822_phy_driver(dp83825cs_phy_id, "ti dp83825cs"), + { dp83825s_phy_id, 0xfffffff0 }, + { dp83825cm_phy_id, 0xfffffff0 }, + { dp83825cs_phy_id, 0xfffffff0 },
|
Networking
|
2ace13e10dbd1c8c5c9f118e5d4d0e0a77b152c7
|
dan murphy andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
phy: dp83826: add phy ids for dp83826n and 826nc
|
add phy ids to the dp83822 phy driver for the dp83826n and the dp83826nc devices. the register map and features are the same for basic enablement.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add phy ids for dp83826n and 826nc
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['phy ', 'dp83826']
|
['c', 'kconfig']
| 2
| 8
| 2
|
--- diff --git a/drivers/net/phy/kconfig b/drivers/net/phy/kconfig --- a/drivers/net/phy/kconfig +++ b/drivers/net/phy/kconfig - tristate "texas instruments dp83822/825 phys" + tristate "texas instruments dp83822/825/826 phys" ---help--- - supports the dp83822 and dp83825i phys. + supports the dp83822, dp83825i, dp83826c and dp83826nc phys. diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c +#define dp83826c_phy_id 0x2000a130 +#define dp83826nc_phy_id 0x2000a110 + dp83822_phy_driver(dp83826c_phy_id, "ti dp83826c"), + dp83822_phy_driver(dp83826nc_phy_id, "ti dp83826nc"), + { dp83826c_phy_id, 0xfffffff0 }, + { dp83826nc_phy_id, 0xfffffff0 },
|
Networking
|
783da36bb90cbf45be7fa82a0d0d3910f1f6fcc7
|
dan murphy andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: phylink: add support for polling mac pcs
|
some mac pcs blocks are unable to provide interrupts when their status changes. as we already have support in phylink for polling status, use this to provide a hook for macs to enable polling mode.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for polling mac pcs
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['phy ', 'phylink']
|
['c', 'h', 'rst']
| 3
| 6
| 2
|
--- diff --git a/documentation/networking/sfp-phylink.rst b/documentation/networking/sfp-phylink.rst --- a/documentation/networking/sfp-phylink.rst +++ b/documentation/networking/sfp-phylink.rst - otherwise. + otherwise. if a mac is unable to provide these interrupts, then + it should set ''priv->phylink_config.pcs_poll = true;'' in step 9. diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c - if (pl->cfg_link_an_mode == mlo_an_fixed && pl->get_fixed_state) + if ((pl->cfg_link_an_mode == mlo_an_fixed && pl->get_fixed_state) || + pl->config->pcs_poll) diff --git a/include/linux/phylink.h b/include/linux/phylink.h --- a/include/linux/phylink.h +++ b/include/linux/phylink.h + * @pcs_poll: mac pcs cannot provide link change interrupt + bool pcs_poll;
|
Networking
|
1511ed0a0167f523a84b4e727372a5d2ce1b6c2f
|
vladimir oltean
|
documentation
|
networking
|
phy
|
qed: fw 8.42.2.0 add fw overlay feature
|
this feature enables the fw to page out fw code when required
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
fw 8.42.2.0 add fw overlay feature
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['qed']
|
['h', 'c']
| 5
| 224
| 1
|
--- diff --git a/drivers/net/ethernet/qlogic/qed/qed.h b/drivers/net/ethernet/qlogic/qed/qed.h --- a/drivers/net/ethernet/qlogic/qed/qed.h +++ b/drivers/net/ethernet/qlogic/qed/qed.h + const u32 *fw_overlays; + u32 fw_overlays_len; + struct phys_mem_desc *fw_overlay_mem; diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c + qed_fw_overlay_mem_free(p_hwfn, p_hwfn->fw_overlay_mem); + qed_fw_overlay_init_ram(p_hwfn, p_ptt, p_hwfn->fw_overlay_mem); + - int rc = 0, i; + const u32 *fw_overlays; + u32 fw_overlays_len; + int rc = 0, i; + fw_overlays = cdev->fw_data->fw_overlays; + fw_overlays_len = cdev->fw_data->fw_overlays_len; + p_hwfn->fw_overlay_mem = + qed_fw_overlay_mem_alloc(p_hwfn, fw_overlays, + fw_overlays_len); + if (!p_hwfn->fw_overlay_mem) { + dp_notice(p_hwfn, + "failed to allocate fw overlay memory "); + goto load_err; + } + diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h b/drivers/net/ethernet/qlogic/qed/qed_hsi.h --- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h +++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h +/* physical memory descriptor */ +struct phys_mem_desc { + dma_addr_t phys_addr; + void *virt_addr; + u32 size; /* in bytes */ +}; + +/* virtual memory descriptor */ +struct virt_mem_desc { + void *ptr; + u32 size; /* in bytes */ +}; + +/* fw overlay buffer header */ +struct fw_overlay_buf_hdr { + u32 data; +#define fw_overlay_buf_hdr_storm_id_mask 0xff +#define fw_overlay_buf_hdr_storm_id_shift 0 +#define fw_overlay_buf_hdr_buf_size_mask 0xffffff +#define fw_overlay_buf_hdr_buf_size_shift 8 +}; + +/** + * @brief qed_fw_overlay_mem_alloc - allocates and fills the fw overlay memory. + * + * @param p_hwfn - hw device data + * @param fw_overlay_in_buf - the input fw overlay buffer. + * @param buf_size - the size of the input fw overlay buffer in bytes. + * must be aligned to dwords. + * @param fw_overlay_out_mem - out: a pointer to the allocated overlays memory. + * + * @return a pointer to the allocated overlays memory, + * or null in case of failures. + */ +struct phys_mem_desc * +qed_fw_overlay_mem_alloc(struct qed_hwfn *p_hwfn, + const u32 * const fw_overlay_in_buf, + u32 buf_size_in_bytes); + +/** + * @brief qed_fw_overlay_init_ram - initializes the fw overlay ram. + * + * @param p_hwfn - hw device data. + * @param p_ptt - ptt window used for writing the registers. + * @param fw_overlay_mem - the allocated fw overlay memory. + */ +void qed_fw_overlay_init_ram(struct qed_hwfn *p_hwfn, + struct qed_ptt *p_ptt, + struct phys_mem_desc *fw_overlay_mem); + +/** + * @brief qed_fw_overlay_mem_free - frees the fw overlay memory. + * + * @param p_hwfn - hw device data. + * @param fw_overlay_mem - the allocated fw overlay memory to free. + */ +void qed_fw_overlay_mem_free(struct qed_hwfn *p_hwfn, + struct phys_mem_desc *fw_overlay_mem); diff --git a/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c b/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c --- a/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c +++ b/drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c + +#define phys_addr_dwords div_round_up(sizeof(dma_addr_t), 4) +#define overlay_hdr_size_dwords (sizeof(struct fw_overlay_buf_hdr) / 4) + +static u32 qed_get_overlay_addr_ram_addr(struct qed_hwfn *p_hwfn, u8 storm_id) +{ + switch (storm_id) { + case 0: + return tsem_reg_fast_memory + sem_fast_reg_int_ram + + tstorm_overlay_buf_addr_offset; + case 1: + return msem_reg_fast_memory + sem_fast_reg_int_ram + + mstorm_overlay_buf_addr_offset; + case 2: + return usem_reg_fast_memory + sem_fast_reg_int_ram + + ustorm_overlay_buf_addr_offset; + case 3: + return xsem_reg_fast_memory + sem_fast_reg_int_ram + + xstorm_overlay_buf_addr_offset; + case 4: + return ysem_reg_fast_memory + sem_fast_reg_int_ram + + ystorm_overlay_buf_addr_offset; + case 5: + return psem_reg_fast_memory + sem_fast_reg_int_ram + + pstorm_overlay_buf_addr_offset; + + default: + return 0; + } +} + +struct phys_mem_desc *qed_fw_overlay_mem_alloc(struct qed_hwfn *p_hwfn, + const u32 * const + fw_overlay_in_buf, + u32 buf_size_in_bytes) +{ + u32 buf_size = buf_size_in_bytes / sizeof(u32), buf_offset = 0; + struct phys_mem_desc *allocated_mem; + + if (!buf_size) + return null; + + allocated_mem = kcalloc(num_storms, sizeof(struct phys_mem_desc), + gfp_kernel); + if (!allocated_mem) + return null; + + memset(allocated_mem, 0, num_storms * sizeof(struct phys_mem_desc)); + + /* for each storm, set physical address in ram */ + while (buf_offset < buf_size) { + struct phys_mem_desc *storm_mem_desc; + struct fw_overlay_buf_hdr *hdr; + u32 storm_buf_size; + u8 storm_id; + + hdr = + (struct fw_overlay_buf_hdr *)&fw_overlay_in_buf[buf_offset]; + storm_buf_size = get_field(hdr->data, + fw_overlay_buf_hdr_buf_size); + storm_id = get_field(hdr->data, fw_overlay_buf_hdr_storm_id); + storm_mem_desc = allocated_mem + storm_id; + storm_mem_desc->size = storm_buf_size * sizeof(u32); + + /* allocate physical memory for storm's overlays buffer */ + storm_mem_desc->virt_addr = + dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, + storm_mem_desc->size, + &storm_mem_desc->phys_addr, gfp_kernel); + if (!storm_mem_desc->virt_addr) + break; + + /* skip overlays buffer header */ + buf_offset += overlay_hdr_size_dwords; + + /* copy storm's overlays buffer to allocated memory */ + memcpy(storm_mem_desc->virt_addr, + &fw_overlay_in_buf[buf_offset], storm_mem_desc->size); + + /* advance to next storm */ + buf_offset += storm_buf_size; + } + + /* if memory allocation has failed, free all allocated memory */ + if (buf_offset < buf_size) { + qed_fw_overlay_mem_free(p_hwfn, allocated_mem); + return null; + } + + return allocated_mem; +} + +void qed_fw_overlay_init_ram(struct qed_hwfn *p_hwfn, + struct qed_ptt *p_ptt, + struct phys_mem_desc *fw_overlay_mem) +{ + u8 storm_id; + + for (storm_id = 0; storm_id < num_storms; storm_id++) { + struct phys_mem_desc *storm_mem_desc = + (struct phys_mem_desc *)fw_overlay_mem + storm_id; + u32 ram_addr, i; + + /* skip storms with no fw overlays */ + if (!storm_mem_desc->virt_addr) + continue; + + /* calculate overlay ram grc address of current pf */ + ram_addr = qed_get_overlay_addr_ram_addr(p_hwfn, storm_id) + + sizeof(dma_addr_t) * p_hwfn->rel_pf_id; + + /* write storm's overlay physical address to ram */ + for (i = 0; i < phys_addr_dwords; i++, ram_addr += sizeof(u32)) + qed_wr(p_hwfn, p_ptt, ram_addr, + ((u32 *)&storm_mem_desc->phys_addr)[i]); + } +} + +void qed_fw_overlay_mem_free(struct qed_hwfn *p_hwfn, + struct phys_mem_desc *fw_overlay_mem) +{ + u8 storm_id; + + if (!fw_overlay_mem) + return; + + for (storm_id = 0; storm_id < num_storms; storm_id++) { + struct phys_mem_desc *storm_mem_desc = + (struct phys_mem_desc *)fw_overlay_mem + storm_id; + + /* free storm's physical memory */ + if (storm_mem_desc->virt_addr) + dma_free_coherent(&p_hwfn->cdev->pdev->dev, + storm_mem_desc->size, + storm_mem_desc->virt_addr, + storm_mem_desc->phys_addr); + } + + /* free allocated virtual memory */ + kfree(fw_overlay_mem); +} diff --git a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c --- a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c +++ b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c + offset = buf_hdr[bin_buf_init_overlays].offset; + fw->fw_overlays = (u32 *)(data + offset); + len = buf_hdr[bin_buf_init_overlays].length; + fw->fw_overlays_len = len; +
|
Networking
|
30d5f85895fad1b3fec34b86cb779d4f56f85e32
|
michal kalderon
|
drivers
|
net
|
ethernet, qed, qlogic
|
net: qmi_wwan: add support for askey wwhc050
|
askey wwhc050 is a mcie lte modem. the oem configuration states:
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for askey wwhc050
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['qmi_wwan ']
|
['c']
| 1
| 1
| 0
|
--- diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c + {qmi_fixed_intf(0x1690, 0x7588, 4)}, /* askey wwhc050 */
|
Networking
|
12a5ba5a1994568d4ceaff9e78c6b0329d953386
|
pawel dembicki
|
drivers
|
net
|
usb
|
qmi_wwan: re-add dw5821e pre-production variant
|
commit f25e1392fdb5 removed the support for the pre-production variant of the dell dw5821e to avoid probing another usb interface unnecessarily. however, the pre-production samples are found in the wild, and this lack of support is causing problems for users of such samples. it is therefore necessary to support both variants.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
re-add dw5821e pre-production variant
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['qmi_wwan ']
|
['c']
| 1
| 1
| 0
|
--- diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c + {qmi_fixed_intf(0x413c, 0x81d7, 1)}, /* dell wireless 5821e preproduction config */
|
Networking
|
88bf54603f6f2c137dfee1abf6436ceac3528d2d
|
bj rn mork
|
drivers
|
net
|
usb
|
qtnfmac: add module param to configure dfs offload
|
firmware may support dfs offload. however the final decision on whether to use it or not should be up to the user. so even if firmware supports dfs offload, it should be enabled only if user explicitly requests it. for this purpose introduce kernel param dfs_offload which is disabled by default.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add module param to configure dfs offload
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['qtnfmac ']
|
['c', 'h']
| 6
| 22
| 7
|
--- diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c - ret = qtnf_cmd_reg_notify(mac, req, qtnf_slave_radar_get()); + ret = qtnf_cmd_reg_notify(mac, req, qtnf_slave_radar_get(), + qtnf_dfs_offload_get()); - if (bus->hw_info.hw_capab & qlink_hw_capab_dfs_offload) + if (qtnf_dfs_offload_get() && + (bus->hw_info.hw_capab & qlink_hw_capab_dfs_offload)) - if (hw_info->hw_capab & qlink_hw_capab_dfs_offload) + if (qtnf_dfs_offload_get() && + (hw_info->hw_capab & qlink_hw_capab_dfs_offload)) diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c - bool slave_radar) + bool slave_radar, bool dfs_offload) + cmd->dfs_offload = dfs_offload; diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h - bool slave_radar); + bool slave_radar, bool dfs_offload); diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c +static bool dfs_offload; +module_param(dfs_offload, bool, 0644); +module_parm_desc(dfs_offload, "set 1 to enable dfs offload to firmware"); + +bool qtnf_dfs_offload_get(void) +{ + return dfs_offload; +} + diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h +bool qtnf_dfs_offload_get(void); diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h - * @slave_radar: whether slave device should enable radar detection. + * @slave_radar: whether slave device should enable radar detection. + * @dfs_offload: enable or disable dfs offload to firmware. - u8 rsvd[1]; + u8 dfs_offload;
|
Networking
|
155b424c86f8169b30d30beb46ad216c5e61749a
|
sergey matyukevich
|
drivers
|
net
|
qtnfmac, quantenna, wireless
|
qtnfmac: add support for sta he rates
|
add he rates into sta info. report he rx/tx mcs if sta supports them.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for sta he rates
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['qtnfmac ']
|
['c', 'h']
| 2
| 3
| 0
|
--- diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c + else if (rate_src->flags & qlink_sta_info_rate_flag_he_mcs) + rate_dst->flags |= rate_info_flags_he_mcs; diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h + qlink_sta_info_rate_flag_he_mcs = bit(4),
|
Networking
|
b73f0aac731ce87a656d9911cb9e2e79eb721d1a
|
sergey matyukevich
|
drivers
|
net
|
qtnfmac, quantenna, wireless
|
qtnfmac: add support for twt responder and spatial reuse
|
add support for 11ax features: twt responder and spatial reuse. add separate structure for spatial reuse parameters and pass this structure to firmware along with other parameters in start_ap command. pass twt responder value to firmware. bump qlink protocol version.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for twt responder and spatial reuse
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['qtnfmac ']
|
['c', 'h']
| 2
| 53
| 1
|
--- diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c + cmd->twt_responder = s->twt_responder; + if (s->he_obss_pd.enable) { + cmd->sr_params.sr_control |= qlink_sr_srg_information_present; + cmd->sr_params.srg_obss_pd_min_offset = + s->he_obss_pd.min_offset; + cmd->sr_params.srg_obss_pd_max_offset = + s->he_obss_pd.max_offset; + } diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h -#define qlink_proto_ver 15 +#define qlink_proto_ver 16 +/** + * enum qlink_sr_ctrl_flags - control flags for spatial reuse parameter set + * + * @qlink_sr_psr_disallowed: indicates whether or not psr-based spatial reuse + * transmissions are allowed for stas associated with the ap + * @qlink_sr_non_srg_obss_pd_sr_disallowed: indicates whether or not + * non-srg obss pd spatial reuse transmissions are allowed for stas associated + * with the ap + * @non_srg_offset_present: indicates whether or not non-srg obss pd max offset + * field is valid in the element + * @qlink_sr_srg_information_present: indicates whether or not srg obss pd + * min/max offset fields ore valid in the element + */ +enum qlink_sr_ctrl_flags { + qlink_sr_psr_disallowed = bit(0), + qlink_sr_non_srg_obss_pd_sr_disallowed = bit(1), + qlink_sr_non_srg_offset_present = bit(2), + qlink_sr_srg_information_present = bit(3), +}; + +/** + * struct qlink_sr_params - spatial reuse parameters + * + * @sr_control: spatial reuse control field; flags contained in this field are + * defined in @qlink_sr_ctrl_flags + * @non_srg_obss_pd_max: added to -82 dbm to generate the value of the + * non-srg obss pd max parameter + * @srg_obss_pd_min_offset: added to -82 dbm to generate the value of the + * srg obss pd min parameter + * @srg_obss_pd_max_offset: added to -82 dbm to generate the value of the + * srg pbss pd max parameter + */ +struct qlink_sr_params { + u8 sr_control; + u8 non_srg_obss_pd_max; + u8 srg_obss_pd_min_offset; + u8 srg_obss_pd_max_offset; +} __packed; + + * @sr_params: spatial reuse parameters + * @twt_responder: enable target wake time + struct qlink_sr_params sr_params; + u8 twt_responder; + u8 rsvd[3];
|
Networking
|
ed7791d9d0abc7e24223ab1663931c8e5351fea8
|
mikhail karpenko
|
drivers
|
net
|
qtnfmac, quantenna, wireless
|
r8152: add mac passthrough support to new device
|
device 0xa387 also supports mac passthrough, therefore add it to the whitelst.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add mac passthrough support to new device
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 10
| 3
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c +#define device_id_thinkpad_thunderbolt3_dock_gen2 0x3082 +#define device_id_thinkpad_usb_c_dock_gen2 0xa387 + - if (le16_to_cpu(udev->descriptor.idvendor) == vendor_id_lenovo && - le16_to_cpu(udev->descriptor.idproduct) == 0x3082) - set_bit(lenovo_macpassthru, &tp->flags); + if (le16_to_cpu(udev->descriptor.idvendor) == vendor_id_lenovo) { + switch (le16_to_cpu(udev->descriptor.idproduct)) { + case device_id_thinkpad_thunderbolt3_dock_gen2: + case device_id_thinkpad_usb_c_dock_gen2: + set_bit(lenovo_macpassthru, &tp->flags); + } + }
|
Networking
|
b4b771fd51fda70577dc980429347c41e807c64f
|
kai heng feng
|
drivers
|
net
|
usb
|
r8169: use generic ndo_do_ioctl handler phy_do_ioctl
|
replace rtl8169_ioctl with new generic function phy_do_ioctl.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
use generic ndo_do_ioctl handler phy_do_ioctl
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8169']
|
['c']
| 1
| 1
| 11
|
--- diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c -static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct rtl8169_private *tp = netdev_priv(dev); - - if (!netif_running(dev)) - return -enodev; - - return phy_mii_ioctl(tp->phydev, ifr, cmd); -} - - .ndo_do_ioctl = rtl8169_ioctl, + .ndo_do_ioctl = phy_do_ioctl,
|
Networking
|
df007186488e33716ccf0c01f93cc5fe1ef91847
|
heiner kallweit
|
drivers
|
net
|
ethernet, realtek
|
rtw88: pci: reset ring index when release skbs in tx ring
|
when skbs queued for each tx ring are relased in pci stop flow, the ring index should be reset at the same time.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['c']
| 1
| 1
| 0
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c + rtw_pci_reset_trx_ring(rtwdev);
|
Networking
|
25cab7e71da32d46651f5fc9373eef9b79938629
|
chin yen lee
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: pci: reset dma when reset pci trx ring
|
when pci trx rings are reset, the dma engine should also be reset. otherswise, the rx_tag of rx flow is not synchronous to hw.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['c']
| 1
| 10
| 9
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c -static int rtw_pci_setup(struct rtw_dev *rtwdev) -{ - rtw_pci_reset_trx_ring(rtwdev); - - return 0; -} - +static int rtw_pci_setup(struct rtw_dev *rtwdev) +{ + struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; + + rtw_pci_reset_trx_ring(rtwdev); + rtw_pci_dma_reset(rtwdev, rtwpci); + + return 0; +} + - rtw_pci_dma_reset(rtwdev, rtwpci); -
|
Networking
|
fd30e891e0bc68735b52d480d078959e5fb30e70
|
chin yen lee
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: add interface config for 8822c
|
some devices need to configure interface/hci related reigsters in power on flow. add interface_cfg for hci for the settings.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['h', 'c']
| 4
| 27
| 0
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/hci.h b/drivers/net/wireless/realtek/rtw88/hci.h --- a/drivers/net/wireless/realtek/rtw88/hci.h +++ b/drivers/net/wireless/realtek/rtw88/hci.h + void (*interface_cfg)(struct rtw_dev *rtwdev); +static inline void rtw_hci_interface_cfg(struct rtw_dev *rtwdev) +{ + rtwdev->hci.ops->interface_cfg(rtwdev); +} + diff --git a/drivers/net/wireless/realtek/rtw88/mac.c b/drivers/net/wireless/realtek/rtw88/mac.c --- a/drivers/net/wireless/realtek/rtw88/mac.c +++ b/drivers/net/wireless/realtek/rtw88/mac.c + rtw_hci_interface_cfg(rtwdev); + diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c +#include "reg.h" +static void rtw_pci_interface_cfg(struct rtw_dev *rtwdev) +{ + struct rtw_chip_info *chip = rtwdev->chip; + + switch (chip->id) { + case rtw_chip_type_8822c: + if (rtwdev->hal.cut_version >= rtw_chip_ver_cut_d) + rtw_write32_mask(rtwdev, reg_hci_mix_cfg, + bit_pcie_emac_pdn_aux_to_fast_clk, 1); + break; + default: + break; + } +} + + .interface_cfg = rtw_pci_interface_cfg, diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h +#define reg_hci_mix_cfg 0x03fc +#define bit_pcie_emac_pdn_aux_to_fast_clk bit(26)
|
Networking
|
786221048e8f74bafb87b4ba8b613cd5bc0ea159
|
yan hsuan chuang
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: load wowlan firmware if wowlan is supported
|
driver used to download normal firmware only, but some devices support wowlan and require to download wowlan firmware when system suspends. so modify rtw_load_firmware() and its callback to allow driver to download both normal and wowlan firmware.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['c', 'h']
| 2
| 70
| 12
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c +static int rtw_wait_firmware_completion(struct rtw_dev *rtwdev) +{ + struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_fw_state *fw; + + fw = &rtwdev->fw; + wait_for_completion(&fw->completion); + if (!fw->firmware) + return -einval; + + if (chip->wow_fw_name) { + fw = &rtwdev->wow_fw; + wait_for_completion(&fw->completion); + if (!fw->firmware) + return -einval; + } + + return 0; +} + - wait_for_completion(&fw->completion); - if (!fw->firmware) { - ret = -einval; - rtw_err(rtwdev, "failed to load firmware "); - goto err; + ret = rtw_wait_firmware_completion(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to wait firmware completion "); + goto err_off; - struct rtw_dev *rtwdev = context; - struct rtw_fw_state *fw = &rtwdev->fw; + struct rtw_fw_state *fw = context; + struct rtw_dev *rtwdev = fw->rtwdev; -static int rtw_load_firmware(struct rtw_dev *rtwdev, const char *fw_name) +static int rtw_load_firmware(struct rtw_dev *rtwdev, enum rtw_fw_type type) - struct rtw_fw_state *fw = &rtwdev->fw; + const char *fw_name; + struct rtw_fw_state *fw; + switch (type) { + case rtw_wowlan_fw: + fw = &rtwdev->wow_fw; + fw_name = rtwdev->chip->wow_fw_name; + break; + + case rtw_normal_fw: + fw = &rtwdev->fw; + fw_name = rtwdev->chip->fw_name; + break; + + default: + rtw_warn(rtwdev, "unsupported firmware type "); + return -enoent; + } + + fw->rtwdev = rtwdev; - gfp_kernel, rtwdev, rtw_load_firmware_cb); + gfp_kernel, fw, rtw_load_firmware_cb); - rtw_err(rtwdev, "async firmware request failed "); + rtw_err(rtwdev, "failed to async firmware request "); - ret = rtw_load_firmware(rtwdev, rtwdev->chip->fw_name); + ret = rtw_load_firmware(rtwdev, rtw_normal_fw); + if (chip->wow_fw_name) { + ret = rtw_load_firmware(rtwdev, rtw_wowlan_fw); + if (ret) { + rtw_warn(rtwdev, "no wow firmware loaded "); + return ret; + } + } + struct rtw_fw_state *wow_fw = &rtwdev->wow_fw; + if (wow_fw->firmware) + release_firmware(wow_fw->firmware); + diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h +enum rtw_fw_type { + rtw_normal_fw = 0x0, + rtw_wowlan_fw = 0x1, +}; + + const char *wow_fw_name; + + struct rtw_dev *rtwdev; + struct rtw_fw_state wow_fw; +
|
Networking
|
c8e5695eae9959fc5774c0f490f2450be8bad3de
|
chin yen lee
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: support wowlan feature for 8822c
|
wake on wlan(wowlan) is a feature which allows devices to be woken up from suspend state through wlan events.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['h', 'c', 'makefile']
| 13
| 836
| 0
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/makefile b/drivers/net/wireless/realtek/rtw88/makefile --- a/drivers/net/wireless/realtek/rtw88/makefile +++ b/drivers/net/wireless/realtek/rtw88/makefile + wow.o \ diff --git a/drivers/net/wireless/realtek/rtw88/debug.h b/drivers/net/wireless/realtek/rtw88/debug.h --- a/drivers/net/wireless/realtek/rtw88/debug.h +++ b/drivers/net/wireless/realtek/rtw88/debug.h + rtw_dbg_wow = 0x00001000, diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c +#include "wow.h" +void rtw_fw_set_keep_alive_cmd(struct rtw_dev *rtwdev, bool enable) +{ + u8 h2c_pkt[h2c_pkt_size] = {0}; + struct rtw_fw_wow_keep_alive_para mode = { + .adopt = true, + .pkt_type = keep_alive_null_pkt, + .period = 5, + }; + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_keep_alive); + set_keep_alive_enable(h2c_pkt, enable); + set_keep_alive_adopt(h2c_pkt, mode.adopt); + set_keep_alive_pkt_type(h2c_pkt, mode.pkt_type); + set_keep_alive_check_period(h2c_pkt, mode.period); + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} + +void rtw_fw_set_disconnect_decision_cmd(struct rtw_dev *rtwdev, bool enable) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + u8 h2c_pkt[h2c_pkt_size] = {0}; + struct rtw_fw_wow_disconnect_para mode = { + .adopt = true, + .period = 30, + .retry_count = 5, + }; + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_disconnect_decision); + + if (test_bit(rtw_wow_flag_en_disconnect, rtw_wow->flags)) { + set_disconnect_decision_enable(h2c_pkt, enable); + set_disconnect_decision_adopt(h2c_pkt, mode.adopt); + set_disconnect_decision_check_period(h2c_pkt, mode.period); + set_disconnect_decision_try_pkt_num(h2c_pkt, mode.retry_count); + } + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} + +void rtw_fw_set_wowlan_ctrl_cmd(struct rtw_dev *rtwdev, bool enable) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + u8 h2c_pkt[h2c_pkt_size] = {0}; + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_wowlan); + + set_wowlan_func_enable(h2c_pkt, enable); + if (rtw_wow_mgd_linked(rtwdev)) { + if (test_bit(rtw_wow_flag_en_magic_pkt, rtw_wow->flags)) + set_wowlan_magic_pkt_enable(h2c_pkt, enable); + if (test_bit(rtw_wow_flag_en_disconnect, rtw_wow->flags)) + set_wowlan_deauth_wakeup_enable(h2c_pkt, enable); + if (test_bit(rtw_wow_flag_en_rekey_pkt, rtw_wow->flags)) + set_wowlan_rekey_wakeup_enable(h2c_pkt, enable); + } + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} + +void rtw_fw_set_aoac_global_info_cmd(struct rtw_dev *rtwdev, + u8 pairwise_key_enc, + u8 group_key_enc) +{ + u8 h2c_pkt[h2c_pkt_size] = {0}; + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_aoac_global_info); + + set_aoac_global_info_pairwise_enc_alg(h2c_pkt, pairwise_key_enc); + set_aoac_global_info_group_enc_alg(h2c_pkt, group_key_enc); + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} + +void rtw_fw_set_remote_wake_ctrl_cmd(struct rtw_dev *rtwdev, bool enable) +{ + u8 h2c_pkt[h2c_pkt_size] = {0}; + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_remote_wake_ctrl); + + set_remote_wakectrl_enable(h2c_pkt, enable); + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} + diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h +enum rtw_keep_alive_pkt_type { + keep_alive_null_pkt = 0, + keep_alive_arp_rsp = 1, +}; + +struct rtw_fw_wow_keep_alive_para { + bool adopt; + u8 pkt_type; + u8 period; /* unit: sec */ +}; + +struct rtw_fw_wow_disconnect_para { + bool adopt; + u8 period; /* unit: sec */ + u8 retry_count; +}; + +#define h2c_cmd_keep_alive 0x03 +#define h2c_cmd_disconnect_decision 0x04 +#define h2c_cmd_wowlan 0x80 +#define h2c_cmd_remote_wake_ctrl 0x81 +#define h2c_cmd_aoac_global_info 0x82 +#define set_keep_alive_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(8)) +#define set_keep_alive_adopt(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(9)) +#define set_keep_alive_pkt_type(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(10)) +#define set_keep_alive_check_period(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, genmask(23, 16)) + +#define set_disconnect_decision_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(8)) +#define set_disconnect_decision_adopt(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(9)) +#define set_disconnect_decision_check_period(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, genmask(23, 16)) +#define set_disconnect_decision_try_pkt_num(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, genmask(31, 24)) + +#define set_wowlan_func_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(8)) +#define set_wowlan_magic_pkt_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(10)) +#define set_wowlan_unicast_pkt_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(11)) +#define set_wowlan_rekey_wakeup_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(14)) +#define set_wowlan_deauth_wakeup_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(15)) + +#define set_remote_wakectrl_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(8)) +#define set_remote_wake_ctrl_nlo_offload_en(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(12)) + +#define set_aoac_global_info_pairwise_enc_alg(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, genmask(15, 8)) +#define set_aoac_global_info_group_enc_alg(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, genmask(23, 16)) + +void rtw_fw_set_remote_wake_ctrl_cmd(struct rtw_dev *rtwdev, bool enable); +void rtw_fw_set_wowlan_ctrl_cmd(struct rtw_dev *rtwdev, bool enable); +void rtw_fw_set_keep_alive_cmd(struct rtw_dev *rtwdev, bool enable); +void rtw_fw_set_disconnect_decision_cmd(struct rtw_dev *rtwdev, bool enable); +void rtw_fw_set_aoac_global_info_cmd(struct rtw_dev *rtwdev, + u8 pairwise_key_enc, + u8 group_key_enc); + diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c +#include "wow.h" +#ifdef config_pm +static int rtw_ops_suspend(struct ieee80211_hw *hw, + struct cfg80211_wowlan *wowlan) +{ + struct rtw_dev *rtwdev = hw->priv; + int ret; + + mutex_lock(&rtwdev->mutex); + ret = rtw_wow_suspend(rtwdev, wowlan); + if (ret) + rtw_err(rtwdev, "failed to suspend for wow %d ", ret); + mutex_unlock(&rtwdev->mutex); + + return ret ? 1 : 0; +} + +static int rtw_ops_resume(struct ieee80211_hw *hw) +{ + struct rtw_dev *rtwdev = hw->priv; + int ret; + + mutex_lock(&rtwdev->mutex); + ret = rtw_wow_resume(rtwdev); + if (ret) + rtw_err(rtwdev, "failed to resume for wow %d ", ret); + mutex_unlock(&rtwdev->mutex); + + return ret ? 1 : 0; +} + +static void rtw_ops_set_wakeup(struct ieee80211_hw *hw, bool enabled) +{ + struct rtw_dev *rtwdev = hw->priv; + + device_set_wakeup_enable(rtwdev->dev, enabled); +} +#endif + +#ifdef config_pm + .suspend = rtw_ops_suspend, + .resume = rtw_ops_resume, + .set_wakeup = rtw_ops_set_wakeup, +#endif diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c +#ifdef config_pm + hw->wiphy->wowlan = rtwdev->chip->wowlan_stub; +#endif diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h + rtw_flag_wowlan, +enum rtw_wow_flags { + rtw_wow_flag_en_magic_pkt, + rtw_wow_flag_en_rekey_pkt, + rtw_wow_flag_en_disconnect, + + /* keep it last */ + rtw_wow_flag_max, +}; + +struct rtw_wow_param { + struct ieee80211_vif *wow_vif; + declare_bitmap(flags, rtw_wow_flag_max); + u8 txpause; +}; + + const struct wiphy_wowlan_support *wowlan_stub; + struct rtw_wow_param wow; diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c +#ifdef config_pm +static int rtw_pci_suspend(struct device *dev) +{ + return 0; +} + +static int rtw_pci_resume(struct device *dev) +{ + return 0; +} + +static simple_dev_pm_ops(rtw_pm_ops, rtw_pci_suspend, rtw_pci_resume); +#define rtw_pm_ops (&rtw_pm_ops) +#else +#define rtw_pm_ops null +#endif + + .driver.pm = rtw_pm_ops, diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h +#define bit_r_dis_prst bit(6) +#define bit_wlock_1c_b6 bit(5) +#define reg_fe1imr 0x0120 +#define bit_fs_rxdone bit(16) +#define reg_mcutst_ii 0x01c4 +#define reg_wowlan_wake_reason 0x01c7 +#define reg_rxpkt_num 0x0284 +#define bit_rxdma_req bit(19) +#define bit_rw_release bit(18) +#define bit_rxdma_idle bit(17) +#define reg_rxpktnum 0x02b0 +#define reg_bcnq_info 0x0418 +#define bit_mgq_cpu_empty bit(24) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c +#ifdef config_pm +static const struct wiphy_wowlan_support rtw_wowlan_stub_8822c = { + .flags = wiphy_wowlan_magic_pkt | wiphy_wowlan_gtk_rekey_failure | + wiphy_wowlan_disconnect | wiphy_wowlan_supports_gtk_rekey, +}; +#endif + +#ifdef config_pm + .wow_fw_name = "rtw88/rtw8822c_wow_fw.bin", + .wowlan_stub = &rtw_wowlan_stub_8822c, +#endif +module_firmware("rtw88/rtw8822c_wow_fw.bin"); diff --git a/drivers/net/wireless/realtek/rtw88/util.h b/drivers/net/wireless/realtek/rtw88/util.h --- a/drivers/net/wireless/realtek/rtw88/util.h +++ b/drivers/net/wireless/realtek/rtw88/util.h +#define rtw_iterate_keys(rtwdev, vif, iterator, data) \ + ieee80211_iter_keys(rtwdev->hw, vif, iterator, data) diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c --- /dev/null +++ b/drivers/net/wireless/realtek/rtw88/wow.c +// spdx-license-identifier: gpl-2.0 or bsd-3-clause +/* copyright(c) 2018-2019 realtek corporation + */ + +#include "main.h" +#include "fw.h" +#include "wow.h" +#include "reg.h" +#include "debug.h" +#include "mac.h" +#include "ps.h" + +static void rtw_wow_show_wakeup_reason(struct rtw_dev *rtwdev) +{ + u8 reason; + + reason = rtw_read8(rtwdev, reg_wowlan_wake_reason); + + if (reason == rtw_wow_rsn_rx_deauth) + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: rx deauth "); + else if (reason == rtw_wow_rsn_disconnect) + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: ap is off "); + else if (reason == rtw_wow_rsn_rx_magic_pkt) + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: rx magic packet "); + else if (reason == rtw_wow_rsn_rx_gtk_rekey) + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: rx gtk rekey "); + else if (reason == rtw_wow_rsn_rx_ptk_rekey) + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: rx ptk rekey "); + else + rtw_warn(rtwdev, "unknown wakeup reason %x ", reason); +} + +static void rtw_wow_bb_stop(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + + /* wait 100ms for firmware to finish tx */ + msleep(100); + + if (!rtw_read32_mask(rtwdev, reg_bcnq_info, bit_mgq_cpu_empty)) + rtw_warn(rtwdev, "wrong status of mgq_cpu empty! "); + + rtw_wow->txpause = rtw_read8(rtwdev, reg_txpause); + rtw_write8(rtwdev, reg_txpause, 0xff); + rtw_write8_clr(rtwdev, reg_sys_func_en, bit_fen_bb_rstb); +} + +static void rtw_wow_bb_start(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + + rtw_write8_set(rtwdev, reg_sys_func_en, bit_fen_bb_rstb); + rtw_write8(rtwdev, reg_txpause, rtw_wow->txpause); +} + +static void rtw_wow_rx_dma_stop(struct rtw_dev *rtwdev) +{ + /* wait 100ms for hw to finish rx dma */ + msleep(100); + + rtw_write32_set(rtwdev, reg_rxpkt_num, bit_rw_release); + + if (!check_hw_ready(rtwdev, reg_rxpkt_num, bit_rxdma_idle, 1)) + rtw_err(rtwdev, "failed to stop rx dma "); +} + +static void rtw_wow_rx_dma_start(struct rtw_dev *rtwdev) +{ + rtw_write32_clr(rtwdev, reg_rxpkt_num, bit_rw_release); +} + +static bool rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool wow_enable) +{ + bool ret; + + /* wait 100ms for wow firmware to finish work */ + msleep(100); + + if (wow_enable) { + if (!rtw_read8(rtwdev, reg_wowlan_wake_reason)) + ret = 0; + } else { + if (rtw_read32_mask(rtwdev, reg_fe1imr, bit_fs_rxdone) == 0 && + rtw_read32_mask(rtwdev, reg_rxpkt_num, bit_rw_release) == 0) + ret = 0; + } + + if (ret) + rtw_err(rtwdev, "failed to check wow status %s ", + wow_enable ? "enabled" : "disabled"); + + return ret; +} + +static void rtw_wow_fw_security_type_iter(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key, + void *data) +{ + struct rtw_fw_key_type_iter_data *iter_data = data; + struct rtw_dev *rtwdev = hw->priv; + u8 hw_key_type; + + if (vif != rtwdev->wow.wow_vif) + return; + + switch (key->cipher) { + case wlan_cipher_suite_wep40: + hw_key_type = rtw_cam_wep40; + break; + case wlan_cipher_suite_wep104: + hw_key_type = rtw_cam_wep104; + break; + case wlan_cipher_suite_tkip: + hw_key_type = rtw_cam_tkip; + key->flags |= ieee80211_key_flag_generate_mmic; + break; + case wlan_cipher_suite_ccmp: + hw_key_type = rtw_cam_aes; + key->flags |= ieee80211_key_flag_sw_mgmt_tx; + break; + default: + rtw_err(rtwdev, "unsupported key type for wowlan mode "); + hw_key_type = 0; + break; + } + + if (sta) + iter_data->pairwise_key_type = hw_key_type; + else + iter_data->group_key_type = hw_key_type; +} + +static void rtw_wow_fw_security_type(struct rtw_dev *rtwdev) +{ + struct rtw_fw_key_type_iter_data data = {}; + struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; + + data.rtwdev = rtwdev; + rtw_iterate_keys(rtwdev, wow_vif, + rtw_wow_fw_security_type_iter, &data); + rtw_fw_set_aoac_global_info_cmd(rtwdev, data.pairwise_key_type, + data.group_key_type); +} + +static int rtw_wow_fw_start(struct rtw_dev *rtwdev) +{ + if (rtw_wow_mgd_linked(rtwdev)) { + rtw_send_rsvd_page_h2c(rtwdev); + rtw_wow_fw_security_type(rtwdev); + rtw_fw_set_disconnect_decision_cmd(rtwdev, true); + rtw_fw_set_keep_alive_cmd(rtwdev, true); + } + + rtw_fw_set_wowlan_ctrl_cmd(rtwdev, true); + rtw_fw_set_remote_wake_ctrl_cmd(rtwdev, true); + + return rtw_wow_check_fw_status(rtwdev, true); +} + +static int rtw_wow_fw_stop(struct rtw_dev *rtwdev) +{ + if (rtw_wow_mgd_linked(rtwdev)) { + rtw_fw_set_disconnect_decision_cmd(rtwdev, false); + rtw_fw_set_keep_alive_cmd(rtwdev, false); + } + + rtw_fw_set_wowlan_ctrl_cmd(rtwdev, false); + rtw_fw_set_remote_wake_ctrl_cmd(rtwdev, false); + + return rtw_wow_check_fw_status(rtwdev, false); +} + +static void rtw_wow_avoid_reset_mac(struct rtw_dev *rtwdev) +{ + /* when resuming from wowlan mode, some hosts issue signal + * (pcie: prest, usb: se0rst) to device, and lead to reset + * mac core. if it happens, the connection to ap will be lost. + * setting reg_rsv_ctrl register can avoid this process. + */ + switch (rtw_hci_type(rtwdev)) { + case rtw_hci_type_pcie: + case rtw_hci_type_usb: + rtw_write8(rtwdev, reg_rsv_ctrl, bit_wlock_1c_b6); + rtw_write8(rtwdev, reg_rsv_ctrl, + bit_wlock_1c_b6 | bit_r_dis_prst); + break; + default: + rtw_warn(rtwdev, "unsupported hci type to disable reset mac "); + break; + } +} + +static void rtw_wow_fw_media_status_iter(void *data, struct ieee80211_sta *sta) +{ + struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; + struct rtw_fw_media_status_iter_data *iter_data = data; + struct rtw_dev *rtwdev = iter_data->rtwdev; + + rtw_fw_media_status_report(rtwdev, si->mac_id, iter_data->connect); +} + +static void rtw_wow_fw_media_status(struct rtw_dev *rtwdev, bool connect) +{ + struct rtw_fw_media_status_iter_data data; + + data.rtwdev = rtwdev; + data.connect = connect; + + rtw_iterate_stas_atomic(rtwdev, rtw_wow_fw_media_status_iter, &data); +} + +static void rtw_wow_config_linked_rsvd_page(struct rtw_dev *rtwdev) +{ + rtw_add_rsvd_page(rtwdev, rsvd_ps_poll, true); + rtw_add_rsvd_page(rtwdev, rsvd_qos_null, true); + rtw_add_rsvd_page(rtwdev, rsvd_null, true); + rtw_add_rsvd_page(rtwdev, rsvd_lps_pg_dpk, true); + rtw_add_rsvd_page(rtwdev, rsvd_lps_pg_info, true); +} + +static void rtw_wow_config_rsvd_page(struct rtw_dev *rtwdev) +{ + rtw_reset_rsvd_page(rtwdev); + + if (rtw_wow_mgd_linked(rtwdev)) + rtw_wow_config_linked_rsvd_page(rtwdev); +} + +static int rtw_wow_dl_fw_rsvd_page(struct rtw_dev *rtwdev) +{ + struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; + + rtw_wow_config_rsvd_page(rtwdev); + + return rtw_fw_download_rsvd_page(rtwdev, wow_vif); +} + +static int rtw_wow_swap_fw(struct rtw_dev *rtwdev, enum rtw_fw_type type) +{ + struct rtw_fw_state *fw; + int ret; + + switch (type) { + case rtw_wowlan_fw: + fw = &rtwdev->wow_fw; + break; + + case rtw_normal_fw: + fw = &rtwdev->fw; + break; + + default: + rtw_warn(rtwdev, "unsupported firmware type to swap "); + return -enoent; + } + + ret = rtw_download_firmware(rtwdev, fw); + if (ret) + goto out; + + rtw_fw_send_general_info(rtwdev); + rtw_fw_send_phydm_info(rtwdev); + rtw_wow_fw_media_status(rtwdev, true); + +out: + return ret; +} + +static int rtw_wow_leave_linked_ps(struct rtw_dev *rtwdev) +{ + if (!test_bit(rtw_flag_wowlan, rtwdev->flags)) + cancel_delayed_work_sync(&rtwdev->watch_dog_work); + + return 0; +} + +static int rtw_wow_leave_ps(struct rtw_dev *rtwdev) +{ + int ret = 0; + + if (rtw_wow_mgd_linked(rtwdev)) + ret = rtw_wow_leave_linked_ps(rtwdev); + + return ret; +} + +static int rtw_wow_enter_linked_ps(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; + struct rtw_vif *rtwvif = (struct rtw_vif *)wow_vif->drv_priv; + + rtw_enter_lps(rtwdev, rtwvif->port); + + return 0; +} + +static int rtw_wow_enter_ps(struct rtw_dev *rtwdev) +{ + int ret = 0; + + if (rtw_wow_mgd_linked(rtwdev)) + ret = rtw_wow_enter_linked_ps(rtwdev); + + return ret; +} + +static void rtw_wow_stop_trx(struct rtw_dev *rtwdev) +{ + rtw_wow_bb_stop(rtwdev); + rtw_wow_rx_dma_stop(rtwdev); +} + +static int rtw_wow_start(struct rtw_dev *rtwdev) +{ + int ret; + + ret = rtw_wow_fw_start(rtwdev); + if (ret) + goto out; + + rtw_hci_stop(rtwdev); + rtw_wow_bb_start(rtwdev); + rtw_wow_avoid_reset_mac(rtwdev); + +out: + return ret; +} + +static int rtw_wow_enable(struct rtw_dev *rtwdev) +{ + int ret = 0; + + rtw_wow_stop_trx(rtwdev); + + ret = rtw_wow_swap_fw(rtwdev, rtw_wowlan_fw); + if (ret) { + rtw_err(rtwdev, "failed to swap wow fw "); + goto error; + } + + set_bit(rtw_flag_wowlan, rtwdev->flags); + + ret = rtw_wow_dl_fw_rsvd_page(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to download wowlan rsvd page "); + goto error; + } + + ret = rtw_wow_start(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to start wow "); + goto error; + } + + return ret; + +error: + clear_bit(rtw_flag_wowlan, rtwdev->flags); + return ret; +} + +static int rtw_wow_stop(struct rtw_dev *rtwdev) +{ + int ret; + + /* some hci related registers will be reset after resume, + * need to set them again. + */ + ret = rtw_hci_setup(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to setup hci "); + return ret; + } + + ret = rtw_hci_start(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to start hci "); + return ret; + } + + ret = rtw_wow_fw_stop(rtwdev); + if (ret) + rtw_err(rtwdev, "failed to stop wowlan fw "); + + rtw_wow_bb_stop(rtwdev); + + return ret; +} + +static void rtw_wow_resume_trx(struct rtw_dev *rtwdev) +{ + rtw_wow_rx_dma_start(rtwdev); + rtw_wow_bb_start(rtwdev); + ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, + rtw_watch_dog_delay_time); +} + +static int rtw_wow_disable(struct rtw_dev *rtwdev) +{ + int ret; + + clear_bit(rtw_flag_wowlan, rtwdev->flags); + + ret = rtw_wow_stop(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to stop wow "); + goto out; + } + + ret = rtw_wow_swap_fw(rtwdev, rtw_normal_fw); + if (ret) { + rtw_err(rtwdev, "failed to swap normal fw "); + goto out; + } + + ret = rtw_wow_dl_fw_rsvd_page(rtwdev); + if (ret) + rtw_err(rtwdev, "failed to download normal rsvd page "); + +out: + rtw_wow_resume_trx(rtwdev); + return ret; +} + +static void rtw_wow_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) +{ + struct rtw_dev *rtwdev = data; + struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + + /* current wowlan function support setting of only one station vif. + * so when one suitable vif is found, stop the iteration. + */ + if (rtw_wow->wow_vif || vif->type != nl80211_iftype_station) + return; + + switch (rtwvif->net_type) { + case rtw_net_mgd_linked: + rtw_wow->wow_vif = vif; + break; + default: + break; + } +} + +static int rtw_wow_set_wakeups(struct rtw_dev *rtwdev, + struct cfg80211_wowlan *wowlan) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + + if (wowlan->disconnect) + set_bit(rtw_wow_flag_en_disconnect, rtw_wow->flags); + if (wowlan->magic_pkt) + set_bit(rtw_wow_flag_en_magic_pkt, rtw_wow->flags); + if (wowlan->gtk_rekey_failure) + set_bit(rtw_wow_flag_en_rekey_pkt, rtw_wow->flags); + + rtw_iterate_vifs_atomic(rtwdev, rtw_wow_vif_iter, rtwdev); + if (!rtw_wow->wow_vif) + return -eperm; + + return 0; +} + +static void rtw_wow_clear_wakeups(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + + memset(rtw_wow, 0, sizeof(rtwdev->wow)); +} + +int rtw_wow_suspend(struct rtw_dev *rtwdev, struct cfg80211_wowlan *wowlan) +{ + int ret = 0; + + ret = rtw_wow_set_wakeups(rtwdev, wowlan); + if (ret) { + rtw_err(rtwdev, "failed to set wakeup event "); + goto out; + } + + ret = rtw_wow_leave_ps(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to leave ps from normal mode "); + goto out; + } + + ret = rtw_wow_enable(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to enable wow "); + goto out; + } + + ret = rtw_wow_enter_ps(rtwdev); + if (ret) + rtw_err(rtwdev, "failed to enter ps for wow "); + +out: + return ret; +} + +int rtw_wow_resume(struct rtw_dev *rtwdev) +{ + int ret; + + /* if wowlan mode is not enabled, do nothing */ + if (!test_bit(rtw_flag_wowlan, rtwdev->flags)) { + rtw_err(rtwdev, "wow is not enabled "); + ret = -eperm; + goto out; + } + + ret = rtw_wow_leave_ps(rtwdev); + if (ret) { + rtw_err(rtwdev, "failed to leave ps from wowlan mode "); + goto out; + } + + rtw_wow_show_wakeup_reason(rtwdev); + + ret = rtw_wow_disable(rtwdev); + if (ret) + rtw_err(rtwdev, "failed to disable wow "); + +out: + rtw_wow_clear_wakeups(rtwdev); + return ret; +} diff --git a/drivers/net/wireless/realtek/rtw88/wow.h b/drivers/net/wireless/realtek/rtw88/wow.h --- /dev/null +++ b/drivers/net/wireless/realtek/rtw88/wow.h +/* spdx-license-identifier: gpl-2.0 or bsd-3-clause */ +/* copyright(c) 2018-2019 realtek corporation + */ + +#ifndef __rtw_wow_h__ +#define __rtw_wow_h__ + +enum rtw_wake_reason { + rtw_wow_rsn_rx_ptk_rekey = 0x1, + rtw_wow_rsn_rx_gtk_rekey = 0x2, + rtw_wow_rsn_rx_deauth = 0x8, + rtw_wow_rsn_disconnect = 0x10, + rtw_wow_rsn_rx_magic_pkt = 0x21, +}; + +struct rtw_fw_media_status_iter_data { + struct rtw_dev *rtwdev; + u8 connect; +}; + +struct rtw_fw_key_type_iter_data { + struct rtw_dev *rtwdev; + u8 group_key_type; + u8 pairwise_key_type; +}; + +static inline bool rtw_wow_mgd_linked(struct rtw_dev *rtwdev) +{ + struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; + struct rtw_vif *rtwvif = (struct rtw_vif *)wow_vif->drv_priv; + + return (rtwvif->net_type == rtw_net_mgd_linked); +} + +int rtw_wow_suspend(struct rtw_dev *rtwdev, struct cfg80211_wowlan *wowlan); +int rtw_wow_resume(struct rtw_dev *rtwdev); + +#endif
|
Networking
|
44bc17f7f5b3b2cc4084eba6307ba750078a8a73
|
chin yen lee
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: add wowlan pattern match support
|
pattern match is an option of wowlan to allow the device to be woken up from suspend mode when receiving packets matched user-designed patterns.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['c', 'h']
| 7
| 274
| 0
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c + if (rtw_wow->pattern_cnt) + set_wowlan_pattern_match_enable(h2c_pkt, enable); + lps_pg_pattern_cam_en(h2c_pkt, conf->pattern_cam_backup); + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + pg_info_hdr->pattern_count = rtw_wow->pattern_cnt; + conf->pattern_cam_backup = rtw_wow->pattern_cnt != 0; diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h +#define lps_pg_pattern_cam_en(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(10)) +#define set_wowlan_pattern_match_enable(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(9)) diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h +#define rtw_max_pattern_num 12 +#define rtw_max_pattern_mask_size 16 +#define rtw_max_pattern_size 128 + + bool pattern_cam_backup; +struct rtw_wow_pattern { + u16 crc; + u8 type; + u8 valid; + u8 mask[rtw_max_pattern_mask_size]; +}; + + u8 pattern_cnt; + struct rtw_wow_pattern patterns[rtw_max_pattern_num]; diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h +#define reg_wkfmcam_cmd 0x0698 +#define bit_wkfcam_polling_v1 bit(31) +#define bit_wkfcam_clr_v1 bit(30) +#define bit_wkfcam_we bit(16) +#define bit_shift_wkfcam_addr_v2 8 +#define bit_mask_wkfcam_addr_v2 0xff +#define bit_wkfcam_addr_v2(x) \ + (((x) & bit_mask_wkfcam_addr_v2) << bit_shift_wkfcam_addr_v2) +#define reg_wkfmcam_rwd 0x069c +#define bit_wkfmcam_valid bit(31) +#define bit_wkfmcam_bc bit(26) +#define bit_wkfmcam_mc bit(25) +#define bit_wkfmcam_uc bit(24) + diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c + .n_patterns = rtw_max_pattern_num, + .pattern_max_len = rtw_max_pattern_size, + .pattern_min_len = 1, diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c + else if (reason == rtw_wow_rsn_rx_pattern_match) + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: rx pattern match packet "); +static void rtw_wow_pattern_write_cam(struct rtw_dev *rtwdev, u8 addr, + u32 wdata) +{ + rtw_write32(rtwdev, reg_wkfmcam_rwd, wdata); + rtw_write32(rtwdev, reg_wkfmcam_cmd, bit_wkfcam_polling_v1 | + bit_wkfcam_we | bit_wkfcam_addr_v2(addr)); + + if (!check_hw_ready(rtwdev, reg_wkfmcam_cmd, bit_wkfcam_polling_v1, 0)) + rtw_err(rtwdev, "failed to write pattern cam "); +} + +static void rtw_wow_pattern_write_cam_ent(struct rtw_dev *rtwdev, u8 id, + struct rtw_wow_pattern *rtw_pattern) +{ + int i; + u8 addr; + u32 wdata; + + for (i = 0; i < rtw_max_pattern_mask_size / 4; i++) { + addr = (id << 3) + i; + wdata = rtw_pattern->mask[i * 4]; + wdata |= rtw_pattern->mask[i * 4 + 1] << 8; + wdata |= rtw_pattern->mask[i * 4 + 2] << 16; + wdata |= rtw_pattern->mask[i * 4 + 3] << 24; + rtw_wow_pattern_write_cam(rtwdev, addr, wdata); + } + + wdata = rtw_pattern->crc; + addr = (id << 3) + rtw_max_pattern_mask_size / 4; + + switch (rtw_pattern->type) { + case rtw_pattern_broadcast: + wdata |= bit_wkfmcam_bc | bit_wkfmcam_valid; + break; + case rtw_pattern_multicast: + wdata |= bit_wkfmcam_mc | bit_wkfmcam_valid; + break; + case rtw_pattern_unicast: + wdata |= bit_wkfmcam_uc | bit_wkfmcam_valid; + break; + default: + break; + } + rtw_wow_pattern_write_cam(rtwdev, addr, wdata); +} + +/* rtk internal crc16 for pattern cam */ +static u16 __rtw_cal_crc16(u8 data, u16 crc) +{ + u8 shift_in, data_bit; + u8 crc_bit4, crc_bit11, crc_bit15; + u16 crc_result; + int index; + + for (index = 0; index < 8; index++) { + crc_bit15 = ((crc & bit(15)) ? 1 : 0); + data_bit = (data & (bit(0) << index) ? 1 : 0); + shift_in = crc_bit15 ^ data_bit; + + crc_result = crc << 1; + + if (shift_in == 0) + crc_result &= (~bit(0)); + else + crc_result |= bit(0); + + crc_bit11 = ((crc & bit(11)) ? 1 : 0) ^ shift_in; + + if (crc_bit11 == 0) + crc_result &= (~bit(12)); + else + crc_result |= bit(12); + + crc_bit4 = ((crc & bit(4)) ? 1 : 0) ^ shift_in; + + if (crc_bit4 == 0) + crc_result &= (~bit(5)); + else + crc_result |= bit(5); + + crc = crc_result; + } + return crc; +} + +static u16 rtw_calc_crc(u8 *pdata, int length) +{ + u16 crc = 0xffff; + int i; + + for (i = 0; i < length; i++) + crc = __rtw_cal_crc16(pdata[i], crc); + + /* get 1' complement */ + return ~crc; +} + +static void rtw_wow_pattern_generate(struct rtw_dev *rtwdev, + struct rtw_vif *rtwvif, + const struct cfg80211_pkt_pattern *pkt_pattern, + struct rtw_wow_pattern *rtw_pattern) +{ + const u8 *mask; + const u8 *pattern; + u8 mask_hw[rtw_max_pattern_mask_size] = {0}; + u8 content[rtw_max_pattern_size] = {0}; + u8 mac_addr[eth_alen] = {0}; + u8 mask_len; + u16 count; + int len; + int i; + + pattern = pkt_pattern->pattern; + len = pkt_pattern->pattern_len; + mask = pkt_pattern->mask; + + ether_addr_copy(mac_addr, rtwvif->mac_addr); + memset(rtw_pattern, 0, sizeof(*rtw_pattern)); + + mask_len = div_round_up(len, 8); + + if (is_broadcast_ether_addr(pattern)) + rtw_pattern->type = rtw_pattern_broadcast; + else if (is_multicast_ether_addr(pattern)) + rtw_pattern->type = rtw_pattern_multicast; + else if (ether_addr_equal(pattern, mac_addr)) + rtw_pattern->type = rtw_pattern_unicast; + else + rtw_pattern->type = rtw_pattern_invalid; + + /* translate mask from os to mask for hw + * pattern from os uses 'ethenet frame', like this: + * | 6 | 6 | 2 | 20 | variable | 4 | + * |--------+--------+------+-----------+------------+-----| + * | 802.3 mac header | ip header | tcp packet | fcs | + * | da | sa | type | + * + * but, packet catched by our hw is in '802.11 frame', begin from llc + * | 24 or 30 | 6 | 2 | 20 | variable | 4 | + * |-------------------+--------+------+-----------+------------+-----| + * | 802.11 mac header | llc | ip header | tcp packet | fcs | + * | others | tpye | + * + * therefore, we need translate mask_from_os to mask_to_hw. + * we should left-shift mask by 6 bits, then set the new bit[0~5] = 0, + * because new mask[0~5] means 'sa', but our hw packet begins from llc, + * bit[0~5] corresponds to first 6 bytes in llc, they just don't match. + */ + + /* shift 6 bits */ + for (i = 0; i < mask_len - 1; i++) { + mask_hw[i] = u8_get_bits(mask[i], genmask(7, 6)); + mask_hw[i] |= u8_get_bits(mask[i + 1], genmask(5, 0)) << 2; + } + mask_hw[i] = u8_get_bits(mask[i], genmask(7, 6)); + + /* set bit 0-5 to zero */ + mask_hw[0] &= (~genmask(5, 0)); + + memcpy(rtw_pattern->mask, mask_hw, rtw_max_pattern_mask_size); + + /* to get the wake up pattern from the mask. + * we do not count first 12 bits which means + * da[6] and sa[6] in the pattern to match hw design. + */ + count = 0; + for (i = 12; i < len; i++) { + if ((mask[i / 8] >> (i % 8)) & 0x01) { + content[count] = pattern[i]; + count++; + } + } + + rtw_pattern->crc = rtw_calc_crc(content, count); +} + +static void rtw_wow_pattern_clear_cam(struct rtw_dev *rtwdev) +{ + bool ret; + + rtw_write32(rtwdev, reg_wkfmcam_cmd, bit_wkfcam_polling_v1 | + bit_wkfcam_clr_v1); + + ret = check_hw_ready(rtwdev, reg_wkfmcam_cmd, bit_wkfcam_polling_v1, 0); + if (!ret) + rtw_err(rtwdev, "failed to clean pattern cam "); +} + +static void rtw_wow_pattern_write(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + struct rtw_wow_pattern *rtw_pattern = rtw_wow->patterns; + int i = 0; + + for (i = 0; i < rtw_wow->pattern_cnt; i++) + rtw_wow_pattern_write_cam_ent(rtwdev, i, rtw_pattern + i); +} + +static void rtw_wow_pattern_clear(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + + rtw_wow_pattern_clear_cam(rtwdev); + + rtw_wow->pattern_cnt = 0; + memset(rtw_wow->patterns, 0, sizeof(rtw_wow->patterns)); +} + + rtw_wow_pattern_write(rtwdev); + rtw_wow_pattern_clear(rtwdev); + struct rtw_wow_pattern *rtw_patterns = rtw_wow->patterns; + struct rtw_vif *rtwvif; + int i; + rtwvif = (struct rtw_vif *)rtw_wow->wow_vif->drv_priv; + if (wowlan->n_patterns && wowlan->patterns) { + rtw_wow->pattern_cnt = wowlan->n_patterns; + for (i = 0; i < wowlan->n_patterns; i++) + rtw_wow_pattern_generate(rtwdev, rtwvif, + wowlan->patterns + i, + rtw_patterns + i); + } + diff --git a/drivers/net/wireless/realtek/rtw88/wow.h b/drivers/net/wireless/realtek/rtw88/wow.h --- a/drivers/net/wireless/realtek/rtw88/wow.h +++ b/drivers/net/wireless/realtek/rtw88/wow.h +enum rtw_wow_pattern_type { + rtw_pattern_broadcast = 0, + rtw_pattern_multicast, + rtw_pattern_unicast, + rtw_pattern_valid, + rtw_pattern_invalid, +}; + + rtw_wow_rsn_rx_pattern_match = 0x23,
|
Networking
|
e3e400df30078830871b927ca24826667d97d1f6
|
chin yen lee
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: add wowlan net-detect support
|
net-detect is an option of wowlan to allow the device to be woken up from suspend mode when configured network is detected.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add wowlan support for 8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88']
|
['c', 'h']
| 7
| 571
| 15
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c + if (rtw_wow_no_link(rtwdev)) + set_remote_wake_ctrl_nlo_offload_en(h2c_pkt, enable); + +void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable) +{ + u8 h2c_pkt[h2c_pkt_size] = {0}; + u8 loc_nlo; + + loc_nlo = rtw_get_rsvd_page_location(rtwdev, rsvd_nlo_info); + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_nlo_info); + + set_nlo_fun_en(h2c_pkt, enable); + if (enable) { + if (rtw_fw_lps_deep_mode) + set_nlo_ps_32k(h2c_pkt, enable); + set_nlo_ignore_security(h2c_pkt, enable); + set_nlo_loc_nlo_info(h2c_pkt, loc_nlo); + } + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} + +u8 rtw_get_rsvd_page_probe_req_location(struct rtw_dev *rtwdev, + struct cfg80211_ssid *ssid) +{ + struct rtw_rsvd_page *rsvd_pkt; + u8 location = 0; + + list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { + if (rsvd_pkt->type != rsvd_probe_req) + continue; + if ((!ssid && !rsvd_pkt->ssid) || + rtw_ssid_equal(rsvd_pkt->ssid, ssid)) + location = rsvd_pkt->page; + } + + return location; +} + +u16 rtw_get_rsvd_page_probe_req_size(struct rtw_dev *rtwdev, + struct cfg80211_ssid *ssid) +{ + struct rtw_rsvd_page *rsvd_pkt; + u16 size = 0; + + list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { + if (rsvd_pkt->type != rsvd_probe_req) + continue; + if ((!ssid && !rsvd_pkt->ssid) || + rtw_ssid_equal(rsvd_pkt->ssid, ssid)) + size = rsvd_pkt->skb->len; + } + + return size; +} + +static struct sk_buff *rtw_nlo_info_get(struct ieee80211_hw *hw) +{ + struct rtw_dev *rtwdev = hw->priv; + struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_pno_request *pno_req = &rtwdev->wow.pno_req; + struct rtw_nlo_info_hdr *nlo_hdr; + struct cfg80211_ssid *ssid; + struct sk_buff *skb; + u8 *pos, loc; + u32 size; + int i; + + if (!pno_req->inited || !pno_req->match_set_cnt) + return null; + + size = sizeof(struct rtw_nlo_info_hdr) + pno_req->match_set_cnt * + ieee80211_max_ssid_len + chip->tx_pkt_desc_sz; + + skb = alloc_skb(size, gfp_kernel); + if (!skb) + return null; + + skb_reserve(skb, chip->tx_pkt_desc_sz); + + nlo_hdr = skb_put_zero(skb, sizeof(struct rtw_nlo_info_hdr)); + + nlo_hdr->nlo_count = pno_req->match_set_cnt; + nlo_hdr->hidden_ap_count = pno_req->match_set_cnt; + + /* pattern check for firmware */ + memset(nlo_hdr->pattern_check, 0xa5, fw_nlo_info_check_size); + + for (i = 0; i < pno_req->match_set_cnt; i++) + nlo_hdr->ssid_len[i] = pno_req->match_sets[i].ssid.ssid_len; + + for (i = 0; i < pno_req->match_set_cnt; i++) { + ssid = &pno_req->match_sets[i].ssid; + loc = rtw_get_rsvd_page_probe_req_location(rtwdev, ssid); + if (!loc) { + rtw_err(rtwdev, "failed to get probe req rsvd loc "); + kfree(skb); + return null; + } + nlo_hdr->location[i] = loc; + } + + for (i = 0; i < pno_req->match_set_cnt; i++) { + pos = skb_put_zero(skb, ieee80211_max_ssid_len); + memcpy(pos, pno_req->match_sets[i].ssid.ssid, + pno_req->match_sets[i].ssid.ssid_len); + } + + return skb; +} + +static struct sk_buff *rtw_cs_channel_info_get(struct ieee80211_hw *hw) +{ + struct rtw_dev *rtwdev = hw->priv; + struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_pno_request *pno_req = &rtwdev->wow.pno_req; + struct ieee80211_channel *channels = pno_req->channels; + struct sk_buff *skb; + int count = pno_req->channel_cnt; + u8 *pos; + int i = 0; + + skb = alloc_skb(4 * count + chip->tx_pkt_desc_sz, gfp_kernel); + if (!skb) + return null; + + skb_reserve(skb, chip->tx_pkt_desc_sz); + + for (i = 0; i < count; i++) { + pos = skb_put_zero(skb, 4); + + chsw_info_set_ch(pos, channels[i].hw_value); + + if (channels[i].flags & ieee80211_chan_radar) + chsw_info_set_action_id(pos, 0); + else + chsw_info_set_action_id(pos, 1); + chsw_info_set_timeout(pos, 1); + chsw_info_set_pri_ch_idx(pos, 1); + chsw_info_set_bw(pos, 0); + } + + return skb; +} + - enum rtw_rsvd_packet_type type) + struct rtw_rsvd_page *rsvd_pkt) + struct cfg80211_ssid *ssid; - switch (type) { + switch (rsvd_pkt->type) { + case rsvd_probe_req: + ssid = (struct cfg80211_ssid *)rsvd_pkt->ssid; + if (ssid) + skb_new = ieee80211_probereq_get(hw, vif->addr, + ssid->ssid, + ssid->ssid_len, 0); + else + skb_new = ieee80211_probereq_get(hw, vif->addr, null, 0, 0); + break; + case rsvd_nlo_info: + skb_new = rtw_nlo_info_get(hw); + break; + case rsvd_ch_info: + skb_new = rtw_cs_channel_info_get(hw); + break; +static struct rtw_rsvd_page *rtw_alloc_rsvd_page(struct rtw_dev *rtwdev, + enum rtw_rsvd_packet_type type, + bool txdesc) +{ + struct rtw_rsvd_page *rsvd_pkt = null; + + rsvd_pkt = kzalloc(sizeof(*rsvd_pkt), gfp_kernel); + + if (!rsvd_pkt) + return null; + + rsvd_pkt->type = type; + rsvd_pkt->add_txdesc = txdesc; + + return rsvd_pkt; +} + +static void rtw_insert_rsvd_page(struct rtw_dev *rtwdev, + struct rtw_rsvd_page *rsvd_pkt) +{ + lockdep_assert_held(&rtwdev->mutex); + list_add_tail(&rsvd_pkt->list, &rtwdev->rsvd_page_list); +} + - lockdep_assert_held(&rtwdev->mutex); + rsvd_pkt = rtw_alloc_rsvd_page(rtwdev, type, txdesc); + if (!rsvd_pkt) + return; - list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { - if (rsvd_pkt->type == type) - return; - } + rtw_insert_rsvd_page(rtwdev, rsvd_pkt); +} - rsvd_pkt = kmalloc(sizeof(*rsvd_pkt), gfp_kernel); +void rtw_add_rsvd_page_probe_req(struct rtw_dev *rtwdev, + struct cfg80211_ssid *ssid) +{ + struct rtw_rsvd_page *rsvd_pkt; + + rsvd_pkt = rtw_alloc_rsvd_page(rtwdev, rsvd_probe_req, true); - rsvd_pkt->type = type; - rsvd_pkt->add_txdesc = txdesc; - list_add_tail(&rsvd_pkt->list, &rtwdev->rsvd_page_list); + rsvd_pkt->ssid = ssid; + rtw_insert_rsvd_page(rtwdev, rsvd_pkt); - iter = rtw_get_rsvd_page_skb(hw, vif, rsvd_pkt->type); + iter = rtw_get_rsvd_page_skb(hw, vif, rsvd_pkt); + +static void __rtw_fw_update_pkt(struct rtw_dev *rtwdev, u8 pkt_id, u16 size, + u8 location) +{ + u8 h2c_pkt[h2c_pkt_size] = {0}; + u16 total_size = h2c_pkt_hdr_size + h2c_pkt_update_pkt_len; + + rtw_h2c_pkt_set_header(h2c_pkt, h2c_pkt_update_pkt); + + set_pkt_h2c_total_len(h2c_pkt, total_size); + update_pkt_set_pkt_id(h2c_pkt, pkt_id); + update_pkt_set_location(h2c_pkt, location); + + /* include txdesc size */ + update_pkt_set_size(h2c_pkt, size); + + rtw_fw_send_h2c_packet(rtwdev, h2c_pkt); +} + +void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev, + struct cfg80211_ssid *ssid) +{ + u8 loc; + u32 size; + + loc = rtw_get_rsvd_page_probe_req_location(rtwdev, ssid); + if (!loc) { + rtw_err(rtwdev, "failed to get probe_req rsvd loc "); + return; + } + + size = rtw_get_rsvd_page_probe_req_size(rtwdev, ssid); + if (!size) { + rtw_err(rtwdev, "failed to get probe_req rsvd size "); + return; + } + + __rtw_fw_update_pkt(rtwdev, rtw_packet_probe_req, size, loc); +} + +void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable) +{ + struct rtw_pno_request *rtw_pno_req = &rtwdev->wow.pno_req; + u8 h2c_pkt[h2c_pkt_size] = {0}; + u16 total_size = h2c_pkt_hdr_size + h2c_pkt_ch_switch_len; + u8 loc_ch_info; + const struct rtw_ch_switch_option cs_option = { + .dest_ch_en = 1, + .dest_ch = 1, + .periodic_option = 2, + .normal_period = 5, + .normal_period_sel = 0, + .normal_cycle = 10, + .slow_period = 1, + .slow_period_sel = 1, + }; + + rtw_h2c_pkt_set_header(h2c_pkt, h2c_pkt_ch_switch); + set_pkt_h2c_total_len(h2c_pkt, total_size); + + ch_switch_set_start(h2c_pkt, enable); + ch_switch_set_dest_ch_en(h2c_pkt, cs_option.dest_ch_en); + ch_switch_set_dest_ch(h2c_pkt, cs_option.dest_ch); + ch_switch_set_normal_period(h2c_pkt, cs_option.normal_period); + ch_switch_set_normal_period_sel(h2c_pkt, cs_option.normal_period_sel); + ch_switch_set_slow_period(h2c_pkt, cs_option.slow_period); + ch_switch_set_slow_period_sel(h2c_pkt, cs_option.slow_period_sel); + ch_switch_set_normal_cycle(h2c_pkt, cs_option.normal_cycle); + ch_switch_set_periodic_opt(h2c_pkt, cs_option.periodic_option); + + ch_switch_set_ch_num(h2c_pkt, rtw_pno_req->channel_cnt); + ch_switch_set_info_size(h2c_pkt, rtw_pno_req->channel_cnt * 4); + + loc_ch_info = rtw_get_rsvd_page_location(rtwdev, rsvd_ch_info); + ch_switch_set_info_loc(h2c_pkt, loc_ch_info); + + rtw_fw_send_h2c_packet(rtwdev, h2c_pkt); +} diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h +#define fw_nlo_info_check_size 4 + + rsvd_probe_req, + rsvd_nlo_info, + rsvd_ch_info, + struct cfg80211_ssid *ssid; +struct rtw_nlo_info_hdr { + u8 nlo_count; + u8 hidden_ap_count; + u8 rsvd1[2]; + u8 pattern_check[fw_nlo_info_check_size]; + u8 rsvd2[8]; + u8 ssid_len[16]; + u8 chiper[16]; + u8 rsvd3[16]; + u8 location[8]; +} __packed; + +enum rtw_packet_type { + rtw_packet_probe_req = 0x00, + + rtw_packet_undefine = 0x7fffffff, +}; + +struct rtw_ch_switch_option { + u8 periodic_option; + u32 tsf_high; + u32 tsf_low; + u8 dest_ch_en; + u8 absolute_time_en; + u8 dest_ch; + u8 normal_period; + u8 normal_period_sel; + u8 normal_cycle; + u8 slow_period; + u8 slow_period_sel; + u8 nlo_en; +}; + +#define h2c_pkt_ch_switch 0x02 +#define h2c_pkt_update_pkt 0x0c + +#define h2c_pkt_ch_switch_len 0x20 +#define h2c_pkt_update_pkt_len 0x4 + +#define chsw_info_set_ch(pkt, value) \ + le32p_replace_bits((__le32 *)(pkt) + 0x00, value, genmask(7, 0)) +#define chsw_info_set_pri_ch_idx(pkt, value) \ + le32p_replace_bits((__le32 *)(pkt) + 0x00, value, genmask(11, 8)) +#define chsw_info_set_bw(pkt, value) \ + le32p_replace_bits((__le32 *)(pkt) + 0x00, value, genmask(15, 12)) +#define chsw_info_set_timeout(pkt, value) \ + le32p_replace_bits((__le32 *)(pkt) + 0x00, value, genmask(23, 16)) +#define chsw_info_set_action_id(pkt, value) \ + le32p_replace_bits((__le32 *)(pkt) + 0x00, value, genmask(30, 24)) + +#define update_pkt_set_size(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(15, 0)) +#define update_pkt_set_pkt_id(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(23, 16)) +#define update_pkt_set_location(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(31, 24)) + +#define ch_switch_set_start(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, bit(0)) +#define ch_switch_set_dest_ch_en(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, bit(1)) +#define ch_switch_set_absolute_time(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, bit(2)) +#define ch_switch_set_periodic_opt(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(4, 3)) +#define ch_switch_set_info_loc(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(15, 8)) +#define ch_switch_set_ch_num(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(23, 16)) +#define ch_switch_set_pri_ch_idx(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, genmask(27, 24)) +#define ch_switch_set_dest_ch(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, genmask(7, 0)) +#define ch_switch_set_normal_period(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, genmask(13, 8)) +#define ch_switch_set_normal_period_sel(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, genmask(15, 14)) +#define ch_switch_set_slow_period(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, genmask(21, 16)) +#define ch_switch_set_slow_period_sel(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, genmask(23, 22)) +#define ch_switch_set_normal_cycle(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x03, value, genmask(31, 24)) +#define ch_switch_set_tsf_high(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x04, value, genmask(31, 0)) +#define ch_switch_set_tsf_low(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x05, value, genmask(31, 0)) +#define ch_switch_set_info_size(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x06, value, genmask(15, 0)) + +#define h2c_cmd_nlo_info 0x8c + +#define set_nlo_fun_en(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(8)) +#define set_nlo_ps_32k(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(9)) +#define set_nlo_ignore_security(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(10)) +#define set_nlo_loc_nlo_info(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, genmask(23, 16)) + +void rtw_add_rsvd_page_probe_req(struct rtw_dev *rtwdev, + struct cfg80211_ssid *ssid); +void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable); +void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev, + struct cfg80211_ssid *ssid); +void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable); diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c + hw->wiphy->max_sched_scan_ssids = rtwdev->chip->max_sched_scan_ssids; diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h +struct rtw_pno_request { + bool inited; + u32 match_set_cnt; + struct cfg80211_match_set *match_sets; + u8 channel_cnt; + struct ieee80211_channel *channels; + struct cfg80211_sched_scan_plan scan_plan; +}; + + + bool ips_enabled; + struct rtw_pno_request pno_req; + const u8 max_sched_scan_ssids; +static inline bool rtw_ssid_equal(struct cfg80211_ssid *a, + struct cfg80211_ssid *b) +{ + if (!a || !b || a->ssid_len != b->ssid_len) + return false; + + if (memcmp(a->ssid, b->ssid, a->ssid_len)) + return false; + + return true; +} + diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c - wiphy_wowlan_disconnect | wiphy_wowlan_supports_gtk_rekey, + wiphy_wowlan_disconnect | wiphy_wowlan_supports_gtk_rekey | + wiphy_wowlan_net_detect, + .max_nd_match_sets = 4, + .max_sched_scan_ssids = 4, diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c + else if (reason == rtw_wow_rsn_rx_nlo) + rtw_dbg(rtwdev, rtw_dbg_wow, "rx nlo "); + } else if (rtw_wow_no_link(rtwdev)) { + rtw_fw_set_nlo_info(rtwdev, true); + rtw_fw_update_pkt_probe_req(rtwdev, null); + rtw_fw_channel_switch(rtwdev, true); + } else if (rtw_wow_no_link(rtwdev)) { + rtw_fw_channel_switch(rtwdev, false); + rtw_fw_set_nlo_info(rtwdev, false); +static void rtw_wow_config_pno_rsvd_page(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + struct rtw_pno_request *rtw_pno_req = &rtw_wow->pno_req; + struct cfg80211_ssid *ssid; + int i; + + for (i = 0 ; i < rtw_pno_req->match_set_cnt; i++) { + ssid = &rtw_pno_req->match_sets[i].ssid; + rtw_add_rsvd_page_probe_req(rtwdev, ssid); + } + rtw_add_rsvd_page_probe_req(rtwdev, null); + rtw_add_rsvd_page(rtwdev, rsvd_nlo_info, false); + rtw_add_rsvd_page(rtwdev, rsvd_ch_info, true); +} + - if (rtw_wow_mgd_linked(rtwdev)) + if (rtw_wow_mgd_linked(rtwdev)) { + } else if (test_bit(rtw_flag_wowlan, rtwdev->flags) && + rtw_wow_no_link(rtwdev)) { + rtw_wow_config_pno_rsvd_page(rtwdev); + } +static void rtw_wow_check_pno(struct rtw_dev *rtwdev, + struct cfg80211_sched_scan_request *nd_config) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + struct rtw_pno_request *pno_req = &rtw_wow->pno_req; + struct ieee80211_channel *channel; + int i, size; + + if (!nd_config->n_match_sets || !nd_config->n_channels) + goto err; + + pno_req->match_set_cnt = nd_config->n_match_sets; + size = sizeof(*pno_req->match_sets) * pno_req->match_set_cnt; + pno_req->match_sets = kmemdup(nd_config->match_sets, size, gfp_kernel); + if (!pno_req->match_sets) + goto err; + + pno_req->channel_cnt = nd_config->n_channels; + size = sizeof(*nd_config->channels[0]) * nd_config->n_channels; + pno_req->channels = kmalloc(size, gfp_kernel); + if (!pno_req->channels) + goto channel_err; + + for (i = 0 ; i < pno_req->channel_cnt; i++) { + channel = pno_req->channels + i; + memcpy(channel, nd_config->channels[i], sizeof(*channel)); + } + + pno_req->scan_plan = *nd_config->scan_plans; + pno_req->inited = true; + + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: net-detect is enabled "); + + return; + +channel_err: + kfree(pno_req->match_sets); + +err: + rtw_dbg(rtwdev, rtw_dbg_wow, "wow: net-detect is disabled "); +} + + rtw_leave_lps(rtwdev); + + return 0; +} + +static int rtw_wow_leave_no_link_ps(struct rtw_dev *rtwdev) +{ + struct rtw_wow_param *rtw_wow = &rtwdev->wow; + int ret = 0; + + if (test_bit(rtw_flag_wowlan, rtwdev->flags)) { + if (rtw_fw_lps_deep_mode) + rtw_leave_lps_deep(rtwdev); + } else { + if (test_bit(rtw_flag_inactive_ps, rtwdev->flags)) { + rtw_wow->ips_enabled = true; + ret = rtw_leave_ips(rtwdev); + if (ret) + return ret; + } + } + + else if (rtw_wow_no_link(rtwdev)) + ret = rtw_wow_leave_no_link_ps(rtwdev); + + return ret; +} + +static int rtw_wow_restore_ps(struct rtw_dev *rtwdev) +{ + int ret = 0; + + if (rtw_wow_no_link(rtwdev) && rtwdev->wow.ips_enabled) + ret = rtw_enter_ips(rtwdev); +static int rtw_wow_enter_no_link_ps(struct rtw_dev *rtwdev) +{ + /* firmware enters deep ps by itself if supported */ + set_bit(rtw_flag_leisure_ps_deep, rtwdev->flags); + + return 0; +} + + else if (rtw_wow_no_link(rtwdev) && rtw_fw_lps_deep_mode) + ret = rtw_wow_enter_no_link_ps(rtwdev); + case rtw_net_no_link: + if (rtw_wow->pno_req.inited) + rtwdev->wow.wow_vif = vif; + break; + if (wowlan->nd_config) + rtw_wow_check_pno(rtwdev, wowlan->nd_config); + + struct rtw_pno_request *pno_req = &rtw_wow->pno_req; + + if (pno_req->inited) { + kfree(pno_req->channels); + kfree(pno_req->match_sets); + } + rtw_wow_restore_ps(rtwdev); - if (ret) + if (ret) { + goto out; + } + + ret = rtw_wow_restore_ps(rtwdev); + if (ret) + rtw_err(rtwdev, "failed to restore ps to normal mode "); diff --git a/drivers/net/wireless/realtek/rtw88/wow.h b/drivers/net/wireless/realtek/rtw88/wow.h --- a/drivers/net/wireless/realtek/rtw88/wow.h +++ b/drivers/net/wireless/realtek/rtw88/wow.h +#define pno_check_byte 4 + + rtw_wow_rsn_rx_nlo = 0x55, +static inline bool rtw_wow_no_link(struct rtw_dev *rtwdev) +{ + struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; + struct rtw_vif *rtwvif = (struct rtw_vif *)wow_vif->drv_priv; + + return (rtwvif->net_type == rtw_net_no_link); +} +
|
Networking
|
b6c12908a33e4e413523e73464cd5957690f1a76
|
chin yen lee
|
drivers
|
net
|
realtek, rtw88, wireless
|
net: stmmac: add basic est support for gmac5+
|
adds the support for est in gmac5+ cores. this feature allows to offload scheduling of queues opening time to the ip.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 8
| 150
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h + /* tsn features */ + unsigned int estwid; + unsigned int estdep; + unsigned int estsel; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +#define gmac_config_ipg genmask(26, 24) +#define gmac_config_ipg_shift 24 +#define gmac_config_fes_shift 14 +#define gmac_config_eipg genmask(29, 25) +#define gmac_config_eipg_shift 25 +#define gmac_config_eipg_en bit(24) +#define gmac_hw_feat_estwid genmask(21, 20) +#define gmac_hw_feat_estdep genmask(19, 17) +#define gmac_hw_feat_estsel bit(16) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c + .est_configure = dwmac5_est_configure, + .est_configure = dwmac5_est_configure, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c + dma_cap->estwid = (hw_cap & gmac_hw_feat_estwid) >> 20; + dma_cap->estdep = (hw_cap & gmac_hw_feat_estdep) >> 17; + dma_cap->estsel = (hw_cap & gmac_hw_feat_estsel) >> 16; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c + +static int dwmac5_est_write(void __iomem *ioaddr, u32 reg, u32 val, bool gcl) +{ + u32 ctrl; + + writel(val, ioaddr + mtl_est_gcl_data); + + ctrl = (reg << addr_shift); + ctrl |= gcl ? 0 : gcrr; + + writel(ctrl, ioaddr + mtl_est_gcl_control); + + ctrl |= srwo; + writel(ctrl, ioaddr + mtl_est_gcl_control); + + return readl_poll_timeout(ioaddr + mtl_est_gcl_control, + ctrl, !(ctrl & srwo), 100, 5000); +} + +int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, + unsigned int ptp_rate) +{ + u32 speed, total_offset, offset, ctrl, ctr_low; + u32 extcfg = readl(ioaddr + gmac_ext_config); + u32 mac_cfg = readl(ioaddr + gmac_config); + int i, ret = 0x0; + u64 total_ctr; + + if (extcfg & gmac_config_eipg_en) { + offset = (extcfg & gmac_config_eipg) >> gmac_config_eipg_shift; + offset = 104 + (offset * 8); + } else { + offset = (mac_cfg & gmac_config_ipg) >> gmac_config_ipg_shift; + offset = 96 - (offset * 8); + } + + speed = mac_cfg & (gmac_config_ps | gmac_config_fes); + speed = speed >> gmac_config_fes_shift; + + switch (speed) { + case 0x0: + offset = offset * 1000; /* 1g */ + break; + case 0x1: + offset = offset * 400; /* 2.5g */ + break; + case 0x2: + offset = offset * 100000; /* 10m */ + break; + case 0x3: + offset = offset * 10000; /* 100m */ + break; + default: + return -einval; + } + + offset = offset / 1000; + + ret |= dwmac5_est_write(ioaddr, btr_low, cfg->btr[0], false); + ret |= dwmac5_est_write(ioaddr, btr_high, cfg->btr[1], false); + ret |= dwmac5_est_write(ioaddr, ter, cfg->ter, false); + ret |= dwmac5_est_write(ioaddr, llr, cfg->gcl_size, false); + if (ret) + return ret; + + total_offset = 0; + for (i = 0; i < cfg->gcl_size; i++) { + ret = dwmac5_est_write(ioaddr, i, cfg->gcl[i] + offset, true); + if (ret) + return ret; + + total_offset += offset; + } + + total_ctr = cfg->ctr[0] + cfg->ctr[1] * 1000000000; + total_ctr += total_offset; + + ctr_low = do_div(total_ctr, 1000000000); + + ret |= dwmac5_est_write(ioaddr, ctr_low, ctr_low, false); + ret |= dwmac5_est_write(ioaddr, ctr_high, total_ctr, false); + if (ret) + return ret; + + ctrl = readl(ioaddr + mtl_est_control); + ctrl &= ~ptov; + ctrl |= ((1000000000 / ptp_rate) * 6) << ptov_shift; + if (cfg->enable) + ctrl |= eest | sswl; + else + ctrl &= ~eest; + + writel(ctrl, ioaddr + mtl_est_control); + return 0; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +#define mtl_est_control 0x00000c50 +#define ptov genmask(31, 24) +#define ptov_shift 24 +#define sswl bit(1) +#define eest bit(0) +#define mtl_est_gcl_control 0x00000c80 +#define btr_low 0x0 +#define btr_high 0x1 +#define ctr_low 0x2 +#define ctr_high 0x3 +#define ter 0x4 +#define llr 0x5 +#define addr_shift 8 +#define gcrr bit(2) +#define srwo bit(0) +#define mtl_est_gcl_data 0x00000c84 + +int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, + unsigned int ptp_rate); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h +struct stmmac_est; + int (*est_configure)(void __iomem *ioaddr, struct stmmac_est *cfg, + unsigned int ptp_rate); +#define stmmac_est_configure(__priv, __args...) \ + stmmac_do_callback(__priv, mac, est_configure, __args) diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h +#define est_gcl 1024 +struct stmmac_est { + int enable; + u32 btr_offset[2]; + u32 btr[2]; + u32 ctr[2]; + u32 ter; + u32 gcl_unaligned[est_gcl]; + u32 gcl[est_gcl]; + u32 gcl_size; +}; + + struct stmmac_est *est;
|
Networking
|
504723af0d85434be5fb6f2dde0b62644a7f1ead
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add basic est support for xgmac
|
adds the support for est in xgmac cores. this feature allows to offload scheduling of queues opening time to the ip.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 3
| 74
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +#define xgmac_hwfeat_estwid genmask(24, 23) +#define xgmac_hwfeat_estdep genmask(22, 20) +#define xgmac_hwfeat_estsel bit(19) +#define xgmac_mtl_est_control 0x00001050 +#define xgmac_ptov genmask(31, 23) +#define xgmac_ptov_shift 23 +#define xgmac_sswl bit(1) +#define xgmac_eest bit(0) +#define xgmac_mtl_est_gcl_control 0x00001080 +#define xgmac_btr_low 0x0 +#define xgmac_btr_high 0x1 +#define xgmac_ctr_low 0x2 +#define xgmac_ctr_high 0x3 +#define xgmac_ter 0x4 +#define xgmac_llr 0x5 +#define xgmac_addr_shift 8 +#define xgmac_gcrr bit(2) +#define xgmac_srwo bit(0) +#define xgmac_mtl_est_gcl_data 0x00001084 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +static int dwxgmac3_est_write(void __iomem *ioaddr, u32 reg, u32 val, bool gcl) +{ + u32 ctrl; + + writel(val, ioaddr + xgmac_mtl_est_gcl_data); + + ctrl = (reg << xgmac_addr_shift); + ctrl |= gcl ? 0 : xgmac_gcrr; + + writel(ctrl, ioaddr + xgmac_mtl_est_gcl_control); + + ctrl |= xgmac_srwo; + writel(ctrl, ioaddr + xgmac_mtl_est_gcl_control); + + return readl_poll_timeout_atomic(ioaddr + xgmac_mtl_est_gcl_control, + ctrl, !(ctrl & xgmac_srwo), 100, 5000); +} + +static int dwxgmac3_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, + unsigned int ptp_rate) +{ + int i, ret = 0x0; + u32 ctrl; + + ret |= dwxgmac3_est_write(ioaddr, xgmac_btr_low, cfg->btr[0], false); + ret |= dwxgmac3_est_write(ioaddr, xgmac_btr_high, cfg->btr[1], false); + ret |= dwxgmac3_est_write(ioaddr, xgmac_ter, cfg->ter, false); + ret |= dwxgmac3_est_write(ioaddr, xgmac_llr, cfg->gcl_size, false); + ret |= dwxgmac3_est_write(ioaddr, xgmac_ctr_low, cfg->ctr[0], false); + ret |= dwxgmac3_est_write(ioaddr, xgmac_ctr_high, cfg->ctr[1], false); + if (ret) + return ret; + + for (i = 0; i < cfg->gcl_size; i++) { + ret = dwxgmac3_est_write(ioaddr, i, cfg->gcl[i], true); + if (ret) + return ret; + } + + ctrl = readl(ioaddr + xgmac_mtl_est_control); + ctrl &= ~xgmac_ptov; + ctrl |= ((1000000000 / ptp_rate) * 9) << xgmac_ptov_shift; + if (cfg->enable) + ctrl |= xgmac_eest | xgmac_sswl; + else + ctrl &= ~xgmac_eest; + + writel(ctrl, ioaddr + xgmac_mtl_est_control); + return 0; +} + + .est_configure = dwxgmac3_est_configure, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c + dma_cap->estwid = (hw_cap & xgmac_hwfeat_estwid) >> 23; + dma_cap->estdep = (hw_cap & xgmac_hwfeat_estdep) >> 20; + dma_cap->estsel = (hw_cap & xgmac_hwfeat_estsel) >> 19;
|
Networking
|
8572aec3d0dc43045254fd1bf581fb980bfdbc4b
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: integrate est with taprio scheduler api
|
now that we have the est code for xgmac and qos we can use it with the taprio scheduler. integrate it into the main driver and use the api to configure the est feature.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 3
| 115
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h +struct tc_taprio_qopt_offload; + int (*setup_taprio)(struct stmmac_priv *priv, + struct tc_taprio_qopt_offload *qopt); +#define stmmac_tc_setup_taprio(__priv, __args...) \ + stmmac_do_callback(__priv, tc, setup_taprio, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + case tc_setup_qdisc_taprio: + return stmmac_tc_setup_taprio(priv, priv, type_data); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +static int tc_setup_taprio(struct stmmac_priv *priv, + struct tc_taprio_qopt_offload *qopt) +{ + u32 size, wid = priv->dma_cap.estwid, dep = priv->dma_cap.estdep; + struct plat_stmmacenet_data *plat = priv->plat; + struct timespec64 time; + int i, ret = 0; + + if (!priv->dma_cap.estsel) + return -eopnotsupp; + + switch (wid) { + case 0x1: + wid = 16; + break; + case 0x2: + wid = 20; + break; + case 0x3: + wid = 24; + break; + default: + return -eopnotsupp; + } + + switch (dep) { + case 0x1: + dep = 64; + break; + case 0x2: + dep = 128; + break; + case 0x3: + dep = 256; + break; + case 0x4: + dep = 512; + break; + case 0x5: + dep = 1024; + break; + default: + return -eopnotsupp; + } + + if (!qopt->enable) + goto disable; + if (qopt->num_entries >= dep) + return -einval; + if (!qopt->base_time) + return -erange; + if (!qopt->cycle_time) + return -erange; + + if (!plat->est) { + plat->est = devm_kzalloc(priv->device, sizeof(*plat->est), + gfp_kernel); + if (!plat->est) + return -enomem; + } else { + memset(plat->est, 0, sizeof(*plat->est)); + } + + size = qopt->num_entries; + + priv->plat->est->gcl_size = size; + priv->plat->est->enable = qopt->enable; + + for (i = 0; i < size; i++) { + s64 delta_ns = qopt->entries[i].interval; + u32 gates = qopt->entries[i].gate_mask; + + if (delta_ns > genmask(wid, 0)) + return -erange; + if (gates > genmask(31 - wid, 0)) + return -erange; + if (qopt->entries[i].command != tc_taprio_cmd_set_gates) + return -eopnotsupp; + + priv->plat->est->gcl[i] = delta_ns | (gates << wid); + } + + /* adjust for real system time */ + time = ktime_to_timespec64(qopt->base_time); + priv->plat->est->btr[0] = (u32)time.tv_nsec; + priv->plat->est->btr[1] = (u32)time.tv_sec; + + priv->plat->est->ctr[0] = (u32)(qopt->cycle_time % nsec_per_sec); + priv->plat->est->ctr[1] = (u32)(qopt->cycle_time / nsec_per_sec); + + ret = stmmac_est_configure(priv, priv->ioaddr, priv->plat->est, + priv->plat->clk_ptp_rate); + if (ret) { + netdev_err(priv->dev, "failed to configure est "); + goto disable; + } + + netdev_info(priv->dev, "configured est "); + return 0; + +disable: + priv->plat->est->enable = false; + stmmac_est_configure(priv, priv->ioaddr, priv->plat->est, + priv->plat->clk_ptp_rate); + return ret; +} + + .setup_taprio = tc_setup_taprio,
|
Networking
|
b60189e0392fa06348911077ef281eb2b1047b6a
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add frame preemption support using taprio api
|
adds the support for frame preemption using taprio api. this works along with est feature and allows to select if preemptable traffic shall be sent during specific queues opening time.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 3
| 33
| 1
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h + unsigned int fpesel; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h + void (*fpe_configure)(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, + bool enable); +#define stmmac_fpe_configure(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, fpe_configure, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c + bool fpe = false; - if (qopt->entries[i].command != tc_taprio_cmd_set_gates) + + switch (qopt->entries[i].command) { + case tc_taprio_cmd_set_gates: + if (fpe) + return -einval; + break; + case tc_taprio_cmd_set_and_hold: + gates |= bit(0); + fpe = true; + break; + case tc_taprio_cmd_set_and_release: + gates &= ~bit(0); + fpe = true; + break; + default: + } + if (fpe && !priv->dma_cap.fpesel) + return -eopnotsupp; + + ret = stmmac_fpe_configure(priv, priv->ioaddr, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, fpe); + if (ret && fpe) { + netdev_err(priv->dev, "failed to enable frame preemption "); + return ret; + } +
|
Networking
|
1ac14241543c0108e9fd23aca4927a148a44c815
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: gmac5+: add support for frame preemption
|
adds the hw specific support for frame preemption on gmac5+ cores.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 5
| 34
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +#define gmac_rxqctrl_fprq genmask(26, 24) +#define gmac_rxqctrl_fprq_shift 24 +#define gmac_hw_feat_fpesel bit(26) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c + .fpe_configure = dwmac5_fpe_configure, + .fpe_configure = dwmac5_fpe_configure, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c + dma_cap->fpesel = (hw_cap & gmac_hw_feat_fpesel) >> 26; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c + +void dwmac5_fpe_configure(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, + bool enable) +{ + u32 value; + + if (!enable) { + value = readl(ioaddr + mac_fpe_ctrl_sts); + + value &= ~efpe; + + writel(value, ioaddr + mac_fpe_ctrl_sts); + } + + value = readl(ioaddr + gmac_rxq_ctrl1); + value &= ~gmac_rxqctrl_fprq; + value |= (num_rxq - 1) << gmac_rxqctrl_fprq_shift; + writel(value, ioaddr + gmac_rxq_ctrl1); + + value = readl(ioaddr + mac_fpe_ctrl_sts); + value |= efpe; + writel(value, ioaddr + mac_fpe_ctrl_sts); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +#define mac_fpe_ctrl_sts 0x00000234 +#define efpe bit(0) + +void dwmac5_fpe_configure(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, + bool enable);
|
Networking
|
7c7282746883e48aff54ff6d55e6d8674a0c414a
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: xgmac3+: add support for frame preemption
|
adds the hw specific support for frame preemption on xgmac3+ cores.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 3
| 31
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +#define xgmac_rxq_ctrl1 0x000000a4 +#define xgmac_rq genmask(7, 4) +#define xgmac_rq_shift 4 +#define xgmac_hwfeat_fpesel bit(26) +#define xgmac_fpe_ctrl_sts 0x00000280 +#define xgmac_efpe bit(0) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +static void dwxgmac3_fpe_configure(void __iomem *ioaddr, u32 num_txq, + u32 num_rxq, bool enable) +{ + u32 value; + + if (!enable) { + value = readl(ioaddr + xgmac_fpe_ctrl_sts); + + value &= ~xgmac_efpe; + + writel(value, ioaddr + xgmac_fpe_ctrl_sts); + } + + value = readl(ioaddr + xgmac_rxq_ctrl1); + value &= ~xgmac_rq; + value |= (num_rxq - 1) << xgmac_rq_shift; + writel(value, ioaddr + xgmac_rxq_ctrl1); + + value = readl(ioaddr + xgmac_fpe_ctrl_sts); + value |= xgmac_efpe; + writel(value, ioaddr + xgmac_fpe_ctrl_sts); +} + + .fpe_configure = dwxgmac3_fpe_configure, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c + dma_cap->fpesel = (hw_cap & xgmac_hwfeat_fpesel) >> 26;
|
Networking
|
f0e56c8d8f7d0e03e571e21c778f02d226aaeb97
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: mmc: add frame preemption counters on gmac5+ cores
|
this can be useful for debug. add these counters on gmac5+ cores just like we did for xgmac.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
tsn support using taprio api
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 16
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c +#define mmc_tx_fpe_frag 0x1a8 +#define mmc_tx_hold_req 0x1ac +#define mmc_rx_pkt_assembly_err 0x1c8 +#define mmc_rx_pkt_smd_err 0x1cc +#define mmc_rx_pkt_assembly_ok 0x1d0 +#define mmc_rx_fpe_frag 0x1d4 + + + mmc->mmc_tx_fpe_fragment_cntr += readl(mmcaddr + mmc_tx_fpe_frag); + mmc->mmc_tx_hold_req_cntr += readl(mmcaddr + mmc_tx_hold_req); + mmc->mmc_rx_packet_assembly_err_cntr += + readl(mmcaddr + mmc_rx_pkt_assembly_err); + mmc->mmc_rx_packet_smd_err_cntr += readl(mmcaddr + mmc_rx_pkt_smd_err); + mmc->mmc_rx_packet_assembly_ok_cntr += + readl(mmcaddr + mmc_rx_pkt_assembly_ok); + mmc->mmc_rx_fpe_fragment_cntr += readl(mmcaddr + mmc_rx_fpe_frag);
|
Networking
|
ea77b8c813c6e56b20bb88567b63acc147cefb57
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: initial support for tbs
|
adds the initial hooks for tbs support. this needs a 32 byte descriptor in order for it to work with current hw. adds all the logic for enhanced descriptors in main core but no hw related logic for now.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 5
| 156
| 65
|
- use bitfield for tbs status / support (jakub) - remove unneeded cache alignment (jakub) - fix checkpatch issues --- diff --git a/drivers/net/ethernet/stmicro/stmmac/descs.h b/drivers/net/ethernet/stmicro/stmmac/descs.h --- a/drivers/net/ethernet/stmicro/stmmac/descs.h +++ b/drivers/net/ethernet/stmicro/stmmac/descs.h +/* enhanced descriptor for tbs */ +struct dma_edesc { + __le32 des4; + __le32 des5; + __le32 des6; + __le32 des7; + struct dma_desc basic; +}; + diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h +struct dma_edesc; + void (*set_tbs)(struct dma_edesc *p, u32 sec, u32 nsec); +#define stmmac_set_desc_tbs(__priv, __args...) \ + stmmac_do_void_callback(__priv, desc, set_tbs, __args) + int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan); +#define stmmac_enable_tbs(__priv, __args...) \ + stmmac_do_callback(__priv, dma, enable_tbs, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h +#define stmmac_tbs_avail bit(0) +#define stmmac_tbs_en bit(1) + + int tbs; + struct dma_edesc *dma_entx; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + else if (tx_q->tbs & stmmac_tbs_avail) + head_tx = (void *)tx_q->dma_entx; - for (i = 0; i < dma_tx_size; i++) + for (i = 0; i < dma_tx_size; i++) { + int last = (i == (dma_tx_size - 1)); + struct dma_desc *p; + - stmmac_init_tx_desc(priv, &tx_q->dma_etx[i].basic, - priv->mode, (i == dma_tx_size - 1)); + p = &tx_q->dma_etx[i].basic; + else if (tx_q->tbs & stmmac_tbs_avail) + p = &tx_q->dma_entx[i].basic; - stmmac_init_tx_desc(priv, &tx_q->dma_tx[i], - priv->mode, (i == dma_tx_size - 1)); + p = &tx_q->dma_tx[i]; + + stmmac_init_tx_desc(priv, p, priv->mode, last); + } - else + else if (!(tx_q->tbs & stmmac_tbs_avail)) + else if (tx_q->tbs & stmmac_tbs_avail) + p = &((tx_q->dma_entx + i)->basic); + size_t size; + void *addr; - /* free dma regions of consistent memory previously allocated */ - if (!priv->extend_desc) - dma_free_coherent(priv->device, - dma_tx_size * sizeof(struct dma_desc), - tx_q->dma_tx, tx_q->dma_tx_phy); - else - dma_free_coherent(priv->device, dma_tx_size * - sizeof(struct dma_extended_desc), - tx_q->dma_etx, tx_q->dma_tx_phy); + if (priv->extend_desc) { + size = sizeof(struct dma_extended_desc); + addr = tx_q->dma_etx; + } else if (tx_q->tbs & stmmac_tbs_avail) { + size = sizeof(struct dma_edesc); + addr = tx_q->dma_entx; + } else { + size = sizeof(struct dma_desc); + addr = tx_q->dma_tx; + } + + size *= dma_tx_size; + + dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); + size_t size; + void *addr; - if (priv->extend_desc) { - tx_q->dma_etx = dma_alloc_coherent(priv->device, - dma_tx_size * sizeof(struct dma_extended_desc), - &tx_q->dma_tx_phy, - gfp_kernel); - if (!tx_q->dma_etx) - goto err_dma; - } else { - tx_q->dma_tx = dma_alloc_coherent(priv->device, - dma_tx_size * sizeof(struct dma_desc), - &tx_q->dma_tx_phy, - gfp_kernel); - if (!tx_q->dma_tx) - goto err_dma; - } + if (priv->extend_desc) + size = sizeof(struct dma_extended_desc); + else if (tx_q->tbs & stmmac_tbs_avail) + size = sizeof(struct dma_edesc); + else + size = sizeof(struct dma_desc); + + size *= dma_tx_size; + + addr = dma_alloc_coherent(priv->device, size, + &tx_q->dma_tx_phy, gfp_kernel); + if (!addr) + goto err_dma; + + if (priv->extend_desc) + tx_q->dma_etx = addr; + else if (tx_q->tbs & stmmac_tbs_avail) + tx_q->dma_entx = addr; + else + tx_q->dma_tx = addr; - + else if (tx_q->tbs & stmmac_tbs_avail) + p = &tx_q->dma_entx[entry].basic; - int i; - for (i = 0; i < dma_tx_size; i++) - if (priv->extend_desc) - stmmac_init_tx_desc(priv, &tx_q->dma_etx[i].basic, - priv->mode, (i == dma_tx_size - 1)); - else - stmmac_init_tx_desc(priv, &tx_q->dma_tx[i], - priv->mode, (i == dma_tx_size - 1)); + stmmac_clear_tx_descriptors(priv, chan); + /* tbs */ + for (chan = 0; chan < tx_cnt; chan++) { + struct stmmac_tx_queue *tx_q = &priv->tx_queue[chan]; + int enable = tx_q->tbs & stmmac_tbs_avail; + + stmmac_enable_tbs(priv, priv->ioaddr, enable, chan); + } + + /* earlier check for tbs */ + for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) { + struct stmmac_tx_queue *tx_q = &priv->tx_queue[chan]; + int tbs_en = priv->plat->tx_queues_cfg[chan].tbs_en; + + tx_q->tbs |= tbs_en ? stmmac_tbs_avail : 0; + if (stmmac_enable_tbs(priv, priv->ioaddr, tbs_en, chan)) + tx_q->tbs &= ~stmmac_tbs_avail; + } + - p = tx_q->dma_tx + tx_q->cur_tx; + if (tx_q->tbs & stmmac_tbs_avail) + p = &tx_q->dma_entx[tx_q->cur_tx].basic; + else + p = &tx_q->dma_tx[tx_q->cur_tx]; + - desc = tx_q->dma_tx + tx_q->cur_tx; + + if (tx_q->tbs & stmmac_tbs_avail) + desc = &tx_q->dma_entx[tx_q->cur_tx].basic; + else + desc = &tx_q->dma_tx[tx_q->cur_tx]; + int desc_size, tmp_pay_len = 0, first_tx; - int tmp_pay_len = 0, first_tx; - u8 proto_hdr_len, hdr; + u8 proto_hdr_len, hdr; - mss_desc = tx_q->dma_tx + tx_q->cur_tx; + if (tx_q->tbs & stmmac_tbs_avail) + mss_desc = &tx_q->dma_entx[tx_q->cur_tx].basic; + else + mss_desc = &tx_q->dma_tx[tx_q->cur_tx]; + - desc = tx_q->dma_tx + first_entry; + if (tx_q->tbs & stmmac_tbs_avail) + desc = &tx_q->dma_entx[first_entry].basic; + else + desc = &tx_q->dma_tx[first_entry]; - desc = &tx_q->dma_tx[tx_q->cur_tx]; + if (tx_q->tbs & stmmac_tbs_avail) + desc = &tx_q->dma_entx[tx_q->cur_tx].basic; + else + desc = &tx_q->dma_tx[tx_q->cur_tx]; + - - stmmac_display_ring(priv, (void *)tx_q->dma_tx, dma_tx_size, 0); - - tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc)); + if (tx_q->tbs & stmmac_tbs_avail) + desc_size = sizeof(struct dma_edesc); + else + desc_size = sizeof(struct dma_desc); + + tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size); + struct dma_edesc *tbs_desc = null; + int entry, desc_size, first_tx; - int entry, first_tx; + else if (tx_q->tbs & stmmac_tbs_avail) + desc = &tx_q->dma_entx[entry].basic; + else if (tx_q->tbs & stmmac_tbs_avail) + desc = &tx_q->dma_entx[entry].basic; + else if (tx_q->tbs & stmmac_tbs_avail) + desc = &tx_q->dma_entx[entry].basic; - void *tx_head; - - if (priv->extend_desc) - tx_head = (void *)tx_q->dma_etx; - else - tx_head = (void *)tx_q->dma_tx; - - stmmac_display_ring(priv, tx_head, dma_tx_size, false); - - csum_insertion, priv->mode, 1, last_segment, + csum_insertion, priv->mode, 0, last_segment, - } else { - stmmac_set_tx_owner(priv, first); + if (tx_q->tbs & stmmac_tbs_en) { + struct timespec64 ts = ns_to_timespec64(skb->tstamp); + + tbs_desc = &tx_q->dma_entx[first_entry]; + stmmac_set_desc_tbs(priv, tbs_desc, ts.tv_sec, ts.tv_nsec); + } + + stmmac_set_tx_owner(priv, first); + - tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc)); + if (likely(priv->extend_desc)) + desc_size = sizeof(struct dma_extended_desc); + else if (tx_q->tbs & stmmac_tbs_avail) + desc_size = sizeof(struct dma_edesc); + else + desc_size = sizeof(struct dma_desc); + + tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size); - } else { + } else if (!(tx_q->tbs & stmmac_tbs_avail)) { diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + int tbs_en;
|
Networking
|
579a25a854d482bc9d0f9ab0e07ba32fb66bd9e3
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: tc: add support for etf scheduler using tbs
|
adds the support for etf scheduler using tbs feature which is available in xgmac and qos ips.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 4
| 29
| 0
|
- fix checkpatch issues (jakub) - use the tbs bitfield --- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h + unsigned int tbssel; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h +struct tc_etf_qopt_offload; + int (*setup_etf)(struct stmmac_priv *priv, + struct tc_etf_qopt_offload *qopt); +#define stmmac_tc_setup_etf(__priv, __args...) \ + stmmac_do_callback(__priv, tc, setup_etf, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + case tc_setup_qdisc_etf: + return stmmac_tc_setup_etf(priv, priv, type_data); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +static int tc_setup_etf(struct stmmac_priv *priv, + struct tc_etf_qopt_offload *qopt) +{ + if (!priv->dma_cap.tbssel) + return -eopnotsupp; + if (qopt->queue >= priv->plat->tx_queues_to_use) + return -einval; + if (!(priv->tx_queue[qopt->queue].tbs & stmmac_tbs_avail)) + return -einval; + + if (qopt->enable) + priv->tx_queue[qopt->queue].tbs |= stmmac_tbs_en; + else + priv->tx_queue[qopt->queue].tbs &= ~stmmac_tbs_en; + + netdev_info(priv->dev, "%s etf for queue %d ", + qopt->enable ? "enabled" : "disabled", qopt->queue); + return 0; +} + + .setup_etf = tc_setup_etf,
|
Networking
|
430b383c737ca07e83e0fe2a8d1ecdff6f4974bd
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: xgmac: add tbs support
|
adds all the necessary hw hooks to support tbs feature in xgmac cores.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 3
| 46
| 0
|
- remove unneeded lt shift as the ip already does this. --- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +#define xgmac_hwfeat_tbssel bit(27) +#define xgmac_dma_tbs_ctrl0 0x00003054 +#define xgmac_dma_tbs_ctrl1 0x00003058 +#define xgmac_dma_tbs_ctrl2 0x0000305c +#define xgmac_dma_tbs_ctrl3 0x00003060 +#define xgmac_ftos genmask(31, 8) +#define xgmac_ftov bit(0) +#define xgmac_def_ftos (xgmac_ftos | xgmac_ftov) +#define xgmac_edse bit(28) +#define xgmac_tdes0_ltv bit(31) +#define xgmac_tdes0_lt genmask(7, 0) +#define xgmac_tdes1_lt genmask(31, 8) +#define xgmac_tdes3_tbsv bit(24) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +static void dwxgmac2_set_tbs(struct dma_edesc *p, u32 sec, u32 nsec) +{ + p->des4 = cpu_to_le32((sec & xgmac_tdes0_lt) | xgmac_tdes0_ltv); + p->des5 = cpu_to_le32(nsec & xgmac_tdes1_lt); + p->des6 = 0; + p->des7 = 0; +} + + .set_tbs = dwxgmac2_set_tbs, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c + dma_cap->tbssel = (hw_cap & xgmac_hwfeat_tbssel) >> 27; +static int dwxgmac2_enable_tbs(void __iomem *ioaddr, bool en, u32 chan) +{ + u32 value = readl(ioaddr + xgmac_dma_ch_tx_control(chan)); + + if (en) + value |= xgmac_edse; + else + value &= ~xgmac_edse; + + writel(value, ioaddr + xgmac_dma_ch_tx_control(chan)); + + value = readl(ioaddr + xgmac_dma_ch_tx_control(chan)) & xgmac_edse; + if (en && !value) + return -eio; + + writel(xgmac_def_ftos, ioaddr + xgmac_dma_tbs_ctrl0); + writel(xgmac_def_ftos, ioaddr + xgmac_dma_tbs_ctrl1); + writel(xgmac_def_ftos, ioaddr + xgmac_dma_tbs_ctrl2); + writel(xgmac_def_ftos, ioaddr + xgmac_dma_tbs_ctrl3); + return 0; +} + + .enable_tbs = dwxgmac2_enable_tbs,
|
Networking
|
6a549b9f0dcd9a73991077da64eb3603b3e5f681
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: gmac4+: add tbs support
|
adds all the necessary hw hooks to support tbs feature in qos cores.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 5
| 46
| 0
|
- remove unneeded lt shift as the ip already does this. --- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +#define gmac_hw_feat_tbssel bit(27) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +#include "dwmac4.h" +static void dwmac4_set_tbs(struct dma_edesc *p, u32 sec, u32 nsec) +{ + p->des4 = cpu_to_le32((sec & tdes4_lt) | tdes4_ltv); + p->des5 = cpu_to_le32(nsec & tdes5_lt); + p->des6 = 0; + p->des7 = 0; +} + + .set_tbs = dwmac4_set_tbs, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h +/* tdes4 */ +#define tdes4_ltv bit(31) +#define tdes4_lt genmask(7, 0) + +/* tdes5 */ +#define tdes5_lt genmask(31, 8) + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c + dma_cap->tbssel = (hw_cap & gmac_hw_feat_tbssel) >> 27; +static int dwmac4_enable_tbs(void __iomem *ioaddr, bool en, u32 chan) +{ + u32 value = readl(ioaddr + dma_chan_tx_control(chan)); + + if (en) + value |= dma_control_edse; + else + value &= ~dma_control_edse; + + writel(value, ioaddr + dma_chan_tx_control(chan)); + + value = readl(ioaddr + dma_chan_tx_control(chan)) & dma_control_edse; + if (en && !value) + return -eio; + + writel(dma_tbs_def_ftos, ioaddr + dma_tbs_ctrl); + return 0; +} + + .enable_tbs = dwmac4_enable_tbs, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +#define dma_tbs_ctrl 0x00001050 +/* dma tbs control */ +#define dma_tbs_ftos genmask(31, 8) +#define dma_tbs_ftov bit(0) +#define dma_tbs_def_ftos (dma_tbs_ftos | dma_tbs_ftov) + +#define dma_control_edse bit(28)
|
Networking
|
58ae92814008a324fc5698fa76fcd7497207fe0f
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: pci: enable tbs on gmac5 ipk pci entry
|
enable tbs support on gmac5 pci entry for all queues except queue 0.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 2
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c + if (i > 0) + plat->tx_queues_cfg[i].tbs_en = 1;
|
Networking
|
7eadf57290ecd2b8e01a48dfaf55126ad60e6a3b
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add missing information in debugfs capabilities file
|
adds more information regarding hw capabilities in the corresponding debugfs file.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 6
| 0
|
- remove the tx/rx queues in use (jakub) --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + seq_printf(seq, " enhancements to scheduled traffic (est): %s ", + priv->dma_cap.estsel ? "y" : "n"); + seq_printf(seq, " frame preemption (fpe): %s ", + priv->dma_cap.fpesel ? "y" : "n"); + seq_printf(seq, " time-based scheduling (tbs): %s ", + priv->dma_cap.tbssel ? "y" : "n");
|
Networking
|
44e6547570654a447edcfff33023cf61f5fdcd01
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: selftests: switch to dev_direct_xmit()
|
in the upcoming commit for tbs selftest we will need to send a packet on a specific queue. as stmmac fallsback to netdev_pick_tx() on the select queue callback, we need to switch all selftests logic to dev_direct_xmit() so that we can send the given skb on a specific queue.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 6
| 19
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c - skb_set_queue_mapping(skb, attr->queue_mapping); - ret = dev_queue_xmit(skb); + ret = dev_direct_xmit(skb, attr->queue_mapping); - skb_set_queue_mapping(skb, 0); - ret = dev_queue_xmit(skb); + ret = dev_direct_xmit(skb, 0); - skb_set_queue_mapping(skb, 0); - ret = dev_queue_xmit(skb); + ret = dev_direct_xmit(skb, 0); - skb_set_queue_mapping(skb, 0); - ret = dev_queue_xmit(skb); + ret = dev_direct_xmit(skb, 0); - skb_set_queue_mapping(skb, 0); - ret = dev_queue_xmit(skb); + ret = dev_direct_xmit(skb, 0); - int carrier = netif_carrier_ok(dev); - } else if (!carrier) { + } else if (!netif_carrier_ok(dev)) { - /* we don't want extra traffic */ - netif_carrier_off(dev); - - - /* restart everything */ - if (carrier) - netif_carrier_on(dev);
|
Networking
|
05373e31baed87c3daafdc6d30dc679f057b5cd0
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: selftests: add a test for tbs feature
|
add a new test for tbs feature which is used in etf scheduler. in this test, we send a packet with a launch time specified as now + 500ms and check if the packet was transmitted on that time frame.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
etf support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 71
| 0
|
- use the tbs bitfield - remove debug message --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +#include <net/pkt_sched.h> + u64 timestamp; + if (attr->timestamp) + skb->tstamp = ns_to_ktime(attr->timestamp); + +static int stmmac_test_tbs(struct stmmac_priv *priv) +{ +#define stmmac_tbs_lt_offset (500 * 1000 * 1000) /* 500 ms*/ + struct stmmac_packet_attrs attr = { }; + struct tc_etf_qopt_offload qopt; + u64 start_time, curr_time = 0; + unsigned long flags; + int ret, i; + + if (!priv->hwts_tx_en) + return -eopnotsupp; + + /* find first tbs enabled queue, if any */ + for (i = 0; i < priv->plat->tx_queues_to_use; i++) + if (priv->tx_queue[i].tbs & stmmac_tbs_avail) + break; + + if (i >= priv->plat->tx_queues_to_use) + return -eopnotsupp; + + qopt.enable = true; + qopt.queue = i; + + ret = stmmac_tc_setup_etf(priv, priv, &qopt); + if (ret) + return ret; + + spin_lock_irqsave(&priv->ptp_lock, flags); + stmmac_get_systime(priv, priv->ptpaddr, &curr_time); + spin_unlock_irqrestore(&priv->ptp_lock, flags); + + if (!curr_time) { + ret = -eopnotsupp; + goto fail_disable; + } + + start_time = curr_time; + curr_time += stmmac_tbs_lt_offset; + + attr.dst = priv->dev->dev_addr; + attr.timestamp = curr_time; + attr.timeout = nsecs_to_jiffies(2 * stmmac_tbs_lt_offset); + attr.queue_mapping = i; + + ret = __stmmac_test_loopback(priv, &attr); + if (ret) + goto fail_disable; + + /* check if expected time has elapsed */ + spin_lock_irqsave(&priv->ptp_lock, flags); + stmmac_get_systime(priv, priv->ptpaddr, &curr_time); + spin_unlock_irqrestore(&priv->ptp_lock, flags); + + if ((curr_time - start_time) < stmmac_tbs_lt_offset) + ret = -einval; + +fail_disable: + qopt.enable = false; + stmmac_tc_setup_etf(priv, priv, &qopt); + return ret; +} + + }, { + .name = "tbs (etf scheduler) ", + .lb = stmmac_loopback_phy, + .fn = stmmac_test_tbs,
|
Networking
|
28c1cf73c923065d1265ea32b9c1bfc8d63370e9
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: print more information in debugfs dma capabilities file
|
dma capabilites have grown but the debugfs that shows this info has not been updated. lets add the missing information.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
print more information in debugfs dma capabilities file
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 30
| 1
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + seq_printf(seq, " number of additional rx queues: %d ", + priv->dma_cap.number_rx_queues); + seq_printf(seq, " number of additional tx queues: %d ", + priv->dma_cap.number_tx_queues); - + seq_printf(seq, " tx fifo size: %d ", priv->dma_cap.tx_fifo_size); + seq_printf(seq, " rx fifo size: %d ", priv->dma_cap.rx_fifo_size); + seq_printf(seq, " hash table size: %d ", priv->dma_cap.hash_tb_sz); + seq_printf(seq, " tso: %s ", priv->dma_cap.tsoen ? "y" : "n"); + seq_printf(seq, " number of pps outputs: %d ", + priv->dma_cap.pps_out_num); + seq_printf(seq, " safety features: %s ", + priv->dma_cap.asp ? "y" : "n"); + seq_printf(seq, " flexible rx parser: %s ", + priv->dma_cap.frpsel ? "y" : "n"); + seq_printf(seq, " enhanced addressing: %d ", + priv->dma_cap.addr64); + seq_printf(seq, " receive side scaling: %s ", + priv->dma_cap.rssen ? "y" : "n"); + seq_printf(seq, " vlan hash filtering: %s ", + priv->dma_cap.vlhash ? "y" : "n"); + seq_printf(seq, " split header: %s ", + priv->dma_cap.sphen ? "y" : "n"); + seq_printf(seq, " vlan tx insertion: %s ", + priv->dma_cap.vlins ? "y" : "n"); + seq_printf(seq, " double vlan: %s ", + priv->dma_cap.dvlan ? "y" : "n"); + seq_printf(seq, " number of l3/l4 filters: %d ", + priv->dma_cap.l3l4fnum); + seq_printf(seq, " arp offloading: %s ", + priv->dma_cap.arpoffsel ? "y" : "n");
|
Networking
|
7d0b447a3f82f5a1a70bae20c362f332e9fa91ea
|
jose abreu
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
wil6210: add support for set_cqm_rssi_config
|
set_cqm_rssi_config() is used by the kernel to configure connection quality monitor rssi threshold. wil6210 uses wmi_set_link_monitor_cmdid to set the rssi threshold to fw which in turn reports rssi threshold changes with wmi_link_monitor_eventid.
|
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
|
add support for set_cqm_rssi_config
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
|
['wil6210 ']
|
['c', 'h']
| 4
| 130
| 0
|
--- diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c +static int wil_cfg80211_set_cqm_rssi_config(struct wiphy *wiphy, + struct net_device *dev, + s32 rssi_thold, u32 rssi_hyst) +{ + struct wil6210_priv *wil = wiphy_to_wil(wiphy); + int rc; + + wil->cqm_rssi_thold = rssi_thold; + + rc = wmi_set_cqm_rssi_config(wil, rssi_thold, rssi_hyst); + if (rc) + /* reset stored value upon failure */ + wil->cqm_rssi_thold = 0; + + return rc; +} + + .set_cqm_rssi_config = wil_cfg80211_set_cqm_rssi_config, diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h --- a/drivers/net/wireless/ath/wil6210/wil6210.h +++ b/drivers/net/wireless/ath/wil6210/wil6210.h + s32 cqm_rssi_thold; +int wmi_set_cqm_rssi_config(struct wil6210_priv *wil, + s32 rssi_thold, u32 rssi_hyst); diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c --- a/drivers/net/wireless/ath/wil6210/wmi.c +++ b/drivers/net/wireless/ath/wil6210/wmi.c + case wmi_set_link_monitor_cmdid: + return "wmi_set_link_monitor_cmd"; + case wmi_set_link_monitor_eventid: + return "wmi_set_link_monitor_event"; + case wmi_link_monitor_eventid: + return "wmi_link_monitor_event"; +static void +wmi_evt_link_monitor(struct wil6210_vif *vif, int id, void *d, int len) +{ + struct wil6210_priv *wil = vif_to_wil(vif); + struct net_device *ndev = vif_to_ndev(vif); + struct wmi_link_monitor_event *evt = d; + enum nl80211_cqm_rssi_threshold_event event_type; + + if (len < sizeof(*evt)) { + wil_err(wil, "link monitor event too short %d ", len); + return; + } + + wil_dbg_wmi(wil, "link monitor event, type %d rssi %d (stored %d) ", + evt->type, evt->rssi_level, wil->cqm_rssi_thold); + + if (evt->type != wmi_link_monitor_notif_rssi_threshold_evt) + /* ignore */ + return; + + event_type = (evt->rssi_level > wil->cqm_rssi_thold ? + nl80211_cqm_rssi_threshold_event_high : + nl80211_cqm_rssi_threshold_event_low); + cfg80211_cqm_rssi_notify(ndev, event_type, evt->rssi_level, gfp_kernel); +} + + {wmi_link_monitor_eventid, wmi_evt_link_monitor}, + +int wmi_set_cqm_rssi_config(struct wil6210_priv *wil, + s32 rssi_thold, u32 rssi_hyst) +{ + struct net_device *ndev = wil->main_ndev; + struct wil6210_vif *vif = ndev_to_vif(ndev); + int rc; + struct { + struct wmi_set_link_monitor_cmd cmd; + s8 rssi_thold; + } __packed cmd = { + .cmd = { + .rssi_hyst = rssi_hyst, + .rssi_thresholds_list_size = 1, + }, + .rssi_thold = rssi_thold, + }; + struct { + struct wmi_cmd_hdr hdr; + struct wmi_set_link_monitor_event evt; + } __packed reply = { + .evt = {.status = wmi_fw_status_failure}, + }; + + if (rssi_thold > s8_max || rssi_thold < s8_min || rssi_hyst > u8_max) + return -einval; + + rc = wmi_call(wil, wmi_set_link_monitor_cmdid, vif->mid, &cmd, + sizeof(cmd), wmi_set_link_monitor_eventid, + &reply, sizeof(reply), wil_wmi_call_general_to_ms); + if (rc) { + wil_err(wil, "wmi_set_link_monitor_cmdid failed, rc %d ", rc); + return rc; + } + + if (reply.evt.status != wmi_fw_status_success) { + wil_err(wil, "wmi_set_link_monitor_cmdid failed, status %d ", + reply.evt.status); + return -einval; + } + + return 0; +} diff --git a/drivers/net/wireless/ath/wil6210/wmi.h b/drivers/net/wireless/ath/wil6210/wmi.h --- a/drivers/net/wireless/ath/wil6210/wmi.h +++ b/drivers/net/wireless/ath/wil6210/wmi.h + wmi_set_link_monitor_cmdid = 0x845, + wmi_link_monitor_eventid = 0x100e, + wmi_set_link_monitor_eventid = 0x1845, +/* wmi_set_link_monitor_cmdid */ +struct wmi_set_link_monitor_cmd { + u8 rssi_hyst; + u8 reserved[12]; + u8 rssi_thresholds_list_size; + s8 rssi_thresholds_list[0]; +} __packed; + +/* wmi_link_monitor_event_type */ +enum wmi_link_monitor_event_type { + wmi_link_monitor_notif_rssi_threshold_evt = 0x00, + wmi_link_monitor_notif_tx_err_evt = 0x01, + wmi_link_monitor_notif_thermal_evt = 0x02, +}; + +/* wmi_set_link_monitor_eventid */ +struct wmi_set_link_monitor_event { + /* wmi_fw_status */ + u8 status; + u8 reserved[3]; +} __packed; + +/* wmi_link_monitor_eventid */ +struct wmi_link_monitor_event { + /* link_monitor_event_type */ + u8 type; + s8 rssi_level; + u8 reserved[2]; +} __packed; +
|
Networking
|
4315a74a482f86750a1e78ac536c5baeb05ff6b1
|
dedy lansky
|
drivers
|
net
|
ath, wil6210, wireless
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.