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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
devlink: add support for reporter recovery completion
|
it is possible that a reporter recovery completion do not finish successfully when recovery is triggered via devlink_health_reporter_recover as recovery could be processed in different context. in such scenario an error is returned by driver when recover hook is invoked and successful recovery completion is intimated later. expose devlink recover done api to update recovery 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.
|
devlink notification after recovery complete
|
['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']
|
['bnxt_en ']
|
['h', 'c']
| 2
| 11
| 2
|
--- diff --git a/include/net/devlink.h b/include/net/devlink.h --- a/include/net/devlink.h +++ b/include/net/devlink.h +void +devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter); diff --git a/net/core/devlink.c b/net/core/devlink.c --- a/net/core/devlink.c +++ b/net/core/devlink.c +void +devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter) +{ + reporter->recovery_count++; + reporter->last_recovery_ts = jiffies; +} +export_symbol_gpl(devlink_health_reporter_recovery_done); + - reporter->recovery_count++; + devlink_health_reporter_recovery_done(reporter); - reporter->last_recovery_ts = jiffies;
|
Networking
|
6181e5cb752e5de9f56fbcee3f0206a2c51f1478
|
vikas gupta
|
include
|
net
| |
devlink: add devink notification when reporter update health state
|
add a devlink notification when reporter update the health state.
|
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.
|
devlink notification after recovery complete
|
['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']
|
['bnxt_en ']
|
['c']
| 1
| 42
| 17
|
--- diff --git a/net/core/devlink.c b/net/core/devlink.c --- a/net/core/devlink.c +++ b/net/core/devlink.c -void -devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, - enum devlink_health_reporter_state state) -{ - if (warn_on(state != devlink_health_reporter_state_healthy && - state != devlink_health_reporter_state_error)) - return; - - if (reporter->health_state == state) - return; - - reporter->health_state = state; - trace_devlink_health_reporter_state_update(reporter->devlink, - reporter->ops->name, state); -} -export_symbol_gpl(devlink_health_reporter_state_update); - +static void devlink_recover_notify(struct devlink_health_reporter *reporter, + enum devlink_command cmd) +{ + struct sk_buff *msg; + int err; + + warn_on(cmd != devlink_cmd_health_reporter_recover); + + msg = nlmsg_new(nlmsg_default_size, gfp_kernel); + if (!msg) + return; + + err = devlink_nl_health_reporter_fill(msg, reporter->devlink, + reporter, cmd, 0, 0, 0); + if (err) { + nlmsg_free(msg); + return; + } + + genlmsg_multicast_netns(&devlink_nl_family, + devlink_net(reporter->devlink), + msg, 0, devlink_mcgrp_config, gfp_kernel); +} + +void +devlink_health_reporter_state_update(struct devlink_health_reporter *reporter, + enum devlink_health_reporter_state state) +{ + if (warn_on(state != devlink_health_reporter_state_healthy && + state != devlink_health_reporter_state_error)) + return; + + if (reporter->health_state == state) + return; + + reporter->health_state = state; + trace_devlink_health_reporter_state_update(reporter->devlink, + reporter->ops->name, state); + devlink_recover_notify(reporter, devlink_cmd_health_reporter_recover); +} +export_symbol_gpl(devlink_health_reporter_state_update); +
|
Networking
|
97ff3bd37face9bc1bc824cc08241fc1f860ff46
|
vikas gupta
|
net
|
core
| |
bnxt_en: call recovery done after reset is successfully done
|
return einprogress to devlink health reporter recover as we are not yet done and call devlink_health_reporter_recovery_done once reset is successfully completed from workqueue context.
|
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.
|
devlink notification after recovery complete
|
['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']
|
['bnxt_en ']
|
['c', 'h']
| 3
| 14
| 2
|
--- diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c + bnxt_dl_health_recovery_done(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c - return 0; + return -einprogress; - return 0; + return -einprogress; +void bnxt_dl_health_recovery_done(struct bnxt *bp) +{ + struct bnxt_fw_health *hlth = bp->fw_health; + + if (hlth->fatal) + devlink_health_reporter_recovery_done(hlth->fw_fatal_reporter); + else + devlink_health_reporter_recovery_done(hlth->fw_reset_reporter); +} + diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h +void bnxt_dl_health_recovery_done(struct bnxt *bp);
|
Networking
|
737d7a6c55964955604b9de398dac3791bab5a64
|
vikas gupta
|
drivers
|
net
|
bnxt, broadcom, ethernet
|
bnxt_en: add support to update progress of flash update
|
this patch adds status notification to devlink flash update while flashing is in progress.
|
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 to update progress of flash update
|
['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']
|
['bnxt_en ']
|
['c']
| 1
| 13
| 1
|
--- diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c + int rc; - return bnxt_flash_package_from_file(bp->dev, filename, 0); + devlink_flash_update_begin_notify(dl); + devlink_flash_update_status_notify(dl, "preparing to flash", region, 0, + 0); + rc = bnxt_flash_package_from_file(bp->dev, filename, 0); + if (!rc) + devlink_flash_update_status_notify(dl, "flashing done", region, + 0, 0); + else + devlink_flash_update_status_notify(dl, "flashing failed", + region, 0, 0); + devlink_flash_update_end_notify(dl); + return rc;
|
Networking
|
8159cbe3e0b24489f97ca0fb7df7a1710f03a26b
|
vasundhara volam
|
drivers
|
net
|
bnxt, broadcom, ethernet
|
bnxt_en: improve link up detection.
|
in bnxt_update_phy_setting(), ethtool_get_link_ksettings() and bnxt_disable_an_for_lpbk(), we inconsistently use netif_carrier_ok() to determine link. instead, we should use bp->link_info.link_up which has the true link state. the netif_carrier state may be off during self-test and while the device is being reset and may not always reflect the true link state.
|
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.
|
improve link up detection
|
['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']
|
['bnxt_en ']
|
['c']
| 2
| 9
| 9
|
--- diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c - if (!netif_carrier_ok(bp->dev)) + if (!bp->link_info.link_up) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c - if (link_info->phy_link_status == bnxt_link_link) + base->duplex = duplex_unknown; + if (link_info->phy_link_status == bnxt_link_link) { + if (link_info->duplex & bnxt_link_duplex_full) + base->duplex = duplex_full; + else + base->duplex = duplex_half; + } - if (!netif_carrier_ok(dev)) - base->duplex = duplex_unknown; - else if (link_info->duplex & bnxt_link_duplex_full) - base->duplex = duplex_full; - else - base->duplex = duplex_half; - if (netif_carrier_ok(bp->dev)) + if (bp->link_info.link_up)
|
Networking
|
83d8f5e92d034a4c4a04d780107e73af31a38504
|
michael chan
|
drivers
|
net
|
bnxt, broadcom, ethernet
|
bnxt_en: support udp rss hashing on 575xx chips.
|
575xx (p5) chips have the same udp rss hashing capability as p4 chips, so we can enable it on p5 chips.
|
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.
|
support udp rss hashing on 575xx chips
|
['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']
|
['bnxt_en ']
|
['c']
| 1
| 1
| 1
|
--- diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c - if (bnxt_chip_p4(bp) && bp->hwrm_spec_code >= 0x10501) { + if (bnxt_chip_p4_plus(bp) && bp->hwrm_spec_code >= 0x10501) {
|
Networking
|
c66c06c5e28a55920c87b386876461c139aa1878
|
michael chan
|
drivers
|
net
|
bnxt, broadcom, ethernet
|
brcmfmac: add initial support for monitor mode
|
report monitor interface availability using cfg80211 and support it in the add_virtual_intf() and del_virtual_intf() callbacks. this new feature is conditional and depends on firmware flagging monitor packets. receiving monitor frames is already handled by the brcmf_netif_mon_rx().
|
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 initial support for monitor mode
|
['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']
|
['brcmfmac ']
|
['c', 'h']
| 6
| 174
| 13
|
--- diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +#include <uapi/linux/if_arp.h> +/** + * brcmf_mon_add_vif() - create monitor mode virtual interface + * + * @wiphy: wiphy device of new interface. + * @name: name of the new interface. + */ +static struct wireless_dev *brcmf_mon_add_vif(struct wiphy *wiphy, + const char *name) +{ + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); + struct brcmf_cfg80211_vif *vif; + struct net_device *ndev; + struct brcmf_if *ifp; + int err; + + if (cfg->pub->mon_if) { + err = -eexist; + goto err_out; + } + + vif = brcmf_alloc_vif(cfg, nl80211_iftype_monitor); + if (is_err(vif)) { + err = ptr_err(vif); + goto err_out; + } + + ndev = alloc_netdev(sizeof(*ifp), name, net_name_unknown, ether_setup); + if (!ndev) { + err = -enomem; + goto err_free_vif; + } + ndev->type = arphrd_ieee80211_radiotap; + ndev->ieee80211_ptr = &vif->wdev; + ndev->needs_free_netdev = true; + ndev->priv_destructor = brcmf_cfg80211_free_netdev; + set_netdev_dev(ndev, wiphy_dev(cfg->wiphy)); + + ifp = netdev_priv(ndev); + ifp->vif = vif; + ifp->ndev = ndev; + ifp->drvr = cfg->pub; + + vif->ifp = ifp; + vif->wdev.netdev = ndev; + + err = brcmf_net_mon_attach(ifp); + if (err) { + brcmf_err("failed to attach %s device ", ndev->name); + free_netdev(ndev); + goto err_free_vif; + } + + cfg->pub->mon_if = ifp; + + return &vif->wdev; + +err_free_vif: + brcmf_free_vif(vif); +err_out: + return err_ptr(err); +} + +static int brcmf_mon_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) +{ + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); + struct net_device *ndev = wdev->netdev; + + ndev->netdev_ops->ndo_stop(ndev); + + brcmf_net_detach(ndev, true); + + cfg->pub->mon_if = null; + + return 0; +} + - case nl80211_iftype_monitor: + case nl80211_iftype_monitor: + return brcmf_mon_add_vif(wiphy, name); - case nl80211_iftype_monitor: + case nl80211_iftype_monitor: + return brcmf_mon_del_vif(wiphy, wdev); - bool mbss, p2p, rsdb, mchan; - int i, c, n_combos; + bool mon_flag, mbss, p2p, rsdb, mchan; + int i, c, n_combos, n_limits; + mon_flag = brcmf_feat_is_enabled(ifp, brcmf_feat_monitor_flag); + if (mon_flag) + wiphy->interface_modes |= bit(nl80211_iftype_monitor); - if (p2p && rsdb) - c0_limits = kcalloc(4, sizeof(*c0_limits), gfp_kernel); - else if (p2p) - c0_limits = kcalloc(3, sizeof(*c0_limits), gfp_kernel); - else - c0_limits = kcalloc(2, sizeof(*c0_limits), gfp_kernel); + n_limits = 1 + mon_flag + (p2p ? 2 : 0) + (rsdb || !p2p); + c0_limits = kcalloc(n_limits, sizeof(*c0_limits), gfp_kernel); + if (mon_flag) { + c0_limits[i].max = 1; + c0_limits[i++].types = bit(nl80211_iftype_monitor); + } - mbss_limits = kcalloc(1, sizeof(*mbss_limits), gfp_kernel); + n_limits = 1 + mon_flag; + mbss_limits = kcalloc(n_limits, sizeof(*mbss_limits), + gfp_kernel); + if (mon_flag) { + mbss_limits[i].max = 1; + mbss_limits[i++].types = bit(nl80211_iftype_monitor); + } - combo[c].max_interfaces = 4; + combo[c].max_interfaces = 4 + mon_flag; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c -static void brcmf_net_detach(struct net_device *ndev, bool rtnl_locked) +void brcmf_net_detach(struct net_device *ndev, bool rtnl_locked) +static int brcmf_net_mon_open(struct net_device *ndev) +{ + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_pub *drvr = ifp->drvr; + u32 monitor; + int err; + + brcmf_dbg(trace, "enter "); + + err = brcmf_fil_cmd_int_get(ifp, brcmf_c_get_monitor, &monitor); + if (err) { + bphy_err(drvr, "brcmf_c_get_monitor error (%d) ", err); + return err; + } else if (monitor) { + bphy_err(drvr, "monitor mode is already enabled "); + return -eexist; + } + + monitor = 3; + err = brcmf_fil_cmd_int_set(ifp, brcmf_c_set_monitor, monitor); + if (err) + bphy_err(drvr, "brcmf_c_set_monitor error (%d) ", err); + + return err; +} + +static int brcmf_net_mon_stop(struct net_device *ndev) +{ + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_pub *drvr = ifp->drvr; + u32 monitor; + int err; + + brcmf_dbg(trace, "enter "); + + monitor = 0; + err = brcmf_fil_cmd_int_set(ifp, brcmf_c_set_monitor, monitor); + if (err) + bphy_err(drvr, "brcmf_c_set_monitor error (%d) ", err); + + return err; +} + +static const struct net_device_ops brcmf_netdev_ops_mon = { + .ndo_open = brcmf_net_mon_open, + .ndo_stop = brcmf_net_mon_stop, +}; + +int brcmf_net_mon_attach(struct brcmf_if *ifp) +{ + struct brcmf_pub *drvr = ifp->drvr; + struct net_device *ndev; + int err; + + brcmf_dbg(trace, "enter "); + + ndev = ifp->ndev; + ndev->netdev_ops = &brcmf_netdev_ops_mon; + + err = register_netdevice(ndev); + if (err) + bphy_err(drvr, "failed to register %s device ", ndev->name); + + return err; +} + diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h +void brcmf_net_detach(struct net_device *ndev, bool rtnl_locked); +int brcmf_net_mon_attach(struct brcmf_if *ifp); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c + { brcmf_feat_monitor_flag, "rtap" }, diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h + * monitor_flag: firmware flags monitor packets. + brcmf_feat_def(monitor_flag) \ diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h +#define brcmf_c_get_monitor 107 +#define brcmf_c_set_monitor 108
|
Networking
|
20f2c5fa3af060401c72e444999470a4cab641cf
|
rafa mi ecki
|
drivers
|
net
|
brcm80211, brcmfmac, broadcom, wireless
|
brcmfmac: add support for bcm4359 sdio chipset
|
bcm4359 is a 2x2 802.11 abgn+ac dual-band ht80 combo chip and it supports real simultaneous dual band 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.
|
add support for bcm4359 sdio chipset
|
['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']
|
['brcmfmac ']
|
['c', 'h']
| 4
| 7
| 0
|
--- diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c + brcmf_sdio_device(sdio_device_id_broadcom_4359), + brcmf_sdio_device(sdio_device_id_cypress_89359), diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c + case brcm_cc_4359_chip_id: diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +brcmf_fw_def(4359, "brcmfmac4359-sdio"); + brcmf_fw_entry(brcm_cc_4359_chip_id, 0xffffffff, 4359), diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h --- a/include/linux/mmc/sdio_ids.h +++ b/include/linux/mmc/sdio_ids.h +#define sdio_device_id_broadcom_4359 0x4359 +#define sdio_device_id_cypress_89359 0x4355
|
Networking
|
d4aef159394d5940bd7158ab789969dab82f7c76
|
soeren moch
|
include
|
linux
|
brcm80211, brcmfmac, broadcom, mmc, wireless
|
cxgb4: add support for high priority filters
|
t6 has a separate region known as high priority filter region that allows classifying packets going through uld path. so, query firmware for hpfilter resources and enable the high priority offload filter support when it is available.
|
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 high priority filters
|
['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']
|
['cxgb4']
|
['h', 'c']
| 9
| 234
| 86
|
--- diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +#include "t4fw_api.h" +#define fw_param_dev(param) \ + (fw_params_mnem_v(fw_params_mnem_dev) | \ + fw_params_param_x_v(fw_params_param_dev_##param)) + +#define fw_param_pfvf(param) \ + (fw_params_mnem_v(fw_params_mnem_pfvf) | \ + fw_params_param_x_v(fw_params_param_pfvf_##param) | \ + fw_params_param_y_v(0) | \ + fw_params_param_z_v(0)) + diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c + if (t->nhpftids) + seq_printf(seq, "hpftid range: %u..%u ", t->hpftid_base, + t->hpftid_base + t->nhpftids - 1); diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +static int cxgb4_set_hpftid(struct tid_info *t, int fidx, int family) +{ + spin_lock_bh(&t->ftid_lock); + + if (test_bit(fidx, t->hpftid_bmap)) { + spin_unlock_bh(&t->ftid_lock); + return -ebusy; + } + + if (family == pf_inet) + __set_bit(fidx, t->hpftid_bmap); + else + bitmap_allocate_region(t->hpftid_bmap, fidx, 1); + + spin_unlock_bh(&t->ftid_lock); + return 0; +} + +static void cxgb4_clear_hpftid(struct tid_info *t, int fidx, int family) +{ + spin_lock_bh(&t->ftid_lock); + + if (family == pf_inet) + __clear_bit(fidx, t->hpftid_bmap); + else + bitmap_release_region(t->hpftid_bmap, fidx, 1); + + spin_unlock_bh(&t->ftid_lock); +} + + struct filter_entry *prev_fe, *next_fe, *tab; - struct filter_entry *prev_fe, *next_fe; + u32 prev_ftid, next_ftid, max_tid; - u32 prev_ftid, next_ftid; + unsigned long *bmap; + if (idx < t->nhpftids) { + bmap = t->hpftid_bmap; + tab = t->hpftid_tab; + max_tid = t->nhpftids; + } else { + idx -= t->nhpftids; + bmap = t->ftid_bmap; + tab = t->ftid_tab; + max_tid = t->nftids; + } + + - if (test_bit(idx, t->ftid_bmap)) { + if (test_bit(idx, bmap)) { - next_ftid = find_next_bit(t->ftid_bmap, t->nftids, idx); - if (next_ftid >= t->nftids) + next_ftid = find_next_bit(bmap, max_tid, idx); + if (next_ftid >= max_tid) - next_fe = &adap->tids.ftid_tab[next_ftid]; + next_fe = &tab[next_ftid]; - prev_ftid = find_last_bit(t->ftid_bmap, idx); + prev_ftid = find_last_bit(bmap, idx); - prev_fe = &adap->tids.ftid_tab[prev_ftid & ~0x3]; + prev_fe = &tab[prev_ftid & ~0x3]; - prev_fe = &adap->tids.ftid_tab[prev_ftid]; + prev_fe = &tab[prev_ftid]; - prev_fe = &adap->tids.ftid_tab[prev_ftid & ~0x1]; + prev_fe = &tab[prev_ftid & ~0x1]; - prev_fe = &adap->tids.ftid_tab[prev_ftid]; + prev_fe = &tab[prev_ftid]; - struct filter_entry *f = &adapter->tids.ftid_tab[fidx]; + struct filter_entry *f; + if (fidx < adapter->tids.nhpftids) + f = &adapter->tids.hpftid_tab[fidx]; + else + f = &adapter->tids.ftid_tab[fidx - adapter->tids.nhpftids]; + - struct filter_entry *f = &adapter->tids.ftid_tab[fidx]; + struct filter_entry *f; + if (fidx < adapter->tids.nhpftids) + f = &adapter->tids.hpftid_tab[fidx]; + else + f = &adapter->tids.ftid_tab[fidx - adapter->tids.nhpftids]; + + if (adapter->tids.hpftid_tab) { + struct filter_entry *f = &adapter->tids.hpftid_tab[0]; + + for (i = 0; i < adapter->tids.nhpftids; i++, f++) + if (f->valid || f->pending) + cxgb4_del_filter(dev, i, &f->fs); + } + - adapter->tids.nsftids; + adapter->tids.nsftids + + adapter->tids.nhpftids; + - for (i = 0; i < max_ftid; i++, f++) + for (i = adapter->tids.nhpftids; i < max_ftid; i++, f++) -int __cxgb4_set_filter(struct net_device *dev, int filter_id, +int __cxgb4_set_filter(struct net_device *dev, int ftid, - unsigned int chip_ver = chelsio_chip_version(adapter->params.chip); - unsigned int max_fidx, fidx; - struct filter_entry *f; + unsigned int max_fidx, fidx, chip_ver; + int iq, ret, filter_id = ftid; + struct filter_entry *f, *tab; - int iq, ret; + chip_ver = chelsio_chip_version(adapter->params.chip); - max_fidx = adapter->tids.nftids; + max_fidx = adapter->tids.nftids + adapter->tids.nhpftids; + if (fs->prio) { + tab = &adapter->tids.hpftid_tab[0]; + } else { + tab = &adapter->tids.ftid_tab[0]; + filter_id = ftid - adapter->tids.nhpftids; + } + - if (fidx != filter_id && - adapter->tids.ftid_tab[fidx].fs.type) { - f = &adapter->tids.ftid_tab[fidx]; + if (fidx != filter_id && tab[fidx].fs.type) { + f = &tab[fidx]; - f = &adapter->tids.ftid_tab[fidx]; + f = &tab[fidx]; - f = &adapter->tids.ftid_tab[fidx]; + f = &tab[fidx]; - f = &adapter->tids.ftid_tab[filter_id]; + f = &tab[filter_id]; - fidx = filter_id + adapter->tids.ftid_base; - ret = cxgb4_set_ftid(&adapter->tids, filter_id, - fs->type ? pf_inet6 : pf_inet, - chip_ver); + if (fs->prio) { + fidx = filter_id + adapter->tids.hpftid_base; + ret = cxgb4_set_hpftid(&adapter->tids, filter_id, + fs->type ? pf_inet6 : pf_inet); + } else { + fidx = filter_id + adapter->tids.ftid_base; + ret = cxgb4_set_ftid(&adapter->tids, filter_id, + fs->type ? pf_inet6 : pf_inet, + chip_ver); + } + - if (ret) { - /* clear the bits we have set above */ - cxgb4_clear_ftid(&adapter->tids, filter_id, - fs->type ? pf_inet6 : pf_inet, - chip_ver); - return ret; - } + if (ret) + goto free_tid; - if (ret) { - cxgb4_clear_ftid(&adapter->tids, filter_id, pf_inet6, - chip_ver); - return ret; - } + if (ret) + goto free_tid; - goto free_clip; + goto free_tid; - ret = set_filter_wr(adapter, filter_id); - if (ret) { + ret = set_filter_wr(adapter, ftid); + if (ret) + goto free_tid; + + return ret; + +free_tid: + if (f->fs.prio) + cxgb4_clear_hpftid(&adapter->tids, filter_id, + fs->type ? pf_inet6 : pf_inet); + else - clear_filter(adapter, f); - } - return ret; - -free_clip: - if (is_t6(adapter->params.chip) && f->fs.type) - cxgb4_clip_release(f->dev, (const u32 *)&f->fs.val.lip, 1); - cxgb4_clear_ftid(&adapter->tids, filter_id, - fs->type ? pf_inet6 : pf_inet, chip_ver); + clear_filter(adapter, f); - unsigned int chip_ver = chelsio_chip_version(adapter->params.chip); + unsigned int max_fidx, chip_ver; - unsigned int max_fidx; + chip_ver = chelsio_chip_version(adapter->params.chip); - max_fidx = adapter->tids.nftids; + max_fidx = adapter->tids.nftids + adapter->tids.nhpftids; - f = &adapter->tids.ftid_tab[filter_id]; + if (filter_id < adapter->tids.nhpftids) + f = &adapter->tids.hpftid_tab[filter_id]; + else + f = &adapter->tids.ftid_tab[filter_id - adapter->tids.nhpftids]; + - cxgb4_clear_ftid(&adapter->tids, filter_id, - f->fs.type ? pf_inet6 : pf_inet, - chip_ver); + if (f->fs.prio) + cxgb4_clear_hpftid(&adapter->tids, + f->tid - adapter->tids.hpftid_base, + f->fs.type ? pf_inet6 : pf_inet); + else + cxgb4_clear_ftid(&adapter->tids, + f->tid - adapter->tids.ftid_base, + f->fs.type ? pf_inet6 : pf_inet, + chip_ver); - /* check this in normal filter region */ - idx = tid - adap->tids.ftid_base; - if (idx >= max_fidx) - return; - f = &adap->tids.ftid_tab[idx]; + idx = tid - adap->tids.hpftid_base; + if (idx < adap->tids.nhpftids) { + f = &adap->tids.hpftid_tab[idx]; + } else { + /* check this in normal filter region */ + idx = tid - adap->tids.ftid_base; + if (idx >= max_fidx) + return; + f = &adap->tids.ftid_tab[idx]; + idx += adap->tids.nhpftids; + } + diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +static void adap_config_hpfilter(struct adapter *adapter) +{ + u32 param, val = 0; + int ret; + + /* enable hp filter region. older fw will fail this request and + * it is fine. + */ + param = fw_param_dev(hpfilter_region_support); + ret = t4_set_params(adapter, adapter->mbox, adapter->pf, 0, + 1, ¶m, &val); + + /* an error means fw doesn't know about hp filter support, + * it's not a problem, don't return an error. + */ + if (ret < 0) + dev_err(adapter->pdev_dev, + "hp filter region isn't supported by fw "); +} + + unsigned int hpftid_bmap_size; + hpftid_bmap_size = bits_to_longs(t->nhpftids); + t->nhpftids * sizeof(*t->hpftid_tab) + + hpftid_bmap_size * sizeof(long) + - t->ftid_tab = (struct filter_entry *)&t->stid_bmap[stid_bmap_size]; + t->hpftid_tab = (struct filter_entry *)&t->stid_bmap[stid_bmap_size]; + t->hpftid_bmap = (unsigned long *)&t->hpftid_tab[t->nhpftids]; + t->ftid_tab = (struct filter_entry *)&t->hpftid_bmap[hpftid_bmap_size]; + if (t->nhpftids) + bitmap_zero(t->hpftid_bmap, t->nhpftids); + adap_config_hpfilter(adapter); -#define fw_param_dev(param) \ - (fw_params_mnem_v(fw_params_mnem_dev) | \ - fw_params_param_x_v(fw_params_param_dev_##param)) - -#define fw_param_pfvf(param) \ - fw_params_mnem_v(fw_params_mnem_pfvf) | \ - fw_params_param_x_v(fw_params_param_pfvf_##param)| \ - fw_params_param_y_v(0) | \ - fw_params_param_z_v(0) - + params[0] = fw_param_pfvf(hpfilter_start); + params[1] = fw_param_pfvf(hpfilter_end); + ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2, + params, val); + if (ret < 0) + goto bye; + + adap->tids.hpftid_base = val[0]; + adap->tids.nhpftids = val[1] - val[0] + 1; + -#undef fw_param_pfvf -#undef fw_param_dev diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c - if (cls->common.prio <= adap->tids.nftids) + if (cls->common.prio <= adap->tids.nftids) { - else + if (fidx < adap->tids.nhpftids) + fs->prio = 1; + } else { + } diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c + if (fidx < adap->tids.nhpftids) + fs->prio = 1; diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c - if (filter_id >= adapter->tids.nftids || + if (filter_id >= adapter->tids.nftids + adapter->tids.nhpftids || + if (filter_id < adapter->tids.nhpftids) + fs.prio = 1; + struct filter_entry *f; - if (filter_id >= adapter->tids.nftids || - cls->knode.handle != adapter->tids.ftid_tab[filter_id].fs.tc_cookie) + if (filter_id >= adapter->tids.nftids + adapter->tids.nhpftids) + return -erange; + + if (filter_id < adapter->tids.nhpftids) + f = &adapter->tids.hpftid_tab[filter_id]; + else + f = &adapter->tids.ftid_tab[filter_id - adapter->tids.nhpftids]; + + if (cls->knode.handle != f->fs.tc_cookie) - unsigned int max_tids = adap->tids.nftids; + unsigned int max_tids = adap->tids.nftids + adap->tids.nhpftids; diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h + struct filter_entry *hpftid_tab; + unsigned long *hpftid_bmap; + unsigned int nhpftids; + unsigned int hpftid_base; + diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h --- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h + fw_params_param_dev_hpfilter_region_support = 0x26,
|
Networking
|
c21939998802b48e7afd0c0568193f6e4e4954f8
|
shahjada abul husain
|
drivers
|
net
|
chelsio, cxgb4, ethernet
|
dpaa2-ptp: add external trigger event support
|
this patch is to add external trigger event support for dpaa2-ptp driver with v2 dprtc_set_irq_mask() api.
|
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 external trigger event 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']
|
['dpaa2-ptp']
|
['c', 'h']
| 3
| 25
| 1
|
--- diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c + case ptp_clk_req_extts: + switch (rq->extts.index) { + case 0: + bit = dprtc_event_ets1; + break; + case 1: + bit = dprtc_event_ets2; + break; + default: + return -einval; + } + if (on) + extts_clean_up(ptp_qoriq, rq->extts.index, false); + break; + if (status & dprtc_event_ets1) + extts_clean_up(ptp_qoriq, 0, true); + + if (status & dprtc_event_ets2) + extts_clean_up(ptp_qoriq, 1, true); + diff --git a/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h --- a/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h +++ b/drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h +#define dprtc_cmd_version_2 2 +#define dprtc_cmd_v2(id) (((id) << dprtc_cmd_id_offset) | dprtc_cmd_version_2) -#define dprtc_cmdid_set_irq_mask dprtc_cmd(0x014) +#define dprtc_cmdid_set_irq_mask dprtc_cmd_v2(0x014) diff --git a/drivers/net/ethernet/freescale/dpaa2/dprtc.h b/drivers/net/ethernet/freescale/dpaa2/dprtc.h --- a/drivers/net/ethernet/freescale/dpaa2/dprtc.h +++ b/drivers/net/ethernet/freescale/dpaa2/dprtc.h +#define dprtc_event_ets1 0x00800000 +#define dprtc_event_ets2 0x00400000
|
Networking
|
17568c62cd2c9a8d75eb5da44b7df093819b6ebe
|
yangbo lu
|
drivers
|
net
|
dpaa2, ethernet, freescale
|
net: dsa: add support for atheros ar9331 built-in switch
|
provide basic support for atheros ar9331 built-in switch. so far it works as port multiplexer without any hardware offloading 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 support for atheros ar9331 built-in switch
|
['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']
|
['dsa ']
|
['c', 'kconfig', 'makefile']
| 5
| 869
| 0
|
--- diff --git a/drivers/net/dsa/kconfig b/drivers/net/dsa/kconfig --- a/drivers/net/dsa/kconfig +++ b/drivers/net/dsa/kconfig +source "drivers/net/dsa/qca/kconfig" + diff --git a/drivers/net/dsa/makefile b/drivers/net/dsa/makefile --- a/drivers/net/dsa/makefile +++ b/drivers/net/dsa/makefile +obj-y += qca/ diff --git a/drivers/net/dsa/qca/kconfig b/drivers/net/dsa/qca/kconfig --- /dev/null +++ b/drivers/net/dsa/qca/kconfig +# spdx-license-identifier: gpl-2.0-only +config net_dsa_ar9331 + tristate "qualcomm atheros ar9331 ethernet switch support" + depends on net_dsa + select net_dsa_tag_ar9331 + select regmap + ---help--- + this enables support for the qualcomm atheros ar9331 built-in ethernet + switch. diff --git a/drivers/net/dsa/qca/makefile b/drivers/net/dsa/qca/makefile --- /dev/null +++ b/drivers/net/dsa/qca/makefile +# spdx-license-identifier: gpl-2.0-only +obj-$(config_net_dsa_ar9331) += ar9331.o diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c --- /dev/null +++ b/drivers/net/dsa/qca/ar9331.c +// spdx-license-identifier: gpl-2.0-only +// copyright (c) 2019 pengutronix, oleksij rempel <kernel@pengutronix.de> +/* + * +----------------------+ + * gmac1----rgmii----|--mac0 | + * \---mdio1----|--regs |----mdio3----\ + * | | | +------+ + * | | +--| | + * | mac1-|----rmii--m-----| phy0 |-o p0 + * | | | | +------+ + * | | | +--| | + * | mac2-|----rmii--------| phy1 |-o p1 + * | | | | +------+ + * | | | +--| | + * | mac3-|----rmii--------| phy2 |-o p2 + * | | | | +------+ + * | | | +--| | + * | mac4-|----rmii--------| phy3 |-o p3 + * | | | | +------+ + * | | | +--| | + * | mac5-|--+-rmii--m-----|-phy4-|-o p4 + * | | | | +------+ + * +----------------------+ | \--cfg_sw_phy_swap + * gmac0---------------rmii--------------------/ \-cfg_sw_phy_addr_swap + * \---mdio0--nc + * + * gmac0 and mac5 are connected together and use same phy. depending on + * configuration it can be phy4 (default) or phy0. only gmac0 or mac5 can be + * used at same time. if gmac0 is used (default) then mac5 should be disabled. + * + * cfg_sw_phy_swap - swap connections of phy0 and phy4. if this bit is not set + * phy4 is connected to gmac0/mac5 bundle and phy0 is connected to mac1. if this + * bit is set, phy4 is connected to mac1 and phy0 is connected to gmac0/mac5 + * bundle. + * + * cfg_sw_phy_addr_swap - swap addresses of phy0 and phy4 + * + * cfg_sw_phy_swap and cfg_sw_phy_addr_swap are part of soc specific register + * set and not related to switch internal registers. + */ + +#include <linux/bitfield.h> +#include <linux/module.h> +#include <linux/of_irq.h> +#include <linux/of_mdio.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <net/dsa.h> + +#define ar9331_sw_name "ar9331_switch" +#define ar9331_sw_ports 6 + +/* dummy reg to change page */ +#define ar9331_sw_reg_page 0x40000 + +/* global interrupt */ +#define ar9331_sw_reg_gint 0x10 +#define ar9331_sw_reg_gint_mask 0x14 +#define ar9331_sw_gint_phy_int bit(2) + +#define ar9331_sw_reg_flood_mask 0x2c +#define ar9331_sw_flood_mask_broad_to_cpu bit(26) + +#define ar9331_sw_reg_global_ctrl 0x30 +#define ar9331_sw_global_ctrl_mfs_m genmask(13, 0) + +#define ar9331_sw_reg_mdio_ctrl 0x98 +#define ar9331_sw_mdio_ctrl_busy bit(31) +#define ar9331_sw_mdio_ctrl_master_en bit(30) +#define ar9331_sw_mdio_ctrl_cmd_read bit(27) +#define ar9331_sw_mdio_ctrl_phy_addr_m genmask(25, 21) +#define ar9331_sw_mdio_ctrl_reg_addr_m genmask(20, 16) +#define ar9331_sw_mdio_ctrl_data_m genmask(16, 0) + +#define ar9331_sw_reg_port_status(_port) (0x100 + (_port) * 0x100) + +/* flow_link_en - enable mac flow control config auto-neg with phy. + * if not set, mac can be config by software. + */ +#define ar9331_sw_port_status_flow_link_en bit(12) + +/* link_en - if set, mac is configured from phy link status. + * if not set, mac should be configured by software. + */ +#define ar9331_sw_port_status_link_en bit(9) +#define ar9331_sw_port_status_duplex_mode bit(6) +#define ar9331_sw_port_status_rx_flow_en bit(5) +#define ar9331_sw_port_status_tx_flow_en bit(4) +#define ar9331_sw_port_status_rxmac bit(3) +#define ar9331_sw_port_status_txmac bit(2) +#define ar9331_sw_port_status_speed_m genmask(1, 0) +#define ar9331_sw_port_status_speed_1000 2 +#define ar9331_sw_port_status_speed_100 1 +#define ar9331_sw_port_status_speed_10 0 + +#define ar9331_sw_port_status_mac_mask \ + (ar9331_sw_port_status_txmac | ar9331_sw_port_status_rxmac) + +#define ar9331_sw_port_status_link_mask \ + (ar9331_sw_port_status_link_en | ar9331_sw_port_status_flow_link_en | \ + ar9331_sw_port_status_duplex_mode | \ + ar9331_sw_port_status_rx_flow_en | ar9331_sw_port_status_tx_flow_en | \ + ar9331_sw_port_status_speed_m) + +/* phy bypass mode + * ------------------------------------------------------------------------ + * bit: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | + * + * real | start | op | phyaddr | reg addr | ta | + * atheros| start | op | 2'b00 |phyadd[2:0]| reg addr[4:0] | ta | + * + * + * bit: |16 |17 |18 |19 |20 |21 |22 |23 |24 |25 |26 |27 |28 |29 |30 |31 | + * real | data | + * atheros| data | + * + * ------------------------------------------------------------------------ + * page address mode + * ------------------------------------------------------------------------ + * bit: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | + * real | start | op | phyaddr | reg addr | ta | + * atheros| start | op | 2'b11 | 8'b0 | ta | + * + * bit: |16 |17 |18 |19 |20 |21 |22 |23 |24 |25 |26 |27 |28 |29 |30 |31 | + * real | data | + * atheros| | page [9:0] | + */ +/* in case of page address mode, bit[18:9] of 32 bit register address should be + * written to bits[9:0] of mdio data register. + */ +#define ar9331_sw_addr_page genmask(18, 9) + +/* ------------------------------------------------------------------------ + * normal register access mode + * ------------------------------------------------------------------------ + * bit: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | + * real | start | op | phyaddr | reg addr | ta | + * atheros| start | op | 2'b10 | low_addr[7:0] | ta | + * + * bit: |16 |17 |18 |19 |20 |21 |22 |23 |24 |25 |26 |27 |28 |29 |30 |31 | + * real | data | + * atheros| data | + * ------------------------------------------------------------------------ + */ +#define ar9331_sw_low_addr_phy genmask(8, 6) +#define ar9331_sw_low_addr_reg genmask(5, 1) + +#define ar9331_sw_mdio_phy_mode_m genmask(4, 3) +#define ar9331_sw_mdio_phy_mode_page 3 +#define ar9331_sw_mdio_phy_mode_reg 2 +#define ar9331_sw_mdio_phy_mode_bypass 0 +#define ar9331_sw_mdio_phy_addr_m genmask(2, 0) + +/* empirical determined values */ +#define ar9331_sw_mdio_poll_sleep_us 1 +#define ar9331_sw_mdio_poll_timeout_us 20 + +struct ar9331_sw_priv { + struct device *dev; + struct dsa_switch ds; + struct dsa_switch_ops ops; + struct irq_domain *irqdomain; + struct mii_bus *mbus; /* mdio master */ + struct mii_bus *sbus; /* mdio slave */ + struct regmap *regmap; + struct reset_control *sw_reset; +}; + +/* warning: switch reset will reset last ar9331_sw_mdio_phy_mode_page request + * if some kind of optimization is used, the request should be repeated. + */ +static int ar9331_sw_reset(struct ar9331_sw_priv *priv) +{ + int ret; + + ret = reset_control_assert(priv->sw_reset); + if (ret) + goto error; + + /* ar9331 doc do not provide any information about proper reset + * sequence. the ar8136 (the closes switch to the ar9331) doc says: + * reset duration should be greater than 10ms. so, let's use this value + * for now. + */ + usleep_range(10000, 15000); + ret = reset_control_deassert(priv->sw_reset); + if (ret) + goto error; + /* there is no information on how long should we wait after reset. + * ar8136 has an eeprom and there is an interrupt for eeprom load + * status. ar9331 has no eeprom support. + * for now, do not wait. in case ar8136 will be needed, the after + * reset delay can be added as well. + */ + + return 0; +error: + dev_err_ratelimited(priv->dev, "%s: %i ", __func__, ret); + return ret; +} + +static int ar9331_sw_mbus_write(struct mii_bus *mbus, int port, int regnum, + u16 data) +{ + struct ar9331_sw_priv *priv = mbus->priv; + struct regmap *regmap = priv->regmap; + u32 val; + int ret; + + ret = regmap_write(regmap, ar9331_sw_reg_mdio_ctrl, + ar9331_sw_mdio_ctrl_busy | + ar9331_sw_mdio_ctrl_master_en | + field_prep(ar9331_sw_mdio_ctrl_phy_addr_m, port) | + field_prep(ar9331_sw_mdio_ctrl_reg_addr_m, regnum) | + field_prep(ar9331_sw_mdio_ctrl_data_m, data)); + if (ret) + goto error; + + ret = regmap_read_poll_timeout(regmap, ar9331_sw_reg_mdio_ctrl, val, + !(val & ar9331_sw_mdio_ctrl_busy), + ar9331_sw_mdio_poll_sleep_us, + ar9331_sw_mdio_poll_timeout_us); + if (ret) + goto error; + + return 0; +error: + dev_err_ratelimited(priv->dev, "phy write error: %i ", ret); + return ret; +} + +static int ar9331_sw_mbus_read(struct mii_bus *mbus, int port, int regnum) +{ + struct ar9331_sw_priv *priv = mbus->priv; + struct regmap *regmap = priv->regmap; + u32 val; + int ret; + + ret = regmap_write(regmap, ar9331_sw_reg_mdio_ctrl, + ar9331_sw_mdio_ctrl_busy | + ar9331_sw_mdio_ctrl_master_en | + ar9331_sw_mdio_ctrl_cmd_read | + field_prep(ar9331_sw_mdio_ctrl_phy_addr_m, port) | + field_prep(ar9331_sw_mdio_ctrl_reg_addr_m, regnum)); + if (ret) + goto error; + + ret = regmap_read_poll_timeout(regmap, ar9331_sw_reg_mdio_ctrl, val, + !(val & ar9331_sw_mdio_ctrl_busy), + ar9331_sw_mdio_poll_sleep_us, + ar9331_sw_mdio_poll_timeout_us); + if (ret) + goto error; + + ret = regmap_read(regmap, ar9331_sw_reg_mdio_ctrl, &val); + if (ret) + goto error; + + return field_get(ar9331_sw_mdio_ctrl_data_m, val); + +error: + dev_err_ratelimited(priv->dev, "phy read error: %i ", ret); + return ret; +} + +static int ar9331_sw_mbus_init(struct ar9331_sw_priv *priv) +{ + struct device *dev = priv->dev; + static struct mii_bus *mbus; + struct device_node *np, *mnp; + int ret; + + np = dev->of_node; + + mbus = devm_mdiobus_alloc(dev); + if (!mbus) + return -enomem; + + mbus->name = np->full_name; + snprintf(mbus->id, mii_bus_id_size, "%pof", np); + + mbus->read = ar9331_sw_mbus_read; + mbus->write = ar9331_sw_mbus_write; + mbus->priv = priv; + mbus->parent = dev; + + mnp = of_get_child_by_name(np, "mdio"); + if (!mnp) + return -enodev; + + ret = of_mdiobus_register(mbus, mnp); + of_node_put(mnp); + if (ret) + return ret; + + priv->mbus = mbus; + + return 0; +} + +static int ar9331_sw_setup(struct dsa_switch *ds) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int ret; + + ret = ar9331_sw_reset(priv); + if (ret) + return ret; + + /* reset will set proper defaults. cpu - port0 will be enabled and + * configured. all other ports (ports 1 - 5) are disabled + */ + ret = ar9331_sw_mbus_init(priv); + if (ret) + return ret; + + /* do not drop broadcast frames */ + ret = regmap_write_bits(regmap, ar9331_sw_reg_flood_mask, + ar9331_sw_flood_mask_broad_to_cpu, + ar9331_sw_flood_mask_broad_to_cpu); + if (ret) + goto error; + + /* set max frame size to the maximum supported value */ + ret = regmap_write_bits(regmap, ar9331_sw_reg_global_ctrl, + ar9331_sw_global_ctrl_mfs_m, + ar9331_sw_global_ctrl_mfs_m); + if (ret) + goto error; + + return 0; +error: + dev_err_ratelimited(priv->dev, "%s: %i ", __func__, ret); + return ret; +} + +static void ar9331_sw_port_disable(struct dsa_switch *ds, int port) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int ret; + + ret = regmap_write(regmap, ar9331_sw_reg_port_status(port), 0); + if (ret) + dev_err_ratelimited(priv->dev, "%s: %i ", __func__, ret); +} + +static enum dsa_tag_protocol ar9331_sw_get_tag_protocol(struct dsa_switch *ds, + int port) +{ + return dsa_tag_proto_ar9331; +} + +static void ar9331_sw_phylink_validate(struct dsa_switch *ds, int port, + unsigned long *supported, + struct phylink_link_state *state) +{ + __ethtool_declare_link_mode_mask(mask) = { 0, }; + + switch (port) { + case 0: + if (state->interface != phy_interface_mode_gmii) + goto unsupported; + + phylink_set(mask, 1000baset_full); + phylink_set(mask, 1000baset_half); + break; + case 1: + case 2: + case 3: + case 4: + case 5: + if (state->interface != phy_interface_mode_internal) + goto unsupported; + break; + default: + bitmap_zero(supported, __ethtool_link_mode_mask_nbits); + dev_err(ds->dev, "unsupported port: %i ", port); + return; + } + + phylink_set_port_modes(mask); + phylink_set(mask, pause); + phylink_set(mask, asym_pause); + + phylink_set(mask, 10baset_half); + phylink_set(mask, 10baset_full); + phylink_set(mask, 100baset_half); + phylink_set(mask, 100baset_full); + + bitmap_and(supported, supported, mask, + __ethtool_link_mode_mask_nbits); + bitmap_and(state->advertising, state->advertising, mask, + __ethtool_link_mode_mask_nbits); + + return; + +unsupported: + bitmap_zero(supported, __ethtool_link_mode_mask_nbits); + dev_err(ds->dev, "unsupported interface: %d, port: %d ", + state->interface, port); +} + +static void ar9331_sw_phylink_mac_config(struct dsa_switch *ds, int port, + unsigned int mode, + const struct phylink_link_state *state) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int ret; + u32 val; + + switch (state->speed) { + case speed_1000: + val = ar9331_sw_port_status_speed_1000; + break; + case speed_100: + val = ar9331_sw_port_status_speed_100; + break; + case speed_10: + val = ar9331_sw_port_status_speed_10; + break; + default: + return; + } + + if (state->duplex) + val |= ar9331_sw_port_status_duplex_mode; + + if (state->pause & mlo_pause_tx) + val |= ar9331_sw_port_status_tx_flow_en; + + if (state->pause & mlo_pause_rx) + val |= ar9331_sw_port_status_rx_flow_en; + + ret = regmap_update_bits(regmap, ar9331_sw_reg_port_status(port), + ar9331_sw_port_status_link_mask, val); + if (ret) + dev_err_ratelimited(priv->dev, "%s: %i ", __func__, ret); +} + +static void ar9331_sw_phylink_mac_link_down(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int ret; + + ret = regmap_update_bits(regmap, ar9331_sw_reg_port_status(port), + ar9331_sw_port_status_mac_mask, 0); + if (ret) + dev_err_ratelimited(priv->dev, "%s: %i ", __func__, ret); +} + +static void ar9331_sw_phylink_mac_link_up(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface, + struct phy_device *phydev) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int ret; + + ret = regmap_update_bits(regmap, ar9331_sw_reg_port_status(port), + ar9331_sw_port_status_mac_mask, + ar9331_sw_port_status_mac_mask); + if (ret) + dev_err_ratelimited(priv->dev, "%s: %i ", __func__, ret); +} + +static const struct dsa_switch_ops ar9331_sw_ops = { + .get_tag_protocol = ar9331_sw_get_tag_protocol, + .setup = ar9331_sw_setup, + .port_disable = ar9331_sw_port_disable, + .phylink_validate = ar9331_sw_phylink_validate, + .phylink_mac_config = ar9331_sw_phylink_mac_config, + .phylink_mac_link_down = ar9331_sw_phylink_mac_link_down, + .phylink_mac_link_up = ar9331_sw_phylink_mac_link_up, +}; + +static irqreturn_t ar9331_sw_irq(int irq, void *data) +{ + struct ar9331_sw_priv *priv = data; + struct regmap *regmap = priv->regmap; + u32 stat; + int ret; + + ret = regmap_read(regmap, ar9331_sw_reg_gint, &stat); + if (ret) { + dev_err(priv->dev, "can't read interrupt status "); + return irq_none; + } + + if (!stat) + return irq_none; + + if (stat & ar9331_sw_gint_phy_int) { + int child_irq; + + child_irq = irq_find_mapping(priv->irqdomain, 0); + handle_nested_irq(child_irq); + } + + ret = regmap_write(regmap, ar9331_sw_reg_gint, stat); + if (ret) { + dev_err(priv->dev, "can't write interrupt status "); + return irq_none; + } + + return irq_handled; +} + +static void ar9331_sw_mask_irq(struct irq_data *d) +{ + struct ar9331_sw_priv *priv = irq_data_get_irq_chip_data(d); + struct regmap *regmap = priv->regmap; + int ret; + + ret = regmap_update_bits(regmap, ar9331_sw_reg_gint_mask, + ar9331_sw_gint_phy_int, 0); + if (ret) + dev_err(priv->dev, "could not mask irq "); +} + +static void ar9331_sw_unmask_irq(struct irq_data *d) +{ + struct ar9331_sw_priv *priv = irq_data_get_irq_chip_data(d); + struct regmap *regmap = priv->regmap; + int ret; + + ret = regmap_update_bits(regmap, ar9331_sw_reg_gint_mask, + ar9331_sw_gint_phy_int, + ar9331_sw_gint_phy_int); + if (ret) + dev_err(priv->dev, "could not unmask irq "); +} + +static struct irq_chip ar9331_sw_irq_chip = { + .name = ar9331_sw_name, + .irq_mask = ar9331_sw_mask_irq, + .irq_unmask = ar9331_sw_unmask_irq, +}; + +static int ar9331_sw_irq_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + irq_set_chip_data(irq, domain->host_data); + irq_set_chip_and_handler(irq, &ar9331_sw_irq_chip, handle_simple_irq); + irq_set_nested_thread(irq, 1); + irq_set_noprobe(irq); + + return 0; +} + +static void ar9331_sw_irq_unmap(struct irq_domain *d, unsigned int irq) +{ + irq_set_nested_thread(irq, 0); + irq_set_chip_and_handler(irq, null, null); + irq_set_chip_data(irq, null); +} + +static const struct irq_domain_ops ar9331_sw_irqdomain_ops = { + .map = ar9331_sw_irq_map, + .unmap = ar9331_sw_irq_unmap, + .xlate = irq_domain_xlate_onecell, +}; + +static int ar9331_sw_irq_init(struct ar9331_sw_priv *priv) +{ + struct device_node *np = priv->dev->of_node; + struct device *dev = priv->dev; + int ret, irq; + + irq = of_irq_get(np, 0); + if (irq <= 0) { + dev_err(dev, "failed to get parent irq "); + return irq ? irq : -einval; + } + + ret = devm_request_threaded_irq(dev, irq, null, ar9331_sw_irq, + irqf_oneshot, ar9331_sw_name, priv); + if (ret) { + dev_err(dev, "unable to request irq: %d ", ret); + return ret; + } + + priv->irqdomain = irq_domain_add_linear(np, 1, &ar9331_sw_irqdomain_ops, + priv); + if (!priv->irqdomain) { + dev_err(dev, "failed to create irq domain "); + return -einval; + } + + irq_set_parent(irq_create_mapping(priv->irqdomain, 0), irq); + + return 0; +} + +static int __ar9331_mdio_write(struct mii_bus *sbus, u8 mode, u16 reg, u16 val) +{ + u8 r, p; + + p = field_prep(ar9331_sw_mdio_phy_mode_m, mode) | + field_get(ar9331_sw_low_addr_phy, reg); + r = field_get(ar9331_sw_low_addr_reg, reg); + + return mdiobus_write(sbus, p, r, val); +} + +static int __ar9331_mdio_read(struct mii_bus *sbus, u16 reg) +{ + u8 r, p; + + p = field_prep(ar9331_sw_mdio_phy_mode_m, ar9331_sw_mdio_phy_mode_reg) | + field_get(ar9331_sw_low_addr_phy, reg); + r = field_get(ar9331_sw_low_addr_reg, reg); + + return mdiobus_read(sbus, p, r); +} + +static int ar9331_mdio_read(void *ctx, const void *reg_buf, size_t reg_len, + void *val_buf, size_t val_len) +{ + struct ar9331_sw_priv *priv = ctx; + struct mii_bus *sbus = priv->sbus; + u32 reg = *(u32 *)reg_buf; + int ret; + + if (reg == ar9331_sw_reg_page) { + /* we cannot read the page selector register from hardware and + * we cache its value in regmap. return all bits set here, + * that regmap will always write the page on first use. + */ + *(u32 *)val_buf = genmask(9, 0); + return 0; + } + + ret = __ar9331_mdio_read(sbus, reg); + if (ret < 0) + goto error; + + *(u32 *)val_buf = ret; + ret = __ar9331_mdio_read(sbus, reg + 2); + if (ret < 0) + goto error; + + *(u32 *)val_buf |= ret << 16; + + return 0; +error: + dev_err_ratelimited(&sbus->dev, "bus error. failed to read register. "); + return ret; +} + +static int ar9331_mdio_write(void *ctx, u32 reg, u32 val) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ctx; + struct mii_bus *sbus = priv->sbus; + int ret; + + if (reg == ar9331_sw_reg_page) { + ret = __ar9331_mdio_write(sbus, ar9331_sw_mdio_phy_mode_page, + 0, val); + if (ret < 0) + goto error; + + return 0; + } + + ret = __ar9331_mdio_write(sbus, ar9331_sw_mdio_phy_mode_reg, reg, val); + if (ret < 0) + goto error; + + ret = __ar9331_mdio_write(sbus, ar9331_sw_mdio_phy_mode_reg, reg + 2, + val >> 16); + if (ret < 0) + goto error; + + return 0; +error: + dev_err_ratelimited(&sbus->dev, "bus error. failed to write register. "); + return ret; +} + +static int ar9331_sw_bus_write(void *context, const void *data, size_t count) +{ + u32 reg = *(u32 *)data; + u32 val = *((u32 *)data + 1); + + return ar9331_mdio_write(context, reg, val); +} + +static const struct regmap_range ar9331_valid_regs[] = { + regmap_reg_range(0x0, 0x0), + regmap_reg_range(0x10, 0x14), + regmap_reg_range(0x20, 0x24), + regmap_reg_range(0x2c, 0x30), + regmap_reg_range(0x40, 0x44), + regmap_reg_range(0x50, 0x78), + regmap_reg_range(0x80, 0x98), + + regmap_reg_range(0x100, 0x120), + regmap_reg_range(0x200, 0x220), + regmap_reg_range(0x300, 0x320), + regmap_reg_range(0x400, 0x420), + regmap_reg_range(0x500, 0x520), + regmap_reg_range(0x600, 0x620), + + regmap_reg_range(0x20000, 0x200a4), + regmap_reg_range(0x20100, 0x201a4), + regmap_reg_range(0x20200, 0x202a4), + regmap_reg_range(0x20300, 0x203a4), + regmap_reg_range(0x20400, 0x204a4), + regmap_reg_range(0x20500, 0x205a4), + + /* dummy page selector reg */ + regmap_reg_range(ar9331_sw_reg_page, ar9331_sw_reg_page), +}; + +static const struct regmap_range ar9331_nonvolatile_regs[] = { + regmap_reg_range(ar9331_sw_reg_page, ar9331_sw_reg_page), +}; + +static const struct regmap_range_cfg ar9331_regmap_range[] = { + { + .selector_reg = ar9331_sw_reg_page, + .selector_mask = genmask(9, 0), + .selector_shift = 0, + + .window_start = 0, + .window_len = 512, + + .range_min = 0, + .range_max = ar9331_sw_reg_page - 4, + }, +}; + +static const struct regmap_access_table ar9331_register_set = { + .yes_ranges = ar9331_valid_regs, + .n_yes_ranges = array_size(ar9331_valid_regs), +}; + +static const struct regmap_access_table ar9331_volatile_set = { + .no_ranges = ar9331_nonvolatile_regs, + .n_no_ranges = array_size(ar9331_nonvolatile_regs), +}; + +static const struct regmap_config ar9331_mdio_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .max_register = ar9331_sw_reg_page, + + .ranges = ar9331_regmap_range, + .num_ranges = array_size(ar9331_regmap_range), + + .volatile_table = &ar9331_volatile_set, + .wr_table = &ar9331_register_set, + .rd_table = &ar9331_register_set, + + .cache_type = regcache_rbtree, +}; + +static struct regmap_bus ar9331_sw_bus = { + .reg_format_endian_default = regmap_endian_native, + .val_format_endian_default = regmap_endian_native, + .read = ar9331_mdio_read, + .write = ar9331_sw_bus_write, + .max_raw_read = 4, + .max_raw_write = 4, +}; + +static int ar9331_sw_probe(struct mdio_device *mdiodev) +{ + struct ar9331_sw_priv *priv; + struct dsa_switch *ds; + int ret; + + priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), gfp_kernel); + if (!priv) + return -enomem; + + priv->regmap = devm_regmap_init(&mdiodev->dev, &ar9331_sw_bus, priv, + &ar9331_mdio_regmap_config); + if (is_err(priv->regmap)) { + ret = ptr_err(priv->regmap); + dev_err(&mdiodev->dev, "regmap init failed: %d ", ret); + return ret; + } + + priv->sw_reset = devm_reset_control_get(&mdiodev->dev, "switch"); + if (is_err(priv->sw_reset)) { + dev_err(&mdiodev->dev, "missing switch reset "); + return ptr_err(priv->sw_reset); + } + + priv->sbus = mdiodev->bus; + priv->dev = &mdiodev->dev; + + ret = ar9331_sw_irq_init(priv); + if (ret) + return ret; + + ds = &priv->ds; + ds->dev = &mdiodev->dev; + ds->num_ports = ar9331_sw_ports; + ds->priv = priv; + priv->ops = ar9331_sw_ops; + ds->ops = &priv->ops; + dev_set_drvdata(&mdiodev->dev, priv); + + ret = dsa_register_switch(ds); + if (ret) + goto err_remove_irq; + + return 0; + +err_remove_irq: + irq_domain_remove(priv->irqdomain); + + return ret; +} + +static void ar9331_sw_remove(struct mdio_device *mdiodev) +{ + struct ar9331_sw_priv *priv = dev_get_drvdata(&mdiodev->dev); + + irq_domain_remove(priv->irqdomain); + mdiobus_unregister(priv->mbus); + dsa_unregister_switch(&priv->ds); + + reset_control_assert(priv->sw_reset); +} + +static const struct of_device_id ar9331_sw_of_match[] = { + { .compatible = "qca,ar9331-switch" }, + { }, +}; + +static struct mdio_driver ar9331_sw_mdio_driver = { + .probe = ar9331_sw_probe, + .remove = ar9331_sw_remove, + .mdiodrv.driver = { + .name = ar9331_sw_name, + .of_match_table = ar9331_sw_of_match, + }, +}; + +mdio_module_driver(ar9331_sw_mdio_driver); + +module_author("oleksij rempel <kernel@pengutronix.de>"); +module_description("driver for atheros ar9331 switch"); +module_license("gpl v2");
|
Networking
|
ec6698c272debe16c8825c88a5b3c3f68a12ef4a
|
oleksij rempel andrew lunn andrew lunn ch vivien didelot vivien didelot gmail com
|
drivers
|
net
|
dsa, qca
|
net: dsa: add support for atheros ar9331 tag format
|
add support for tag format used in atheros ar9331 built-in switch.
|
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 atheros ar9331 tag format
|
['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']
|
['dsa ']
|
['h', 'kconfig', 'c', 'makefile']
| 4
| 105
| 0
|
--- diff --git a/include/net/dsa.h b/include/net/dsa.h --- a/include/net/dsa.h +++ b/include/net/dsa.h +#define dsa_tag_proto_ar9331_value 16 + dsa_tag_proto_ar9331 = dsa_tag_proto_ar9331_value, diff --git a/net/dsa/kconfig b/net/dsa/kconfig --- a/net/dsa/kconfig +++ b/net/dsa/kconfig +config net_dsa_tag_ar9331 + tristate "tag driver for atheros ar9331 soc with built-in switch" + help + say y or m if you want to enable support for tagging frames for + the atheros ar9331 soc with built-in switch. + diff --git a/net/dsa/makefile b/net/dsa/makefile --- a/net/dsa/makefile +++ b/net/dsa/makefile +obj-$(config_net_dsa_tag_ar9331) += tag_ar9331.o diff --git a/net/dsa/tag_ar9331.c b/net/dsa/tag_ar9331.c --- /dev/null +++ b/net/dsa/tag_ar9331.c +// spdx-license-identifier: gpl-2.0 +/* + * copyright (c) 2019 pengutronix, oleksij rempel <kernel@pengutronix.de> + */ + + +#include <linux/bitfield.h> +#include <linux/etherdevice.h> + +#include "dsa_priv.h" + +#define ar9331_hdr_len 2 +#define ar9331_hdr_version 1 + +#define ar9331_hdr_version_mask genmask(15, 14) +#define ar9331_hdr_priority_mask genmask(13, 12) +#define ar9331_hdr_type_mask genmask(10, 8) +#define ar9331_hdr_broadcast bit(7) +#define ar9331_hdr_from_cpu bit(6) +/* ar9331_hdr_reserved - not used or may be version field. + * according to the ar8216 doc it should 0b10. on ar9331 it is 0b11 on rx path + * and should be set to 0b11 to make it work. + */ +#define ar9331_hdr_reserved_mask genmask(5, 4) +#define ar9331_hdr_port_num_mask genmask(3, 0) + +static struct sk_buff *ar9331_tag_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + __le16 *phdr; + u16 hdr; + + if (skb_cow_head(skb, 0) < 0) + return null; + + phdr = skb_push(skb, ar9331_hdr_len); + + hdr = field_prep(ar9331_hdr_version_mask, ar9331_hdr_version); + hdr |= ar9331_hdr_from_cpu | dp->index; + /* 0b10 for ar8216 and 0b11 for ar9331 */ + hdr |= ar9331_hdr_reserved_mask; + + phdr[0] = cpu_to_le16(hdr); + + return skb; +} + +static struct sk_buff *ar9331_tag_rcv(struct sk_buff *skb, + struct net_device *ndev, + struct packet_type *pt) +{ + u8 ver, port; + u16 hdr; + + if (unlikely(!pskb_may_pull(skb, ar9331_hdr_len))) + return null; + + hdr = le16_to_cpu(*(__le16 *)skb_mac_header(skb)); + + ver = field_get(ar9331_hdr_version_mask, hdr); + if (unlikely(ver != ar9331_hdr_version)) { + netdev_warn_once(ndev, "%s:%i wrong header version 0x%2x ", + __func__, __line__, hdr); + return null; + } + + if (unlikely(hdr & ar9331_hdr_from_cpu)) { + netdev_warn_once(ndev, "%s:%i packet should not be from cpu 0x%2x ", + __func__, __line__, hdr); + return null; + } + + skb_pull_rcsum(skb, ar9331_hdr_len); + + /* get source port information */ + port = field_get(ar9331_hdr_port_num_mask, hdr); + + skb->dev = dsa_master_find_slave(ndev, 0, port); + if (!skb->dev) + return null; + + return skb; +} + +static const struct dsa_device_ops ar9331_netdev_ops = { + .name = "ar9331", + .proto = dsa_tag_proto_ar9331, + .xmit = ar9331_tag_xmit, + .rcv = ar9331_tag_rcv, + .overhead = ar9331_hdr_len, +}; + +module_license("gpl v2"); +module_alias_dsa_tag_driver(dsa_tag_proto_ar9331); +module_dsa_tag_driver(ar9331_netdev_ops);
|
Networking
|
48fda74f0a9377ce2145ac5f06b6db0274880826
|
oleksij rempel vivien didelot vivien didelot gmail com andrew lunn andrew lunn ch
|
net
|
dsa
| |
net: dsa: get information about stacked dsa protocol
|
it is possible to stack multiple dsa switches in a way that they are not part of the tree (disjoint) but the dsa master of a switch is a dsa slave of another. when that happens switch drivers may have to know this is the case so as to determine whether their tagging protocol has a remove chance of working.
|
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.
|
enable broadcom tags for 531x5/539x families
|
['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']
|
['dsa ', 'b53']
|
['c', 'h']
| 20
| 78
| 29
|
--- diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c - bool tag_en = !(ds->ops->get_tag_protocol(ds, port) == - dsa_tag_proto_none); + bool tag_en = !(dev->tag_protocol == dsa_tag_proto_none); -enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port) +enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, + enum dsa_tag_protocol mprot) - !b53_can_enable_brcm_tags(ds, port)) - return dsa_tag_proto_none; + !b53_can_enable_brcm_tags(ds, port)) { + dev->tag_protocol = dsa_tag_proto_none; + goto out; + } - if (dev->chip_id == bcm58xx_device_id && port == b53_cpu_port) - return dsa_tag_proto_brcm_prepend; + if (dev->chip_id == bcm58xx_device_id && port == b53_cpu_port) { + dev->tag_protocol = dsa_tag_proto_brcm_prepend; + goto out; + } - return dsa_tag_proto_brcm; + dev->tag_protocol = dsa_tag_proto_brcm; +out: + return dev->tag_protocol; diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h --- a/drivers/net/dsa/b53/b53_priv.h +++ b/drivers/net/dsa/b53/b53_priv.h + enum dsa_tag_protocol tag_protocol; -enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port); +enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, + enum dsa_tag_protocol mprot); diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c --- a/drivers/net/dsa/dsa_loop.c +++ b/drivers/net/dsa/dsa_loop.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c -mtk_get_tag_protocol(struct dsa_switch *ds, int port) +mtk_get_tag_protocol(struct dsa_switch *ds, int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c - int port) + int port, + enum dsa_tag_protocol m) 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 - int port) + int port, + enum dsa_tag_protocol m) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c - int port) + int port, + enum dsa_tag_protocol m) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c -qca8k_get_tag_protocol(struct dsa_switch *ds, int port) +qca8k_get_tag_protocol(struct dsa_switch *ds, int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c -sja1105_get_tag_protocol(struct dsa_switch *ds, int port) +sja1105_get_tag_protocol(struct dsa_switch *ds, int port, + enum dsa_tag_protocol mp) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c - int port) + int port, + enum dsa_tag_protocol mp) diff --git a/include/net/dsa.h b/include/net/dsa.h --- a/include/net/dsa.h +++ b/include/net/dsa.h - int port); + int port, + enum dsa_tag_protocol mprot); diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c +static enum dsa_tag_protocol dsa_get_tag_protocol(struct dsa_port *dp, + struct net_device *master) +{ + enum dsa_tag_protocol tag_protocol = dsa_tag_proto_none; + struct dsa_switch *mds, *ds = dp->ds; + unsigned int mdp_upstream; + struct dsa_port *mdp; + + /* it is possible to stack dsa switches onto one another when that + * happens the switch driver may want to know if its tagging protocol + * is going to work in such a configuration. + */ + if (dsa_slave_dev_check(master)) { + mdp = dsa_slave_to_port(master); + mds = mdp->ds; + mdp_upstream = dsa_upstream_port(mds, mdp->index); + tag_protocol = mds->ops->get_tag_protocol(mds, mdp_upstream, + dsa_tag_proto_none); + } + + /* if the master device is not itself a dsa slave in a disjoint dsa + * tree, then return immediately. + */ + return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol); +} + - tag_protocol = ds->ops->get_tag_protocol(ds, dp->index); + tag_protocol = dsa_get_tag_protocol(dp, master); + dp->master = null; + dp->master = master; - dp->master = master; diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h +bool dsa_slave_dev_check(const struct net_device *dev); diff --git a/net/dsa/slave.c b/net/dsa/slave.c --- a/net/dsa/slave.c +++ b/net/dsa/slave.c -static bool dsa_slave_dev_check(const struct net_device *dev); - -static bool dsa_slave_dev_check(const struct net_device *dev) +bool dsa_slave_dev_check(const struct net_device *dev)
|
Networking
|
4d776482ecc689bdd68627985ac4cb5a6f325953
|
florian fainelli
|
drivers
|
net
|
b53, dsa, microchip, mv88e6xxx, ocelot, qca, sja1105
|
net: dsa: b53: enable broadcom tags for 531x5/539x families
|
the bcm531x5 and bcm539x families require that the imp port be enabled within the management page and that management mode (sm_sw_fwd_mode) be turned on. once this is done, everything works as expected, including multicast with standalone dsa devices or bridge devices.
|
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.
|
enable broadcom tags for 531x5/539x families
|
['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']
|
['dsa ', 'b53']
|
['c']
| 1
| 37
| 9
|
--- diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c - mgmt &= ~sm_sw_fwd_mode; - + /* enable management mode if tagging is requested */ + b53_read8(dev, b53_ctrl_page, b53_switch_mode, &hdr_ctl); + if (tag_en) + hdr_ctl |= sm_sw_fwd_mode; + else + hdr_ctl &= ~sm_sw_fwd_mode; + b53_write8(dev, b53_ctrl_page, b53_switch_mode, hdr_ctl); + + /* configure the appropriate imp port */ + b53_read8(dev, b53_mgmt_page, b53_global_config, &hdr_ctl); + if (port == 8) + hdr_ctl |= gc_frm_mgmt_port_mii; + else if (port == 5) + hdr_ctl |= gc_frm_mgmt_port_m; + b53_write8(dev, b53_mgmt_page, b53_global_config, hdr_ctl); + -static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port) +static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port, + enum dsa_tag_protocol tag_protocol) - if (!ret) + if (!ret) { + return ret; + } + + switch (tag_protocol) { + case dsa_tag_proto_brcm: + case dsa_tag_proto_brcm_prepend: + dev_warn(ds->dev, + "port %d is stacked to broadcom tag switch ", port); + ret = false; + break; + default: + ret = true; + break; + } + - * not support in net/dsa/tag_brcm.c yet. 539x and 531x5 require managed - * mode to be turned on which means we need to specifically manage arl - * misses on multicast addresses (tbd). + * not support in net/dsa/tag_brcm.c yet. - if (is5325(dev) || is5365(dev) || is539x(dev) || is531x5(dev) || - !b53_can_enable_brcm_tags(ds, port)) { + if (is5325(dev) || is5365(dev) || + !b53_can_enable_brcm_tags(ds, port, mprot)) {
|
Networking
|
8fab459e69abfd04a66d76423d18ba853fced4ab
|
florian fainelli
|
drivers
|
net
|
b53, dsa
|
net: dsa: felix: add pcs operations for phylink
|
layerscape socs traditionally expose the serdes configuration/status for ethernet protocols (pcs for sgmii/usxgmii/10gbase-r etc etc) in a register format that is compatible with clause 22 or clause 45 (depending on serdes protocol). each mac has its own internal mdio bus on which there is one or more of these pcs's, responding to commands at a configurable phy address. the per-port internal mdio bus (which is just for pcss) is totally separate and has nothing to do with the dedicated external mdio controller (which is just for phys), but the register map for the mdio controller is the same.
|
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 pcs operations for phylink
|
['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']
|
['dsa ', 'felix']
|
['c', 'kconfig', 'h']
| 4
| 767
| 17
|
+------------------------------------------------------------------------+ +------------------------------------------------------------------------+ +-----------------|------------------------------------------------------+ - bar 4: the switch's effective registers - bar 0: the mdio controller register map lended from enetc port 2 - the phy mode (serdes protocol) cannot change at runtime due to soc - there is a circular dependency in that we need to know what clause the --- diff --git a/drivers/net/dsa/ocelot/kconfig b/drivers/net/dsa/ocelot/kconfig --- a/drivers/net/dsa/ocelot/kconfig +++ b/drivers/net/dsa/ocelot/kconfig + depends on net_vendor_freescale + select fsl_enetc_mdio diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c +#include <soc/mscc/ocelot_qsys.h> +#include <soc/mscc/ocelot_sys.h> +#include <soc/mscc/ocelot_dev.h> +#include <soc/mscc/ocelot_ana.h> +#include <linux/of_net.h> -static void felix_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) -{ - struct ocelot *ocelot = ds->priv; - - ocelot_adjust_link(ocelot, port, phydev); -} - +static void felix_phylink_validate(struct dsa_switch *ds, int port, + unsigned long *supported, + struct phylink_link_state *state) +{ + struct ocelot *ocelot = ds->priv; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + __ethtool_declare_link_mode_mask(mask) = { 0, }; + + if (state->interface != phy_interface_mode_na && + state->interface != ocelot_port->phy_mode) { + bitmap_zero(supported, __ethtool_link_mode_mask_nbits); + return; + } + + /* no half-duplex. */ + phylink_set_port_modes(mask); + phylink_set(mask, autoneg); + phylink_set(mask, pause); + phylink_set(mask, asym_pause); + if (state->interface != phy_interface_mode_2500basex) { + phylink_set(mask, 10baset_full); + phylink_set(mask, 100baset_full); + phylink_set(mask, 1000baset_full); + } + /* the internal ports that run at 2.5g are overclocked gmii */ + if (state->interface == phy_interface_mode_gmii || + state->interface == phy_interface_mode_2500basex || + state->interface == phy_interface_mode_usxgmii) { + phylink_set(mask, 2500baset_full); + phylink_set(mask, 2500basex_full); + } + + bitmap_and(supported, supported, mask, + __ethtool_link_mode_mask_nbits); + bitmap_and(state->advertising, state->advertising, mask, + __ethtool_link_mode_mask_nbits); +} + +static int felix_phylink_mac_pcs_get_state(struct dsa_switch *ds, int port, + struct phylink_link_state *state) +{ + struct ocelot *ocelot = ds->priv; + struct felix *felix = ocelot_to_felix(ocelot); + + if (felix->info->pcs_link_state) + felix->info->pcs_link_state(ocelot, port, state); + + return 0; +} + +static void felix_phylink_mac_config(struct dsa_switch *ds, int port, + unsigned int link_an_mode, + const struct phylink_link_state *state) +{ + struct ocelot *ocelot = ds->priv; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct felix *felix = ocelot_to_felix(ocelot); + u32 mac_fc_cfg; + + /* take port out of reset by clearing the mac_tx_rst, mac_rx_rst and + * port_rst bits in clock_cfg + */ + ocelot_port_writel(ocelot_port, dev_clock_cfg_link_speed(state->speed), + dev_clock_cfg); + + /* flow control. link speed is only used here to evaluate the time + * specification in incoming pause frames. + */ + mac_fc_cfg = sys_mac_fc_cfg_fc_link_speed(state->speed); + if (state->pause & mlo_pause_rx) + mac_fc_cfg |= sys_mac_fc_cfg_rx_fc_ena; + if (state->pause & mlo_pause_tx) + mac_fc_cfg |= sys_mac_fc_cfg_tx_fc_ena | + sys_mac_fc_cfg_pause_val_cfg(0xffff) | + sys_mac_fc_cfg_fc_latency_cfg(0x7) | + sys_mac_fc_cfg_zero_pause_ena; + ocelot_write_rix(ocelot, mac_fc_cfg, sys_mac_fc_cfg, port); + + ocelot_write_rix(ocelot, 0, ana_pol_flowc, port); + + if (felix->info->pcs_init) + felix->info->pcs_init(ocelot, port, link_an_mode, state); +} + +static void felix_phylink_mac_an_restart(struct dsa_switch *ds, int port) +{ + struct ocelot *ocelot = ds->priv; + struct felix *felix = ocelot_to_felix(ocelot); + + if (felix->info->pcs_an_restart) + felix->info->pcs_an_restart(ocelot, port); +} + +static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port, + unsigned int link_an_mode, + phy_interface_t interface) +{ + struct ocelot *ocelot = ds->priv; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + ocelot_port_writel(ocelot_port, 0, dev_mac_ena_cfg); + ocelot_rmw_rix(ocelot, 0, qsys_switch_port_mode_port_ena, + qsys_switch_port_mode, port); +} + +static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port, + unsigned int link_an_mode, + phy_interface_t interface, + struct phy_device *phydev) +{ + struct ocelot *ocelot = ds->priv; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + /* enable mac module */ + ocelot_port_writel(ocelot_port, dev_mac_ena_cfg_rx_ena | + dev_mac_ena_cfg_tx_ena, dev_mac_ena_cfg); + + /* enable receiving frames on the port, and activate auto-learning of + * mac addresses. + */ + ocelot_write_gix(ocelot, ana_port_port_cfg_learnauto | + ana_port_port_cfg_recv_ena | + ana_port_port_cfg_portid_val(port), + ana_port_port_cfg, port); + + /* core: enable port for frame transfer */ + ocelot_write_rix(ocelot, qsys_switch_port_mode_ingress_drop_mode | + qsys_switch_port_mode_sch_next_cfg(1) | + qsys_switch_port_mode_port_ena, + qsys_switch_port_mode, port); +} + +static int felix_parse_ports_node(struct felix *felix, + struct device_node *ports_node, + phy_interface_t *port_phy_modes) +{ + struct ocelot *ocelot = &felix->ocelot; + struct device *dev = felix->ocelot.dev; + struct device_node *child; + + for_each_child_of_node(ports_node, child) { + phy_interface_t phy_mode; + u32 port; + int err; + + /* get switch port number from dt */ + if (of_property_read_u32(child, "reg", &port) < 0) { + dev_err(dev, "port number not defined in device tree " + "(property "reg") "); + of_node_put(child); + return -enodev; + } + + /* get phy mode from dt */ + err = of_get_phy_mode(child, &phy_mode); + if (err) { + dev_err(dev, "failed to read phy-mode or " + "phy-interface-type property for port %d ", + port); + of_node_put(child); + return -enodev; + } + + err = felix->info->prevalidate_phy_mode(ocelot, port, phy_mode); + if (err < 0) { + dev_err(dev, "unsupported phy mode %s on port %d ", + phy_modes(phy_mode), port); + return err; + } + + port_phy_modes[port] = phy_mode; + } + + return 0; +} + +static int felix_parse_dt(struct felix *felix, phy_interface_t *port_phy_modes) +{ + struct device *dev = felix->ocelot.dev; + struct device_node *switch_node; + struct device_node *ports_node; + int err; + + switch_node = dev->of_node; + + ports_node = of_get_child_by_name(switch_node, "ports"); + if (!ports_node) { + dev_err(dev, "incorrect bindings: absent "ports" node "); + return -enodev; + } + + err = felix_parse_ports_node(felix, ports_node, port_phy_modes); + of_node_put(ports_node); + + return err; +} + - resource_size_t base; + phy_interface_t *port_phy_modes; + resource_size_t switch_base; - base = pci_resource_start(felix->pdev, felix->info->pci_bar); + port_phy_modes = kcalloc(num_phys_ports, sizeof(phy_interface_t), + gfp_kernel); + if (!port_phy_modes) + return -enomem; + + err = felix_parse_dt(felix, port_phy_modes); + if (err) { + kfree(port_phy_modes); + return err; + } + + switch_base = pci_resource_start(felix->pdev, + felix->info->switch_pci_bar); - res->start += base; - res->end += base; + res->start += switch_base; + res->end += switch_base; + kfree(port_phy_modes); + kfree(port_phy_modes); + kfree(port_phy_modes); - res->start += base; - res->end += base; + res->start += switch_base; + res->end += switch_base; + kfree(port_phy_modes); + ocelot_port->phy_mode = port_phy_modes[port]; + kfree(port_phy_modes); + + if (felix->info->mdio_bus_alloc) { + err = felix->info->mdio_bus_alloc(ocelot); + if (err < 0) + return err; + } + + /* it looks like the mac/pcs interrupt register - pm0_ievent (0x8040) + * isn't instantiated for the felix pf. + * in-band an may take a few ms to complete, so we need to poll. + */ + ds->pcs_poll = true; + + struct felix *felix = ocelot_to_felix(ocelot); + + if (felix->info->mdio_bus_free) + felix->info->mdio_bus_free(ocelot); - .adjust_link = felix_adjust_link, + .phylink_validate = felix_phylink_validate, + .phylink_mac_link_state = felix_phylink_mac_pcs_get_state, + .phylink_mac_config = felix_phylink_mac_config, + .phylink_mac_an_restart = felix_phylink_mac_an_restart, + .phylink_mac_link_down = felix_phylink_mac_link_down, + .phylink_mac_link_up = felix_phylink_mac_link_up, diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h + struct resource *imdio_res; - int pci_bar; + int switch_pci_bar; + int imdio_pci_bar; + int (*mdio_bus_alloc)(struct ocelot *ocelot); + void (*mdio_bus_free)(struct ocelot *ocelot); + void (*pcs_init)(struct ocelot *ocelot, int port, + unsigned int link_an_mode, + const struct phylink_link_state *state); + void (*pcs_an_restart)(struct ocelot *ocelot, int port); + void (*pcs_link_state)(struct ocelot *ocelot, int port, + struct phylink_link_state *state); + int (*prevalidate_phy_mode)(struct ocelot *ocelot, int port, + phy_interface_t phy_mode); + struct mii_bus *imdio; + struct phy_device **pcs; diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c +#include <linux/fsl/enetc_mdio.h> +/* todo: should find a better place for these */ +#define usxgmii_bmcr_reset bit(15) +#define usxgmii_bmcr_an_en bit(12) +#define usxgmii_bmcr_rst_an bit(9) +#define usxgmii_bmsr_lnks(status) (((status) & genmask(2, 2)) >> 2) +#define usxgmii_bmsr_an_cmpl(status) (((status) & genmask(5, 5)) >> 5) +#define usxgmii_advertise_lnks(x) (((x) << 15) & bit(15)) +#define usxgmii_advertise_fdx bit(12) +#define usxgmii_advertise_speed(x) (((x) << 9) & genmask(11, 9)) +#define usxgmii_lpa_lnks(lpa) ((lpa) >> 15) +#define usxgmii_lpa_duplex(lpa) (((lpa) & genmask(12, 12)) >> 12) +#define usxgmii_lpa_speed(lpa) (((lpa) & genmask(11, 9)) >> 9) + +enum usxgmii_speed { + usxgmii_speed_10 = 0, + usxgmii_speed_100 = 1, + usxgmii_speed_1000 = 2, + usxgmii_speed_2500 = 4, +}; + +/* port mac 0 internal mdio bus through which the serdes acting as an + * sgmii/qsgmii mac pcs can be found. + */ +static struct resource vsc9959_imdio_res = { + .start = 0x8030, + .end = 0x8040, + .name = "imdio", +}; + +static void vsc9959_pcs_an_restart_sgmii(struct phy_device *pcs) +{ + phy_set_bits(pcs, mii_bmcr, bmcr_anrestart); +} + +static void vsc9959_pcs_an_restart_usxgmii(struct phy_device *pcs) +{ + phy_write_mmd(pcs, mdio_mmd_vend2, mii_bmcr, + usxgmii_bmcr_reset | + usxgmii_bmcr_an_en | + usxgmii_bmcr_rst_an); +} + +static void vsc9959_pcs_an_restart(struct ocelot *ocelot, int port) +{ + struct felix *felix = ocelot_to_felix(ocelot); + struct phy_device *pcs = felix->pcs[port]; + + if (!pcs) + return; + + switch (pcs->interface) { + case phy_interface_mode_sgmii: + case phy_interface_mode_qsgmii: + vsc9959_pcs_an_restart_sgmii(pcs); + break; + case phy_interface_mode_usxgmii: + vsc9959_pcs_an_restart_usxgmii(pcs); + break; + default: + dev_err(ocelot->dev, "invalid pcs interface type %s ", + phy_modes(pcs->interface)); + break; + } +} + +/* we enable sgmii an only when the phy has managed = "in-band-status" in the + * device tree. if we are in mlo_an_phy mode, we program directly state->speed + * into the pcs, which is retrieved out-of-band over mdio. this also has the + * benefit of working with sgmii fixed-links, like downstream switches, where + * both link partners attempt to operate as an slaves and therefore an never + * completes. but it also has the disadvantage that some phy chips don't pass + * traffic if sgmii an is enabled but not completed (acknowledged by us), so + * setting mlo_an_inband is actually required for those. + */ +static void vsc9959_pcs_init_sgmii(struct phy_device *pcs, + unsigned int link_an_mode, + const struct phylink_link_state *state) +{ + if (link_an_mode == mlo_an_inband) { + /* sgmii spec requires tx_config_reg[15:0] to be exactly 0x4001 + * for the mac pcs in order to acknowledge the an. + */ + phy_write(pcs, mii_advertise, advertise_sgmii | + advertise_lpack); + + phy_write(pcs, enetc_pcs_if_mode, + enetc_pcs_if_mode_sgmii_en | + enetc_pcs_if_mode_use_sgmii_an); + + /* adjust link timer for sgmii */ + phy_write(pcs, enetc_pcs_link_timer1, + enetc_pcs_link_timer1_val); + phy_write(pcs, enetc_pcs_link_timer2, + enetc_pcs_link_timer2_val); + + phy_write(pcs, mii_bmcr, bmcr_anrestart | bmcr_anenable); + } else { + int speed; + + if (state->duplex == duplex_half) { + phydev_err(pcs, "half duplex not supported "); + return; + } + switch (state->speed) { + case speed_1000: + speed = enetc_pcs_speed_1000; + break; + case speed_100: + speed = enetc_pcs_speed_100; + break; + case speed_10: + speed = enetc_pcs_speed_10; + break; + case speed_unknown: + /* silently don't do anything */ + return; + default: + phydev_err(pcs, "invalid pcs speed %d ", state->speed); + return; + } + + phy_write(pcs, enetc_pcs_if_mode, + enetc_pcs_if_mode_sgmii_en | + enetc_pcs_if_mode_sgmii_speed(speed)); + + /* yes, not a mistake: speed is given by if_mode. */ + phy_write(pcs, mii_bmcr, bmcr_reset | + bmcr_speed1000 | + bmcr_fulldplx); + } +} + +/* 2500base-x is serdes protocol 7 on felix and 6 on enetc. it is a serdes lane + * clocked at 3.125 ghz which encodes symbols with 8b/10b and does not have + * auto-negotiation of any link parameters. electrically it is compatible with + * a single lane of xaui. + * the hardware reference manual wants to call this mode sgmii, but it isn't + * really, since the fundamental features of sgmii: + * - downgrading the link speed by duplicating symbols + * - auto-negotiation + * are not there. + * the speed is configured at 1000 in the if_mode and bmcr mdio registers + * because the clock frequency is actually given by a pll configured in the + * reset configuration word (rcw). + * since there is no difference between fixed speed sgmii w/o an and 802.3z w/o + * an, we call this phy interface type 2500base-x. in case a phy negotiates a + * lower link speed on line side, the system-side interface remains fixed at + * 2500 mbps and we do rate adaptation through pause frames. + */ +static void vsc9959_pcs_init_2500basex(struct phy_device *pcs, + unsigned int link_an_mode, + const struct phylink_link_state *state) +{ + if (link_an_mode == mlo_an_inband) { + phydev_err(pcs, "an not supported on 3.125ghz serdes lane "); + return; + } + + phy_write(pcs, enetc_pcs_if_mode, + enetc_pcs_if_mode_sgmii_en | + enetc_pcs_if_mode_sgmii_speed(enetc_pcs_speed_2500)); + + phy_write(pcs, mii_bmcr, bmcr_speed1000 | + bmcr_fulldplx | + bmcr_reset); +} + +static void vsc9959_pcs_init_usxgmii(struct phy_device *pcs, + unsigned int link_an_mode, + const struct phylink_link_state *state) +{ + if (link_an_mode != mlo_an_inband) { + phydev_err(pcs, "usxgmii only supports in-band an for now "); + return; + } + + /* configure device ability for the usxgmii replicator */ + phy_write_mmd(pcs, mdio_mmd_vend2, mii_advertise, + usxgmii_advertise_speed(usxgmii_speed_2500) | + usxgmii_advertise_lnks(1) | + advertise_sgmii | + advertise_lpack | + usxgmii_advertise_fdx); +} + +static void vsc9959_pcs_init(struct ocelot *ocelot, int port, + unsigned int link_an_mode, + const struct phylink_link_state *state) +{ + struct felix *felix = ocelot_to_felix(ocelot); + struct phy_device *pcs = felix->pcs[port]; + + if (!pcs) + return; + + /* the pcs does not implement the bmsr register fully, so capability + * detection via genphy_read_abilities does not work. since we can get + * the phy config word from the lpa register though, there is still + * value in using the generic phy_resolve_aneg_linkmode function. so + * populate the supported and advertising link modes manually here. + */ + linkmode_set_bit_array(phy_basic_ports_array, + array_size(phy_basic_ports_array), + pcs->supported); + linkmode_set_bit(ethtool_link_mode_10baset_full_bit, pcs->supported); + linkmode_set_bit(ethtool_link_mode_100baset_full_bit, pcs->supported); + linkmode_set_bit(ethtool_link_mode_1000baset_full_bit, pcs->supported); + if (pcs->interface == phy_interface_mode_2500basex || + pcs->interface == phy_interface_mode_usxgmii) + linkmode_set_bit(ethtool_link_mode_2500basex_full_bit, + pcs->supported); + if (pcs->interface != phy_interface_mode_2500basex) + linkmode_set_bit(ethtool_link_mode_autoneg_bit, + pcs->supported); + phy_advertise_supported(pcs); + + switch (pcs->interface) { + case phy_interface_mode_sgmii: + case phy_interface_mode_qsgmii: + vsc9959_pcs_init_sgmii(pcs, link_an_mode, state); + break; + case phy_interface_mode_2500basex: + vsc9959_pcs_init_2500basex(pcs, link_an_mode, state); + break; + case phy_interface_mode_usxgmii: + vsc9959_pcs_init_usxgmii(pcs, link_an_mode, state); + break; + default: + dev_err(ocelot->dev, "unsupported link mode %s ", + phy_modes(pcs->interface)); + } +} + +static void vsc9959_pcs_link_state_resolve(struct phy_device *pcs, + struct phylink_link_state *state) +{ + state->an_complete = pcs->autoneg_complete; + state->an_enabled = pcs->autoneg; + state->link = pcs->link; + state->duplex = pcs->duplex; + state->speed = pcs->speed; + /* sgmii an does not negotiate flow control, but that's ok, + * since phylink already knows that, and does: + * link_state.pause |= pl->phy_state.pause; + */ + state->pause = mlo_pause_none; + + phydev_dbg(pcs, + "mode=%s/%s/%s adv=%*pb lpa=%*pb link=%u an_enabled=%u an_complete=%u ", + phy_modes(pcs->interface), + phy_speed_to_str(pcs->speed), + phy_duplex_to_str(pcs->duplex), + __ethtool_link_mode_mask_nbits, pcs->advertising, + __ethtool_link_mode_mask_nbits, pcs->lp_advertising, + pcs->link, pcs->autoneg, pcs->autoneg_complete); +} + +static void vsc9959_pcs_link_state_sgmii(struct phy_device *pcs, + struct phylink_link_state *state) +{ + int err; + + err = genphy_update_link(pcs); + if (err < 0) + return; + + if (pcs->autoneg_complete) { + u16 lpa = phy_read(pcs, mii_lpa); + + mii_lpa_to_linkmode_lpa_sgmii(pcs->lp_advertising, lpa); + + phy_resolve_aneg_linkmode(pcs); + } +} + +static void vsc9959_pcs_link_state_2500basex(struct phy_device *pcs, + struct phylink_link_state *state) +{ + int err; + + err = genphy_update_link(pcs); + if (err < 0) + return; + + pcs->speed = speed_2500; + pcs->asym_pause = true; + pcs->pause = true; +} + +static void vsc9959_pcs_link_state_usxgmii(struct phy_device *pcs, + struct phylink_link_state *state) +{ + int status, lpa; + + status = phy_read_mmd(pcs, mdio_mmd_vend2, mii_bmsr); + if (status < 0) + return; + + pcs->autoneg = true; + pcs->autoneg_complete = usxgmii_bmsr_an_cmpl(status); + pcs->link = usxgmii_bmsr_lnks(status); + + if (!pcs->link || !pcs->autoneg_complete) + return; + + lpa = phy_read_mmd(pcs, mdio_mmd_vend2, mii_lpa); + if (lpa < 0) + return; + + switch (usxgmii_lpa_speed(lpa)) { + case usxgmii_speed_10: + pcs->speed = speed_10; + break; + case usxgmii_speed_100: + pcs->speed = speed_100; + break; + case usxgmii_speed_1000: + pcs->speed = speed_1000; + break; + case usxgmii_speed_2500: + pcs->speed = speed_2500; + break; + default: + break; + } + + pcs->link = usxgmii_lpa_lnks(lpa); + if (usxgmii_lpa_duplex(lpa)) + pcs->duplex = duplex_full; + else + pcs->duplex = duplex_half; +} + +static void vsc9959_pcs_link_state(struct ocelot *ocelot, int port, + struct phylink_link_state *state) +{ + struct felix *felix = ocelot_to_felix(ocelot); + struct phy_device *pcs = felix->pcs[port]; + + if (!pcs) + return; + + pcs->speed = speed_unknown; + pcs->duplex = duplex_unknown; + pcs->pause = 0; + pcs->asym_pause = 0; + + switch (pcs->interface) { + case phy_interface_mode_sgmii: + case phy_interface_mode_qsgmii: + vsc9959_pcs_link_state_sgmii(pcs, state); + break; + case phy_interface_mode_2500basex: + vsc9959_pcs_link_state_2500basex(pcs, state); + break; + case phy_interface_mode_usxgmii: + vsc9959_pcs_link_state_usxgmii(pcs, state); + break; + default: + return; + } + + vsc9959_pcs_link_state_resolve(pcs, state); +} + +static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port, + phy_interface_t phy_mode) +{ + switch (phy_mode) { + case phy_interface_mode_gmii: + /* only supported on internal to-cpu ports */ + if (port != 4 && port != 5) + return -enotsupp; + return 0; + case phy_interface_mode_sgmii: + case phy_interface_mode_qsgmii: + case phy_interface_mode_usxgmii: + case phy_interface_mode_2500basex: + /* not supported on internal to-cpu ports */ + if (port == 4 || port == 5) + return -enotsupp; + return 0; + default: + return -enotsupp; + } +} + +static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + struct enetc_mdio_priv *mdio_priv; + struct device *dev = ocelot->dev; + resource_size_t imdio_base; + void __iomem *imdio_regs; + struct resource *res; + struct enetc_hw *hw; + struct mii_bus *bus; + int port; + int rc; + + felix->pcs = devm_kcalloc(dev, felix->info->num_ports, + sizeof(struct phy_device *), + gfp_kernel); + if (!felix->pcs) { + dev_err(dev, "failed to allocate array for pcs phys "); + return -enomem; + } + + imdio_base = pci_resource_start(felix->pdev, + felix->info->imdio_pci_bar); + + res = felix->info->imdio_res; + res->flags = ioresource_mem; + res->start += imdio_base; + res->end += imdio_base; + + imdio_regs = devm_ioremap_resource(dev, res); + if (is_err(imdio_regs)) { + dev_err(dev, "failed to map internal mdio registers "); + return ptr_err(imdio_regs); + } + + hw = enetc_hw_alloc(dev, imdio_regs); + if (is_err(hw)) { + dev_err(dev, "failed to allocate enetc hw structure "); + return ptr_err(hw); + } + + bus = devm_mdiobus_alloc_size(dev, sizeof(*mdio_priv)); + if (!bus) + return -enomem; + + bus->name = "vsc9959 internal mdio bus"; + bus->read = enetc_mdio_read; + bus->write = enetc_mdio_write; + bus->parent = dev; + mdio_priv = bus->priv; + mdio_priv->hw = hw; + /* this gets added to imdio_regs, which already maps addresses + * starting with the proper offset. + */ + mdio_priv->mdio_base = 0; + snprintf(bus->id, mii_bus_id_size, "%s-imdio", dev_name(dev)); + + /* needed in order to initialize the bus mutex lock */ + rc = mdiobus_register(bus); + if (rc < 0) { + dev_err(dev, "failed to register mdio bus "); + return rc; + } + + felix->imdio = bus; + + for (port = 0; port < felix->info->num_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct phy_device *pcs; + bool is_c45 = false; + + if (ocelot_port->phy_mode == phy_interface_mode_usxgmii) + is_c45 = true; + + pcs = get_phy_device(felix->imdio, port, is_c45); + if (is_err(pcs)) + continue; + + pcs->interface = ocelot_port->phy_mode; + felix->pcs[port] = pcs; + + dev_info(dev, "found pcs at internal mdio address %d ", port); + } + + return 0; +} + +static void vsc9959_mdio_bus_free(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct phy_device *pcs = felix->pcs[port]; + + if (!pcs) + continue; + + put_device(&pcs->mdio.dev); + } + mdiobus_unregister(felix->imdio); +} + + .imdio_res = &vsc9959_imdio_res, - .pci_bar = 4, + .switch_pci_bar = 4, + .imdio_pci_bar = 0, + .mdio_bus_alloc = vsc9959_mdio_bus_alloc, + .mdio_bus_free = vsc9959_mdio_bus_free, + .pcs_init = vsc9959_pcs_init, + .pcs_an_restart = vsc9959_pcs_an_restart, + .pcs_link_state = vsc9959_pcs_link_state, + .prevalidate_phy_mode = vsc9959_prevalidate_phy_mode,
|
Networking
|
bdeced75b13f8a0fc8e32b70e517a8dbb7d51738
|
vladimir oltean
|
drivers
|
net
|
dsa, ocelot
|
net: dsa: mv88e6xxx: add serdes stats counters to all 6390 family members
|
the serdes statistics are valid for all members of the 6390 family, not just the 6390 itself. add the needed callbacks to all members of the family.
|
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 stats counters to all 6390 family members
|
['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']
|
['dsa ', 'mv88e6xxx']
|
['c']
| 1
| 15
| 0
|
--- 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_strings = mv88e6390_serdes_get_strings, + .serdes_get_stats = mv88e6390_serdes_get_stats, + .phylink_validate = mv88e6390_phylink_validate, + .serdes_get_strings = mv88e6390_serdes_get_strings, + .serdes_get_stats = mv88e6390_serdes_get_stats, + .phylink_validate = mv88e6390_phylink_validate, + .serdes_get_strings = mv88e6390_serdes_get_strings, + .serdes_get_stats = mv88e6390_serdes_get_stats, + .phylink_validate = mv88e6390_phylink_validate, + .serdes_get_strings = mv88e6390_serdes_get_strings, + .serdes_get_stats = mv88e6390_serdes_get_stats, + .phylink_validate = mv88e6390_phylink_validate, + .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, + .serdes_get_strings = mv88e6390_serdes_get_strings, + .serdes_get_stats = mv88e6390_serdes_get_stats,
|
Networking
|
4262c38dc42e092987f41cb1695240ac7dab86a9
|
andrew lunn
|
drivers
|
net
|
dsa, mv88e6xxx
|
net: ena: implement xdp drop support
|
this commit implements the basic functionality of drop/pass logic in the ena 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.
|
implement xdp
|
['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']
|
['ena ']
|
['c', 'h']
| 2
| 233
| 11
|
--- diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c -#include <linux/if_vlan.h> +#include <linux/bpf_trace.h> +static void ena_down(struct ena_adapter *adapter); +static int ena_up(struct ena_adapter *adapter); +static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp) +{ + struct bpf_prog *xdp_prog; + u32 verdict = xdp_pass; + + rcu_read_lock(); + xdp_prog = read_once(rx_ring->xdp_bpf_prog); + + if (!xdp_prog) + goto out; + + verdict = bpf_prog_run_xdp(xdp_prog, xdp); + + if (unlikely(verdict == xdp_aborted)) + trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict); + else if (unlikely(verdict >= xdp_tx)) + bpf_warn_invalid_xdp_action(verdict); +out: + rcu_read_unlock(); + return verdict; +} + +void ena_xdp_exchange_program_rx_in_range(struct ena_adapter *adapter, + struct bpf_prog *prog, + int first, + int count) +{ + struct ena_ring *rx_ring; + int i = 0; + + for (i = first; i < count; i++) { + rx_ring = &adapter->rx_ring[i]; + xchg(&rx_ring->xdp_bpf_prog, prog); + if (prog) + rx_ring->rx_headroom = xdp_packet_headroom; + else + rx_ring->rx_headroom = 0; + } +} + +void ena_xdp_exchange_program(struct ena_adapter *adapter, + struct bpf_prog *prog) +{ + struct bpf_prog *old_bpf_prog = xchg(&adapter->xdp_bpf_prog, prog); + + ena_xdp_exchange_program_rx_in_range(adapter, + prog, + 0, + adapter->num_io_queues); + + if (old_bpf_prog) + bpf_prog_put(old_bpf_prog); +} + +static int ena_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf) +{ + struct ena_adapter *adapter = netdev_priv(netdev); + struct bpf_prog *prog = bpf->prog; + int rc, prev_mtu; + bool is_up; + + is_up = test_bit(ena_flag_dev_up, &adapter->flags); + + if (ena_xdp_allowed(adapter)) { + if (is_up) + ena_down(adapter); + + ena_xdp_exchange_program(adapter, prog); + + prev_mtu = netdev->max_mtu; + netdev->max_mtu = prog ? ena_xdp_max_mtu : adapter->max_mtu; + if (is_up) { + rc = ena_up(adapter); + if (rc) + return rc; + } + netif_info(adapter, drv, adapter->netdev, "xdp program set, changging the max_mtu from %d to %d", + prev_mtu, netdev->max_mtu); + + } else { + netif_err(adapter, drv, adapter->netdev, "failed to set xdp program, the current mtu (%d) is larger than the maximum allowed mtu (%lu) while xdp is on", + netdev->mtu, ena_xdp_max_mtu); + nl_set_err_msg_mod(bpf->extack, "failed to set xdp program, the current mtu is larger than the maximum allowed mtu. check the dmesg for more info"); + return -einval; + } + + return 0; +} + +/* this is the main xdp callback, it's used by the kernel to set/unset the xdp + * program as well as to query the current xdp program id. + */ +static int ena_xdp(struct net_device *netdev, struct netdev_bpf *bpf) +{ + struct ena_adapter *adapter = netdev_priv(netdev); + + switch (bpf->command) { + case xdp_setup_prog: + return ena_xdp_set(netdev, bpf); + case xdp_query_prog: + bpf->prog_id = adapter->xdp_bpf_prog ? + adapter->xdp_bpf_prog->aux->id : 0; + break; + default: + return -einval; + } + return 0; +} + + + xdp_rxq_info_unreg_mem_model(&rx_ring->xdp_rxq); + xdp_rxq_info_unreg(&rx_ring->xdp_rxq); - ena_buf->paddr = dma; + ena_buf->paddr = dma + rx_ring->rx_headroom; +int ena_xdp_handle_buff(struct ena_ring *rx_ring, struct xdp_buff *xdp) +{ + struct ena_rx_buffer *rx_info; + int ret; + + rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id]; + xdp->data = page_address(rx_info->page) + + rx_info->page_offset + rx_ring->rx_headroom; + xdp_set_data_meta_invalid(xdp); + xdp->data_hard_start = page_address(rx_info->page); + xdp->data_end = xdp->data + rx_ring->ena_bufs[0].len; + /* if for some reason we received a bigger packet than + * we expect, then we simply drop it + */ + if (unlikely(rx_ring->ena_bufs[0].len > ena_xdp_max_mtu)) + return xdp_drop; + + ret = ena_xdp_execute(rx_ring, xdp); + + /* the xdp program might expand the headers */ + if (ret == xdp_pass) { + rx_info->page_offset = xdp->data - xdp->data_hard_start; + rx_ring->ena_bufs[0].len = xdp->data_end - xdp->data; + } + + return ret; +} + int rx_copybreak_pkt = 0; + int refill_threshold; - int refill_threshold; - int rc = 0; + struct xdp_buff xdp; - int rx_copybreak_pkt = 0; + int xdp_verdict; + int rc = 0; - + xdp.rxq = &rx_ring->xdp_rxq; + xdp_verdict = xdp_pass; + skb = null; + if (ena_xdp_present_ring(rx_ring)) + xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp); + - skb = ena_rx_skb(rx_ring, rx_ring->ena_bufs, ena_rx_ctx.descs, - &next_to_clean); + if (xdp_verdict == xdp_pass) + skb = ena_rx_skb(rx_ring, + rx_ring->ena_bufs, + ena_rx_ctx.descs, + &next_to_clean); - /* exit if we failed to retrieve a buffer */ + if (xdp_verdict == xdp_drop) + continue; - ena_com_destroy_io_queue(ena_dev, ena_qid); - return rc; + goto err; + rc = xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev, qid); + + if (rc) { + netif_err(adapter, ifup, adapter->netdev, + "failed to register xdp rx queue info. rx queue num %d rc: %d ", + qid, rc); + goto err; + } + + rc = xdp_rxq_info_reg_mem_model(&rx_ring->xdp_rxq, mem_type_page_shared, + null); + + if (rc) { + netif_err(adapter, ifup, adapter->netdev, + "failed to register xdp rx queue info memory model. rx queue num %d rc: %d ", + qid, rc); + xdp_rxq_info_unreg(&rx_ring->xdp_rxq); + goto err; + } + + return rc; +err: + ena_com_destroy_io_queue(ena_dev, ena_qid); + int prev_channel_count; + prev_channel_count = adapter->num_io_queues; + + if (ena_xdp_present(adapter) && ena_xdp_allowed(adapter)) { + if (prev_channel_count > new_channel_count) + ena_xdp_exchange_program_rx_in_range(adapter, + null, + new_channel_count, + prev_channel_count); + else + ena_xdp_exchange_program_rx_in_range(adapter, + adapter->xdp_bpf_prog, + prev_channel_count, + new_channel_count); + } + + .ndo_bpf = ena_xdp, diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h --- a/drivers/net/ethernet/amazon/ena/ena_netdev.h +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h +#include <linux/if_vlan.h> +/* the max mtu size is configured to be the ethernet frame size without + * the overhead of the ethernet header, which can have a vlan header, and + * a frame check sequence (fcs). + * the buffer size we share with the device is defined to be ena_page_size + */ + +#define ena_xdp_max_mtu (ena_page_size - eth_hlen - eth_fcs_len - \ + vlan_hlen - xdp_packet_headroom) + + struct bpf_prog *xdp_bpf_prog; + struct xdp_rxq_info xdp_rxq; + u16 rx_headroom; + + struct bpf_prog *xdp_bpf_prog; + +static inline bool ena_xdp_present(struct ena_adapter *adapter) +{ + return !!adapter->xdp_bpf_prog; +} + +static inline bool ena_xdp_present_ring(struct ena_ring *ring) +{ + return !!ring->xdp_bpf_prog; +} + +static inline bool ena_xdp_allowed(struct ena_adapter *adapter) +{ + return adapter->netdev->mtu <= ena_xdp_max_mtu; +} +
|
Networking
|
838c93dc5449e5d6378bae117b0a65a122cf7361
|
sameeh jubran
|
drivers
|
net
|
amazon, ena, ethernet
|
net: ena: implement xdp_tx action
|
this commit implements the xdp_tx action in the ena driver. we allocate separate tx queues for the xdp_tx. we currently allow xdp only when there is enough queues to allocate for xdp.
|
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.
|
implement xdp
|
['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']
|
['ena ']
|
['c', 'h']
| 3
| 701
| 186
|
--- diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c - if (count < ena_min_num_io_queues) + if (count < ena_min_num_io_queues || + (ena_xdp_present(adapter) && + !ena_xdp_legal_queue_count(adapter, channels->combined_count))) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c -static void ena_down(struct ena_adapter *adapter); + +static void ena_init_io_rings(struct ena_adapter *adapter, + int first_index, int count); +static void ena_init_napi_in_range(struct ena_adapter *adapter, int first_index, + int count); +static void ena_del_napi_in_range(struct ena_adapter *adapter, int first_index, + int count); +static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid); +static int ena_setup_tx_resources_in_range(struct ena_adapter *adapter, + int first_index, + int count); +static int ena_create_io_tx_queue(struct ena_adapter *adapter, int qid); +static void ena_free_tx_resources(struct ena_adapter *adapter, int qid); +static int ena_clean_xdp_irq(struct ena_ring *xdp_ring, u32 budget); +static void ena_destroy_all_tx_queues(struct ena_adapter *adapter); +static void ena_free_all_io_tx_resources(struct ena_adapter *adapter); +static void ena_napi_disable_in_range(struct ena_adapter *adapter, + int first_index, int count); +static void ena_napi_enable_in_range(struct ena_adapter *adapter, + int first_index, int count); +static void ena_down(struct ena_adapter *adapter); +static void ena_unmask_interrupt(struct ena_ring *tx_ring, + struct ena_ring *rx_ring); +static void ena_update_ring_numa_node(struct ena_ring *tx_ring, + struct ena_ring *rx_ring); +static void ena_unmap_tx_buff(struct ena_ring *tx_ring, + struct ena_tx_buffer *tx_info); +static int ena_create_io_tx_queues_in_range(struct ena_adapter *adapter, + int first_index, int count); -static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp) +static int ena_xmit_common(struct net_device *dev, + struct ena_ring *ring, + struct ena_tx_buffer *tx_info, + struct ena_com_tx_ctx *ena_tx_ctx, + u16 next_to_use, + u32 bytes) +{ + struct ena_adapter *adapter = netdev_priv(dev); + int rc, nb_hw_desc; + + if (unlikely(ena_com_is_doorbell_needed(ring->ena_com_io_sq, + ena_tx_ctx))) { + netif_dbg(adapter, tx_queued, dev, + "llq tx max burst size of queue %d achieved, writing doorbell to send burst ", + ring->qid); + ena_com_write_sq_doorbell(ring->ena_com_io_sq); + } + + /* prepare the packet's descriptors to dma engine */ + rc = ena_com_prepare_tx(ring->ena_com_io_sq, ena_tx_ctx, + &nb_hw_desc); + + /* in case there isn't enough space in the queue for the packet, + * we simply drop it. all other failure reasons of + * ena_com_prepare_tx() are fatal and therefore require a device reset. + */ + if (unlikely(rc)) { + netif_err(adapter, tx_queued, dev, + "failed to prepare tx bufs "); + u64_stats_update_begin(&ring->syncp); + ring->tx_stats.prepare_ctx_err++; + u64_stats_update_end(&ring->syncp); + if (rc != -enomem) { + adapter->reset_reason = + ena_regs_reset_driver_invalid_state; + set_bit(ena_flag_trigger_reset, &adapter->flags); + } + return rc; + } + + u64_stats_update_begin(&ring->syncp); + ring->tx_stats.cnt++; + ring->tx_stats.bytes += bytes; + u64_stats_update_end(&ring->syncp); + + tx_info->tx_descs = nb_hw_desc; + tx_info->last_jiffies = jiffies; + tx_info->print_once = 0; + + ring->next_to_use = ena_tx_ring_idx_next(next_to_use, + ring->ring_size); + return 0; +} + +/* this is the xdp napi callback. xdp queues use a separate napi callback + * than rx/tx queues. + */ +static int ena_xdp_io_poll(struct napi_struct *napi, int budget) +{ + struct ena_napi *ena_napi = container_of(napi, struct ena_napi, napi); + u32 xdp_work_done, xdp_budget; + struct ena_ring *xdp_ring; + int napi_comp_call = 0; + int ret; + + xdp_ring = ena_napi->xdp_ring; + + xdp_budget = budget; + + if (!test_bit(ena_flag_dev_up, &xdp_ring->adapter->flags) || + test_bit(ena_flag_trigger_reset, &xdp_ring->adapter->flags)) { + napi_complete_done(napi, 0); + return 0; + } + + xdp_work_done = ena_clean_xdp_irq(xdp_ring, xdp_budget); + + /* if the device is about to reset or down, avoid unmask + * the interrupt and return 0 so napi won't reschedule + */ + if (unlikely(!test_bit(ena_flag_dev_up, &xdp_ring->adapter->flags))) { + napi_complete_done(napi, 0); + ret = 0; + } else if (xdp_budget > xdp_work_done) { + napi_comp_call = 1; + if (napi_complete_done(napi, xdp_work_done)) + ena_unmask_interrupt(xdp_ring, null); + ena_update_ring_numa_node(xdp_ring, null); + ret = xdp_work_done; + } else { + ret = xdp_budget; + } + + u64_stats_update_begin(&xdp_ring->syncp); + xdp_ring->tx_stats.napi_comp += napi_comp_call; + xdp_ring->tx_stats.tx_poll++; + u64_stats_update_end(&xdp_ring->syncp); + + return ret; +} + +static int ena_xdp_tx_map_buff(struct ena_ring *xdp_ring, + struct ena_tx_buffer *tx_info, + struct xdp_buff *xdp, + void **push_hdr, + u32 *push_len) +{ + struct ena_adapter *adapter = xdp_ring->adapter; + struct ena_com_buf *ena_buf; + dma_addr_t dma = 0; + u32 size; + + tx_info->xdpf = convert_to_xdp_frame(xdp); + size = tx_info->xdpf->len; + ena_buf = tx_info->bufs; + + /* llq push buffer */ + *push_len = min_t(u32, size, xdp_ring->tx_max_header_size); + *push_hdr = tx_info->xdpf->data; + + if (size - *push_len > 0) { + dma = dma_map_single(xdp_ring->dev, + *push_hdr + *push_len, + size - *push_len, + dma_to_device); + if (unlikely(dma_mapping_error(xdp_ring->dev, dma))) + goto error_report_dma_error; + + tx_info->map_linear_data = 1; + tx_info->num_of_bufs = 1; + } + + ena_buf->paddr = dma; + ena_buf->len = size; + + return 0; + +error_report_dma_error: + u64_stats_update_begin(&xdp_ring->syncp); + xdp_ring->tx_stats.dma_mapping_err++; + u64_stats_update_end(&xdp_ring->syncp); + netdev_warn(adapter->netdev, "failed to map xdp buff "); + + xdp_return_frame_rx_napi(tx_info->xdpf); + tx_info->xdpf = null; + tx_info->num_of_bufs = 0; + + return -einval; +} + +static int ena_xdp_xmit_buff(struct net_device *dev, + struct xdp_buff *xdp, + int qid, + struct ena_rx_buffer *rx_info) +{ + struct ena_adapter *adapter = netdev_priv(dev); + struct ena_com_tx_ctx ena_tx_ctx = {0}; + struct ena_tx_buffer *tx_info; + struct ena_ring *xdp_ring; + struct ena_ring *rx_ring; + u16 next_to_use, req_id; + int rc; + void *push_hdr; + u32 push_len; + + xdp_ring = &adapter->tx_ring[qid]; + next_to_use = xdp_ring->next_to_use; + req_id = xdp_ring->free_ids[next_to_use]; + tx_info = &xdp_ring->tx_buffer_info[req_id]; + tx_info->num_of_bufs = 0; + rx_ring = &xdp_ring->adapter->rx_ring[qid - + xdp_ring->adapter->xdp_first_ring]; + page_ref_inc(rx_info->page); + tx_info->xdp_rx_page = rx_info->page; + + rc = ena_xdp_tx_map_buff(xdp_ring, tx_info, xdp, &push_hdr, &push_len); + if (unlikely(rc)) + goto error_drop_packet; + + ena_tx_ctx.ena_bufs = tx_info->bufs; + ena_tx_ctx.push_header = push_hdr; + ena_tx_ctx.num_bufs = tx_info->num_of_bufs; + ena_tx_ctx.req_id = req_id; + ena_tx_ctx.header_len = push_len; + + rc = ena_xmit_common(dev, + xdp_ring, + tx_info, + &ena_tx_ctx, + next_to_use, + xdp->data_end - xdp->data); + if (rc) + goto error_unmap_dma; + /* trigger the dma engine. ena_com_write_sq_doorbell() + * has a mb + */ + ena_com_write_sq_doorbell(xdp_ring->ena_com_io_sq); + u64_stats_update_begin(&xdp_ring->syncp); + xdp_ring->tx_stats.doorbells++; + u64_stats_update_end(&xdp_ring->syncp); + + return netdev_tx_ok; + +error_unmap_dma: + ena_unmap_tx_buff(xdp_ring, tx_info); + tx_info->xdpf = null; +error_drop_packet: + + return netdev_tx_ok; +} + +static int ena_xdp_execute(struct ena_ring *rx_ring, + struct xdp_buff *xdp, + struct ena_rx_buffer *rx_info) - if (unlikely(verdict == xdp_aborted)) + if (verdict == xdp_tx) + ena_xdp_xmit_buff(rx_ring->netdev, + xdp, + rx_ring->qid + rx_ring->adapter->num_io_queues, + rx_info); + else if (unlikely(verdict == xdp_aborted)) - else if (unlikely(verdict >= xdp_tx)) + else if (unlikely(verdict > xdp_tx)) +static void ena_init_all_xdp_queues(struct ena_adapter *adapter) +{ + adapter->xdp_first_ring = adapter->num_io_queues; + adapter->xdp_num_queues = adapter->num_io_queues; + + ena_init_io_rings(adapter, + adapter->xdp_first_ring, + adapter->xdp_num_queues); +} + +static int ena_setup_and_create_all_xdp_queues(struct ena_adapter *adapter) +{ + int rc = 0; + + rc = ena_setup_tx_resources_in_range(adapter, adapter->xdp_first_ring, + adapter->xdp_num_queues); + if (rc) + goto setup_err; + + rc = ena_create_io_tx_queues_in_range(adapter, + adapter->xdp_first_ring, + adapter->xdp_num_queues); + if (rc) + goto create_err; + + return 0; + +create_err: + ena_free_all_io_tx_resources(adapter); +setup_err: + return rc; +} + +/* provides a way for both kernel and bpf-prog to know + * more about the rx-queue a given xdp frame arrived on. + */ +static int ena_xdp_register_rxq_info(struct ena_ring *rx_ring) +{ + int rc; + + rc = xdp_rxq_info_reg(&rx_ring->xdp_rxq, rx_ring->netdev, rx_ring->qid); + + if (rc) { + netif_err(rx_ring->adapter, ifup, rx_ring->netdev, + "failed to register xdp rx queue info. rx queue num %d rc: %d ", + rx_ring->qid, rc); + goto err; + } + + rc = xdp_rxq_info_reg_mem_model(&rx_ring->xdp_rxq, mem_type_page_shared, + null); + + if (rc) { + netif_err(rx_ring->adapter, ifup, rx_ring->netdev, + "failed to register xdp rx queue info memory model. rx queue num %d rc: %d ", + rx_ring->qid, rc); + xdp_rxq_info_unreg(&rx_ring->xdp_rxq); + } + +err: + return rc; +} + +static void ena_xdp_unregister_rxq_info(struct ena_ring *rx_ring) +{ + xdp_rxq_info_unreg_mem_model(&rx_ring->xdp_rxq); + xdp_rxq_info_unreg(&rx_ring->xdp_rxq); +} + - if (prog) + if (prog) { + ena_xdp_register_rxq_info(rx_ring); - else + } else { + ena_xdp_unregister_rxq_info(rx_ring); + } +static int ena_destroy_and_free_all_xdp_queues(struct ena_adapter *adapter) +{ + bool was_up; + int rc; + + was_up = test_bit(ena_flag_dev_up, &adapter->flags); + + if (was_up) + ena_down(adapter); + + adapter->xdp_first_ring = 0; + adapter->xdp_num_queues = 0; + ena_xdp_exchange_program(adapter, null); + if (was_up) { + rc = ena_up(adapter); + if (rc) + return rc; + } + return 0; +} + + struct bpf_prog *old_bpf_prog; + rc = ena_xdp_allowed(adapter); + if (rc == ena_xdp_allowed) { + old_bpf_prog = adapter->xdp_bpf_prog; + if (prog) { + if (!is_up) { + ena_init_all_xdp_queues(adapter); + } else if (!old_bpf_prog) { + ena_down(adapter); + ena_init_all_xdp_queues(adapter); + } + ena_xdp_exchange_program(adapter, prog); - if (ena_xdp_allowed(adapter)) { - if (is_up) - ena_down(adapter); - - ena_xdp_exchange_program(adapter, prog); - - prev_mtu = netdev->max_mtu; - netdev->max_mtu = prog ? ena_xdp_max_mtu : adapter->max_mtu; - if (is_up) { - rc = ena_up(adapter); + if (is_up && !old_bpf_prog) { + rc = ena_up(adapter); + if (rc) + return rc; + } + } else if (old_bpf_prog) { + rc = ena_destroy_and_free_all_xdp_queues(adapter); - netif_info(adapter, drv, adapter->netdev, "xdp program set, changging the max_mtu from %d to %d", - prev_mtu, netdev->max_mtu); - } else { - netif_err(adapter, drv, adapter->netdev, "failed to set xdp program, the current mtu (%d) is larger than the maximum allowed mtu (%lu) while xdp is on", + prev_mtu = netdev->max_mtu; + netdev->max_mtu = prog ? ena_xdp_max_mtu : adapter->max_mtu; + + if (!old_bpf_prog) + netif_info(adapter, drv, adapter->netdev, + "xdp program set, changing the max_mtu from %d to %d", + prev_mtu, netdev->max_mtu); + + } else if (rc == ena_xdp_current_mtu_too_large) { + netif_err(adapter, drv, adapter->netdev, + "failed to set xdp program, the current mtu (%d) is larger than the maximum allowed mtu (%lu) while xdp is on", - nl_set_err_msg_mod(bpf->extack, "failed to set xdp program, the current mtu is larger than the maximum allowed mtu. check the dmesg for more info"); + nl_set_err_msg_mod(bpf->extack, + "failed to set xdp program, the current mtu is larger than the maximum allowed mtu. check the dmesg for more info"); + return -einval; + } else if (rc == ena_xdp_no_enough_queues) { + netif_err(adapter, drv, adapter->netdev, + "failed to set xdp program, the rx/tx channel count should be at most half of the maximum allowed channel count. the current queue count (%d), the maximal queue count (%d) ", + adapter->num_io_queues, adapter->max_num_io_queues); + nl_set_err_msg_mod(bpf->extack, + "failed to set xdp program, there is no enough space for allocating xdp queues, check the dmesg for more info"); -static void ena_init_io_rings(struct ena_adapter *adapter) +static void ena_init_io_rings(struct ena_adapter *adapter, + int first_index, int count) - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = first_index; i < first_index + count; i++) { - /* tx/rx common ring state */ + /* tx common ring state */ - ena_init_io_rings_common(adapter, rxr, i); - /* rx specific ring state */ - rxr->ring_size = adapter->requested_rx_ring_size; - rxr->rx_copybreak = adapter->rx_copybreak; - rxr->sgl_size = adapter->max_rx_sgl_size; - rxr->smoothed_interval = - ena_com_get_nonadaptive_moderation_interval_rx(ena_dev); - rxr->empty_rx_queue = 0; - adapter->ena_napi[i].dim.mode = dim_cq_period_mode_start_from_eqe; + /* don't init rx queues for xdp queues */ + if (!ena_is_xdp_index(adapter, i)) { + /* rx common ring state */ + ena_init_io_rings_common(adapter, rxr, i); + + /* rx specific ring state */ + rxr->ring_size = adapter->requested_rx_ring_size; + rxr->rx_copybreak = adapter->rx_copybreak; + rxr->sgl_size = adapter->max_rx_sgl_size; + rxr->smoothed_interval = + ena_com_get_nonadaptive_moderation_interval_rx(ena_dev); + rxr->empty_rx_queue = 0; + adapter->ena_napi[i].dim.mode = dim_cq_period_mode_start_from_eqe; + } -/* ena_setup_all_tx_resources - allocate i/o tx queues resources for all queues - * @adapter: private structure - * - * return 0 on success, negative on failure - */ -static int ena_setup_all_tx_resources(struct ena_adapter *adapter) +static int ena_setup_tx_resources_in_range(struct ena_adapter *adapter, + int first_index, + int count) - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = first_index; i < first_index + count; i++) { - while (i--) + while (first_index < i--) +static void ena_free_all_io_tx_resources_in_range(struct ena_adapter *adapter, + int first_index, int count) +{ + int i; + + for (i = first_index; i < first_index + count; i++) + ena_free_tx_resources(adapter, i); +} + - int i; - - for (i = 0; i < adapter->num_io_queues; i++) - ena_free_tx_resources(adapter, i); + ena_free_all_io_tx_resources_in_range(adapter, + 0, + adapter->xdp_num_queues + + adapter->num_io_queues); - - xdp_rxq_info_unreg_mem_model(&rx_ring->xdp_rxq); - xdp_rxq_info_unreg(&rx_ring->xdp_rxq); - ena_buf->len = ena_page_size; + ena_buf->len = ena_page_size - rx_ring->rx_headroom; - dma_unmap_page(rx_ring->dev, ena_buf->paddr, ena_page_size, + dma_unmap_page(rx_ring->dev, + ena_buf->paddr - rx_ring->rx_headroom, + ena_page_size, -static void ena_unmap_tx_skb(struct ena_ring *tx_ring, - struct ena_tx_buffer *tx_info) +static void ena_unmap_tx_buff(struct ena_ring *tx_ring, + struct ena_tx_buffer *tx_info) - ena_unmap_tx_skb(tx_ring, tx_info); + ena_unmap_tx_buff(tx_ring, tx_info); - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = 0; i < adapter->num_io_queues + adapter->xdp_num_queues; i++) { - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = 0; i < adapter->num_io_queues + adapter->xdp_num_queues; i++) { +static int handle_invalid_req_id(struct ena_ring *ring, u16 req_id, + struct ena_tx_buffer *tx_info, bool is_xdp) +{ + if (tx_info) + netif_err(ring->adapter, + tx_done, + ring->netdev, + "tx_info doesn't have valid %s", + is_xdp ? "xdp frame" : "skb"); + else + netif_err(ring->adapter, + tx_done, + ring->netdev, + "invalid req_id: %hu ", + req_id); + + u64_stats_update_begin(&ring->syncp); + ring->tx_stats.bad_req_id++; + u64_stats_update_end(&ring->syncp); + + /* trigger device reset */ + ring->adapter->reset_reason = ena_regs_reset_inv_tx_req_id; + set_bit(ena_flag_trigger_reset, &ring->adapter->flags); + return -efault; +} + - if (tx_info) - netif_err(tx_ring->adapter, tx_done, tx_ring->netdev, - "tx_info doesn't have valid skb "); - else - netif_err(tx_ring->adapter, tx_done, tx_ring->netdev, - "invalid req_id: %hu ", req_id); + return handle_invalid_req_id(tx_ring, req_id, tx_info, false); +} - u64_stats_update_begin(&tx_ring->syncp); - tx_ring->tx_stats.bad_req_id++; - u64_stats_update_end(&tx_ring->syncp); +static int validate_xdp_req_id(struct ena_ring *xdp_ring, u16 req_id) +{ + struct ena_tx_buffer *tx_info = null; - /* trigger device reset */ - tx_ring->adapter->reset_reason = ena_regs_reset_inv_tx_req_id; - set_bit(ena_flag_trigger_reset, &tx_ring->adapter->flags); - return -efault; + if (likely(req_id < xdp_ring->ring_size)) { + tx_info = &xdp_ring->tx_buffer_info[req_id]; + if (likely(tx_info->xdpf)) + return 0; + } + + return handle_invalid_req_id(xdp_ring, req_id, tx_info, true); - ena_unmap_tx_skb(tx_ring, tx_info); + ena_unmap_tx_buff(tx_ring, tx_info); - ret = ena_xdp_execute(rx_ring, xdp); + ret = ena_xdp_execute(rx_ring, xdp, rx_info); - u32 res_budget, work_done; - + u32 res_budget, work_done; + + if (xdp_verdict == xdp_tx) { + ena_free_rx_page(rx_ring, + &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id]); + res_budget--; + } - if (xdp_verdict == xdp_drop) + if (xdp_verdict == xdp_tx || xdp_verdict == xdp_drop) - u32 rx_interval = ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev) ? - rx_ring->smoothed_interval : - ena_com_get_nonadaptive_moderation_interval_rx(rx_ring->ena_dev); + u32 rx_interval = 0; + /* rx ring can be null when for xdp tx queues which don't have an + * accompanying rx_ring pair. + */ + if (rx_ring) + rx_interval = ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev) ? + rx_ring->smoothed_interval : + ena_com_get_nonadaptive_moderation_interval_rx(rx_ring->ena_dev); + * the tx ring is used because the rx_ring is null for xdp queues - ena_com_unmask_intr(rx_ring->ena_com_io_cq, &intr_reg); + ena_com_unmask_intr(tx_ring->ena_com_io_cq, &intr_reg); - ena_com_update_numa_node(rx_ring->ena_com_io_cq, numa_node); + if (rx_ring) + ena_com_update_numa_node(rx_ring->ena_com_io_cq, + numa_node); - rx_ring->cpu = cpu; + if (rx_ring) + rx_ring->cpu = cpu; +static int ena_clean_xdp_irq(struct ena_ring *xdp_ring, u32 budget) +{ + u32 total_done = 0; + u16 next_to_clean; + u32 tx_bytes = 0; + int tx_pkts = 0; + u16 req_id; + int rc; + + if (unlikely(!xdp_ring)) + return 0; + next_to_clean = xdp_ring->next_to_clean; + + while (tx_pkts < budget) { + struct ena_tx_buffer *tx_info; + struct xdp_frame *xdpf; + + rc = ena_com_tx_comp_req_id_get(xdp_ring->ena_com_io_cq, + &req_id); + if (rc) + break; + + rc = validate_xdp_req_id(xdp_ring, req_id); + if (rc) + break; + + tx_info = &xdp_ring->tx_buffer_info[req_id]; + xdpf = tx_info->xdpf; + + tx_info->xdpf = null; + tx_info->last_jiffies = 0; + ena_unmap_tx_buff(xdp_ring, tx_info); + + netif_dbg(xdp_ring->adapter, tx_done, xdp_ring->netdev, + "tx_poll: q %d skb %p completed ", xdp_ring->qid, + xdpf); + + tx_bytes += xdpf->len; + tx_pkts++; + total_done += tx_info->tx_descs; + + __free_page(tx_info->xdp_rx_page); + xdp_ring->free_ids[next_to_clean] = req_id; + next_to_clean = ena_tx_ring_idx_next(next_to_clean, + xdp_ring->ring_size); + } + + xdp_ring->next_to_clean = next_to_clean; + ena_com_comp_ack(xdp_ring->ena_com_io_sq, total_done); + ena_com_update_dev_comp_head(xdp_ring->ena_com_io_cq); + + netif_dbg(xdp_ring->adapter, tx_done, xdp_ring->netdev, + "tx_poll: q %d done. total pkts: %d ", + xdp_ring->qid, tx_pkts); + + return tx_pkts; +} + - + int io_queue_count; + io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues; - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = 0; i < io_queue_count; i++) { -static void ena_del_napi(struct ena_adapter *adapter) +static void ena_del_napi_in_range(struct ena_adapter *adapter, + int first_index, + int count) - for (i = 0; i < adapter->num_io_queues; i++) - netif_napi_del(&adapter->ena_napi[i].napi); + for (i = first_index; i < first_index + count; i++) { + /* check if napi was initialized before */ + if (!ena_is_xdp_index(adapter, i) || + adapter->ena_napi[i].xdp_ring) + netif_napi_del(&adapter->ena_napi[i].napi); + else + warn_on(ena_is_xdp_index(adapter, i) && + adapter->ena_napi[i].xdp_ring); + } -static void ena_init_napi(struct ena_adapter *adapter) +static void ena_init_napi_in_range(struct ena_adapter *adapter, + int first_index, int count) - struct ena_napi *napi; + struct ena_napi *napi = {0}; - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = first_index; i < first_index + count; i++) { - ena_io_poll, + ena_is_xdp_index(adapter, i) ? ena_xdp_io_poll : ena_io_poll, - napi->rx_ring = &adapter->rx_ring[i]; - napi->tx_ring = &adapter->tx_ring[i]; + + if (!ena_is_xdp_index(adapter, i)) { + napi->rx_ring = &adapter->rx_ring[i]; + napi->tx_ring = &adapter->tx_ring[i]; + } else { + napi->xdp_ring = &adapter->tx_ring[i]; + } -static void ena_napi_disable_all(struct ena_adapter *adapter) +static void ena_napi_disable_in_range(struct ena_adapter *adapter, + int first_index, + int count) - for (i = 0; i < adapter->num_io_queues; i++) + for (i = first_index; i < first_index + count; i++) -static void ena_napi_enable_all(struct ena_adapter *adapter) +static void ena_napi_enable_in_range(struct ena_adapter *adapter, + int first_index, + int count) - for (i = 0; i < adapter->num_io_queues; i++) + for (i = first_index; i < first_index + count; i++) - "failed to init rss rc: %d ", rc); + "failed to init rss rc: %d ", rc); - ena_napi_enable_all(adapter); + ena_napi_enable_in_range(adapter, + 0, + adapter->xdp_num_queues + adapter->num_io_queues); - qid, rc); + qid, rc); -static int ena_create_all_io_tx_queues(struct ena_adapter *adapter) +static int ena_create_io_tx_queues_in_range(struct ena_adapter *adapter, + int first_index, int count) - for (i = 0; i < adapter->num_io_queues; i++) { + for (i = first_index; i < first_index + count; i++) { - while (i--) + while (i-- > first_index) - rc = xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev, qid); - - if (rc) { - netif_err(adapter, ifup, adapter->netdev, - "failed to register xdp rx queue info. rx queue num %d rc: %d ", - qid, rc); - goto err; - } - - rc = xdp_rxq_info_reg_mem_model(&rx_ring->xdp_rxq, mem_type_page_shared, - null); - - if (rc) { - netif_err(adapter, ifup, adapter->netdev, - "failed to register xdp rx queue info memory model. rx queue num %d rc: %d ", - qid, rc); - xdp_rxq_info_unreg(&rx_ring->xdp_rxq); - goto err; - } - - int new_tx_size, int new_rx_size) + int new_tx_size, + int new_rx_size) - adapter->requested_rx_ring_size); + adapter->requested_rx_ring_size); - rc = ena_setup_all_tx_resources(adapter); + if (ena_xdp_present(adapter)) { + rc = ena_setup_and_create_all_xdp_queues(adapter); + + if (rc) + goto err_setup_tx; + } + rc = ena_setup_tx_resources_in_range(adapter, + 0, + adapter->num_io_queues); - rc = ena_create_all_io_tx_queues(adapter); + rc = ena_create_io_tx_queues_in_range(adapter, + 0, + adapter->num_io_queues); - rc); + rc); - new_rx_ring_size < ena_min_ring_size) { + new_rx_ring_size < ena_min_ring_size) { - int rc, i; + int io_queue_count, rc, i; + io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues; - ena_init_napi(adapter); + ena_init_napi_in_range(adapter, 0, io_queue_count); - for (i = 0; i < adapter->num_io_queues; i++) + for (i = 0; i < io_queue_count; i++) - ena_del_napi(adapter); + ena_del_napi_in_range(adapter, 0, io_queue_count); + int io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues; + - ena_napi_disable_all(adapter); + ena_napi_disable_in_range(adapter, 0, io_queue_count); - ena_del_napi(adapter); + ena_del_napi_in_range(adapter, 0, io_queue_count); - ena_init_io_rings(adapter); + ena_init_io_rings(adapter, + 0, + adapter->xdp_num_queues + + adapter->num_io_queues); - - if (ena_xdp_present(adapter) && ena_xdp_allowed(adapter)) { + if (ena_xdp_present(adapter) && + ena_xdp_allowed(adapter) == ena_xdp_allowed) { + adapter->xdp_first_ring = new_channel_count; + adapter->xdp_num_queues = new_channel_count; - ena_init_io_rings(adapter); + ena_init_io_rings(adapter, + 0, + adapter->xdp_num_queues + + adapter->num_io_queues); - ena_unmap_tx_skb(tx_ring, tx_info); + ena_unmap_tx_buff(tx_ring, tx_info); - int qid, rc, nb_hw_desc; + int qid, rc; - if (unlikely(ena_com_is_doorbell_needed(tx_ring->ena_com_io_sq, &ena_tx_ctx))) { - netif_dbg(adapter, tx_queued, dev, - "llq tx max burst size of queue %d achieved, writing doorbell to send burst ", - qid); - ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); - } - - /* prepare the packet's descriptors to dma engine */ - rc = ena_com_prepare_tx(tx_ring->ena_com_io_sq, &ena_tx_ctx, - &nb_hw_desc); - - /* ena_com_prepare_tx() can't fail due to overflow of tx queue, - * since the number of free descriptors in the queue is checked - * after sending the previous packet. in case there isn't enough - * space in the queue for the next packet, it is stopped - * until there is again enough available space in the queue. - * all other failure reasons of ena_com_prepare_tx() are fatal - * and therefore require a device reset. - */ - if (unlikely(rc)) { - netif_err(adapter, tx_queued, dev, - "failed to prepare tx bufs "); - u64_stats_update_begin(&tx_ring->syncp); - tx_ring->tx_stats.prepare_ctx_err++; - u64_stats_update_end(&tx_ring->syncp); - adapter->reset_reason = ena_regs_reset_driver_invalid_state; - set_bit(ena_flag_trigger_reset, &adapter->flags); + rc = ena_xmit_common(dev, + tx_ring, + tx_info, + &ena_tx_ctx, + next_to_use, + skb->len); + if (rc) - } - u64_stats_update_begin(&tx_ring->syncp); - tx_ring->tx_stats.cnt++; - tx_ring->tx_stats.bytes += skb->len; - u64_stats_update_end(&tx_ring->syncp); - - tx_info->tx_descs = nb_hw_desc; - tx_info->last_jiffies = jiffies; - tx_info->print_once = 0; - - tx_ring->next_to_use = ena_tx_ring_idx_next(next_to_use, - tx_ring->ring_size); - - ena_unmap_tx_skb(tx_ring, tx_info); + ena_unmap_tx_buff(tx_ring, tx_info); + int io_queue_count; + io_queue_count = adapter->xdp_num_queues + adapter->num_io_queues; - for (i = adapter->last_monitored_tx_qid; i < adapter->num_io_queues; i++) { + for (i = adapter->last_monitored_tx_qid; i < io_queue_count; i++) { - rc = check_for_rx_interrupt_queue(adapter, rx_ring); + rc = !ena_is_xdp_index(adapter, i) ? + check_for_rx_interrupt_queue(adapter, rx_ring) : 0; - adapter->last_monitored_tx_qid = i % adapter->num_io_queues; + adapter->last_monitored_tx_qid = i % io_queue_count; + adapter->xdp_first_ring = 0; + adapter->xdp_num_queues = 0; + - ena_init_io_rings(adapter); + ena_init_io_rings(adapter, + 0, + adapter->xdp_num_queues + + adapter->num_io_queues); diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h --- a/drivers/net/ethernet/amazon/ena/ena_netdev.h +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h +#define ena_is_xdp_index(adapter, index) (((index) >= (adapter)->xdp_first_ring) && \ + ((index) < (adapter)->xdp_first_ring + (adapter)->xdp_num_queues)) + + struct ena_ring *xdp_ring; + /* xdp buffer structure which is used for sending packets in + * the xdp queues + */ + struct xdp_frame *xdpf; + /* the rx page for the rx buffer that was received in rx and + * re transmitted on xdp tx queues as a result of xdp_tx action. + * we need to free the page once we finished cleaning the buffer in + * clean_xdp_irq() + */ + struct page *xdp_rx_page; + + u32 xdp_first_ring; + u32 xdp_num_queues; +enum ena_xdp_errors_t { + ena_xdp_allowed = 0, + ena_xdp_current_mtu_too_large, + ena_xdp_no_enough_queues, +}; + +static inline bool ena_xdp_queues_present(struct ena_adapter *adapter) +{ + return adapter->xdp_first_ring != 0; +} + -static inline bool ena_xdp_allowed(struct ena_adapter *adapter) +static inline int ena_xdp_legal_queue_count(struct ena_adapter *adapter, + u32 queues) - return adapter->netdev->mtu <= ena_xdp_max_mtu; + return 2 * queues <= adapter->max_num_io_queues; +} + +static inline enum ena_xdp_errors_t ena_xdp_allowed(struct ena_adapter *adapter) +{ + enum ena_xdp_errors_t rc = ena_xdp_allowed; + + if (adapter->netdev->mtu > ena_xdp_max_mtu) + rc = ena_xdp_current_mtu_too_large; + else if (!ena_xdp_legal_queue_count(adapter, adapter->num_io_queues)) + rc = ena_xdp_no_enough_queues; + + return rc;
|
Networking
|
548c4940b9f1f527f81509468dd60b61418880b6
|
sameeh jubran
|
drivers
|
net
|
amazon, ena, ethernet
|
net: ena: add first_interrupt field to napi struct
|
the first_interrupt field is accessed in ena_intr_msix_io() upon receiving an interrupt.the rx_ring and tx_ring fields of napi can be null when receiving interrupt for xdp queues. this patch fixes the issue by moving the field to the ena_napi struct.
|
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.
|
implement xdp
|
['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']
|
['ena ']
|
['c', 'h']
| 2
| 6
| 2
|
--- diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c + xdp_ring->first_interrupt = ena_napi->first_interrupt; + tx_ring->first_interrupt = ena_napi->first_interrupt; + rx_ring->first_interrupt = ena_napi->first_interrupt; + - ena_napi->tx_ring->first_interrupt = true; - ena_napi->rx_ring->first_interrupt = true; + ena_napi->first_interrupt = true; diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h --- a/drivers/net/ethernet/amazon/ena/ena_netdev.h +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h + bool first_interrupt;
|
Networking
|
913b0bfd6c859aaf1735e1c8c69731e1d5359d31
|
sameeh jubran
|
drivers
|
net
|
amazon, ena, ethernet
|
enetc: add software timestamping
|
provide a software tx timestamp and add it to the ethtool query interface.
|
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 software timestamping
|
['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']
|
['enetc ']
|
['c']
| 2
| 3
| 0
|
--- diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c + skb_tx_timestamp(skb); + diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c + sof_timestamping_tx_software |
|
Networking
|
4caefbce06d138306ef4e9f635e5b02b62d56911
|
michael walle
|
drivers
|
net
|
enetc, ethernet, freescale
|
enetc: add support time specific departure base on the qos etf
|
enetc implement time specific departure capability, which enables the user to specify when a frame can be transmitted. when this capability is enabled, the device will delay the transmission of the frame so that it can be transmitted at the precisely specified time. the delay departure time up to 0.5 seconds in the future. if the departure time in the transmit bd has not yet been reached, based on the current time, the packet will not be 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 support time specific departure base on the qos etf
|
['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']
|
['enetc ']
|
['c', 'h']
| 4
| 59
| 1
|
- transmit checksum offloads and time specific departure operation - time aware shaper feature (qbv) offload and time specific departure --- diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c + else if (tx_ring->tsd_enable) + flags |= enetc_txbd_flags_tse | enetc_txbd_flags_txstart; + if (flags & enetc_txbd_flags_tse) { + u32 temp; + + temp = (skb->skb_mstamp_ns >> 5 & enetc_txbd_txstart_mask) + | (flags << enetc_txbd_flags_offset); + temp_bd.txstart = cpu_to_le32(temp); + } + + case tc_setup_qdisc_etf: + return enetc_setup_tc_txtime(ndev, type_data); diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h + u8 tsd_enable; /* time specific departure */ +int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data); +#define enetc_setup_tc_txtime(ndev, type_data) -eopnotsupp diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h + __le32 txstart; +#define enetc_txbd_flags_tse bit(1) +#define enetc_txbd_flags_txstart bit(4) - +#define enetc_txbd_txstart_mask genmask(24, 0) +#define enetc_txbd_flags_offset 24 + +/* port time specific departure */ +#define enetc_ptctsdr(n) (0x1210 + 4 * (n)) +#define enetc_tsde bit(31) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c + /* tsd and qbv are mutually exclusive in hardware */ + for (i = 0; i < priv->num_tx_rings; i++) + if (priv->tx_ring[i]->tsd_enable) + return -ebusy; + + +int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct tc_etf_qopt_offload *qopt = type_data; + u8 tc_nums = netdev_get_num_tc(ndev); + int tc; + + if (!tc_nums) + return -eopnotsupp; + + tc = qopt->queue; + + if (tc < 0 || tc > priv->num_tx_rings) + return -einval; + + /* do not support txstart and tx csum offload simutaniously */ + if (ndev->features & netif_f_csum_mask) + return -ebusy; + + /* tsd and qbv are mutually exclusive in hardware */ + if (enetc_rd(&priv->si->hw, enetc_qbv_ptgcr_offset) & enetc_qbv_tge) + return -ebusy; + + priv->tx_ring[tc]->tsd_enable = qopt->enable; + enetc_port_wr(&priv->si->hw, enetc_ptctsdr(tc), + qopt->enable ? enetc_tsde : 0); + + return 0; +}
|
Networking
|
0d08c9ec7d6eb9b4c8639396b1cc6f692cbb7955
|
po liu
|
drivers
|
net
|
enetc, ethernet, freescale
|
net: hns3: add some vf vlan information for command "ip link show"
|
this patch adds some vf vlan information for command "ip link 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.
|
add some vf vlan information for command "ip link show"
|
['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']
|
['hns3 ']
|
['c']
| 1
| 3
| 0
|
--- diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c + ivf->vlan = vport->port_base_vlan_cfg.vlan_info.vlan_tag; + ivf->vlan_proto = htons(vport->port_base_vlan_cfg.vlan_info.vlan_proto); + ivf->qos = vport->port_base_vlan_cfg.vlan_info.qos;
|
Networking
|
89b40c7fe2a8b30ef6d46d45ae8455adcd9c1b47
|
huazhong tan
|
drivers
|
net
|
ethernet, hisilicon, hns3, hns3pf
|
net: hns3: implement ndo_features_check ops for hns3 driver
|
the function netif_skb_features() will disable the tso feature by using dflt_features_check() if the driver does not implement ndo_features_check ops, which may cause performance degradation problem when hns3 hardware can do multiple tagged tso.
|
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.
|
implement ndo_features_check ops for hns3 driver
|
['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']
|
['hns3 ']
|
['c']
| 1
| 32
| 0
|
--- diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +static netdev_features_t hns3_features_check(struct sk_buff *skb, + struct net_device *dev, + netdev_features_t features) +{ +#define hns3_max_hdr_len 480u +#define hns3_max_l4_hdr_len 60u + + size_t len; + + if (skb->ip_summed != checksum_partial) + return features; + + if (skb->encapsulation) + len = skb_inner_transport_header(skb) - skb->data; + else + len = skb_transport_header(skb) - skb->data; + + /* assume l4 is 60 byte as tcp is the only protocol with a + * a flexible value, and it's max len is 60 bytes. + */ + len += hns3_max_l4_hdr_len; + + /* hardware only supports checksum on the skb with a max header + * len of 480 bytes. + */ + if (len > hns3_max_hdr_len) + features &= ~(netif_f_csum_mask | netif_f_gso_mask); + + return features; +} + + .ndo_features_check = hns3_features_check,
|
Networking
|
2a7556bb2b7308c6e0fe646c1ddbbf9522bf1120
|
yunsheng lin
|
drivers
|
net
|
ethernet, hisilicon, hns3
|
hv_netvsc: add xdp support
|
this patch adds support of xdp in native mode for hv_netvsc driver, and transparently sets the xdp program on the associated vf nic 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.
|
add xdp 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']
|
['hv_netvsc']
|
['h', 'c', 'makefile']
| 6
| 409
| 39
|
--- diff --git a/drivers/net/hyperv/makefile b/drivers/net/hyperv/makefile --- a/drivers/net/hyperv/makefile +++ b/drivers/net/hyperv/makefile -hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o netvsc_trace.o +hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o netvsc_trace.o netvsc_bpf.o diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h + struct bpf_prog *bprog; + - struct sk_buff *skb); + struct sk_buff *skb, + bool xdp_tx); +u32 netvsc_run_xdp(struct net_device *ndev, struct netvsc_channel *nvchan, + struct xdp_buff *xdp); +unsigned int netvsc_xdp_fraglen(unsigned int len); +struct bpf_prog *netvsc_xdp_get(struct netvsc_device *nvdev); +int netvsc_xdp_set(struct net_device *dev, struct bpf_prog *prog, + struct netlink_ext_ack *extack, + struct netvsc_device *nvdev); +int netvsc_vf_setxdp(struct net_device *vf_netdev, struct bpf_prog *prog); +int netvsc_bpf(struct net_device *dev, struct netdev_bpf *bpf); + +#define netvsc_xdp_hdrm 256 + + u64 xdp_drop; + struct bpf_prog __rcu *bpf_prog; + struct xdp_rxq_info xdp_rxq; + diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c - for (i = 0; i < vrss_channel_max; i++) + for (i = 0; i < vrss_channel_max; i++) { + xdp_rxq_info_unreg(&nvdev->chan_table[i].xdp_rxq); + } - struct sk_buff *skb) + struct sk_buff *skb, + bool xdp_tx) - /* send control message directly without accessing msd (multi-send - * data) field which may be changed during data packet processing. + /* send a control message or xdp packet directly without accessing + * msd (multi-send data) field which may be changed during data packet + * processing. - if (!skb) + if (!skb || xdp_tx) + + ret = xdp_rxq_info_reg(&nvchan->xdp_rxq, ndev, i); + + if (ret) { + netdev_err(ndev, "xdp_rxq_info_reg fail: %d ", ret); + goto cleanup2; + } + + ret = xdp_rxq_info_reg_mem_model(&nvchan->xdp_rxq, + mem_type_page_shared, null); + + if (ret) { + netdev_err(ndev, "xdp reg_mem_model fail: %d ", ret); + goto cleanup2; + } + +cleanup2: diff --git a/drivers/net/hyperv/netvsc_bpf.c b/drivers/net/hyperv/netvsc_bpf.c --- /dev/null +++ b/drivers/net/hyperv/netvsc_bpf.c +// spdx-license-identifier: gpl-2.0-only +/* copyright (c) 2019, microsoft corporation. + * + * author: + * haiyang zhang <haiyangz@microsoft.com> + */ + +#define pr_fmt(fmt) kbuild_modname ": " fmt + +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/ethtool.h> +#include <linux/bpf.h> +#include <linux/bpf_trace.h> +#include <linux/kernel.h> +#include <net/xdp.h> + +#include <linux/mutex.h> +#include <linux/rtnetlink.h> + +#include "hyperv_net.h" + +u32 netvsc_run_xdp(struct net_device *ndev, struct netvsc_channel *nvchan, + struct xdp_buff *xdp) +{ + void *data = nvchan->rsc.data[0]; + u32 len = nvchan->rsc.len[0]; + struct page *page = null; + struct bpf_prog *prog; + u32 act = xdp_pass; + + xdp->data_hard_start = null; + + rcu_read_lock(); + prog = rcu_dereference(nvchan->bpf_prog); + + if (!prog) + goto out; + + /* allocate page buffer for data */ + page = alloc_page(gfp_atomic); + if (!page) { + act = xdp_drop; + goto out; + } + + xdp->data_hard_start = page_address(page); + xdp->data = xdp->data_hard_start + netvsc_xdp_hdrm; + xdp_set_data_meta_invalid(xdp); + xdp->data_end = xdp->data + len; + xdp->rxq = &nvchan->xdp_rxq; + xdp->handle = 0; + + memcpy(xdp->data, data, len); + + act = bpf_prog_run_xdp(prog, xdp); + + switch (act) { + case xdp_pass: + case xdp_tx: + case xdp_drop: + break; + + case xdp_aborted: + trace_xdp_exception(ndev, prog, act); + break; + + default: + bpf_warn_invalid_xdp_action(act); + } + +out: + rcu_read_unlock(); + + if (page && act != xdp_pass && act != xdp_tx) { + __free_page(page); + xdp->data_hard_start = null; + } + + return act; +} + +unsigned int netvsc_xdp_fraglen(unsigned int len) +{ + return skb_data_align(len) + + skb_data_align(sizeof(struct skb_shared_info)); +} + +struct bpf_prog *netvsc_xdp_get(struct netvsc_device *nvdev) +{ + return rtnl_dereference(nvdev->chan_table[0].bpf_prog); +} + +int netvsc_xdp_set(struct net_device *dev, struct bpf_prog *prog, + struct netlink_ext_ack *extack, + struct netvsc_device *nvdev) +{ + struct bpf_prog *old_prog; + int buf_max, i; + + old_prog = netvsc_xdp_get(nvdev); + + if (!old_prog && !prog) + return 0; + + buf_max = netvsc_xdp_hdrm + netvsc_xdp_fraglen(dev->mtu + eth_hlen); + if (prog && buf_max > page_size) { + netdev_err(dev, "xdp: mtu:%u too large, buf_max:%u ", + dev->mtu, buf_max); + nl_set_err_msg_mod(extack, "xdp: mtu too large"); + + return -eopnotsupp; + } + + if (prog && (dev->features & netif_f_lro)) { + netdev_err(dev, "xdp: not support lro "); + nl_set_err_msg_mod(extack, "xdp: not support lro"); + + return -eopnotsupp; + } + + if (prog) + bpf_prog_add(prog, nvdev->num_chn); + + for (i = 0; i < nvdev->num_chn; i++) + rcu_assign_pointer(nvdev->chan_table[i].bpf_prog, prog); + + if (old_prog) + for (i = 0; i < nvdev->num_chn; i++) + bpf_prog_put(old_prog); + + return 0; +} + +int netvsc_vf_setxdp(struct net_device *vf_netdev, struct bpf_prog *prog) +{ + struct netdev_bpf xdp; + bpf_op_t ndo_bpf; + + assert_rtnl(); + + if (!vf_netdev) + return 0; + + ndo_bpf = vf_netdev->netdev_ops->ndo_bpf; + if (!ndo_bpf) + return 0; + + memset(&xdp, 0, sizeof(xdp)); + + xdp.command = xdp_setup_prog; + xdp.prog = prog; + + return ndo_bpf(vf_netdev, &xdp); +} + +static u32 netvsc_xdp_query(struct netvsc_device *nvdev) +{ + struct bpf_prog *prog = netvsc_xdp_get(nvdev); + + if (prog) + return prog->aux->id; + + return 0; +} + +int netvsc_bpf(struct net_device *dev, struct netdev_bpf *bpf) +{ + struct net_device_context *ndevctx = netdev_priv(dev); + struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); + struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev); + struct netlink_ext_ack *extack = bpf->extack; + int ret; + + if (!nvdev || nvdev->destroy) { + if (bpf->command == xdp_query_prog) { + bpf->prog_id = 0; + return 0; /* query must always succeed */ + } else { + return -enodev; + } + } + + switch (bpf->command) { + case xdp_setup_prog: + ret = netvsc_xdp_set(dev, bpf->prog, extack, nvdev); + + if (ret) + return ret; + + ret = netvsc_vf_setxdp(vf_netdev, bpf->prog); + + if (ret) { + netdev_err(dev, "vf_setxdp failed:%d ", ret); + nl_set_err_msg_mod(extack, "vf_setxdp failed"); + + netvsc_xdp_set(dev, null, extack, nvdev); + } + + return ret; + + case xdp_query_prog: + bpf->prog_id = netvsc_xdp_query(nvdev); + return 0; + + default: + return -einval; + } +} diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c +#include <linux/bpf.h> -static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) +static int netvsc_xmit(struct sk_buff *skb, struct net_device *net, bool xdp_tx) - ret = netvsc_send(net, packet, rndis_msg, pb, skb); + ret = netvsc_send(net, packet, rndis_msg, pb, skb, xdp_tx); +static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + return netvsc_xmit(skb, ndev, false); +} + +static void netvsc_xdp_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + int rc; + + skb->queue_mapping = skb_get_rx_queue(skb); + __skb_push(skb, eth_hlen); + + rc = netvsc_xmit(skb, ndev, true); + + if (dev_xmit_complete(rc)) + return; + + dev_kfree_skb_any(skb); + ndev->stats.tx_dropped++; +} + - struct netvsc_channel *nvchan) + struct netvsc_channel *nvchan, + struct xdp_buff *xdp) + void *xbuf = xdp->data_hard_start; - skb = napi_alloc_skb(napi, nvchan->rsc.pktlen); - if (!skb) - return skb; + if (xbuf) { + unsigned int hdroom = xdp->data - xdp->data_hard_start; + unsigned int xlen = xdp->data_end - xdp->data; + unsigned int frag_size = netvsc_xdp_fraglen(hdroom + xlen); - /* - * copy to skb. this copy is needed here since the memory pointed by - * hv_netvsc_packet cannot be deallocated - */ - for (i = 0; i < nvchan->rsc.cnt; i++) - skb_put_data(skb, nvchan->rsc.data[i], nvchan->rsc.len[i]); + skb = build_skb(xbuf, frag_size); + + if (!skb) { + __free_page(virt_to_page(xbuf)); + return null; + } + + skb_reserve(skb, hdroom); + skb_put(skb, xlen); + skb->dev = napi->dev; + } else { + skb = napi_alloc_skb(napi, nvchan->rsc.pktlen); + + if (!skb) + return null; + + /* copy to skb. this copy is needed here since the memory + * pointed by hv_netvsc_packet cannot be deallocated. + */ + for (i = 0; i < nvchan->rsc.cnt; i++) + skb_put_data(skb, nvchan->rsc.data[i], + nvchan->rsc.len[i]); + } - struct netvsc_stats *rx_stats; + struct netvsc_stats *rx_stats = &nvchan->rx_stats; + struct xdp_buff xdp; + u32 act; + act = netvsc_run_xdp(net, nvchan, &xdp); + + if (act != xdp_pass && act != xdp_tx) { + u64_stats_update_begin(&rx_stats->syncp); + rx_stats->xdp_drop++; + u64_stats_update_end(&rx_stats->syncp); + + return nvsp_stat_success; /* consumed by xdp */ + } + - skb = netvsc_alloc_recv_skb(net, nvchan); + skb = netvsc_alloc_recv_skb(net, nvchan, &xdp); ++net_device_ctx->eth_stats.rx_no_memory; - rx_stats = &nvchan->rx_stats; ++rx_stats->multicast; + if (act == xdp_tx) { + netvsc_xdp_xmit(skb, net); + return nvsp_stat_success; + } + -static struct netvsc_device_info *netvsc_devinfo_get - (struct netvsc_device *nvdev) +static +struct netvsc_device_info *netvsc_devinfo_get(struct netvsc_device *nvdev) + struct bpf_prog *prog; + assert_rtnl(); + + + prog = netvsc_xdp_get(nvdev); + if (prog) { + bpf_prog_inc(prog); + dev_info->bprog = prog; + } +/* free struct netvsc_device_info */ +static void netvsc_devinfo_put(struct netvsc_device_info *dev_info) +{ + if (dev_info->bprog) { + assert_rtnl(); + bpf_prog_put(dev_info->bprog); + } + + kfree(dev_info); +} + + netvsc_xdp_set(ndev, null, null, nvdev); + - int ret; + struct bpf_prog *prog; + int ret = 0; + prog = dev_info->bprog; + if (prog) { + ret = netvsc_xdp_set(ndev, prog, null, nvdev); + if (ret) + goto err1; + } + - goto err; + goto err2; -err: +err2: +err1: - kfree(device_info); + netvsc_devinfo_put(device_info); - kfree(device_info); + netvsc_devinfo_put(device_info); -/* 4 statistics per queue (rx/tx packets/bytes) */ -#define netvsc_queue_stats_len(dev) ((dev)->num_chn * 4) +/* 5 statistics per queue (rx/tx packets/bytes, rx xdp_drop) */ +#define netvsc_queue_stats_len(dev) ((dev)->num_chn * 5) + u64 xdp_drop; + xdp_drop = qstats->xdp_drop; + data[i++] = xdp_drop; + sprintf(p, "rx_queue_%u_xdp_drop", i); + p += eth_gstring_len; - kfree(device_info); + netvsc_devinfo_put(device_info); +static netdev_features_t netvsc_fix_features(struct net_device *ndev, + netdev_features_t features) +{ + struct net_device_context *ndevctx = netdev_priv(ndev); + struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); + + if (!nvdev || nvdev->destroy) + return features; + + if ((features & netif_f_lro) && netvsc_xdp_get(nvdev)) { + features ^= netif_f_lro; + netdev_info(ndev, "skip lro - unsupported with xdp "); + } + + return features; +} + + .ndo_fix_features = netvsc_fix_features, + .ndo_bpf = netvsc_bpf, + struct bpf_prog *prog; + prog = netvsc_xdp_get(netvsc_dev); + netvsc_vf_setxdp(vf_netdev, prog); + + netvsc_vf_setxdp(vf_netdev, null); + - kfree(device_info); + netvsc_devinfo_put(device_info); - kfree(device_info); + netvsc_devinfo_put(device_info); - if (nvdev) + if (nvdev) { + netvsc_xdp_set(net, null, null, nvdev); + } - rtnl_unlock(); - - kfree(device_info); + netvsc_devinfo_put(device_info); + rtnl_unlock(); + diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c - ret = netvsc_send(dev->ndev, packet, null, pb, null); + ret = netvsc_send(dev->ndev, packet, null, pb, null, false);
|
Networking
|
351e1581395fcc7fb952bbd7dda01238f69968fd
|
haiyang zhang
|
drivers
|
net
|
hyperv
|
hv_netvsc: update document for xdp support
|
added the new section in the document regarding xdp support by hv_netvsc 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 xdp 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']
|
['hv_netvsc']
|
['txt']
| 1
| 21
| 0
|
--- diff --git a/documentation/networking/device_drivers/microsoft/netvsc.txt b/documentation/networking/device_drivers/microsoft/netvsc.txt --- a/documentation/networking/device_drivers/microsoft/netvsc.txt +++ b/documentation/networking/device_drivers/microsoft/netvsc.txt + + xdp support + ----------- + xdp (express data path) is a feature that runs ebpf bytecode at the early + stage when packets arrive at a nic card. the goal is to increase performance + for packet processing, reducing the overhead of skb allocation and other + upper network layers. + + hv_netvsc supports xdp in native mode, and transparently sets the xdp + program on the associated vf nic as well. + + setting / unsetting xdp program on synthetic nic (netvsc) propagates to + vf nic automatically. setting / unsetting xdp program on vf nic directly + is not recommended, also not propagated to synthetic nic, and may be + overwritten by setting of synthetic nic. + + xdp program cannot run with lro (rsc) enabled, so you need to disable lro + before running xdp: + ethtool -k eth0 lro off + + xdp_redirect action is not yet supported.
|
Networking
|
12fa74383ed4d1ffa283f77c1e7fe038e8182405
|
haiyang zhang
|
documentation
|
networking
|
device_drivers, microsoft
|
ice: add device ids for e822 devices
|
add support for e822 devices
|
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 device ids for e822 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']
|
['ice ']
|
['h', 'c']
| 3
| 39
| 0
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_devids.h b/drivers/net/ethernet/intel/ice/ice_devids.h --- a/drivers/net/ethernet/intel/ice/ice_devids.h +++ b/drivers/net/ethernet/intel/ice/ice_devids.h +/* intel(r) ethernet connection e822-c for backplane */ +#define ice_dev_id_e822c_backplane 0x1890 +/* intel(r) ethernet connection e822-c for qsfp */ +#define ice_dev_id_e822c_qsfp 0x1891 +/* intel(r) ethernet connection e822-c for sfp */ +#define ice_dev_id_e822c_sfp 0x1892 +/* intel(r) ethernet connection e822-c/x557-at 10gbase-t */ +#define ice_dev_id_e822c_10g_base_t 0x1893 +/* intel(r) ethernet connection e822-c 1gbe */ +#define ice_dev_id_e822c_sgmii 0x1894 +/* intel(r) ethernet connection e822-x for backplane */ +#define ice_dev_id_e822x_backplane 0x1897 +/* intel(r) ethernet connection e822-l for sfp */ +#define ice_dev_id_e822l_sfp 0x1898 +/* intel(r) ethernet connection e822-l/x557-at 10gbase-t */ +#define ice_dev_id_e822l_10g_base_t 0x1899 +/* intel(r) ethernet connection e822-l 1gbe */ +#define ice_dev_id_e822l_sgmii 0x189a diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c + { pci_vdevice(intel, ice_dev_id_e822c_backplane), 0 }, + { pci_vdevice(intel, ice_dev_id_e822c_qsfp), 0 }, + { pci_vdevice(intel, ice_dev_id_e822c_sfp), 0 }, + { pci_vdevice(intel, ice_dev_id_e822c_10g_base_t), 0 }, + { pci_vdevice(intel, ice_dev_id_e822c_sgmii), 0 }, + { pci_vdevice(intel, ice_dev_id_e822x_backplane), 0 }, + { pci_vdevice(intel, ice_dev_id_e822l_sfp), 0 }, + { pci_vdevice(intel, ice_dev_id_e822l_10g_base_t), 0 }, + { pci_vdevice(intel, ice_dev_id_e822l_sgmii), 0 }, diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c --- a/drivers/net/ethernet/intel/ice/ice_nvm.c +++ b/drivers/net/ethernet/intel/ice/ice_nvm.c + /* the following devices do not have boot_cfg_tlv yet */ + if (hw->device_id == ice_dev_id_e822c_backplane || + hw->device_id == ice_dev_id_e822c_qsfp || + hw->device_id == ice_dev_id_e822c_10g_base_t || + hw->device_id == ice_dev_id_e822c_sgmii || + hw->device_id == ice_dev_id_e822c_sfp || + hw->device_id == ice_dev_id_e822x_backplane || + hw->device_id == ice_dev_id_e822l_sfp || + hw->device_id == ice_dev_id_e822l_10g_base_t || + hw->device_id == ice_dev_id_e822l_sgmii) + return status; +
|
Networking
|
5d9e618cbb54f5cbaef7f6f44ceb919978f0e5bc
|
jacob keller andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: enable writing hardware filtering tables
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules. upon loading of ddp package, a minimal configuration should be written to hardware.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['c', 'makefile', 'h']
| 7
| 491
| 4
|
--- diff --git a/drivers/net/ethernet/intel/ice/makefile b/drivers/net/ethernet/intel/ice/makefile --- a/drivers/net/ethernet/intel/ice/makefile +++ b/drivers/net/ethernet/intel/ice/makefile - ice_flex_pipe.o \ + ice_flex_pipe.o \ + ice_flow.o \ diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c +#include "ice_flow.h" - + /* replay per vsi all rss configurations */ + status = ice_replay_rss_cfg(hw, vsi_handle); + if (status) + return status; diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +#include "ice_flow.h" + struct ice_rss_cfg *r, *rt; - hw->blk[i].is_list_init = false; + if (hw->blk[i].is_list_init) { + struct ice_es *es = &hw->blk[i].es; + mutex_destroy(&es->prof_map_lock); + mutex_destroy(&hw->fl_profs_locks[i]); + + hw->blk[i].is_list_init = false; + } + list_for_each_entry_safe(r, rt, &hw->rss_list_head, l_entry) { + list_del(&r->l_entry); + devm_kfree(ice_hw_to_dev(hw), r); + } + mutex_destroy(&hw->rss_locks); +/** + * ice_init_flow_profs - init flow profile locks and list heads + * @hw: pointer to the hardware structure + * @blk_idx: hw block index + */ +static void ice_init_flow_profs(struct ice_hw *hw, u8 blk_idx) +{ + mutex_init(&hw->fl_profs_locks[blk_idx]); + init_list_head(&hw->fl_profs[blk_idx]); +} + + mutex_init(&hw->rss_locks); + init_list_head(&hw->rss_list_head); + ice_init_flow_profs(hw, i); + mutex_init(&es->prof_map_lock); + init_list_head(&es->prof_map); diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_flow.c +// spdx-license-identifier: gpl-2.0 +/* copyright (c) 2019, intel corporation. */ + +#include "ice_common.h" +#include "ice_flow.h" + +/* describe properties of a protocol header field */ +struct ice_flow_field_info { + enum ice_flow_seg_hdr hdr; + s16 off; /* offset from start of a protocol header, in bits */ + u16 size; /* size of fields in bits */ +}; + +#define ice_flow_fld_info(_hdr, _offset_bytes, _size_bytes) { \ + .hdr = _hdr, \ + .off = (_offset_bytes) * bits_per_byte, \ + .size = (_size_bytes) * bits_per_byte, \ +} + +/* table containing properties of supported protocol header fields */ +static const +struct ice_flow_field_info ice_flds_info[ice_flow_field_idx_max] = { + /* ipv4 / ipv6 */ + /* ice_flow_field_idx_ipv4_sa */ + ice_flow_fld_info(ice_flow_seg_hdr_ipv4, 12, sizeof(struct in_addr)), + /* ice_flow_field_idx_ipv4_da */ + ice_flow_fld_info(ice_flow_seg_hdr_ipv4, 16, sizeof(struct in_addr)), + /* ice_flow_field_idx_ipv6_sa */ + ice_flow_fld_info(ice_flow_seg_hdr_ipv6, 8, sizeof(struct in6_addr)), + /* ice_flow_field_idx_ipv6_da */ + ice_flow_fld_info(ice_flow_seg_hdr_ipv6, 24, sizeof(struct in6_addr)), + /* transport */ + /* ice_flow_field_idx_tcp_src_port */ + ice_flow_fld_info(ice_flow_seg_hdr_tcp, 0, sizeof(__be16)), + /* ice_flow_field_idx_tcp_dst_port */ + ice_flow_fld_info(ice_flow_seg_hdr_tcp, 2, sizeof(__be16)), + /* ice_flow_field_idx_udp_src_port */ + ice_flow_fld_info(ice_flow_seg_hdr_udp, 0, sizeof(__be16)), + /* ice_flow_field_idx_udp_dst_port */ + ice_flow_fld_info(ice_flow_seg_hdr_udp, 2, sizeof(__be16)), +}; + +/** + * ice_flow_set_fld_ext - specifies locations of field from entry's input buffer + * @seg: packet segment the field being set belongs to + * @fld: field to be set + * @type: type of the field + * @val_loc: if not ice_flow_fld_off_inval, location of the value to match from + * entry's input buffer + * @mask_loc: if not ice_flow_fld_off_inval, location of mask value from entry's + * input buffer + * @last_loc: if not ice_flow_fld_off_inval, location of last/upper value from + * entry's input buffer + * + * this helper function stores information of a field being matched, including + * the type of the field and the locations of the value to match, the mask, and + * and the upper-bound value in the start of the input buffer for a flow entry. + * this function should only be used for fixed-size data structures. + * + * this function also opportunistically determines the protocol headers to be + * present based on the fields being set. some fields cannot be used alone to + * determine the protocol headers present. sometimes, fields for particular + * protocol headers are not matched. in those cases, the protocol headers + * must be explicitly set. + */ +static void +ice_flow_set_fld_ext(struct ice_flow_seg_info *seg, enum ice_flow_field fld, + enum ice_flow_fld_match_type type, u16 val_loc, + u16 mask_loc, u16 last_loc) +{ + u64 bit = bit_ull(fld); + + seg->match |= bit; + if (type == ice_flow_fld_type_range) + seg->range |= bit; + + seg->fields[fld].type = type; + seg->fields[fld].src.val = val_loc; + seg->fields[fld].src.mask = mask_loc; + seg->fields[fld].src.last = last_loc; + + ice_flow_set_hdrs(seg, ice_flds_info[fld].hdr); +} + +/** + * ice_flow_set_fld - specifies locations of field from entry's input buffer + * @seg: packet segment the field being set belongs to + * @fld: field to be set + * @val_loc: if not ice_flow_fld_off_inval, location of the value to match from + * entry's input buffer + * @mask_loc: if not ice_flow_fld_off_inval, location of mask value from entry's + * input buffer + * @last_loc: if not ice_flow_fld_off_inval, location of last/upper value from + * entry's input buffer + * @range: indicate if field being matched is to be in a range + * + * this function specifies the locations, in the form of byte offsets from the + * start of the input buffer for a flow entry, from where the value to match, + * the mask value, and upper value can be extracted. these locations are then + * stored in the flow profile. when adding a flow entry associated with the + * flow profile, these locations will be used to quickly extract the values and + * create the content of a match entry. this function should only be used for + * fixed-size data structures. + */ +static void +ice_flow_set_fld(struct ice_flow_seg_info *seg, enum ice_flow_field fld, + u16 val_loc, u16 mask_loc, u16 last_loc, bool range) +{ + enum ice_flow_fld_match_type t = range ? + ice_flow_fld_type_range : ice_flow_fld_type_reg; + + ice_flow_set_fld_ext(seg, fld, t, val_loc, mask_loc, last_loc); +} + +#define ice_flow_rss_seg_hdr_l3_masks \ + (ice_flow_seg_hdr_ipv4 | ice_flow_seg_hdr_ipv6) + +#define ice_flow_rss_seg_hdr_l4_masks \ + (ice_flow_seg_hdr_tcp | ice_flow_seg_hdr_udp | ice_flow_seg_hdr_sctp) + +#define ice_flow_rss_seg_hdr_val_masks \ + (ice_flow_rss_seg_hdr_l3_masks | \ + ice_flow_rss_seg_hdr_l4_masks) + +/** + * ice_flow_set_rss_seg_info - setup packet segments for rss + * @segs: pointer to the flow field segment(s) + * @hash_fields: fields to be hashed on for the segment(s) + * @flow_hdr: protocol header fields within a packet segment + * + * helper function to extract fields from hash bitmap and use flow + * header value to set flow field segment for further use in flow + * profile entry or removal. + */ +static enum ice_status +ice_flow_set_rss_seg_info(struct ice_flow_seg_info *segs, u64 hash_fields, + u32 flow_hdr) +{ + u64 val; + u8 i; + + for_each_set_bit(i, (unsigned long *)&hash_fields, + ice_flow_field_idx_max) + ice_flow_set_fld(segs, (enum ice_flow_field)i, + ice_flow_fld_off_inval, ice_flow_fld_off_inval, + ice_flow_fld_off_inval, false); + + ice_flow_set_hdrs(segs, flow_hdr); + + if (segs->hdrs & ~ice_flow_rss_seg_hdr_val_masks) + return ice_err_param; + + val = (u64)(segs->hdrs & ice_flow_rss_seg_hdr_l3_masks); + if (val && !is_power_of_2(val)) + return ice_err_cfg; + + val = (u64)(segs->hdrs & ice_flow_rss_seg_hdr_l4_masks); + if (val && !is_power_of_2(val)) + return ice_err_cfg; + + return 0; +} + +#define ice_rss_outer_headers 1 + +/** + * ice_add_rss_cfg_sync - add an rss configuration + * @hashed_flds: hash bit fields (ice_flow_hash_*) to configure + * @addl_hdrs: protocol header fields + * @segs_cnt: packet segment count + * + * assumption: lock has already been acquired for rss list + */ +static enum ice_status +ice_add_rss_cfg_sync(u64 hashed_flds, u32 addl_hdrs, u8 segs_cnt) +{ + struct ice_flow_seg_info *segs; + enum ice_status status; + + if (!segs_cnt || segs_cnt > ice_flow_seg_max) + return ice_err_param; + + segs = kcalloc(segs_cnt, sizeof(*segs), gfp_kernel); + if (!segs) + return ice_err_no_memory; + + /* construct the packet segment info from the hashed fields */ + status = ice_flow_set_rss_seg_info(&segs[segs_cnt - 1], hashed_flds, + addl_hdrs); + + kfree(segs); + return status; +} + +/** + * ice_add_rss_cfg - add an rss configuration with specified hashed fields + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * @hashed_flds: hash bit fields (ice_flow_hash_*) to configure + * @addl_hdrs: protocol header fields + * + * this function will generate a flow profile based on fields associated with + * the input fields to hash on, the flow type and use the vsi number to add + * a flow entry to the profile. + */ +enum ice_status +ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds, + u32 addl_hdrs) +{ + enum ice_status status; + + if (hashed_flds == ice_hash_invalid || + !ice_is_vsi_valid(hw, vsi_handle)) + return ice_err_param; + + mutex_lock(&hw->rss_locks); + status = ice_add_rss_cfg_sync(hashed_flds, addl_hdrs, + ice_rss_outer_headers); + mutex_unlock(&hw->rss_locks); + + return status; +} + +/** + * ice_replay_rss_cfg - replay rss configurations associated with vsi + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + */ +enum ice_status ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle) +{ + enum ice_status status = 0; + struct ice_rss_cfg *r; + + if (!ice_is_vsi_valid(hw, vsi_handle)) + return ice_err_param; + + mutex_lock(&hw->rss_locks); + list_for_each_entry(r, &hw->rss_list_head, l_entry) { + if (test_bit(vsi_handle, r->vsis)) { + status = ice_add_rss_cfg_sync(r->hashed_flds, + r->packet_hdr, + ice_rss_outer_headers); + if (status) + break; + } + } + mutex_unlock(&hw->rss_locks); + + return status; +} diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_flow.h +/* spdx-license-identifier: gpl-2.0 */ +/* copyright (c) 2019, intel corporation. */ + +#ifndef _ice_flow_h_ +#define _ice_flow_h_ + +#define ice_flow_fld_off_inval 0xffff + +/* generate flow hash field from flow field type(s) */ +#define ice_flow_hash_ipv4 \ + (bit_ull(ice_flow_field_idx_ipv4_sa) | \ + bit_ull(ice_flow_field_idx_ipv4_da)) +#define ice_flow_hash_ipv6 \ + (bit_ull(ice_flow_field_idx_ipv6_sa) | \ + bit_ull(ice_flow_field_idx_ipv6_da)) +#define ice_flow_hash_tcp_port \ + (bit_ull(ice_flow_field_idx_tcp_src_port) | \ + bit_ull(ice_flow_field_idx_tcp_dst_port)) +#define ice_flow_hash_udp_port \ + (bit_ull(ice_flow_field_idx_udp_src_port) | \ + bit_ull(ice_flow_field_idx_udp_dst_port)) + +#define ice_hash_invalid 0 +#define ice_hash_tcp_ipv4 (ice_flow_hash_ipv4 | ice_flow_hash_tcp_port) +#define ice_hash_tcp_ipv6 (ice_flow_hash_ipv6 | ice_flow_hash_tcp_port) +#define ice_hash_udp_ipv4 (ice_flow_hash_ipv4 | ice_flow_hash_udp_port) +#define ice_hash_udp_ipv6 (ice_flow_hash_ipv6 | ice_flow_hash_udp_port) + +/* protocol header fields within a packet segment. a segment consists of one or + * more protocol headers that make up a logical group of protocol headers. each + * logical group of protocol headers encapsulates or is encapsulated using/by + * tunneling or encapsulation protocols for network virtualization such as gre, + * vxlan, etc. + */ +enum ice_flow_seg_hdr { + ice_flow_seg_hdr_none = 0x00000000, + ice_flow_seg_hdr_ipv4 = 0x00000004, + ice_flow_seg_hdr_ipv6 = 0x00000008, + ice_flow_seg_hdr_tcp = 0x00000040, + ice_flow_seg_hdr_udp = 0x00000080, + ice_flow_seg_hdr_sctp = 0x00000100, +}; + +enum ice_flow_field { + /* l3 */ + ice_flow_field_idx_ipv4_sa, + ice_flow_field_idx_ipv4_da, + ice_flow_field_idx_ipv6_sa, + ice_flow_field_idx_ipv6_da, + /* l4 */ + ice_flow_field_idx_tcp_src_port, + ice_flow_field_idx_tcp_dst_port, + ice_flow_field_idx_udp_src_port, + ice_flow_field_idx_udp_dst_port, + /* the total number of enums must not exceed 64 */ + ice_flow_field_idx_max +}; + +#define ice_flow_seg_max 2 +#define ice_flow_set_hdrs(seg, val) ((seg)->hdrs |= (u32)(val)) + +struct ice_flow_seg_xtrct { + u8 prot_id; /* protocol id of extracted header field */ + u16 off; /* starting offset of the field in header in bytes */ + u8 idx; /* index of fv entry used */ + u8 disp; /* displacement of field in bits fr. fv entry's start */ +}; + +enum ice_flow_fld_match_type { + ice_flow_fld_type_reg, /* value, mask */ + ice_flow_fld_type_range, /* value, mask, last (upper bound) */ + ice_flow_fld_type_prefix, /* ip address, prefix, size of prefix */ + ice_flow_fld_type_size, /* value, mask, size of match */ +}; + +struct ice_flow_fld_loc { + /* describe offsets of field information relative to the beginning of + * input buffer provided when adding flow entries. + */ + u16 val; /* offset where the value is located */ + u16 mask; /* offset where the mask/prefix value is located */ + u16 last; /* length or offset where the upper value is located */ +}; + +struct ice_flow_fld_info { + enum ice_flow_fld_match_type type; + /* location where to retrieve data from an input buffer */ + struct ice_flow_fld_loc src; + /* location where to put the data into the final entry buffer */ + struct ice_flow_fld_loc entry; + struct ice_flow_seg_xtrct xtrct; +}; + +struct ice_flow_seg_info { + u32 hdrs; /* bitmask indicating protocol headers present */ + u64 match; /* bitmask indicating header fields to be matched */ + u64 range; /* bitmask indicating header fields matched as ranges */ + + struct ice_flow_fld_info fields[ice_flow_field_idx_max]; +}; + +struct ice_rss_cfg { + struct list_head l_entry; + /* bitmap of vsis added to the rss entry */ + declare_bitmap(vsis, ice_max_vsi); + u64 hashed_flds; + u32 packet_hdr; +}; + +enum ice_status ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle); +enum ice_status +ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds, + u32 addl_hdrs); +#endif /* _ice_flow_h_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c +#include "ice_flow.h" +/** + * ice_vsi_set_rss_flow_fld - sets rss input set for different flows + * @vsi: vsi to be configured + * + * this function will only be called after successful download package call + * during initialization of pf. since the downloaded package will erase the + * rss section, this function will configure rss input sets for different + * flow types. the last profile added has the highest priority, therefore 2 + * tuple profiles (i.e. ipv4 src/dst) are added before 4 tuple profiles + * (i.e. ipv4 src/dst tcp src/dst port). + */ +static void ice_vsi_set_rss_flow_fld(struct ice_vsi *vsi) +{ + u16 vsi_handle = vsi->idx, vsi_num = vsi->vsi_num; + struct ice_pf *pf = vsi->back; + struct ice_hw *hw = &pf->hw; + enum ice_status status; + struct device *dev; + + dev = ice_pf_to_dev(pf); + if (ice_is_safe_mode(pf)) { + dev_dbg(dev, "advanced rss disabled. package download failed, vsi num = %d ", + vsi_num); + return; + } + /* configure rss for ipv4 with input set ip src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_flow_hash_ipv4, + ice_flow_seg_hdr_ipv4); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for ipv4 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for ipv6 with input set ipv6 src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_flow_hash_ipv6, + ice_flow_seg_hdr_ipv6); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for ipv6 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for tcp4 with input set ip src/dst, tcp src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_hash_tcp_ipv4, + ice_flow_seg_hdr_tcp | ice_flow_seg_hdr_ipv4); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for tcp4 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for udp4 with input set ip src/dst, udp src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_hash_udp_ipv4, + ice_flow_seg_hdr_udp | ice_flow_seg_hdr_ipv4); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for udp4 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for sctp4 with input set ip src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_flow_hash_ipv4, + ice_flow_seg_hdr_sctp | ice_flow_seg_hdr_ipv4); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for sctp4 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for tcp6 with input set ipv6 src/dst, tcp src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_hash_tcp_ipv6, + ice_flow_seg_hdr_tcp | ice_flow_seg_hdr_ipv6); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for tcp6 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for udp6 with input set ipv6 src/dst, udp src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_hash_udp_ipv6, + ice_flow_seg_hdr_udp | ice_flow_seg_hdr_ipv6); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for udp6 flow, vsi = %d, error = %d ", + vsi_num, status); + + /* configure rss for sctp6 with input set ipv6 src/dst */ + status = ice_add_rss_cfg(hw, vsi_handle, ice_flow_hash_ipv6, + ice_flow_seg_hdr_sctp | ice_flow_seg_hdr_ipv6); + if (status) + dev_dbg(dev, "ice_add_rss_cfg failed for sctp6 flow, vsi = %d, error = %d ", + vsi_num, status); +} + - if (test_bit(ice_flag_rss_ena, pf->flags)) + if (test_bit(ice_flag_rss_ena, pf->flags)) { + ice_vsi_set_rss_flow_fld(vsi); + } diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h --- a/drivers/net/ethernet/intel/ice/ice_type.h +++ b/drivers/net/ethernet/intel/ice/ice_type.h + struct mutex fl_profs_locks[ice_blk_count]; /* lock fltr profiles */ + struct list_head fl_profs[ice_blk_count]; + struct mutex rss_locks; /* protect rss configuration */ + struct list_head rss_list_head;
|
Networking
|
c90ed40cefe187a20fc565650b119aa696abc2ed
|
tony nguyen
|
drivers
|
net
|
ethernet, ice, intel
|
ice: allocate flow profile
|
create an extraction sequence based on the packet header protocols to be programmed and allocate a flow profile for the extraction sequence.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['h', 'c']
| 12
| 864
| 40
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h --- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +#define ice_aqc_res_type_hash_prof_bldr_profid 0x60 + +#define ice_aqc_res_type_flag_scan_bottom bit(12) +#define ice_aqc_res_type_flag_ignore_index bit(13) + +#define ice_aqc_res_type_flag_dedicated 0x00 diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c +/** + * ice_aq_alloc_free_res - command to allocate/free resources + * @hw: pointer to the hw struct + * @num_entries: number of resource entries in buffer + * @buf: indirect buffer to hold data parameters and response + * @buf_size: size of buffer for indirect commands + * @opc: pass in the command opcode + * @cd: pointer to command details structure or null + * + * helper function to allocate/free resources using the admin queue commands + */ +enum ice_status +ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries, + struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size, + enum ice_adminq_opc opc, struct ice_sq_cd *cd) +{ + struct ice_aqc_alloc_free_res_cmd *cmd; + struct ice_aq_desc desc; + + cmd = &desc.params.sw_res_ctrl; + + if (!buf) + return ice_err_param; + + if (buf_size < (num_entries * sizeof(buf->elem[0]))) + return ice_err_param; + + ice_fill_dflt_direct_cmd_desc(&desc, opc); + + desc.flags |= cpu_to_le16(ice_aq_flag_rd); + + cmd->num_entries = cpu_to_le16(num_entries); + + return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd); +} + +/** + * ice_alloc_hw_res - allocate resource + * @hw: pointer to the hw struct + * @type: type of resource + * @num: number of resources to allocate + * @btm: allocate from bottom + * @res: pointer to array that will receive the resources + */ +enum ice_status +ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res) +{ + struct ice_aqc_alloc_free_res_elem *buf; + enum ice_status status; + u16 buf_len; + + buf_len = struct_size(buf, elem, num - 1); + buf = kzalloc(buf_len, gfp_kernel); + if (!buf) + return ice_err_no_memory; + + /* prepare buffer to allocate resource. */ + buf->num_elems = cpu_to_le16(num); + buf->res_type = cpu_to_le16(type | ice_aqc_res_type_flag_dedicated | + ice_aqc_res_type_flag_ignore_index); + if (btm) + buf->res_type |= cpu_to_le16(ice_aqc_res_type_flag_scan_bottom); + + status = ice_aq_alloc_free_res(hw, 1, buf, buf_len, + ice_aqc_opc_alloc_res, null); + if (status) + goto ice_alloc_res_exit; + + memcpy(res, buf->elem, sizeof(buf->elem) * num); + +ice_alloc_res_exit: + kfree(buf); + return status; +} + diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h --- a/drivers/net/ethernet/intel/ice/ice_common.h +++ b/drivers/net/ethernet/intel/ice/ice_common.h +enum ice_status +ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res); +ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries, + struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size, + enum ice_adminq_opc opc, struct ice_sq_cd *cd); +enum ice_status diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +/** + * ice_find_prof_id - find profile id for a given field vector + * @hw: pointer to the hardware structure + * @blk: hw block + * @fv: field vector to search for + * @prof_id: receives the profile id + */ +static enum ice_status +ice_find_prof_id(struct ice_hw *hw, enum ice_block blk, + struct ice_fv_word *fv, u8 *prof_id) +{ + struct ice_es *es = &hw->blk[blk].es; + u16 off, i; + + for (i = 0; i < es->count; i++) { + off = i * es->fvw; + + if (memcmp(&es->t[off], fv, es->fvw * sizeof(*fv))) + continue; + + *prof_id = i; + return 0; + } + + return ice_err_does_not_exist; +} + +/** + * ice_prof_id_rsrc_type - get profile id resource type for a block type + * @blk: the block type + * @rsrc_type: pointer to variable to receive the resource type + */ +static bool ice_prof_id_rsrc_type(enum ice_block blk, u16 *rsrc_type) +{ + switch (blk) { + case ice_blk_rss: + *rsrc_type = ice_aqc_res_type_hash_prof_bldr_profid; + break; + default: + return false; + } + return true; +} + +/** + * ice_alloc_prof_id - allocate profile id + * @hw: pointer to the hw struct + * @blk: the block to allocate the profile id for + * @prof_id: pointer to variable to receive the profile id + * + * this function allocates a new profile id, which also corresponds to a field + * vector (extraction sequence) entry. + */ +static enum ice_status +ice_alloc_prof_id(struct ice_hw *hw, enum ice_block blk, u8 *prof_id) +{ + enum ice_status status; + u16 res_type; + u16 get_prof; + + if (!ice_prof_id_rsrc_type(blk, &res_type)) + return ice_err_param; + + status = ice_alloc_hw_res(hw, res_type, 1, false, &get_prof); + if (!status) + *prof_id = (u8)get_prof; + + return status; +} + +/** + * ice_prof_inc_ref - increment reference count for profile + * @hw: pointer to the hw struct + * @blk: the block from which to free the profile id + * @prof_id: the profile id for which to increment the reference count + */ +static enum ice_status +ice_prof_inc_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id) +{ + if (prof_id > hw->blk[blk].es.count) + return ice_err_param; + + hw->blk[blk].es.ref_count[prof_id]++; + + return 0; +} + +/** + * ice_write_es - write an extraction sequence to hardware + * @hw: pointer to the hw struct + * @blk: the block in which to write the extraction sequence + * @prof_id: the profile id to write + * @fv: pointer to the extraction sequence to write - null to clear extraction + */ +static void +ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id, + struct ice_fv_word *fv) +{ + u16 off; + + off = prof_id * hw->blk[blk].es.fvw; + if (!fv) { + memset(&hw->blk[blk].es.t[off], 0, + hw->blk[blk].es.fvw * sizeof(*fv)); + hw->blk[blk].es.written[prof_id] = false; + } else { + memcpy(&hw->blk[blk].es.t[off], fv, + hw->blk[blk].es.fvw * sizeof(*fv)); + } +} + + +/** + * ice_add_prof - add profile + * @hw: pointer to the hw struct + * @blk: hardware block + * @id: profile tracking id + * @ptypes: array of bitmaps indicating ptypes (ice_flow_ptype_max bits) + * @es: extraction sequence (length of array is determined by the block) + * + * this function registers a profile, which matches a set of ptgs with a + * particular extraction sequence. while the hardware profile is allocated + * it will not be written until the first call to ice_add_flow that specifies + * the id value used here. + */ +enum ice_status +ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[], + struct ice_fv_word *es) +{ + u32 bytes = div_round_up(ice_flow_ptype_max, bits_per_byte); + declare_bitmap(ptgs_used, ice_xlt1_cnt); + struct ice_prof_map *prof; + enum ice_status status; + u32 byte = 0; + u8 prof_id; + + bitmap_zero(ptgs_used, ice_xlt1_cnt); + + mutex_lock(&hw->blk[blk].es.prof_map_lock); + + /* search for existing profile */ + status = ice_find_prof_id(hw, blk, es, &prof_id); + if (status) { + /* allocate profile id */ + status = ice_alloc_prof_id(hw, blk, &prof_id); + if (status) + goto err_ice_add_prof; + + /* and write new es */ + ice_write_es(hw, blk, prof_id, es); + } + + ice_prof_inc_ref(hw, blk, prof_id); + + /* add profile info */ + prof = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*prof), gfp_kernel); + if (!prof) + goto err_ice_add_prof; + + prof->profile_cookie = id; + prof->prof_id = prof_id; + prof->ptg_cnt = 0; + prof->context = 0; + + /* build list of ptgs */ + while (bytes && prof->ptg_cnt < ice_max_ptg_per_profile) { + u32 bit; + + if (!ptypes[byte]) { + bytes--; + byte++; + continue; + } + + /* examine 8 bits per byte */ + for_each_set_bit(bit, (unsigned long *)&ptypes[byte], + bits_per_byte) { + u16 ptype; + u8 ptg; + u8 m; + + ptype = byte * bits_per_byte + bit; + + /* the package should place all ptypes in a non-zero + * ptg, so the following call should never fail. + */ + if (ice_ptg_find_ptype(hw, blk, ptype, &ptg)) + continue; + + /* if ptg is already added, skip and continue */ + if (test_bit(ptg, ptgs_used)) + continue; + + set_bit(ptg, ptgs_used); + prof->ptg[prof->ptg_cnt] = ptg; + + if (++prof->ptg_cnt >= ice_max_ptg_per_profile) + break; + + /* nothing left in byte, then exit */ + m = ~((1 << (bit + 1)) - 1); + if (!(ptypes[byte] & m)) + break; + } + + bytes--; + byte++; + } + + list_add(&prof->list, &hw->blk[blk].es.prof_map); + status = 0; + +err_ice_add_prof: + mutex_unlock(&hw->blk[blk].es.prof_map_lock); + return status; +} diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h +enum ice_status +ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[], + struct ice_fv_word *es); diff --git a/drivers/net/ethernet/intel/ice/ice_flex_type.h b/drivers/net/ethernet/intel/ice/ice_flex_type.h --- a/drivers/net/ethernet/intel/ice/ice_flex_type.h +++ b/drivers/net/ethernet/intel/ice/ice_flex_type.h + +#define ice_fv_offset_inval 0x1ff + +#define ice_max_ptg_per_profile 32 + +struct ice_prof_map { + struct list_head list; + u64 profile_cookie; + u64 context; + u8 prof_id; + u8 ptg_cnt; + u8 ptg[ice_max_ptg_per_profile]; +}; + +#define ice_flow_ptype_max ice_xlt1_cnt diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c --- a/drivers/net/ethernet/intel/ice/ice_flow.c +++ b/drivers/net/ethernet/intel/ice/ice_flow.c +/* bitmaps indicating relevant packet types for a particular protocol header + * + * packet types for packets with an outer/first/single ipv4 header + */ +static const u32 ice_ptypes_ipv4_ofos[] = { + 0x1dc00000, 0x04000800, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* packet types for packets with an innermost/last ipv4 header */ +static const u32 ice_ptypes_ipv4_il[] = { + 0xe0000000, 0xb807700e, 0x80000003, 0xe01dc03b, + 0x0000000e, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* packet types for packets with an outer/first/single ipv6 header */ +static const u32 ice_ptypes_ipv6_ofos[] = { + 0x00000000, 0x00000000, 0x77000000, 0x10002000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* packet types for packets with an innermost/last ipv6 header */ +static const u32 ice_ptypes_ipv6_il[] = { + 0x00000000, 0x03b80770, 0x000001dc, 0x0ee00000, + 0x00000770, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* udp packet types for non-tunneled packets or tunneled + * packets with inner udp. + */ +static const u32 ice_ptypes_udp_il[] = { + 0x81000000, 0x20204040, 0x04000010, 0x80810102, + 0x00000040, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* packet types for packets with an innermost/last tcp header */ +static const u32 ice_ptypes_tcp_il[] = { + 0x04000000, 0x80810102, 0x10000040, 0x02040408, + 0x00000102, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* packet types for packets with an innermost/last sctp header */ +static const u32 ice_ptypes_sctp_il[] = { + 0x08000000, 0x01020204, 0x20000081, 0x04080810, + 0x00000204, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; + +/* manage parameters and info. used during the creation of a flow profile */ +struct ice_flow_prof_params { + enum ice_block blk; + u16 entry_length; /* # of bytes formatted entry will require */ + u8 es_cnt; + struct ice_flow_prof *prof; + + /* for acl, the es[0] will have the data of ice_rx_mdid_pkt_flags_15_0 + * this will give us the direction flags. + */ + struct ice_fv_word es[ice_max_fv_words]; + declare_bitmap(ptypes, ice_flow_ptype_max); +}; + +#define ice_flow_seg_hdrs_l3_mask \ + (ice_flow_seg_hdr_ipv4 | ice_flow_seg_hdr_ipv6) +#define ice_flow_seg_hdrs_l4_mask \ + (ice_flow_seg_hdr_tcp | ice_flow_seg_hdr_udp | ice_flow_seg_hdr_sctp) + +/** + * ice_flow_val_hdrs - validates packet segments for valid protocol headers + * @segs: array of one or more packet segments that describe the flow + * @segs_cnt: number of packet segments provided + */ +static enum ice_status +ice_flow_val_hdrs(struct ice_flow_seg_info *segs, u8 segs_cnt) +{ + u8 i; + + for (i = 0; i < segs_cnt; i++) { + /* multiple l3 headers */ + if (segs[i].hdrs & ice_flow_seg_hdrs_l3_mask && + !is_power_of_2(segs[i].hdrs & ice_flow_seg_hdrs_l3_mask)) + return ice_err_param; + + /* multiple l4 headers */ + if (segs[i].hdrs & ice_flow_seg_hdrs_l4_mask && + !is_power_of_2(segs[i].hdrs & ice_flow_seg_hdrs_l4_mask)) + return ice_err_param; + } + + return 0; +} + +/** + * ice_flow_proc_seg_hdrs - process protocol headers present in pkt segments + * @params: information about the flow to be processed + * + * this function identifies the packet types associated with the protocol + * headers being present in packet segments of the specified flow profile. + */ +static enum ice_status +ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params) +{ + struct ice_flow_prof *prof; + u8 i; + + memset(params->ptypes, 0xff, sizeof(params->ptypes)); + + prof = params->prof; + + for (i = 0; i < params->prof->segs_cnt; i++) { + const unsigned long *src; + u32 hdrs; + + hdrs = prof->segs[i].hdrs; + + if (hdrs & ice_flow_seg_hdr_ipv4) { + src = !i ? (const unsigned long *)ice_ptypes_ipv4_ofos : + (const unsigned long *)ice_ptypes_ipv4_il; + bitmap_and(params->ptypes, params->ptypes, src, + ice_flow_ptype_max); + } else if (hdrs & ice_flow_seg_hdr_ipv6) { + src = !i ? (const unsigned long *)ice_ptypes_ipv6_ofos : + (const unsigned long *)ice_ptypes_ipv6_il; + bitmap_and(params->ptypes, params->ptypes, src, + ice_flow_ptype_max); + } + + if (hdrs & ice_flow_seg_hdr_udp) { + src = (const unsigned long *)ice_ptypes_udp_il; + bitmap_and(params->ptypes, params->ptypes, src, + ice_flow_ptype_max); + } else if (hdrs & ice_flow_seg_hdr_tcp) { + bitmap_and(params->ptypes, params->ptypes, + (const unsigned long *)ice_ptypes_tcp_il, + ice_flow_ptype_max); + } else if (hdrs & ice_flow_seg_hdr_sctp) { + src = (const unsigned long *)ice_ptypes_sctp_il; + bitmap_and(params->ptypes, params->ptypes, src, + ice_flow_ptype_max); + } + } + + return 0; +} + +/** + * ice_flow_xtract_fld - create an extraction sequence entry for the given field + * @hw: pointer to the hw struct + * @params: information about the flow to be processed + * @seg: packet segment index of the field to be extracted + * @fld: id of field to be extracted + * + * this function determines the protocol id, offset, and size of the given + * field. it then allocates one or more extraction sequence entries for the + * given field, and fill the entries with protocol id and offset information. + */ +static enum ice_status +ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params, + u8 seg, enum ice_flow_field fld) +{ + enum ice_prot_id prot_id = ice_prot_id_inval; + u8 fv_words = hw->blk[params->blk].es.fvw; + struct ice_flow_fld_info *flds; + u16 cnt, ese_bits, i; + u16 off; + + flds = params->prof->segs[seg].fields; + + switch (fld) { + case ice_flow_field_idx_ipv4_sa: + case ice_flow_field_idx_ipv4_da: + prot_id = seg == 0 ? ice_prot_ipv4_of_or_s : ice_prot_ipv4_il; + break; + case ice_flow_field_idx_ipv6_sa: + case ice_flow_field_idx_ipv6_da: + prot_id = seg == 0 ? ice_prot_ipv6_of_or_s : ice_prot_ipv6_il; + break; + case ice_flow_field_idx_tcp_src_port: + case ice_flow_field_idx_tcp_dst_port: + prot_id = ice_prot_tcp_il; + break; + case ice_flow_field_idx_udp_src_port: + case ice_flow_field_idx_udp_dst_port: + prot_id = ice_prot_udp_il_or_s; + break; + default: + return ice_err_not_impl; + } + + /* each extraction sequence entry is a word in size, and extracts a + * word-aligned offset from a protocol header. + */ + ese_bits = ice_flow_fv_extract_sz * bits_per_byte; + + flds[fld].xtrct.prot_id = prot_id; + flds[fld].xtrct.off = (ice_flds_info[fld].off / ese_bits) * + ice_flow_fv_extract_sz; + flds[fld].xtrct.disp = (u8)(ice_flds_info[fld].off % ese_bits); + flds[fld].xtrct.idx = params->es_cnt; + + /* adjust the next field-entry index after accommodating the number of + * entries this field consumes + */ + cnt = div_round_up(flds[fld].xtrct.disp + ice_flds_info[fld].size, + ese_bits); + + /* fill in the extraction sequence entries needed for this field */ + off = flds[fld].xtrct.off; + for (i = 0; i < cnt; i++) { + u8 idx; + + /* make sure the number of extraction sequence required + * does not exceed the block's capability + */ + if (params->es_cnt >= fv_words) + return ice_err_max_limit; + + /* some blocks require a reversed field vector layout */ + if (hw->blk[params->blk].es.reverse) + idx = fv_words - params->es_cnt - 1; + else + idx = params->es_cnt; + + params->es[idx].prot_id = prot_id; + params->es[idx].off = off; + params->es_cnt++; + + off += ice_flow_fv_extract_sz; + } + + return 0; +} + +/** + * ice_flow_create_xtrct_seq - create an extraction sequence for given segments + * @hw: pointer to the hw struct + * @params: information about the flow to be processed + * + * this function iterates through all matched fields in the given segments, and + * creates an extraction sequence for the fields. + */ +static enum ice_status +ice_flow_create_xtrct_seq(struct ice_hw *hw, + struct ice_flow_prof_params *params) +{ + struct ice_flow_prof *prof = params->prof; + enum ice_status status = 0; + u8 i; + + for (i = 0; i < prof->segs_cnt; i++) { + u8 j; + + for_each_set_bit(j, (unsigned long *)&prof->segs[i].match, + ice_flow_field_idx_max) { + status = ice_flow_xtract_fld(hw, params, i, + (enum ice_flow_field)j); + if (status) + return status; + } + } + + return status; +} + +/** + * ice_flow_proc_segs - process all packet segments associated with a profile + * @hw: pointer to the hw struct + * @params: information about the flow to be processed + */ +static enum ice_status +ice_flow_proc_segs(struct ice_hw *hw, struct ice_flow_prof_params *params) +{ + enum ice_status status; + + status = ice_flow_proc_seg_hdrs(params); + if (status) + return status; + + status = ice_flow_create_xtrct_seq(hw, params); + if (status) + return status; + + switch (params->blk) { + case ice_blk_rss: + /* only header information is provided for rss configuration. + * no further processing is needed. + */ + status = 0; + break; + default: + return ice_err_not_impl; + } + + return status; +} + +/** + * ice_flow_add_prof_sync - add a flow profile for packet segments and fields + * @hw: pointer to the hw struct + * @blk: classification stage + * @dir: flow direction + * @prof_id: unique id to identify this flow profile + * @segs: array of one or more packet segments that describe the flow + * @segs_cnt: number of packet segments provided + * @prof: stores the returned flow profile added + * + * assumption: the caller has acquired the lock to the profile list + */ +static enum ice_status +ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk, + enum ice_flow_dir dir, u64 prof_id, + struct ice_flow_seg_info *segs, u8 segs_cnt, + struct ice_flow_prof **prof) +{ + struct ice_flow_prof_params params; + enum ice_status status; + u8 i; + + if (!prof) + return ice_err_bad_ptr; + + memset(¶ms, 0, sizeof(params)); + params.prof = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*params.prof), + gfp_kernel); + if (!params.prof) + return ice_err_no_memory; + + /* initialize extraction sequence to all invalid (0xff) */ + for (i = 0; i < ice_max_fv_words; i++) { + params.es[i].prot_id = ice_prot_invalid; + params.es[i].off = ice_fv_offset_inval; + } + + params.blk = blk; + params.prof->id = prof_id; + params.prof->dir = dir; + params.prof->segs_cnt = segs_cnt; + + /* make a copy of the segments that need to be persistent in the flow + * profile instance + */ + for (i = 0; i < segs_cnt; i++) + memcpy(¶ms.prof->segs[i], &segs[i], sizeof(*segs)); + + status = ice_flow_proc_segs(hw, ¶ms); + if (status) { + ice_debug(hw, ice_dbg_flow, + "error processing a flow's packet segments "); + goto out; + } + + /* add a hw profile for this flow profile */ + status = ice_add_prof(hw, blk, prof_id, (u8 *)params.ptypes, params.es); + if (status) { + ice_debug(hw, ice_dbg_flow, "error adding a hw flow profile "); + goto out; + } + + init_list_head(¶ms.prof->entries); + mutex_init(¶ms.prof->entries_lock); + *prof = params.prof; + +out: + if (status) + devm_kfree(ice_hw_to_dev(hw), params.prof); + + return status; +} + +/** + * ice_flow_add_prof - add a flow profile for packet segments and matched fields + * @hw: pointer to the hw struct + * @blk: classification stage + * @dir: flow direction + * @prof_id: unique id to identify this flow profile + * @segs: array of one or more packet segments that describe the flow + * @segs_cnt: number of packet segments provided + */ +static enum ice_status +ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir, + u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt) +{ + struct ice_flow_prof *prof = null; + enum ice_status status; + + if (segs_cnt > ice_flow_seg_max) + return ice_err_max_limit; + + if (!segs_cnt) + return ice_err_param; + + if (!segs) + return ice_err_bad_ptr; + + status = ice_flow_val_hdrs(segs, segs_cnt); + if (status) + return status; + + mutex_lock(&hw->fl_profs_locks[blk]); + + status = ice_flow_add_prof_sync(hw, blk, dir, prof_id, segs, segs_cnt, + &prof); + if (!status) + list_add(&prof->l_entry, &hw->fl_profs[blk]); + + mutex_unlock(&hw->fl_profs_locks[blk]); + + return status; +} + +#define ice_flow_prof_hash_s 0 +#define ice_flow_prof_hash_m (0xffffffffull << ice_flow_prof_hash_s) +#define ice_flow_prof_hdr_s 32 +#define ice_flow_prof_hdr_m (0x3fffffffull << ice_flow_prof_hdr_s) +#define ice_flow_prof_encap_s 63 +#define ice_flow_prof_encap_m (bit_ull(ice_flow_prof_encap_s)) + +/* flow profile id format: + * [0:31] - packet match fields + * [32:62] - protocol header + * [63] - encapsulation flag, 0 if non-tunneled, 1 if tunneled + */ +#define ice_flow_gen_profid(hash, hdr, segs_cnt) \ + (u64)(((u64)(hash) & ice_flow_prof_hash_m) | \ + (((u64)(hdr) << ice_flow_prof_hdr_s) & ice_flow_prof_hdr_m) | \ + ((u8)((segs_cnt) - 1) ? ice_flow_prof_encap_m : 0)) + + * @hw: pointer to the hardware structure -ice_add_rss_cfg_sync(u64 hashed_flds, u32 addl_hdrs, u8 segs_cnt) +ice_add_rss_cfg_sync(struct ice_hw *hw, u64 hashed_flds, u32 addl_hdrs, + u8 segs_cnt) - + if (status) + goto exit; + + /* create a new flow profile with generated profile and packet + * segment information. + */ + status = ice_flow_add_prof(hw, ice_blk_rss, ice_flow_rx, + ice_flow_gen_profid(hashed_flds, + segs[segs_cnt - 1].hdrs, + segs_cnt), + segs, segs_cnt); + +exit: - status = ice_add_rss_cfg_sync(hashed_flds, addl_hdrs, + status = ice_add_rss_cfg_sync(hw, hashed_flds, addl_hdrs, - status = ice_add_rss_cfg_sync(r->hashed_flds, + status = ice_add_rss_cfg_sync(hw, r->hashed_flds, diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h --- a/drivers/net/ethernet/intel/ice/ice_flow.h +++ b/drivers/net/ethernet/intel/ice/ice_flow.h +enum ice_flow_dir { + ice_flow_rx = 0x02, +}; + +#define ice_flow_fv_extract_sz 2 + +struct ice_flow_prof { + struct list_head l_entry; + + u64 id; + enum ice_flow_dir dir; + u8 segs_cnt; + + /* keep track of flow entries associated with this flow profile */ + struct mutex entries_lock; + struct list_head entries; + + struct ice_flow_seg_info segs[ice_flow_seg_max]; + + /* software vsi handles referenced by this flow profile */ + declare_bitmap(vsis, ice_max_vsi); +}; + diff --git a/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h b/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h --- a/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h +++ b/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h +/* receive descriptor mdid values that access packet flags */ +enum ice_flex_mdid_pkt_flags { + ice_rx_mdid_pkt_flags_15_0 = 20, + ice_rx_mdid_pkt_flags_31_16, + ice_rx_mdid_pkt_flags_47_32, + ice_rx_mdid_pkt_flags_63_48, +}; + diff --git a/drivers/net/ethernet/intel/ice/ice_protocol_type.h b/drivers/net/ethernet/intel/ice/ice_protocol_type.h --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_protocol_type.h +/* spdx-license-identifier: gpl-2.0 */ +/* copyright (c) 2019, intel corporation. */ + +#ifndef _ice_protocol_type_h_ +#define _ice_protocol_type_h_ +/* decoders for ice_prot_id: + * - f: first + * - i: inner + * - l: last + * - o: outer + * - s: single + */ +enum ice_prot_id { + ice_prot_id_inval = 0, + ice_prot_ipv4_of_or_s = 32, + ice_prot_ipv4_il = 33, + ice_prot_ipv6_of_or_s = 40, + ice_prot_ipv6_il = 41, + ice_prot_tcp_il = 49, + ice_prot_udp_il_or_s = 53, + ice_prot_meta_id = 255, /* when offset == metadata */ + ice_prot_invalid = 255 /* when offset == ice_fv_offset_inval */ +}; +#endif /* _ice_protocol_type_h_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c -/** - * ice_aq_alloc_free_res - command to allocate/free resources - * @hw: pointer to the hw struct - * @num_entries: number of resource entries in buffer - * @buf: indirect buffer to hold data parameters and response - * @buf_size: size of buffer for indirect commands - * @opc: pass in the command opcode - * @cd: pointer to command details structure or null - * - * helper function to allocate/free resources using the admin queue commands - */ -static enum ice_status -ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries, - struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size, - enum ice_adminq_opc opc, struct ice_sq_cd *cd) -{ - struct ice_aqc_alloc_free_res_cmd *cmd; - struct ice_aq_desc desc; - - cmd = &desc.params.sw_res_ctrl; - - if (!buf) - return ice_err_param; - - if (buf_size < (num_entries * sizeof(buf->elem[0]))) - return ice_err_param; - - ice_fill_dflt_direct_cmd_desc(&desc, opc); - - desc.flags |= cpu_to_le16(ice_aq_flag_rd); - - cmd->num_entries = cpu_to_le16(num_entries); - - return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd); -} - diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h --- a/drivers/net/ethernet/intel/ice/ice_type.h +++ b/drivers/net/ethernet/intel/ice/ice_type.h +#include "ice_protocol_type.h" +#define ice_dbg_flow bit_ull(9)
|
Networking
|
31ad4e4ee1e4e2e12985e46aa6263c8bd5ad4271
|
tony nguyen andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: populate tcam filter software structures
|
store the tcam entry with the profile data and the vsi group in the respective sw structures. this will be subsequently used to write out the tables to hardware.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['h', 'c']
| 8
| 1,459
| 10
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h --- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +#define ice_aqc_res_type_hash_prof_bldr_tcam 0x61 diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c +/** + * ice_free_hw_res - free allocated hw resource + * @hw: pointer to the hw struct + * @type: type of resource to free + * @num: number of resources + * @res: pointer to array that contains the resources to free + */ +enum ice_status +ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res) +{ + struct ice_aqc_alloc_free_res_elem *buf; + enum ice_status status; + u16 buf_len; + + buf_len = struct_size(buf, elem, num - 1); + buf = kzalloc(buf_len, gfp_kernel); + if (!buf) + return ice_err_no_memory; + + /* prepare buffer to free resource. */ + buf->num_elems = cpu_to_le16(num); + buf->res_type = cpu_to_le16(type); + memcpy(buf->elem, res, sizeof(buf->elem) * num); + + status = ice_aq_alloc_free_res(hw, num, buf, buf_len, + ice_aqc_opc_free_res, null); + if (status) + ice_debug(hw, ice_dbg_sw, "cq cmd buffer: "); + + kfree(buf); + return status; +} + diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h --- a/drivers/net/ethernet/intel/ice/ice_common.h +++ b/drivers/net/ethernet/intel/ice/ice_common.h +enum ice_status +ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res); diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +/* key creation */ + +#define ice_dc_key 0x1 /* don't care */ +#define ice_dc_keyinv 0x1 +#define ice_nm_key 0x0 /* never match */ +#define ice_nm_keyinv 0x0 +#define ice_0_key 0x1 /* match 0 */ +#define ice_0_keyinv 0x0 +#define ice_1_key 0x0 /* match 1 */ +#define ice_1_keyinv 0x1 + +/** + * ice_gen_key_word - generate 16-bits of a key/mask word + * @val: the value + * @valid: valid bits mask (change only the valid bits) + * @dont_care: don't care mask + * @nvr_mtch: never match mask + * @key: pointer to an array of where the resulting key portion + * @key_inv: pointer to an array of where the resulting key invert portion + * + * this function generates 16-bits from a 8-bit value, an 8-bit don't care mask + * and an 8-bit never match mask. the 16-bits of output are divided into 8 bits + * of key and 8 bits of key invert. + * + * '0' = b01, always match a 0 bit + * '1' = b10, always match a 1 bit + * '?' = b11, don't care bit (always matches) + * '~' = b00, never match bit + * + * input: + * val: b0 1 0 1 0 1 + * dont_care: b0 0 1 1 0 0 + * never_mtch: b0 0 0 0 1 1 + * ------------------------------ + * result: key: b01 10 11 11 00 00 + */ +static enum ice_status +ice_gen_key_word(u8 val, u8 valid, u8 dont_care, u8 nvr_mtch, u8 *key, + u8 *key_inv) +{ + u8 in_key = *key, in_key_inv = *key_inv; + u8 i; + + /* 'dont_care' and 'nvr_mtch' masks cannot overlap */ + if ((dont_care ^ nvr_mtch) != (dont_care | nvr_mtch)) + return ice_err_cfg; + + *key = 0; + *key_inv = 0; + + /* encode the 8 bits into 8-bit key and 8-bit key invert */ + for (i = 0; i < 8; i++) { + *key >>= 1; + *key_inv >>= 1; + + if (!(valid & 0x1)) { /* change only valid bits */ + *key |= (in_key & 0x1) << 7; + *key_inv |= (in_key_inv & 0x1) << 7; + } else if (dont_care & 0x1) { /* don't care bit */ + *key |= ice_dc_key << 7; + *key_inv |= ice_dc_keyinv << 7; + } else if (nvr_mtch & 0x1) { /* never match bit */ + *key |= ice_nm_key << 7; + *key_inv |= ice_nm_keyinv << 7; + } else if (val & 0x01) { /* exact 1 match */ + *key |= ice_1_key << 7; + *key_inv |= ice_1_keyinv << 7; + } else { /* exact 0 match */ + *key |= ice_0_key << 7; + *key_inv |= ice_0_keyinv << 7; + } + + dont_care >>= 1; + nvr_mtch >>= 1; + valid >>= 1; + val >>= 1; + in_key >>= 1; + in_key_inv >>= 1; + } + + return 0; +} + +/** + * ice_bits_max_set - determine if the number of bits set is within a maximum + * @mask: pointer to the byte array which is the mask + * @size: the number of bytes in the mask + * @max: the max number of set bits + * + * this function determines if there are at most 'max' number of bits set in an + * array. returns true if the number for bits set is <= max or will return false + * otherwise. + */ +static bool ice_bits_max_set(const u8 *mask, u16 size, u16 max) +{ + u16 count = 0; + u16 i; + + /* check each byte */ + for (i = 0; i < size; i++) { + /* if 0, go to next byte */ + if (!mask[i]) + continue; + + /* we know there is at least one set bit in this byte because of + * the above check; if we already have found 'max' number of + * bits set, then we can return failure now. + */ + if (count == max) + return false; + + /* count the bits in this byte, checking threshold */ + count += hweight8(mask[i]); + if (count > max) + return false; + } + + return true; +} + +/** + * ice_set_key - generate a variable sized key with multiples of 16-bits + * @key: pointer to where the key will be stored + * @size: the size of the complete key in bytes (must be even) + * @val: array of 8-bit values that makes up the value portion of the key + * @upd: array of 8-bit masks that determine what key portion to update + * @dc: array of 8-bit masks that make up the don't care mask + * @nm: array of 8-bit masks that make up the never match mask + * @off: the offset of the first byte in the key to update + * @len: the number of bytes in the key update + * + * this function generates a key from a value, a don't care mask and a never + * match mask. + * upd, dc, and nm are optional parameters, and can be null: + * upd == null --> udp mask is all 1's (update all bits) + * dc == null --> dc mask is all 0's (no don't care bits) + * nm == null --> nm mask is all 0's (no never match bits) + */ +static enum ice_status +ice_set_key(u8 *key, u16 size, u8 *val, u8 *upd, u8 *dc, u8 *nm, u16 off, + u16 len) +{ + u16 half_size; + u16 i; + + /* size must be a multiple of 2 bytes. */ + if (size % 2) + return ice_err_cfg; + + half_size = size / 2; + if (off + len > half_size) + return ice_err_cfg; + + /* make sure at most one bit is set in the never match mask. having more + * than one never match mask bit set will cause hw to consume excessive + * power otherwise; this is a power management efficiency check. + */ +#define ice_nvr_mtch_bits_max 1 + if (nm && !ice_bits_max_set(nm, len, ice_nvr_mtch_bits_max)) + return ice_err_cfg; + + for (i = 0; i < len; i++) + if (ice_gen_key_word(val[i], upd ? upd[i] : 0xff, + dc ? dc[i] : 0, nm ? nm[i] : 0, + key + off + i, key + half_size + off + i)) + return ice_err_cfg; + + return 0; +} + +/* characteristic handling */ + +/** + * ice_match_prop_lst - determine if properties of two lists match + * @list1: first properties list + * @list2: second properties list + * + * count, cookies and the order must match in order to be considered equivalent. + */ +static bool +ice_match_prop_lst(struct list_head *list1, struct list_head *list2) +{ + struct ice_vsig_prof *tmp1; + struct ice_vsig_prof *tmp2; + u16 chk_count = 0; + u16 count = 0; + + /* compare counts */ + list_for_each_entry(tmp1, list1, list) + count++; + list_for_each_entry(tmp2, list2, list) + chk_count++; + if (!count || count != chk_count) + return false; + + tmp1 = list_first_entry(list1, struct ice_vsig_prof, list); + tmp2 = list_first_entry(list2, struct ice_vsig_prof, list); + + /* profile cookies must compare, and in the exact same order to take + * into account priority + */ + while (count--) { + if (tmp2->profile_cookie != tmp1->profile_cookie) + return false; + + tmp1 = list_next_entry(tmp1, list); + tmp2 = list_next_entry(tmp2, list); + } + + return true; +} + +/** + * ice_vsig_alloc - finds a free entry and allocates a new vsig + * @hw: pointer to the hardware structure + * @blk: hw block + * + * this function will iterate through the vsig list and mark the first + * unused entry for the new vsig entry as used and return that value. + */ +static u16 ice_vsig_alloc(struct ice_hw *hw, enum ice_block blk) +{ + u16 i; + + for (i = 1; i < ice_max_vsigs; i++) + if (!hw->blk[blk].xlt2.vsig_tbl[i].in_use) + return ice_vsig_alloc_val(hw, blk, i); + + return ice_default_vsig; +} + +/** + * ice_find_dup_props_vsig - find vsi group with a specified set of properties + * @hw: pointer to the hardware structure + * @blk: hw block + * @chs: characteristic list + * @vsig: returns the vsig with the matching profiles, if found + * + * each vsig is associated with a characteristic set; i.e. all vsis under + * a group have the same characteristic set. to check if there exists a vsig + * which has the same characteristics as the input characteristics; this + * function will iterate through the xlt2 list and return the vsig that has a + * matching configuration. in order to make sure that priorities are accounted + * for, the list must match exactly, including the order in which the + * characteristics are listed. + */ +static enum ice_status +ice_find_dup_props_vsig(struct ice_hw *hw, enum ice_block blk, + struct list_head *chs, u16 *vsig) +{ + struct ice_xlt2 *xlt2 = &hw->blk[blk].xlt2; + u16 i; + + for (i = 0; i < xlt2->count; i++) + if (xlt2->vsig_tbl[i].in_use && + ice_match_prop_lst(chs, &xlt2->vsig_tbl[i].prop_lst)) { + *vsig = ice_vsig_value(i, hw->pf_id); + return 0; + } + + return ice_err_does_not_exist; +} + +/** + * ice_vsig_free - free vsi group + * @hw: pointer to the hardware structure + * @blk: hw block + * @vsig: vsig to remove + * + * the function will remove all vsis associated with the input vsig and move + * them to the default_vsig and mark the vsig available. + */ +static enum ice_status +ice_vsig_free(struct ice_hw *hw, enum ice_block blk, u16 vsig) +{ + struct ice_vsig_prof *dtmp, *del; + struct ice_vsig_vsi *vsi_cur; + u16 idx; + + idx = vsig & ice_vsig_idx_m; + if (idx >= ice_max_vsigs) + return ice_err_param; + + if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) + return ice_err_does_not_exist; + + hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false; + + vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; + /* if the vsig has at least 1 vsi then iterate through the + * list and remove the vsis before deleting the group. + */ + if (vsi_cur) { + /* remove all vsis associated with this vsig xlt2 entry */ + do { + struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; + + vsi_cur->vsig = ice_default_vsig; + vsi_cur->changed = 1; + vsi_cur->next_vsi = null; + vsi_cur = tmp; + } while (vsi_cur); + + /* null terminate head of vsi list */ + hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = null; + } + + /* free characteristic list */ + list_for_each_entry_safe(del, dtmp, + &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) { + list_del(&del->list); + devm_kfree(ice_hw_to_dev(hw), del); + } + + /* if vsig characteristic list was cleared for reset + * re-initialize the list head + */ + init_list_head(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst); + + return 0; +} + +/** + * ice_tcam_ent_rsrc_type - get tcam entry resource type for a block type + * @blk: the block type + * @rsrc_type: pointer to variable to receive the resource type + */ +static bool ice_tcam_ent_rsrc_type(enum ice_block blk, u16 *rsrc_type) +{ + switch (blk) { + case ice_blk_rss: + *rsrc_type = ice_aqc_res_type_hash_prof_bldr_tcam; + break; + default: + return false; + } + return true; +} + +/** + * ice_alloc_tcam_ent - allocate hardware tcam entry + * @hw: pointer to the hw struct + * @blk: the block to allocate the tcam for + * @tcam_idx: pointer to variable to receive the tcam entry + * + * this function allocates a new entry in a profile id tcam for a specific + * block. + */ +static enum ice_status +ice_alloc_tcam_ent(struct ice_hw *hw, enum ice_block blk, u16 *tcam_idx) +{ + u16 res_type; + + if (!ice_tcam_ent_rsrc_type(blk, &res_type)) + return ice_err_param; + + return ice_alloc_hw_res(hw, res_type, 1, true, tcam_idx); +} + +/** + * ice_free_tcam_ent - free hardware tcam entry + * @hw: pointer to the hw struct + * @blk: the block from which to free the tcam entry + * @tcam_idx: the tcam entry to free + * + * this function frees an entry in a profile id tcam for a specific block. + */ +static enum ice_status +ice_free_tcam_ent(struct ice_hw *hw, enum ice_block blk, u16 tcam_idx) +{ + u16 res_type; + + if (!ice_tcam_ent_rsrc_type(blk, &res_type)) + return ice_err_param; + + return ice_free_hw_res(hw, res_type, 1, &tcam_idx); +} + +/** + * ice_prof_gen_key - generate profile id key + * @hw: pointer to the hw struct + * @blk: the block in which to write profile id to + * @ptg: packet type group (ptg) portion of key + * @vsig: vsig portion of key + * @cdid: cdid portion of key + * @flags: flag portion of key + * @vl_msk: valid mask + * @dc_msk: don't care mask + * @nm_msk: never match mask + * @key: output of profile id key + */ +static enum ice_status +ice_prof_gen_key(struct ice_hw *hw, enum ice_block blk, u8 ptg, u16 vsig, + u8 cdid, u16 flags, u8 vl_msk[ice_tcam_key_val_sz], + u8 dc_msk[ice_tcam_key_val_sz], u8 nm_msk[ice_tcam_key_val_sz], + u8 key[ice_tcam_key_sz]) +{ + struct ice_prof_id_key inkey; + + inkey.xlt1 = ptg; + inkey.xlt2_cdid = cpu_to_le16(vsig); + inkey.flags = cpu_to_le16(flags); + + switch (hw->blk[blk].prof.cdid_bits) { + case 0: + break; + case 2: +#define ice_cd_2_m 0xc000u +#define ice_cd_2_s 14 + inkey.xlt2_cdid &= ~cpu_to_le16(ice_cd_2_m); + inkey.xlt2_cdid |= cpu_to_le16(bit(cdid) << ice_cd_2_s); + break; + case 4: +#define ice_cd_4_m 0xf000u +#define ice_cd_4_s 12 + inkey.xlt2_cdid &= ~cpu_to_le16(ice_cd_4_m); + inkey.xlt2_cdid |= cpu_to_le16(bit(cdid) << ice_cd_4_s); + break; + case 8: +#define ice_cd_8_m 0xff00u +#define ice_cd_8_s 16 + inkey.xlt2_cdid &= ~cpu_to_le16(ice_cd_8_m); + inkey.xlt2_cdid |= cpu_to_le16(bit(cdid) << ice_cd_8_s); + break; + default: + ice_debug(hw, ice_dbg_pkg, "error in profile config "); + break; + } + + return ice_set_key(key, ice_tcam_key_sz, (u8 *)&inkey, vl_msk, dc_msk, + nm_msk, 0, ice_tcam_key_sz / 2); +} + +/** + * ice_tcam_write_entry - write tcam entry + * @hw: pointer to the hw struct + * @blk: the block in which to write profile id to + * @idx: the entry index to write to + * @prof_id: profile id + * @ptg: packet type group (ptg) portion of key + * @vsig: vsig portion of key + * @cdid: cdid portion of key + * @flags: flag portion of key + * @vl_msk: valid mask + * @dc_msk: don't care mask + * @nm_msk: never match mask + */ +static enum ice_status +ice_tcam_write_entry(struct ice_hw *hw, enum ice_block blk, u16 idx, + u8 prof_id, u8 ptg, u16 vsig, u8 cdid, u16 flags, + u8 vl_msk[ice_tcam_key_val_sz], + u8 dc_msk[ice_tcam_key_val_sz], + u8 nm_msk[ice_tcam_key_val_sz]) +{ + struct ice_prof_tcam_entry; + enum ice_status status; + + status = ice_prof_gen_key(hw, blk, ptg, vsig, cdid, flags, vl_msk, + dc_msk, nm_msk, hw->blk[blk].prof.t[idx].key); + if (!status) { + hw->blk[blk].prof.t[idx].addr = cpu_to_le16(idx); + hw->blk[blk].prof.t[idx].prof_id = prof_id; + } + + return status; +} + +/** + * ice_vsig_get_ref - returns number of vsis belong to a vsig + * @hw: pointer to the hardware structure + * @blk: hw block + * @vsig: vsig to query + * @refs: pointer to variable to receive the reference count + */ +static enum ice_status +ice_vsig_get_ref(struct ice_hw *hw, enum ice_block blk, u16 vsig, u16 *refs) +{ + u16 idx = vsig & ice_vsig_idx_m; + struct ice_vsig_vsi *ptr; + + *refs = 0; + + if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) + return ice_err_does_not_exist; + + ptr = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; + while (ptr) { + (*refs)++; + ptr = ptr->next_vsi; + } + + return 0; +} + +/** + * ice_has_prof_vsig - check to see if vsig has a specific profile + * @hw: pointer to the hardware structure + * @blk: hw block + * @vsig: vsig to check against + * @hdl: profile handle + */ +static bool +ice_has_prof_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl) +{ + u16 idx = vsig & ice_vsig_idx_m; + struct ice_vsig_prof *ent; + + list_for_each_entry(ent, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) + if (ent->profile_cookie == hdl) + return true; + + ice_debug(hw, ice_dbg_init, + "characteristic list for vsi group %d not found. ", + vsig); + return false; +} + + +/** + * ice_search_prof_id_low - search for a profile tracking id low level + * @hw: pointer to the hw struct + * @blk: hardware block + * @id: profile tracking id + * + * this will search for a profile tracking id which was previously added. this + * version assumes that the caller has already acquired the prof map lock. + */ +static struct ice_prof_map * +ice_search_prof_id_low(struct ice_hw *hw, enum ice_block blk, u64 id) +{ + struct ice_prof_map *entry = null; + struct ice_prof_map *map; + + list_for_each_entry(map, &hw->blk[blk].es.prof_map, list) + if (map->profile_cookie == id) { + entry = map; + break; + } + + return entry; +} + +/** + * ice_search_prof_id - search for a profile tracking id + * @hw: pointer to the hw struct + * @blk: hardware block + * @id: profile tracking id + * + * this will search for a profile tracking id which was previously added. + */ +static struct ice_prof_map * +ice_search_prof_id(struct ice_hw *hw, enum ice_block blk, u64 id) +{ + struct ice_prof_map *entry; + + mutex_lock(&hw->blk[blk].es.prof_map_lock); + entry = ice_search_prof_id_low(hw, blk, id); + mutex_unlock(&hw->blk[blk].es.prof_map_lock); + + return entry; +} + +/** + * ice_rel_tcam_idx - release a tcam index + * @hw: pointer to the hw struct + * @blk: hardware block + * @idx: the index to release + */ +static enum ice_status +ice_rel_tcam_idx(struct ice_hw *hw, enum ice_block blk, u16 idx) +{ + /* masks to invoke a never match entry */ + u8 vl_msk[ice_tcam_key_val_sz] = { 0xff, 0xff, 0xff, 0xff, 0xff }; + u8 dc_msk[ice_tcam_key_val_sz] = { 0xfe, 0xff, 0xff, 0xff, 0xff }; + u8 nm_msk[ice_tcam_key_val_sz] = { 0x01, 0x00, 0x00, 0x00, 0x00 }; + enum ice_status status; + + /* write the tcam entry */ + status = ice_tcam_write_entry(hw, blk, idx, 0, 0, 0, 0, 0, vl_msk, + dc_msk, nm_msk); + if (status) + return status; + + /* release the tcam entry */ + status = ice_free_tcam_ent(hw, blk, idx); + + return status; +} + +/** + * ice_rem_prof_id - remove one profile from a vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @prof: pointer to profile structure to remove + */ +static enum ice_status +ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk, + struct ice_vsig_prof *prof) +{ + enum ice_status status; + u16 i; + + for (i = 0; i < prof->tcam_count; i++) + if (prof->tcam[i].in_use) { + prof->tcam[i].in_use = false; + status = ice_rel_tcam_idx(hw, blk, + prof->tcam[i].tcam_idx); + if (status) + return ice_err_hw_table; + } + + return 0; +} + +/** + * ice_rem_vsig - remove vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsig: the vsig to remove + * @chg: the change list + */ +static enum ice_status +ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, + struct list_head *chg) +{ + u16 idx = vsig & ice_vsig_idx_m; + struct ice_vsig_vsi *vsi_cur; + struct ice_vsig_prof *d, *t; + enum ice_status status; + + /* remove tcam entries */ + list_for_each_entry_safe(d, t, + &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) { + status = ice_rem_prof_id(hw, blk, d); + if (status) + return status; + + list_del(&d->list); + devm_kfree(ice_hw_to_dev(hw), d); + } + + /* move all vsis associated with this vsig to the default vsig */ + vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; + /* if the vsig has at least 1 vsi then iterate through the list + * and remove the vsis before deleting the group. + */ + if (vsi_cur) + do { + struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; + struct ice_chs_chg *p; + + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), + gfp_kernel); + if (!p) + return ice_err_no_memory; + + p->type = ice_vsig_rem; + p->orig_vsig = vsig; + p->vsig = ice_default_vsig; + p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis; + + list_add(&p->list_entry, chg); + + vsi_cur = tmp; + } while (vsi_cur); + + return ice_vsig_free(hw, blk, vsig); +} + +/** + * ice_get_prof - get profile + * @hw: pointer to the hw struct + * @blk: hardware block + * @hdl: profile handle + * @chg: change list + */ +static enum ice_status +ice_get_prof(struct ice_hw *hw, enum ice_block blk, u64 hdl, + struct list_head *chg) +{ + struct ice_prof_map *map; + struct ice_chs_chg *p; + u16 i; + + /* get the details on the profile specified by the handle id */ + map = ice_search_prof_id(hw, blk, hdl); + if (!map) + return ice_err_does_not_exist; + + for (i = 0; i < map->ptg_cnt; i++) + if (!hw->blk[blk].es.written[map->prof_id]) { + /* add es to change list */ + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), + gfp_kernel); + if (!p) + goto err_ice_get_prof; + + p->type = ice_ptg_es_add; + p->ptype = 0; + p->ptg = map->ptg[i]; + p->add_ptg = 0; + + p->add_prof = 1; + p->prof_id = map->prof_id; + + hw->blk[blk].es.written[map->prof_id] = true; + + list_add(&p->list_entry, chg); + } + + return 0; + +err_ice_get_prof: + /* let caller clean up the change list */ + return ice_err_no_memory; +} + +/** + * ice_get_profs_vsig - get a copy of the list of profiles from a vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsig: vsig from which to copy the list + * @lst: output list + * + * this routine makes a copy of the list of profiles in the specified vsig. + */ +static enum ice_status +ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, + struct list_head *lst) +{ + struct ice_vsig_prof *ent1, *ent2; + u16 idx = vsig & ice_vsig_idx_m; + + list_for_each_entry(ent1, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) { + struct ice_vsig_prof *p; + + /* copy to the input list */ + p = devm_kmemdup(ice_hw_to_dev(hw), ent1, sizeof(*p), + gfp_kernel); + if (!p) + goto err_ice_get_profs_vsig; + + list_add_tail(&p->list, lst); + } + + return 0; + +err_ice_get_profs_vsig: + list_for_each_entry_safe(ent1, ent2, lst, list) { + list_del(&ent1->list); + devm_kfree(ice_hw_to_dev(hw), ent1); + } + + return ice_err_no_memory; +} + +/** + * ice_add_prof_to_lst - add profile entry to a list + * @hw: pointer to the hw struct + * @blk: hardware block + * @lst: the list to be added to + * @hdl: profile handle of entry to add + */ +static enum ice_status +ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk, + struct list_head *lst, u64 hdl) +{ + struct ice_prof_map *map; + struct ice_vsig_prof *p; + u16 i; + + map = ice_search_prof_id(hw, blk, hdl); + if (!map) + return ice_err_does_not_exist; + + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), gfp_kernel); + if (!p) + return ice_err_no_memory; + + p->profile_cookie = map->profile_cookie; + p->prof_id = map->prof_id; + p->tcam_count = map->ptg_cnt; + + for (i = 0; i < map->ptg_cnt; i++) { + p->tcam[i].prof_id = map->prof_id; + p->tcam[i].tcam_idx = ice_invalid_tcam; + p->tcam[i].ptg = map->ptg[i]; + } + + list_add(&p->list, lst); + + return 0; +} + +/** + * ice_move_vsi - move vsi to another vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsi: the vsi to move + * @vsig: the vsig to move the vsi to + * @chg: the change list + */ +static enum ice_status +ice_move_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 vsig, + struct list_head *chg) +{ + enum ice_status status; + struct ice_chs_chg *p; + u16 orig_vsig; + + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), gfp_kernel); + if (!p) + return ice_err_no_memory; + + status = ice_vsig_find_vsi(hw, blk, vsi, &orig_vsig); + if (!status) + status = ice_vsig_add_mv_vsi(hw, blk, vsi, vsig); + + if (status) { + devm_kfree(ice_hw_to_dev(hw), p); + return status; + } + + p->type = ice_vsi_move; + p->vsi = vsi; + p->orig_vsig = orig_vsig; + p->vsig = vsig; + + list_add(&p->list_entry, chg); + + return 0; +} + +/** + * ice_prof_tcam_ena_dis - add enable or disable tcam change + * @hw: pointer to the hw struct + * @blk: hardware block + * @enable: true to enable, false to disable + * @vsig: the vsig of the tcam entry + * @tcam: pointer the tcam info structure of the tcam to disable + * @chg: the change list + * + * this function appends an enable or disable tcam entry in the change log + */ +static enum ice_status +ice_prof_tcam_ena_dis(struct ice_hw *hw, enum ice_block blk, bool enable, + u16 vsig, struct ice_tcam_inf *tcam, + struct list_head *chg) +{ + enum ice_status status; + struct ice_chs_chg *p; + + /* default: enable means change the low flag bit to don't care */ + u8 dc_msk[ice_tcam_key_val_sz] = { 0x01, 0x00, 0x00, 0x00, 0x00 }; + u8 nm_msk[ice_tcam_key_val_sz] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; + u8 vl_msk[ice_tcam_key_val_sz] = { 0x01, 0x00, 0x00, 0x00, 0x00 }; + + /* if disabling, free the tcam */ + if (!enable) { + status = ice_free_tcam_ent(hw, blk, tcam->tcam_idx); + tcam->tcam_idx = 0; + tcam->in_use = 0; + return status; + } + + /* for re-enabling, reallocate a tcam */ + status = ice_alloc_tcam_ent(hw, blk, &tcam->tcam_idx); + if (status) + return status; + + /* add tcam to change list */ + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), gfp_kernel); + if (!p) + return ice_err_no_memory; + + status = ice_tcam_write_entry(hw, blk, tcam->tcam_idx, tcam->prof_id, + tcam->ptg, vsig, 0, 0, vl_msk, dc_msk, + nm_msk); + if (status) + goto err_ice_prof_tcam_ena_dis; + + tcam->in_use = 1; + + p->type = ice_tcam_add; + p->add_tcam_idx = true; + p->prof_id = tcam->prof_id; + p->ptg = tcam->ptg; + p->vsig = 0; + p->tcam_idx = tcam->tcam_idx; + + /* log change */ + list_add(&p->list_entry, chg); + + return 0; + +err_ice_prof_tcam_ena_dis: + devm_kfree(ice_hw_to_dev(hw), p); + return status; +} + +/** + * ice_adj_prof_priorities - adjust profile based on priorities + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsig: the vsig for which to adjust profile priorities + * @chg: the change list + */ +static enum ice_status +ice_adj_prof_priorities(struct ice_hw *hw, enum ice_block blk, u16 vsig, + struct list_head *chg) +{ + declare_bitmap(ptgs_used, ice_xlt1_cnt); + struct ice_vsig_prof *t; + enum ice_status status; + u16 idx; + + bitmap_zero(ptgs_used, ice_xlt1_cnt); + idx = vsig & ice_vsig_idx_m; + + /* priority is based on the order in which the profiles are added. the + * newest added profile has highest priority and the oldest added + * profile has the lowest priority. since the profile property list for + * a vsig is sorted from newest to oldest, this code traverses the list + * in order and enables the first of each ptg that it finds (that is not + * already enabled); it also disables any duplicate ptgs that it finds + * in the older profiles (that are currently enabled). + */ + + list_for_each_entry(t, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) { + u16 i; + + for (i = 0; i < t->tcam_count; i++) { + /* scan the priorities from newest to oldest. + * make sure that the newest profiles take priority. + */ + if (test_bit(t->tcam[i].ptg, ptgs_used) && + t->tcam[i].in_use) { + /* need to mark this ptg as never match, as it + * was already in use and therefore duplicate + * (and lower priority) + */ + status = ice_prof_tcam_ena_dis(hw, blk, false, + vsig, + &t->tcam[i], + chg); + if (status) + return status; + } else if (!test_bit(t->tcam[i].ptg, ptgs_used) && + !t->tcam[i].in_use) { + /* need to enable this ptg, as it in not in use + * and not enabled (highest priority) + */ + status = ice_prof_tcam_ena_dis(hw, blk, true, + vsig, + &t->tcam[i], + chg); + if (status) + return status; + } + + /* keep track of used ptgs */ + set_bit(t->tcam[i].ptg, ptgs_used); + } + } + + return 0; +} + +/** + * ice_add_prof_id_vsig - add profile to vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsig: the vsig to which this profile is to be added + * @hdl: the profile handle indicating the profile to add + * @chg: the change list + */ +static enum ice_status +ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl, + struct list_head *chg) +{ + /* masks that ignore flags */ + u8 vl_msk[ice_tcam_key_val_sz] = { 0xff, 0xff, 0xff, 0xff, 0xff }; + u8 dc_msk[ice_tcam_key_val_sz] = { 0xff, 0xff, 0x00, 0x00, 0x00 }; + u8 nm_msk[ice_tcam_key_val_sz] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; + struct ice_prof_map *map; + struct ice_vsig_prof *t; + struct ice_chs_chg *p; + u16 i; + + /* get the details on the profile specified by the handle id */ + map = ice_search_prof_id(hw, blk, hdl); + if (!map) + return ice_err_does_not_exist; + + /* error, if this vsig already has this profile */ + if (ice_has_prof_vsig(hw, blk, vsig, hdl)) + return ice_err_already_exists; + + /* new vsig profile structure */ + t = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*t), gfp_kernel); + if (!t) + return ice_err_no_memory; + + t->profile_cookie = map->profile_cookie; + t->prof_id = map->prof_id; + t->tcam_count = map->ptg_cnt; + + /* create tcam entries */ + for (i = 0; i < map->ptg_cnt; i++) { + enum ice_status status; + u16 tcam_idx; + + /* add tcam to change list */ + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), gfp_kernel); + if (!p) + goto err_ice_add_prof_id_vsig; + + /* allocate the tcam entry index */ + status = ice_alloc_tcam_ent(hw, blk, &tcam_idx); + if (status) { + devm_kfree(ice_hw_to_dev(hw), p); + goto err_ice_add_prof_id_vsig; + } + + t->tcam[i].ptg = map->ptg[i]; + t->tcam[i].prof_id = map->prof_id; + t->tcam[i].tcam_idx = tcam_idx; + t->tcam[i].in_use = true; + + p->type = ice_tcam_add; + p->add_tcam_idx = true; + p->prof_id = t->tcam[i].prof_id; + p->ptg = t->tcam[i].ptg; + p->vsig = vsig; + p->tcam_idx = t->tcam[i].tcam_idx; + + /* write the tcam entry */ + status = ice_tcam_write_entry(hw, blk, t->tcam[i].tcam_idx, + t->tcam[i].prof_id, + t->tcam[i].ptg, vsig, 0, 0, + vl_msk, dc_msk, nm_msk); + if (status) + goto err_ice_add_prof_id_vsig; + + /* log change */ + list_add(&p->list_entry, chg); + } + + /* add profile to vsig */ + list_add(&t->list, + &hw->blk[blk].xlt2.vsig_tbl[(vsig & ice_vsig_idx_m)].prop_lst); + + return 0; + +err_ice_add_prof_id_vsig: + /* let caller clean up the change list */ + devm_kfree(ice_hw_to_dev(hw), t); + return ice_err_no_memory; +} + +/** + * ice_create_prof_id_vsig - add a new vsig with a single profile + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsi: the initial vsi that will be in vsig + * @hdl: the profile handle of the profile that will be added to the vsig + * @chg: the change list + */ +static enum ice_status +ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl, + struct list_head *chg) +{ + enum ice_status status; + struct ice_chs_chg *p; + u16 new_vsig; + + p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*p), gfp_kernel); + if (!p) + return ice_err_no_memory; + + new_vsig = ice_vsig_alloc(hw, blk); + if (!new_vsig) { + status = ice_err_hw_table; + goto err_ice_create_prof_id_vsig; + } + + status = ice_move_vsi(hw, blk, vsi, new_vsig, chg); + if (status) + goto err_ice_create_prof_id_vsig; + + status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, chg); + if (status) + goto err_ice_create_prof_id_vsig; + + p->type = ice_vsig_add; + p->vsi = vsi; + p->orig_vsig = ice_default_vsig; + p->vsig = new_vsig; + + list_add(&p->list_entry, chg); + + return 0; + +err_ice_create_prof_id_vsig: + /* let caller clean up the change list */ + devm_kfree(ice_hw_to_dev(hw), p); + return status; +} + +/** + * ice_create_vsig_from_lst - create a new vsig with a list of profiles + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsi: the initial vsi that will be in vsig + * @lst: the list of profile that will be added to the vsig + * @chg: the change list + */ +static enum ice_status +ice_create_vsig_from_lst(struct ice_hw *hw, enum ice_block blk, u16 vsi, + struct list_head *lst, struct list_head *chg) +{ + struct ice_vsig_prof *t; + enum ice_status status; + u16 vsig; + + vsig = ice_vsig_alloc(hw, blk); + if (!vsig) + return ice_err_hw_table; + + status = ice_move_vsi(hw, blk, vsi, vsig, chg); + if (status) + return status; + + list_for_each_entry(t, lst, list) { + status = ice_add_prof_id_vsig(hw, blk, vsig, t->profile_cookie, + chg); + if (status) + return status; + } + + return 0; +} + +/** + * ice_find_prof_vsig - find a vsig with a specific profile handle + * @hw: pointer to the hw struct + * @blk: hardware block + * @hdl: the profile handle of the profile to search for + * @vsig: returns the vsig with the matching profile + */ +static bool +ice_find_prof_vsig(struct ice_hw *hw, enum ice_block blk, u64 hdl, u16 *vsig) +{ + struct ice_vsig_prof *t; + enum ice_status status; + struct list_head lst; + + init_list_head(&lst); + + t = kzalloc(sizeof(*t), gfp_kernel); + if (!t) + return false; + + t->profile_cookie = hdl; + list_add(&t->list, &lst); + + status = ice_find_dup_props_vsig(hw, blk, &lst, vsig); + + list_del(&t->list); + kfree(t); + + return !status; +} + +/** + * ice_add_prof_id_flow - add profile flow + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsi: the vsi to enable with the profile specified by id + * @hdl: profile handle + * + * calling this function will update the hardware tables to enable the + * profile indicated by the id parameter for the vsis specified in the vsi + * array. once successfully called, the flow will be enabled. + */ +enum ice_status +ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) +{ + struct ice_vsig_prof *tmp1, *del1; + struct ice_chs_chg *tmp, *del; + struct list_head union_lst; + enum ice_status status; + struct list_head chg; + u16 vsig; + + init_list_head(&union_lst); + init_list_head(&chg); + + /* get profile */ + status = ice_get_prof(hw, blk, hdl, &chg); + if (status) + return status; + + /* determine if vsi is already part of a vsig */ + status = ice_vsig_find_vsi(hw, blk, vsi, &vsig); + if (!status && vsig) { + bool only_vsi; + u16 or_vsig; + u16 ref; + + /* found in vsig */ + or_vsig = vsig; + + /* make sure that there is no overlap/conflict between the new + * characteristics and the existing ones; we don't support that + * scenario + */ + if (ice_has_prof_vsig(hw, blk, vsig, hdl)) { + status = ice_err_already_exists; + goto err_ice_add_prof_id_flow; + } + + /* last vsi in the vsig? */ + status = ice_vsig_get_ref(hw, blk, vsig, &ref); + if (status) + goto err_ice_add_prof_id_flow; + only_vsi = (ref == 1); + + /* create a union of the current profiles and the one being + * added + */ + status = ice_get_profs_vsig(hw, blk, vsig, &union_lst); + if (status) + goto err_ice_add_prof_id_flow; + + status = ice_add_prof_to_lst(hw, blk, &union_lst, hdl); + if (status) + goto err_ice_add_prof_id_flow; + + /* search for an existing vsig with an exact charc match */ + status = ice_find_dup_props_vsig(hw, blk, &union_lst, &vsig); + if (!status) { + /* move vsi to the vsig that matches */ + status = ice_move_vsi(hw, blk, vsi, vsig, &chg); + if (status) + goto err_ice_add_prof_id_flow; + + /* vsi has been moved out of or_vsig. if the or_vsig had + * only that vsi it is now empty and can be removed. + */ + if (only_vsi) { + status = ice_rem_vsig(hw, blk, or_vsig, &chg); + if (status) + goto err_ice_add_prof_id_flow; + } + } else if (only_vsi) { + /* if the original vsig only contains one vsi, then it + * will be the requesting vsi. in this case the vsi is + * not sharing entries and we can simply add the new + * profile to the vsig. + */ + status = ice_add_prof_id_vsig(hw, blk, vsig, hdl, &chg); + if (status) + goto err_ice_add_prof_id_flow; + + /* adjust priorities */ + status = ice_adj_prof_priorities(hw, blk, vsig, &chg); + if (status) + goto err_ice_add_prof_id_flow; + } else { + /* no match, so we need a new vsig */ + status = ice_create_vsig_from_lst(hw, blk, vsi, + &union_lst, &chg); + if (status) + goto err_ice_add_prof_id_flow; + + /* adjust priorities */ + status = ice_adj_prof_priorities(hw, blk, vsig, &chg); + if (status) + goto err_ice_add_prof_id_flow; + } + } else { + /* need to find or add a vsig */ + /* search for an existing vsig with an exact charc match */ + if (ice_find_prof_vsig(hw, blk, hdl, &vsig)) { + /* found an exact match */ + /* add or move vsi to the vsig that matches */ + status = ice_move_vsi(hw, blk, vsi, vsig, &chg); + if (status) + goto err_ice_add_prof_id_flow; + } else { + /* we did not find an exact match */ + /* we need to add a vsig */ + status = ice_create_prof_id_vsig(hw, blk, vsi, hdl, + &chg); + if (status) + goto err_ice_add_prof_id_flow; + } + } + +err_ice_add_prof_id_flow: + list_for_each_entry_safe(del, tmp, &chg, list_entry) { + list_del(&del->list_entry); + devm_kfree(ice_hw_to_dev(hw), del); + } + + list_for_each_entry_safe(del1, tmp1, &union_lst, list) { + list_del(&del1->list); + devm_kfree(ice_hw_to_dev(hw), del1); + } + + return status; +} diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h +enum ice_status +ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl); diff --git a/drivers/net/ethernet/intel/ice/ice_flex_type.h b/drivers/net/ethernet/intel/ice/ice_flex_type.h --- a/drivers/net/ethernet/intel/ice/ice_flex_type.h +++ b/drivers/net/ethernet/intel/ice/ice_flex_type.h +#define ice_max_tcam_per_profile 32 +#define ice_invalid_tcam 0xffff + +struct ice_tcam_inf { + u16 tcam_idx; + u8 ptg; + u8 prof_id; + u8 in_use; +}; + +struct ice_vsig_prof { + struct list_head list; + u64 profile_cookie; + u8 prof_id; + u8 tcam_count; + struct ice_tcam_inf tcam[ice_max_tcam_per_profile]; +}; + +/* profile id management */ +struct ice_prof_id_key { + __le16 flags; + u8 xlt1; + __le16 xlt2_cdid; +} __packed; + +enum ice_chg_type { + ice_tcam_none = 0, + ice_ptg_es_add, + ice_tcam_add, + ice_vsig_add, + ice_vsig_rem, + ice_vsi_move, +}; + +struct ice_chs_chg { + struct list_head list_entry; + enum ice_chg_type type; + + u8 add_ptg; + u8 add_vsig; + u8 add_tcam_idx; + u8 add_prof; + u16 ptype; + u8 ptg; + u8 prof_id; + u16 vsi; + u16 vsig; + u16 orig_vsig; + u16 tcam_idx; +}; + diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c --- a/drivers/net/ethernet/intel/ice/ice_flow.c +++ b/drivers/net/ethernet/intel/ice/ice_flow.c +/** + * ice_flow_assoc_prof - associate a vsi with a flow profile + * @hw: pointer to the hardware structure + * @blk: classification stage + * @prof: pointer to flow profile + * @vsi_handle: software vsi handle + * + * assumption: the caller has acquired the lock to the profile list + * and the software vsi handle has been validated + */ +static enum ice_status +ice_flow_assoc_prof(struct ice_hw *hw, enum ice_block blk, + struct ice_flow_prof *prof, u16 vsi_handle) +{ + enum ice_status status = 0; + + if (!test_bit(vsi_handle, prof->vsis)) { + status = ice_add_prof_id_flow(hw, blk, + ice_get_hw_vsi_num(hw, + vsi_handle), + prof->id); + if (!status) + set_bit(vsi_handle, prof->vsis); + else + ice_debug(hw, ice_dbg_flow, + "hw profile add failed, %d ", + status); + } + + return status; +} + + * @prof: stores the returned flow profile added - u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt) + u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt, + struct ice_flow_prof **prof) - struct ice_flow_prof *prof = null; - &prof); + prof); - list_add(&prof->l_entry, &hw->fl_profs[blk]); + list_add(&(*prof)->l_entry, &hw->fl_profs[blk]); + * @vsi_handle: software vsi handle -ice_add_rss_cfg_sync(struct ice_hw *hw, u64 hashed_flds, u32 addl_hdrs, - u8 segs_cnt) +ice_add_rss_cfg_sync(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds, + u32 addl_hdrs, u8 segs_cnt) + const enum ice_block blk = ice_blk_rss; + struct ice_flow_prof *prof = null; - status = ice_flow_add_prof(hw, ice_blk_rss, ice_flow_rx, + status = ice_flow_add_prof(hw, blk, ice_flow_rx, - segs, segs_cnt); + segs, segs_cnt, &prof); + if (status) + goto exit; + + status = ice_flow_assoc_prof(hw, blk, prof, vsi_handle); - status = ice_add_rss_cfg_sync(hw, hashed_flds, addl_hdrs, + status = ice_add_rss_cfg_sync(hw, vsi_handle, hashed_flds, addl_hdrs, - status = ice_add_rss_cfg_sync(hw, r->hashed_flds, + status = ice_add_rss_cfg_sync(hw, vsi_handle, + r->hashed_flds, diff --git a/drivers/net/ethernet/intel/ice/ice_status.h b/drivers/net/ethernet/intel/ice/ice_status.h --- a/drivers/net/ethernet/intel/ice/ice_status.h +++ b/drivers/net/ethernet/intel/ice/ice_status.h + ice_err_hw_table = -19,
|
Networking
|
451f2c4406e035295169a3abe127e377af694398
|
tony nguyen andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: enable writing filtering tables
|
write the hardware tables based on the populated software structures.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['h', 'c']
| 3
| 651
| 0
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h --- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h + ice_aqc_opc_update_pkg = 0x0c42, diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +static const u32 ice_sect_lkup[ice_blk_count][ice_sect_count] = { + /* switch */ + { + ice_sid_xlt0_sw, + ice_sid_xlt_key_builder_sw, + ice_sid_xlt1_sw, + ice_sid_xlt2_sw, + ice_sid_profid_tcam_sw, + ice_sid_profid_redir_sw, + ice_sid_fld_vec_sw, + ice_sid_cdid_key_builder_sw, + ice_sid_cdid_redir_sw + }, + + /* acl */ + { + ice_sid_xlt0_acl, + ice_sid_xlt_key_builder_acl, + ice_sid_xlt1_acl, + ice_sid_xlt2_acl, + ice_sid_profid_tcam_acl, + ice_sid_profid_redir_acl, + ice_sid_fld_vec_acl, + ice_sid_cdid_key_builder_acl, + ice_sid_cdid_redir_acl + }, + + /* fd */ + { + ice_sid_xlt0_fd, + ice_sid_xlt_key_builder_fd, + ice_sid_xlt1_fd, + ice_sid_xlt2_fd, + ice_sid_profid_tcam_fd, + ice_sid_profid_redir_fd, + ice_sid_fld_vec_fd, + ice_sid_cdid_key_builder_fd, + ice_sid_cdid_redir_fd + }, + + /* rss */ + { + ice_sid_xlt0_rss, + ice_sid_xlt_key_builder_rss, + ice_sid_xlt1_rss, + ice_sid_xlt2_rss, + ice_sid_profid_tcam_rss, + ice_sid_profid_redir_rss, + ice_sid_fld_vec_rss, + ice_sid_cdid_key_builder_rss, + ice_sid_cdid_redir_rss + }, + + /* pe */ + { + ice_sid_xlt0_pe, + ice_sid_xlt_key_builder_pe, + ice_sid_xlt1_pe, + ice_sid_xlt2_pe, + ice_sid_profid_tcam_pe, + ice_sid_profid_redir_pe, + ice_sid_fld_vec_pe, + ice_sid_cdid_key_builder_pe, + ice_sid_cdid_redir_pe + } +}; + +/** + * ice_sect_id - returns section id + * @blk: block type + * @sect: section type + * + * this helper function returns the proper section id given a block type and a + * section type. + */ +static u32 ice_sect_id(enum ice_block blk, enum ice_sect sect) +{ + return ice_sect_lkup[blk][sect]; +} + +/** + * ice_acquire_change_lock + * @hw: pointer to the hw structure + * @access: access type (read or write) + * + * this function will request ownership of the change lock. + */ +static enum ice_status +ice_acquire_change_lock(struct ice_hw *hw, enum ice_aq_res_access_type access) +{ + return ice_acquire_res(hw, ice_change_lock_res_id, access, + ice_change_lock_timeout); +} + +/** + * ice_release_change_lock + * @hw: pointer to the hw structure + * + * this function will release the change lock using the proper admin command. + */ +static void ice_release_change_lock(struct ice_hw *hw) +{ + ice_release_res(hw, ice_change_lock_res_id); +} + +/** + * ice_aq_update_pkg + * @hw: pointer to the hardware structure + * @pkg_buf: the package cmd buffer + * @buf_size: the size of the package cmd buffer + * @last_buf: last buffer indicator + * @error_offset: returns error offset + * @error_info: returns error information + * @cd: pointer to command details structure or null + * + * update package (0x0c42) + */ +static enum ice_status +ice_aq_update_pkg(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf, u16 buf_size, + bool last_buf, u32 *error_offset, u32 *error_info, + struct ice_sq_cd *cd) +{ + struct ice_aqc_download_pkg *cmd; + struct ice_aq_desc desc; + enum ice_status status; + + if (error_offset) + *error_offset = 0; + if (error_info) + *error_info = 0; + + cmd = &desc.params.download_pkg; + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_update_pkg); + desc.flags |= cpu_to_le16(ice_aq_flag_rd); + + if (last_buf) + cmd->flags |= ice_aqc_download_pkg_last_buf; + + status = ice_aq_send_cmd(hw, &desc, pkg_buf, buf_size, cd); + if (status == ice_err_aq_error) { + /* read error from buffer only when the fw returned an error */ + struct ice_aqc_download_pkg_resp *resp; + + resp = (struct ice_aqc_download_pkg_resp *)pkg_buf; + if (error_offset) + *error_offset = le32_to_cpu(resp->error_offset); + if (error_info) + *error_info = le32_to_cpu(resp->error_info); + } + + return status; +} + +/** + * ice_update_pkg + * @hw: pointer to the hardware structure + * @bufs: pointer to an array of buffers + * @count: the number of buffers in the array + * + * obtains change lock and updates package. + */ +static enum ice_status +ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count) +{ + enum ice_status status; + u32 offset, info, i; + + status = ice_acquire_change_lock(hw, ice_res_write); + if (status) + return status; + + for (i = 0; i < count; i++) { + struct ice_buf_hdr *bh = (struct ice_buf_hdr *)(bufs + i); + bool last = ((i + 1) == count); + + status = ice_aq_update_pkg(hw, bh, le16_to_cpu(bh->data_end), + last, &offset, &info, null); + + if (status) { + ice_debug(hw, ice_dbg_pkg, + "update pkg failed: err %d off %d inf %d ", + status, offset, info); + break; + } + } + + ice_release_change_lock(hw); + + return status; +} + +/** + * ice_pkg_buf_alloc + * @hw: pointer to the hw structure + * + * allocates a package buffer and returns a pointer to the buffer header. + * note: all package contents must be in little endian form. + */ +static struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw) +{ + struct ice_buf_build *bld; + struct ice_buf_hdr *buf; + + bld = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*bld), gfp_kernel); + if (!bld) + return null; + + buf = (struct ice_buf_hdr *)bld; + buf->data_end = cpu_to_le16(offsetof(struct ice_buf_hdr, + section_entry)); + return bld; +} + +/** + * ice_pkg_buf_free + * @hw: pointer to the hw structure + * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc()) + * + * frees a package buffer + */ +static void ice_pkg_buf_free(struct ice_hw *hw, struct ice_buf_build *bld) +{ + devm_kfree(ice_hw_to_dev(hw), bld); +} + +/** + * ice_pkg_buf_reserve_section + * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc()) + * @count: the number of sections to reserve + * + * reserves one or more section table entries in a package buffer. this routine + * can be called multiple times as long as they are made before calling + * ice_pkg_buf_alloc_section(). once ice_pkg_buf_alloc_section() + * is called once, the number of sections that can be allocated will not be able + * to be increased; not using all reserved sections is fine, but this will + * result in some wasted space in the buffer. + * note: all package contents must be in little endian form. + */ +static enum ice_status +ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count) +{ + struct ice_buf_hdr *buf; + u16 section_count; + u16 data_end; + + if (!bld) + return ice_err_param; + + buf = (struct ice_buf_hdr *)&bld->buf; + + /* already an active section, can't increase table size */ + section_count = le16_to_cpu(buf->section_count); + if (section_count > 0) + return ice_err_cfg; + + if (bld->reserved_section_table_entries + count > ice_max_s_count) + return ice_err_cfg; + bld->reserved_section_table_entries += count; + + data_end = le16_to_cpu(buf->data_end) + + (count * sizeof(buf->section_entry[0])); + buf->data_end = cpu_to_le16(data_end); + + return 0; +} + +/** + * ice_pkg_buf_alloc_section + * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc()) + * @type: the section type value + * @size: the size of the section to reserve (in bytes) + * + * reserves memory in the buffer for a section's content and updates the + * buffers' status accordingly. this routine returns a pointer to the first + * byte of the section start within the buffer, which is used to fill in the + * section contents. + * note: all package contents must be in little endian form. + */ +static void * +ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size) +{ + struct ice_buf_hdr *buf; + u16 sect_count; + u16 data_end; + + if (!bld || !type || !size) + return null; + + buf = (struct ice_buf_hdr *)&bld->buf; + + /* check for enough space left in buffer */ + data_end = le16_to_cpu(buf->data_end); + + /* section start must align on 4 byte boundary */ + data_end = align(data_end, 4); + + if ((data_end + size) > ice_max_s_data_end) + return null; + + /* check for more available section table entries */ + sect_count = le16_to_cpu(buf->section_count); + if (sect_count < bld->reserved_section_table_entries) { + void *section_ptr = ((u8 *)buf) + data_end; + + buf->section_entry[sect_count].offset = cpu_to_le16(data_end); + buf->section_entry[sect_count].size = cpu_to_le16(size); + buf->section_entry[sect_count].type = cpu_to_le32(type); + + data_end += size; + buf->data_end = cpu_to_le16(data_end); + + buf->section_count = cpu_to_le16(sect_count + 1); + return section_ptr; + } + + /* no free section table entries */ + return null; +} + +/** + * ice_pkg_buf_get_active_sections + * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc()) + * + * returns the number of active sections. before using the package buffer + * in an update package command, the caller should make sure that there is at + * least one active section - otherwise, the buffer is not legal and should + * not be used. + * note: all package contents must be in little endian form. + */ +static u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld) +{ + struct ice_buf_hdr *buf; + + if (!bld) + return 0; + + buf = (struct ice_buf_hdr *)&bld->buf; + return le16_to_cpu(buf->section_count); +} + +/** + * ice_pkg_buf + * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc()) + * + * return a pointer to the buffer's header + */ +static struct ice_buf *ice_pkg_buf(struct ice_buf_build *bld) +{ + if (!bld) + return null; + + return &bld->buf; +} + +/** + * ice_prof_bld_es - build profile id extraction sequence changes + * @hw: pointer to the hw struct + * @blk: hardware block + * @bld: the update package buffer build to add to + * @chgs: the list of changes to make in hardware + */ +static enum ice_status +ice_prof_bld_es(struct ice_hw *hw, enum ice_block blk, + struct ice_buf_build *bld, struct list_head *chgs) +{ + u16 vec_size = hw->blk[blk].es.fvw * sizeof(struct ice_fv_word); + struct ice_chs_chg *tmp; + + list_for_each_entry(tmp, chgs, list_entry) + if (tmp->type == ice_ptg_es_add && tmp->add_prof) { + u16 off = tmp->prof_id * hw->blk[blk].es.fvw; + struct ice_pkg_es *p; + u32 id; + + id = ice_sect_id(blk, ice_vec_tbl); + p = (struct ice_pkg_es *) + ice_pkg_buf_alloc_section(bld, id, sizeof(*p) + + vec_size - + sizeof(p->es[0])); + + if (!p) + return ice_err_max_limit; + + p->count = cpu_to_le16(1); + p->offset = cpu_to_le16(tmp->prof_id); + + memcpy(p->es, &hw->blk[blk].es.t[off], vec_size); + } + + return 0; +} + +/** + * ice_prof_bld_tcam - build profile id tcam changes + * @hw: pointer to the hw struct + * @blk: hardware block + * @bld: the update package buffer build to add to + * @chgs: the list of changes to make in hardware + */ +static enum ice_status +ice_prof_bld_tcam(struct ice_hw *hw, enum ice_block blk, + struct ice_buf_build *bld, struct list_head *chgs) +{ + struct ice_chs_chg *tmp; + + list_for_each_entry(tmp, chgs, list_entry) + if (tmp->type == ice_tcam_add && tmp->add_tcam_idx) { + struct ice_prof_id_section *p; + u32 id; + + id = ice_sect_id(blk, ice_prof_tcam); + p = (struct ice_prof_id_section *) + ice_pkg_buf_alloc_section(bld, id, sizeof(*p)); + + if (!p) + return ice_err_max_limit; + + p->count = cpu_to_le16(1); + p->entry[0].addr = cpu_to_le16(tmp->tcam_idx); + p->entry[0].prof_id = tmp->prof_id; + + memcpy(p->entry[0].key, + &hw->blk[blk].prof.t[tmp->tcam_idx].key, + sizeof(hw->blk[blk].prof.t->key)); + } + + return 0; +} + +/** + * ice_prof_bld_xlt1 - build xlt1 changes + * @blk: hardware block + * @bld: the update package buffer build to add to + * @chgs: the list of changes to make in hardware + */ +static enum ice_status +ice_prof_bld_xlt1(enum ice_block blk, struct ice_buf_build *bld, + struct list_head *chgs) +{ + struct ice_chs_chg *tmp; + + list_for_each_entry(tmp, chgs, list_entry) + if (tmp->type == ice_ptg_es_add && tmp->add_ptg) { + struct ice_xlt1_section *p; + u32 id; + + id = ice_sect_id(blk, ice_xlt1); + p = (struct ice_xlt1_section *) + ice_pkg_buf_alloc_section(bld, id, sizeof(*p)); + + if (!p) + return ice_err_max_limit; + + p->count = cpu_to_le16(1); + p->offset = cpu_to_le16(tmp->ptype); + p->value[0] = tmp->ptg; + } + + return 0; +} + +/** + * ice_prof_bld_xlt2 - build xlt2 changes + * @blk: hardware block + * @bld: the update package buffer build to add to + * @chgs: the list of changes to make in hardware + */ +static enum ice_status +ice_prof_bld_xlt2(enum ice_block blk, struct ice_buf_build *bld, + struct list_head *chgs) +{ + struct ice_chs_chg *tmp; + + list_for_each_entry(tmp, chgs, list_entry) { + struct ice_xlt2_section *p; + u32 id; + + switch (tmp->type) { + case ice_vsig_add: + case ice_vsi_move: + case ice_vsig_rem: + id = ice_sect_id(blk, ice_xlt2); + p = (struct ice_xlt2_section *) + ice_pkg_buf_alloc_section(bld, id, sizeof(*p)); + + if (!p) + return ice_err_max_limit; + + p->count = cpu_to_le16(1); + p->offset = cpu_to_le16(tmp->vsi); + p->value[0] = cpu_to_le16(tmp->vsig); + break; + default: + break; + } + } + + return 0; +} + +/** + * ice_upd_prof_hw - update hardware using the change list + * @hw: pointer to the hw struct + * @blk: hardware block + * @chgs: the list of changes to make in hardware + */ +static enum ice_status +ice_upd_prof_hw(struct ice_hw *hw, enum ice_block blk, + struct list_head *chgs) +{ + struct ice_buf_build *b; + struct ice_chs_chg *tmp; + enum ice_status status; + u16 pkg_sects; + u16 xlt1 = 0; + u16 xlt2 = 0; + u16 tcam = 0; + u16 es = 0; + u16 sects; + + /* count number of sections we need */ + list_for_each_entry(tmp, chgs, list_entry) { + switch (tmp->type) { + case ice_ptg_es_add: + if (tmp->add_ptg) + xlt1++; + if (tmp->add_prof) + es++; + break; + case ice_tcam_add: + tcam++; + break; + case ice_vsig_add: + case ice_vsi_move: + case ice_vsig_rem: + xlt2++; + break; + default: + break; + } + } + sects = xlt1 + xlt2 + tcam + es; + + if (!sects) + return 0; + + /* build update package buffer */ + b = ice_pkg_buf_alloc(hw); + if (!b) + return ice_err_no_memory; + + status = ice_pkg_buf_reserve_section(b, sects); + if (status) + goto error_tmp; + + /* preserve order of table update: es, tcam, ptg, vsig */ + if (es) { + status = ice_prof_bld_es(hw, blk, b, chgs); + if (status) + goto error_tmp; + } + + if (tcam) { + status = ice_prof_bld_tcam(hw, blk, b, chgs); + if (status) + goto error_tmp; + } + + if (xlt1) { + status = ice_prof_bld_xlt1(blk, b, chgs); + if (status) + goto error_tmp; + } + + if (xlt2) { + status = ice_prof_bld_xlt2(blk, b, chgs); + if (status) + goto error_tmp; + } + + /* after package buffer build check if the section count in buffer is + * non-zero and matches the number of sections detected for package + * update. + */ + pkg_sects = ice_pkg_buf_get_active_sections(b); + if (!pkg_sects || pkg_sects != sects) { + status = ice_err_inval_size; + goto error_tmp; + } + + /* update package */ + status = ice_update_pkg(hw, ice_pkg_buf(b), 1); + if (status == ice_err_aq_error) + ice_debug(hw, ice_dbg_init, "unable to update hw profile "); + +error_tmp: + ice_pkg_buf_free(hw, b); + return status; +} + + /* update hardware */ + if (!status) + status = ice_upd_prof_hw(hw, blk, &chg); + diff --git a/drivers/net/ethernet/intel/ice/ice_flex_type.h b/drivers/net/ethernet/intel/ice/ice_flex_type.h --- a/drivers/net/ethernet/intel/ice/ice_flex_type.h +++ b/drivers/net/ethernet/intel/ice/ice_flex_type.h +#define ice_sid_xlt0_sw 10 +#define ice_sid_xlt_key_builder_sw 11 +#define ice_sid_cdid_key_builder_sw 17 +#define ice_sid_cdid_redir_sw 18 +#define ice_sid_xlt0_acl 20 +#define ice_sid_xlt_key_builder_acl 21 +#define ice_sid_cdid_key_builder_acl 27 +#define ice_sid_cdid_redir_acl 28 +#define ice_sid_xlt0_fd 30 +#define ice_sid_xlt_key_builder_fd 31 +#define ice_sid_cdid_key_builder_fd 37 +#define ice_sid_cdid_redir_fd 38 +#define ice_sid_xlt0_rss 40 +#define ice_sid_xlt_key_builder_rss 41 +#define ice_sid_cdid_key_builder_rss 47 +#define ice_sid_cdid_redir_rss 48 +#define ice_sid_xlt0_pe 80 +#define ice_sid_xlt_key_builder_pe 81 +#define ice_sid_cdid_key_builder_pe 87 +#define ice_sid_cdid_redir_pe 88 +enum ice_sect { + ice_xlt0 = 0, + ice_xlt_kb, + ice_xlt1, + ice_xlt2, + ice_prof_tcam, + ice_prof_redir, + ice_vec_tbl, + ice_cdid_kb, + ice_cdid_redir, + ice_sect_count +}; + +/* package buffer building */ + +struct ice_buf_build { + struct ice_buf buf; + u16 reserved_section_table_entries; +}; + +struct ice_pkg_es { + __le16 count; + __le16 offset; + struct ice_fv_word es[1]; +}; +
|
Networking
|
43dbfc7bb8f0bd79a98f3fd628266a853d4bae61
|
tony nguyen andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: optimize table usage
|
attempt to optimize tcam entries and reduce table resource usage by searching for profiles that can be reused. provide resource cleanup of both hardware and software structures.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['c', 'h']
| 5
| 773
| 1
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +/** + * ice_free_prof_id - free profile id + * @hw: pointer to the hw struct + * @blk: the block from which to free the profile id + * @prof_id: the profile id to free + * + * this function frees a profile id, which also corresponds to a field vector. + */ +static enum ice_status +ice_free_prof_id(struct ice_hw *hw, enum ice_block blk, u8 prof_id) +{ + u16 tmp_prof_id = (u16)prof_id; + u16 res_type; + + if (!ice_prof_id_rsrc_type(blk, &res_type)) + return ice_err_param; + + return ice_free_hw_res(hw, res_type, 1, &tmp_prof_id); +} + +/** + * ice_prof_dec_ref - decrement reference count for profile + * @hw: pointer to the hw struct + * @blk: the block from which to free the profile id + * @prof_id: the profile id for which to decrement the reference count + */ +static enum ice_status +ice_prof_dec_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id) +{ + if (prof_id > hw->blk[blk].es.count) + return ice_err_param; + + if (hw->blk[blk].es.ref_count[prof_id] > 0) { + if (!--hw->blk[blk].es.ref_count[prof_id]) { + ice_write_es(hw, blk, prof_id, null); + return ice_free_prof_id(hw, blk, prof_id); + } + } + + return 0; +} + +/** + * ice_free_prof_map - free profile map + * @hw: pointer to the hardware structure + * @blk_idx: hw block index + */ +static void ice_free_prof_map(struct ice_hw *hw, u8 blk_idx) +{ + struct ice_es *es = &hw->blk[blk_idx].es; + struct ice_prof_map *del, *tmp; + + mutex_lock(&es->prof_map_lock); + list_for_each_entry_safe(del, tmp, &es->prof_map, list) { + list_del(&del->list); + devm_kfree(ice_hw_to_dev(hw), del); + } + init_list_head(&es->prof_map); + mutex_unlock(&es->prof_map_lock); +} + +/** + * ice_free_flow_profs - free flow profile entries + * @hw: pointer to the hardware structure + * @blk_idx: hw block index + */ +static void ice_free_flow_profs(struct ice_hw *hw, u8 blk_idx) +{ + struct ice_flow_prof *p, *tmp; + + mutex_lock(&hw->fl_profs_locks[blk_idx]); + list_for_each_entry_safe(p, tmp, &hw->fl_profs[blk_idx], l_entry) { + list_del(&p->l_entry); + devm_kfree(ice_hw_to_dev(hw), p); + } + mutex_unlock(&hw->fl_profs_locks[blk_idx]); + + /* if driver is in reset and tables are being cleared + * re-initialize the flow profile list heads + */ + init_list_head(&hw->fl_profs[blk_idx]); +} + +/** + * ice_free_vsig_tbl - free complete vsig table entries + * @hw: pointer to the hardware structure + * @blk: the hw block on which to free the vsig table entries + */ +static void ice_free_vsig_tbl(struct ice_hw *hw, enum ice_block blk) +{ + u16 i; + + if (!hw->blk[blk].xlt2.vsig_tbl) + return; + + for (i = 1; i < ice_max_vsigs; i++) + if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) + ice_vsig_free(hw, blk, i); +} + + ice_free_prof_map(hw, i); + + ice_free_flow_profs(hw, i); + ice_free_vsig_tbl(hw, (enum ice_block)i); + if (hw->blk[i].is_list_init) { + ice_free_prof_map(hw, i); + ice_free_flow_profs(hw, i); + } + + ice_free_vsig_tbl(hw, (enum ice_block)i); + +/** + * ice_vsig_prof_id_count - count profiles in a vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsig: vsig to remove the profile from + */ +static u16 +ice_vsig_prof_id_count(struct ice_hw *hw, enum ice_block blk, u16 vsig) +{ + u16 idx = vsig & ice_vsig_idx_m, count = 0; + struct ice_vsig_prof *p; + + list_for_each_entry(p, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) + count++; + + return count; +} + +/** + * ice_rem_prof_id_vsig - remove a specific profile from a vsig + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsig: vsig to remove the profile from + * @hdl: profile handle indicating which profile to remove + * @chg: list to receive a record of changes + */ +static enum ice_status +ice_rem_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl, + struct list_head *chg) +{ + u16 idx = vsig & ice_vsig_idx_m; + struct ice_vsig_prof *p, *t; + enum ice_status status; + + list_for_each_entry_safe(p, t, + &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, + list) + if (p->profile_cookie == hdl) { + if (ice_vsig_prof_id_count(hw, blk, vsig) == 1) + /* this is the last profile, remove the vsig */ + return ice_rem_vsig(hw, blk, vsig, chg); + + status = ice_rem_prof_id(hw, blk, p); + if (!status) { + list_del(&p->list); + devm_kfree(ice_hw_to_dev(hw), p); + } + return status; + } + + return ice_err_does_not_exist; +} + +/** + * ice_rem_flow_all - remove all flows with a particular profile + * @hw: pointer to the hw struct + * @blk: hardware block + * @id: profile tracking id + */ +static enum ice_status +ice_rem_flow_all(struct ice_hw *hw, enum ice_block blk, u64 id) +{ + struct ice_chs_chg *del, *tmp; + enum ice_status status; + struct list_head chg; + u16 i; + + init_list_head(&chg); + + for (i = 1; i < ice_max_vsigs; i++) + if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) { + if (ice_has_prof_vsig(hw, blk, i, id)) { + status = ice_rem_prof_id_vsig(hw, blk, i, id, + &chg); + if (status) + goto err_ice_rem_flow_all; + } + } + + status = ice_upd_prof_hw(hw, blk, &chg); + +err_ice_rem_flow_all: + list_for_each_entry_safe(del, tmp, &chg, list_entry) { + list_del(&del->list_entry); + devm_kfree(ice_hw_to_dev(hw), del); + } + + return status; +} + +/** + * ice_rem_prof - remove profile + * @hw: pointer to the hw struct + * @blk: hardware block + * @id: profile tracking id + * + * this will remove the profile specified by the id parameter, which was + * previously created through ice_add_prof. if any existing entries + * are associated with this profile, they will be removed as well. + */ +enum ice_status ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id) +{ + struct ice_prof_map *pmap; + enum ice_status status; + + mutex_lock(&hw->blk[blk].es.prof_map_lock); + + pmap = ice_search_prof_id_low(hw, blk, id); + if (!pmap) { + status = ice_err_does_not_exist; + goto err_ice_rem_prof; + } + + /* remove all flows with this profile */ + status = ice_rem_flow_all(hw, blk, pmap->profile_cookie); + if (status) + goto err_ice_rem_prof; + + /* dereference profile, and possibly remove */ + ice_prof_dec_ref(hw, blk, pmap->prof_id); + + list_del(&pmap->list); + devm_kfree(ice_hw_to_dev(hw), pmap); + +err_ice_rem_prof: + mutex_unlock(&hw->blk[blk].es.prof_map_lock); + return status; +} + + +/** + * ice_rem_prof_from_list - remove a profile from list + * @hw: pointer to the hw struct + * @lst: list to remove the profile from + * @hdl: the profile handle indicating the profile to remove + */ +static enum ice_status +ice_rem_prof_from_list(struct ice_hw *hw, struct list_head *lst, u64 hdl) +{ + struct ice_vsig_prof *ent, *tmp; + + list_for_each_entry_safe(ent, tmp, lst, list) + if (ent->profile_cookie == hdl) { + list_del(&ent->list); + devm_kfree(ice_hw_to_dev(hw), ent); + return 0; + } + + return ice_err_does_not_exist; +} + +/** + * ice_rem_prof_id_flow - remove flow + * @hw: pointer to the hw struct + * @blk: hardware block + * @vsi: the vsi from which to remove the profile specified by id + * @hdl: profile tracking handle + * + * calling this function will update the hardware tables to remove the + * profile indicated by the id parameter for the vsis specified in the vsi + * array. once successfully called, the flow will be disabled. + */ +enum ice_status +ice_rem_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) +{ + struct ice_vsig_prof *tmp1, *del1; + struct ice_chs_chg *tmp, *del; + struct list_head chg, copy; + enum ice_status status; + u16 vsig; + + init_list_head(©); + init_list_head(&chg); + + /* determine if vsi is already part of a vsig */ + status = ice_vsig_find_vsi(hw, blk, vsi, &vsig); + if (!status && vsig) { + bool last_profile; + bool only_vsi; + u16 ref; + + /* found in vsig */ + last_profile = ice_vsig_prof_id_count(hw, blk, vsig) == 1; + status = ice_vsig_get_ref(hw, blk, vsig, &ref); + if (status) + goto err_ice_rem_prof_id_flow; + only_vsi = (ref == 1); + + if (only_vsi) { + /* if the original vsig only contains one reference, + * which will be the requesting vsi, then the vsi is not + * sharing entries and we can simply remove the specific + * characteristics from the vsig. + */ + + if (last_profile) { + /* if there are no profiles left for this vsig, + * then simply remove the the vsig. + */ + status = ice_rem_vsig(hw, blk, vsig, &chg); + if (status) + goto err_ice_rem_prof_id_flow; + } else { + status = ice_rem_prof_id_vsig(hw, blk, vsig, + hdl, &chg); + if (status) + goto err_ice_rem_prof_id_flow; + + /* adjust priorities */ + status = ice_adj_prof_priorities(hw, blk, vsig, + &chg); + if (status) + goto err_ice_rem_prof_id_flow; + } + + } else { + /* make a copy of the vsig's list of profiles */ + status = ice_get_profs_vsig(hw, blk, vsig, ©); + if (status) + goto err_ice_rem_prof_id_flow; + + /* remove specified profile entry from the list */ + status = ice_rem_prof_from_list(hw, ©, hdl); + if (status) + goto err_ice_rem_prof_id_flow; + + if (list_empty(©)) { + status = ice_move_vsi(hw, blk, vsi, + ice_default_vsig, &chg); + if (status) + goto err_ice_rem_prof_id_flow; + + } else if (!ice_find_dup_props_vsig(hw, blk, ©, + &vsig)) { + /* found an exact match */ + /* add or move vsi to the vsig that matches */ + /* search for a vsig with a matching profile + * list + */ + + /* found match, move vsi to the matching vsig */ + status = ice_move_vsi(hw, blk, vsi, vsig, &chg); + if (status) + goto err_ice_rem_prof_id_flow; + } else { + /* since no existing vsig supports this + * characteristic pattern, we need to create a + * new vsig and tcam entries + */ + status = ice_create_vsig_from_lst(hw, blk, vsi, + ©, &chg); + if (status) + goto err_ice_rem_prof_id_flow; + + /* adjust priorities */ + status = ice_adj_prof_priorities(hw, blk, vsig, + &chg); + if (status) + goto err_ice_rem_prof_id_flow; + } + } + } else { + status = ice_err_does_not_exist; + } + + /* update hardware tables */ + if (!status) + status = ice_upd_prof_hw(hw, blk, &chg); + +err_ice_rem_prof_id_flow: + list_for_each_entry_safe(del, tmp, &chg, list_entry) { + list_del(&del->list_entry); + devm_kfree(ice_hw_to_dev(hw), del); + } + + list_for_each_entry_safe(del1, tmp1, ©, list) { + list_del(&del1->list); + devm_kfree(ice_hw_to_dev(hw), del1); + } + + return status; +} diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h +enum ice_status +ice_rem_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl); +enum ice_status +ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id); diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c --- a/drivers/net/ethernet/intel/ice/ice_flow.c +++ b/drivers/net/ethernet/intel/ice/ice_flow.c +#define ice_flow_find_prof_chk_flds 0x00000001 +#define ice_flow_find_prof_chk_vsi 0x00000002 +#define ice_flow_find_prof_not_chk_dir 0x00000004 + +/** + * ice_flow_find_prof_conds - find a profile matching headers and conditions + * @hw: pointer to the hw struct + * @blk: classification stage + * @dir: flow direction + * @segs: array of one or more packet segments that describe the flow + * @segs_cnt: number of packet segments provided + * @vsi_handle: software vsi handle to check vsi (ice_flow_find_prof_chk_vsi) + * @conds: additional conditions to be checked (ice_flow_find_prof_chk_*) + */ +static struct ice_flow_prof * +ice_flow_find_prof_conds(struct ice_hw *hw, enum ice_block blk, + enum ice_flow_dir dir, struct ice_flow_seg_info *segs, + u8 segs_cnt, u16 vsi_handle, u32 conds) +{ + struct ice_flow_prof *p, *prof = null; + + mutex_lock(&hw->fl_profs_locks[blk]); + list_for_each_entry(p, &hw->fl_profs[blk], l_entry) + if ((p->dir == dir || conds & ice_flow_find_prof_not_chk_dir) && + segs_cnt && segs_cnt == p->segs_cnt) { + u8 i; + + /* check for profile-vsi association if specified */ + if ((conds & ice_flow_find_prof_chk_vsi) && + ice_is_vsi_valid(hw, vsi_handle) && + !test_bit(vsi_handle, p->vsis)) + continue; + + /* protocol headers must be checked. matched fields are + * checked if specified. + */ + for (i = 0; i < segs_cnt; i++) + if (segs[i].hdrs != p->segs[i].hdrs || + ((conds & ice_flow_find_prof_chk_flds) && + segs[i].match != p->segs[i].match)) + break; + + /* a match is found if all segments are matched */ + if (i == segs_cnt) { + prof = p; + break; + } + } + mutex_unlock(&hw->fl_profs_locks[blk]); + + return prof; +} + +/** + * ice_flow_find_prof_id - look up a profile with given profile id + * @hw: pointer to the hw struct + * @blk: classification stage + * @prof_id: unique id to identify this flow profile + */ +static struct ice_flow_prof * +ice_flow_find_prof_id(struct ice_hw *hw, enum ice_block blk, u64 prof_id) +{ + struct ice_flow_prof *p; + + list_for_each_entry(p, &hw->fl_profs[blk], l_entry) + if (p->id == prof_id) + return p; + + return null; +} + +/** + * ice_flow_rem_prof_sync - remove a flow profile + * @hw: pointer to the hardware structure + * @blk: classification stage + * @prof: pointer to flow profile to remove + * + * assumption: the caller has acquired the lock to the profile list + */ +static enum ice_status +ice_flow_rem_prof_sync(struct ice_hw *hw, enum ice_block blk, + struct ice_flow_prof *prof) +{ + enum ice_status status; + + /* remove all hardware profiles associated with this flow profile */ + status = ice_rem_prof(hw, blk, prof->id); + if (!status) { + list_del(&prof->l_entry); + mutex_destroy(&prof->entries_lock); + devm_kfree(ice_hw_to_dev(hw), prof); + } + + return status; +} + +/** + * ice_flow_disassoc_prof - disassociate a vsi from a flow profile + * @hw: pointer to the hardware structure + * @blk: classification stage + * @prof: pointer to flow profile + * @vsi_handle: software vsi handle + * + * assumption: the caller has acquired the lock to the profile list + * and the software vsi handle has been validated + */ +static enum ice_status +ice_flow_disassoc_prof(struct ice_hw *hw, enum ice_block blk, + struct ice_flow_prof *prof, u16 vsi_handle) +{ + enum ice_status status = 0; + + if (test_bit(vsi_handle, prof->vsis)) { + status = ice_rem_prof_id_flow(hw, blk, + ice_get_hw_vsi_num(hw, + vsi_handle), + prof->id); + if (!status) + clear_bit(vsi_handle, prof->vsis); + else + ice_debug(hw, ice_dbg_flow, + "hw profile remove failed, %d ", + status); + } + + return status; +} + +/** + * ice_flow_rem_prof - remove a flow profile and all entries associated with it + * @hw: pointer to the hw struct + * @blk: the block for which the flow profile is to be removed + * @prof_id: unique id of the flow profile to be removed + */ +static enum ice_status +ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id) +{ + struct ice_flow_prof *prof; + enum ice_status status; + + mutex_lock(&hw->fl_profs_locks[blk]); + + prof = ice_flow_find_prof_id(hw, blk, prof_id); + if (!prof) { + status = ice_err_does_not_exist; + goto out; + } + + /* prof becomes invalid after the call */ + status = ice_flow_rem_prof_sync(hw, blk, prof); + +out: + mutex_unlock(&hw->fl_profs_locks[blk]); + + return status; +} + +/** + * ice_rem_vsi_rss_list - remove vsi from rss list + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * + * remove the vsi from all rss configurations in the list. + */ +void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle) +{ + struct ice_rss_cfg *r, *tmp; + + if (list_empty(&hw->rss_list_head)) + return; + + mutex_lock(&hw->rss_locks); + list_for_each_entry_safe(r, tmp, &hw->rss_list_head, l_entry) + if (test_and_clear_bit(vsi_handle, r->vsis)) + if (bitmap_empty(r->vsis, ice_max_vsi)) { + list_del(&r->l_entry); + devm_kfree(ice_hw_to_dev(hw), r); + } + mutex_unlock(&hw->rss_locks); +} + +/** + * ice_rem_vsi_rss_cfg - remove rss configurations associated with vsi + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * + * this function will iterate through all flow profiles and disassociate + * the vsi from that profile. if the flow profile has no vsis it will + * be removed. + */ +enum ice_status ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle) +{ + const enum ice_block blk = ice_blk_rss; + struct ice_flow_prof *p, *t; + enum ice_status status = 0; + + if (!ice_is_vsi_valid(hw, vsi_handle)) + return ice_err_param; + + if (list_empty(&hw->fl_profs[blk])) + return 0; + + mutex_lock(&hw->fl_profs_locks[blk]); + list_for_each_entry_safe(p, t, &hw->fl_profs[blk], l_entry) + if (test_bit(vsi_handle, p->vsis)) { + status = ice_flow_disassoc_prof(hw, blk, p, vsi_handle); + if (status) + break; + + if (bitmap_empty(p->vsis, ice_max_vsi)) { + status = ice_flow_rem_prof_sync(hw, blk, p); + if (status) + break; + } + } + mutex_unlock(&hw->fl_profs_locks[blk]); + + return status; +} + +/** + * ice_rem_rss_list - remove rss configuration from list + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * @prof: pointer to flow profile + * + * assumption: lock has already been acquired for rss list + */ +static void +ice_rem_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof) +{ + struct ice_rss_cfg *r, *tmp; + + /* search for rss hash fields associated to the vsi that match the + * hash configurations associated to the flow profile. if found + * remove from the rss entry list of the vsi context and delete entry. + */ + list_for_each_entry_safe(r, tmp, &hw->rss_list_head, l_entry) + if (r->hashed_flds == prof->segs[prof->segs_cnt - 1].match && + r->packet_hdr == prof->segs[prof->segs_cnt - 1].hdrs) { + clear_bit(vsi_handle, r->vsis); + if (bitmap_empty(r->vsis, ice_max_vsi)) { + list_del(&r->l_entry); + devm_kfree(ice_hw_to_dev(hw), r); + } + return; + } +} + +/** + * ice_add_rss_list - add rss configuration to list + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * @prof: pointer to flow profile + * + * assumption: lock has already been acquired for rss list + */ +static enum ice_status +ice_add_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof) +{ + struct ice_rss_cfg *r, *rss_cfg; + + list_for_each_entry(r, &hw->rss_list_head, l_entry) + if (r->hashed_flds == prof->segs[prof->segs_cnt - 1].match && + r->packet_hdr == prof->segs[prof->segs_cnt - 1].hdrs) { + set_bit(vsi_handle, r->vsis); + return 0; + } + + rss_cfg = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*rss_cfg), + gfp_kernel); + if (!rss_cfg) + return ice_err_no_memory; + + rss_cfg->hashed_flds = prof->segs[prof->segs_cnt - 1].match; + rss_cfg->packet_hdr = prof->segs[prof->segs_cnt - 1].hdrs; + set_bit(vsi_handle, rss_cfg->vsis); + + list_add_tail(&rss_cfg->l_entry, &hw->rss_list_head); + + return 0; +} + + /* search for a flow profile that has matching headers, hash fields + * and has the input vsi associated to it. if found, no further + * operations required and exit. + */ + prof = ice_flow_find_prof_conds(hw, blk, ice_flow_rx, segs, segs_cnt, + vsi_handle, + ice_flow_find_prof_chk_flds | + ice_flow_find_prof_chk_vsi); + if (prof) + goto exit; + + /* check if a flow profile exists with the same protocol headers and + * associated with the input vsi. if so disassociate the vsi from + * this profile. the vsi will be added to a new profile created with + * the protocol header and new hash field configuration. + */ + prof = ice_flow_find_prof_conds(hw, blk, ice_flow_rx, segs, segs_cnt, + vsi_handle, ice_flow_find_prof_chk_vsi); + if (prof) { + status = ice_flow_disassoc_prof(hw, blk, prof, vsi_handle); + if (!status) + ice_rem_rss_list(hw, vsi_handle, prof); + else + goto exit; + + /* remove profile if it has no vsis associated */ + if (bitmap_empty(prof->vsis, ice_max_vsi)) { + status = ice_flow_rem_prof(hw, blk, prof->id); + if (status) + goto exit; + } + } + + /* search for a profile that has same match fields only. if this + * exists then associate the vsi to this profile. + */ + prof = ice_flow_find_prof_conds(hw, blk, ice_flow_rx, segs, segs_cnt, + vsi_handle, + ice_flow_find_prof_chk_flds); + if (prof) { + status = ice_flow_assoc_prof(hw, blk, prof, vsi_handle); + if (!status) + status = ice_add_rss_list(hw, vsi_handle, prof); + goto exit; + } + + /* if association to a new flow profile failed then this profile can + * be removed. + */ + if (status) { + ice_flow_rem_prof(hw, blk, prof->id); + goto exit; + } + + status = ice_add_rss_list(hw, vsi_handle, prof); diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h --- a/drivers/net/ethernet/intel/ice/ice_flow.h +++ b/drivers/net/ethernet/intel/ice/ice_flow.h +#define ice_flow_entry_handle_inval 0 +enum ice_flow_priority { + ice_flow_prio_low, + ice_flow_prio_normal, + ice_flow_prio_high +}; + +enum ice_status ice_flow_rem_entry(struct ice_hw *hw, u64 entry_h); +void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle); +enum ice_status ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle); diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c - * ice_rss_clean - delete rss related vsi structures that hold user inputs + * ice_vsi_clean_rss_flow_fld - delete rss configuration + * @vsi: the vsi being cleaned up + * + * this function deletes rss input set for all flows that were configured + * for this vsi + */ +static void ice_vsi_clean_rss_flow_fld(struct ice_vsi *vsi) +{ + struct ice_pf *pf = vsi->back; + enum ice_status status; + + if (ice_is_safe_mode(pf)) + return; + + status = ice_rem_vsi_rss_cfg(&pf->hw, vsi->idx); + if (status) + dev_dbg(ice_pf_to_dev(pf), "ice_rem_vsi_rss_cfg failed for vsi = %d, error = %d ", + vsi->vsi_num, status); +} + +/** + * ice_rss_clean - delete rss related vsi structures and configuration + + ice_vsi_clean_rss_flow_fld(vsi); + /* remove rss replay list */ + if (!ice_is_safe_mode(pf)) + ice_rem_vsi_rss_list(&pf->hw, vsi->idx);
|
Networking
|
2c61054c5fdaf3df267c4fa95c8cfc33f7665615
|
tony nguyen andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: initilialize vf rss tables
|
set configuration for hardware rss tables for vfs.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['c', 'h']
| 4
| 225
| 1
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c --- a/drivers/net/ethernet/intel/ice/ice_flow.c +++ b/drivers/net/ethernet/intel/ice/ice_flow.c + /* ice_flow_field_idx_sctp_src_port */ + ice_flow_fld_info(ice_flow_seg_hdr_sctp, 0, sizeof(__be16)), + /* ice_flow_field_idx_sctp_dst_port */ + ice_flow_fld_info(ice_flow_seg_hdr_sctp, 2, sizeof(__be16)), + + case ice_flow_field_idx_sctp_src_port: + case ice_flow_field_idx_sctp_dst_port: + prot_id = ice_prot_sctp_il; + break; +/* mapping of avf hash bit fields to an l3-l4 hash combination. + * as the ice_flow_avf_hdr_field represent individual bit shifts in a hash, + * convert its values to their appropriate flow l3, l4 values. + */ +#define ice_flow_avf_rss_ipv4_masks \ + (bit_ull(ice_avf_flow_field_ipv4_other) | \ + bit_ull(ice_avf_flow_field_frag_ipv4)) +#define ice_flow_avf_rss_tcp_ipv4_masks \ + (bit_ull(ice_avf_flow_field_ipv4_tcp_syn_no_ack) | \ + bit_ull(ice_avf_flow_field_ipv4_tcp)) +#define ice_flow_avf_rss_udp_ipv4_masks \ + (bit_ull(ice_avf_flow_field_unicast_ipv4_udp) | \ + bit_ull(ice_avf_flow_field_multicast_ipv4_udp) | \ + bit_ull(ice_avf_flow_field_ipv4_udp)) +#define ice_flow_avf_rss_all_ipv4_masks \ + (ice_flow_avf_rss_tcp_ipv4_masks | ice_flow_avf_rss_udp_ipv4_masks | \ + ice_flow_avf_rss_ipv4_masks | bit_ull(ice_avf_flow_field_ipv4_sctp)) + +#define ice_flow_avf_rss_ipv6_masks \ + (bit_ull(ice_avf_flow_field_ipv6_other) | \ + bit_ull(ice_avf_flow_field_frag_ipv6)) +#define ice_flow_avf_rss_udp_ipv6_masks \ + (bit_ull(ice_avf_flow_field_unicast_ipv6_udp) | \ + bit_ull(ice_avf_flow_field_multicast_ipv6_udp) | \ + bit_ull(ice_avf_flow_field_ipv6_udp)) +#define ice_flow_avf_rss_tcp_ipv6_masks \ + (bit_ull(ice_avf_flow_field_ipv6_tcp_syn_no_ack) | \ + bit_ull(ice_avf_flow_field_ipv6_tcp)) +#define ice_flow_avf_rss_all_ipv6_masks \ + (ice_flow_avf_rss_tcp_ipv6_masks | ice_flow_avf_rss_udp_ipv6_masks | \ + ice_flow_avf_rss_ipv6_masks | bit_ull(ice_avf_flow_field_ipv6_sctp)) + +/** + * ice_add_avf_rss_cfg - add an rss configuration for avf driver + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * @avf_hash: hash bit fields (ice_avf_flow_field_*) to configure + * + * this function will take the hash bitmap provided by the avf driver via a + * message, convert it to ice-compatible values, and configure rss flow + * profiles. + */ +enum ice_status +ice_add_avf_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 avf_hash) +{ + enum ice_status status = 0; + u64 hash_flds; + + if (avf_hash == ice_avf_flow_field_invalid || + !ice_is_vsi_valid(hw, vsi_handle)) + return ice_err_param; + + /* make sure no unsupported bits are specified */ + if (avf_hash & ~(ice_flow_avf_rss_all_ipv4_masks | + ice_flow_avf_rss_all_ipv6_masks)) + return ice_err_cfg; + + hash_flds = avf_hash; + + /* always create an l3 rss configuration for any l4 rss configuration */ + if (hash_flds & ice_flow_avf_rss_all_ipv4_masks) + hash_flds |= ice_flow_avf_rss_ipv4_masks; + + if (hash_flds & ice_flow_avf_rss_all_ipv6_masks) + hash_flds |= ice_flow_avf_rss_ipv6_masks; + + /* create the corresponding rss configuration for each valid hash bit */ + while (hash_flds) { + u64 rss_hash = ice_hash_invalid; + + if (hash_flds & ice_flow_avf_rss_all_ipv4_masks) { + if (hash_flds & ice_flow_avf_rss_ipv4_masks) { + rss_hash = ice_flow_hash_ipv4; + hash_flds &= ~ice_flow_avf_rss_ipv4_masks; + } else if (hash_flds & + ice_flow_avf_rss_tcp_ipv4_masks) { + rss_hash = ice_flow_hash_ipv4 | + ice_flow_hash_tcp_port; + hash_flds &= ~ice_flow_avf_rss_tcp_ipv4_masks; + } else if (hash_flds & + ice_flow_avf_rss_udp_ipv4_masks) { + rss_hash = ice_flow_hash_ipv4 | + ice_flow_hash_udp_port; + hash_flds &= ~ice_flow_avf_rss_udp_ipv4_masks; + } else if (hash_flds & + bit_ull(ice_avf_flow_field_ipv4_sctp)) { + rss_hash = ice_flow_hash_ipv4 | + ice_flow_hash_sctp_port; + hash_flds &= + ~bit_ull(ice_avf_flow_field_ipv4_sctp); + } + } else if (hash_flds & ice_flow_avf_rss_all_ipv6_masks) { + if (hash_flds & ice_flow_avf_rss_ipv6_masks) { + rss_hash = ice_flow_hash_ipv6; + hash_flds &= ~ice_flow_avf_rss_ipv6_masks; + } else if (hash_flds & + ice_flow_avf_rss_tcp_ipv6_masks) { + rss_hash = ice_flow_hash_ipv6 | + ice_flow_hash_tcp_port; + hash_flds &= ~ice_flow_avf_rss_tcp_ipv6_masks; + } else if (hash_flds & + ice_flow_avf_rss_udp_ipv6_masks) { + rss_hash = ice_flow_hash_ipv6 | + ice_flow_hash_udp_port; + hash_flds &= ~ice_flow_avf_rss_udp_ipv6_masks; + } else if (hash_flds & + bit_ull(ice_avf_flow_field_ipv6_sctp)) { + rss_hash = ice_flow_hash_ipv6 | + ice_flow_hash_sctp_port; + hash_flds &= + ~bit_ull(ice_avf_flow_field_ipv6_sctp); + } + } + + if (rss_hash == ice_hash_invalid) + return ice_err_out_of_range; + + status = ice_add_rss_cfg(hw, vsi_handle, rss_hash, + ice_flow_seg_hdr_none); + if (status) + break; + } + + return status; +} + diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h --- a/drivers/net/ethernet/intel/ice/ice_flow.h +++ b/drivers/net/ethernet/intel/ice/ice_flow.h +#define ice_flow_hash_sctp_port \ + (bit_ull(ice_flow_field_idx_sctp_src_port) | \ + bit_ull(ice_flow_field_idx_sctp_dst_port)) + ice_flow_field_idx_sctp_src_port, + ice_flow_field_idx_sctp_dst_port, +/* flow headers and fields for avf support */ +enum ice_flow_avf_hdr_field { + /* values 0 - 28 are reserved for future use */ + ice_avf_flow_field_invalid = 0, + ice_avf_flow_field_unicast_ipv4_udp = 29, + ice_avf_flow_field_multicast_ipv4_udp, + ice_avf_flow_field_ipv4_udp, + ice_avf_flow_field_ipv4_tcp_syn_no_ack, + ice_avf_flow_field_ipv4_tcp, + ice_avf_flow_field_ipv4_sctp, + ice_avf_flow_field_ipv4_other, + ice_avf_flow_field_frag_ipv4, + /* values 37-38 are reserved */ + ice_avf_flow_field_unicast_ipv6_udp = 39, + ice_avf_flow_field_multicast_ipv6_udp, + ice_avf_flow_field_ipv6_udp, + ice_avf_flow_field_ipv6_tcp_syn_no_ack, + ice_avf_flow_field_ipv6_tcp, + ice_avf_flow_field_ipv6_sctp, + ice_avf_flow_field_ipv6_other, + ice_avf_flow_field_frag_ipv6, + ice_avf_flow_field_rsvd47, + ice_avf_flow_field_fcoe_ox, + ice_avf_flow_field_fcoe_rx, + ice_avf_flow_field_fcoe_other, + /* values 51-62 are reserved */ + ice_avf_flow_field_l2_payload = 63, + ice_avf_flow_field_max +}; + +/* supported rss offloads this macro is defined to support + * virtchnl_op_get_rss_hena_caps ops. pf driver sends the rss hardware + * capabilities to the caller of this ops. + */ +#define ice_default_rss_hena ( \ + bit_ull(ice_avf_flow_field_ipv4_udp) | \ + bit_ull(ice_avf_flow_field_ipv4_sctp) | \ + bit_ull(ice_avf_flow_field_ipv4_tcp) | \ + bit_ull(ice_avf_flow_field_ipv4_other) | \ + bit_ull(ice_avf_flow_field_frag_ipv4) | \ + bit_ull(ice_avf_flow_field_ipv6_udp) | \ + bit_ull(ice_avf_flow_field_ipv6_tcp) | \ + bit_ull(ice_avf_flow_field_ipv6_sctp) | \ + bit_ull(ice_avf_flow_field_ipv6_other) | \ + bit_ull(ice_avf_flow_field_frag_ipv6) | \ + bit_ull(ice_avf_flow_field_ipv4_tcp_syn_no_ack) | \ + bit_ull(ice_avf_flow_field_unicast_ipv4_udp) | \ + bit_ull(ice_avf_flow_field_multicast_ipv4_udp) | \ + bit_ull(ice_avf_flow_field_ipv6_tcp_syn_no_ack) | \ + bit_ull(ice_avf_flow_field_unicast_ipv6_udp) | \ + bit_ull(ice_avf_flow_field_multicast_ipv6_udp)) + +enum ice_status +ice_add_avf_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds); diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c +/** + * ice_vsi_set_vf_rss_flow_fld - sets vf vsi rss input set for different flows + * @vsi: vsi to be configured + * + * this function will only be called during the vf vsi setup. upon successful + * completion of package download, this function will configure default rss + * input sets for vf vsi. + */ +static void ice_vsi_set_vf_rss_flow_fld(struct ice_vsi *vsi) +{ + struct ice_pf *pf = vsi->back; + enum ice_status status; + struct device *dev; + + dev = ice_pf_to_dev(pf); + if (ice_is_safe_mode(pf)) { + dev_dbg(dev, "advanced rss disabled. package download failed, vsi num = %d ", + vsi->vsi_num); + return; + } + + status = ice_add_avf_rss_cfg(&pf->hw, vsi->idx, ice_default_rss_hena); + if (status) + dev_dbg(dev, "ice_add_avf_rss_cfg failed for vsi = %d, error = %d ", + vsi->vsi_num, status); +} + - if (test_bit(ice_flag_rss_ena, pf->flags)) + if (test_bit(ice_flag_rss_ena, pf->flags)) { + ice_vsi_set_vf_rss_flow_fld(vsi); + } diff --git a/drivers/net/ethernet/intel/ice/ice_protocol_type.h b/drivers/net/ethernet/intel/ice/ice_protocol_type.h --- a/drivers/net/ethernet/intel/ice/ice_protocol_type.h +++ b/drivers/net/ethernet/intel/ice/ice_protocol_type.h + ice_prot_sctp_il = 96,
|
Networking
|
1c01c8c6c969a9da1b0783c2b4138debc4d868c2
|
md fahad iqbal polash andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: implement ethtool get/set rx-flow-hash
|
provide support to change or retrieve rss hash options for a flow type. the supported flow-types are: tcp4, tcp6, udp4, udp6, sctp4, sctp6.
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['c', 'h']
| 3
| 273
| 0
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c +#include "ice_flow.h" +/** + * ice_parse_hdrs - parses headers from rss hash input + * @nfc: ethtool rxnfc command + * + * this function parses the rxnfc command and returns intended + * header types for rss configuration + */ +static u32 ice_parse_hdrs(struct ethtool_rxnfc *nfc) +{ + u32 hdrs = ice_flow_seg_hdr_none; + + switch (nfc->flow_type) { + case tcp_v4_flow: + hdrs |= ice_flow_seg_hdr_tcp | ice_flow_seg_hdr_ipv4; + break; + case udp_v4_flow: + hdrs |= ice_flow_seg_hdr_udp | ice_flow_seg_hdr_ipv4; + break; + case sctp_v4_flow: + hdrs |= ice_flow_seg_hdr_sctp | ice_flow_seg_hdr_ipv4; + break; + case tcp_v6_flow: + hdrs |= ice_flow_seg_hdr_tcp | ice_flow_seg_hdr_ipv6; + break; + case udp_v6_flow: + hdrs |= ice_flow_seg_hdr_udp | ice_flow_seg_hdr_ipv6; + break; + case sctp_v6_flow: + hdrs |= ice_flow_seg_hdr_sctp | ice_flow_seg_hdr_ipv6; + break; + default: + break; + } + return hdrs; +} + +#define ice_flow_hash_fld_ipv4_sa bit_ull(ice_flow_field_idx_ipv4_sa) +#define ice_flow_hash_fld_ipv6_sa bit_ull(ice_flow_field_idx_ipv6_sa) +#define ice_flow_hash_fld_ipv4_da bit_ull(ice_flow_field_idx_ipv4_da) +#define ice_flow_hash_fld_ipv6_da bit_ull(ice_flow_field_idx_ipv6_da) +#define ice_flow_hash_fld_tcp_src_port bit_ull(ice_flow_field_idx_tcp_src_port) +#define ice_flow_hash_fld_tcp_dst_port bit_ull(ice_flow_field_idx_tcp_dst_port) +#define ice_flow_hash_fld_udp_src_port bit_ull(ice_flow_field_idx_udp_src_port) +#define ice_flow_hash_fld_udp_dst_port bit_ull(ice_flow_field_idx_udp_dst_port) +#define ice_flow_hash_fld_sctp_src_port \ + bit_ull(ice_flow_field_idx_sctp_src_port) +#define ice_flow_hash_fld_sctp_dst_port \ + bit_ull(ice_flow_field_idx_sctp_dst_port) + +/** + * ice_parse_hash_flds - parses hash fields from rss hash input + * @nfc: ethtool rxnfc command + * + * this function parses the rxnfc command and returns intended + * hash fields for rss configuration + */ +static u64 ice_parse_hash_flds(struct ethtool_rxnfc *nfc) +{ + u64 hfld = ice_hash_invalid; + + if (nfc->data & rxh_ip_src || nfc->data & rxh_ip_dst) { + switch (nfc->flow_type) { + case tcp_v4_flow: + case udp_v4_flow: + case sctp_v4_flow: + if (nfc->data & rxh_ip_src) + hfld |= ice_flow_hash_fld_ipv4_sa; + if (nfc->data & rxh_ip_dst) + hfld |= ice_flow_hash_fld_ipv4_da; + break; + case tcp_v6_flow: + case udp_v6_flow: + case sctp_v6_flow: + if (nfc->data & rxh_ip_src) + hfld |= ice_flow_hash_fld_ipv6_sa; + if (nfc->data & rxh_ip_dst) + hfld |= ice_flow_hash_fld_ipv6_da; + break; + default: + break; + } + } + + if (nfc->data & rxh_l4_b_0_1 || nfc->data & rxh_l4_b_2_3) { + switch (nfc->flow_type) { + case tcp_v4_flow: + case tcp_v6_flow: + if (nfc->data & rxh_l4_b_0_1) + hfld |= ice_flow_hash_fld_tcp_src_port; + if (nfc->data & rxh_l4_b_2_3) + hfld |= ice_flow_hash_fld_tcp_dst_port; + break; + case udp_v4_flow: + case udp_v6_flow: + if (nfc->data & rxh_l4_b_0_1) + hfld |= ice_flow_hash_fld_udp_src_port; + if (nfc->data & rxh_l4_b_2_3) + hfld |= ice_flow_hash_fld_udp_dst_port; + break; + case sctp_v4_flow: + case sctp_v6_flow: + if (nfc->data & rxh_l4_b_0_1) + hfld |= ice_flow_hash_fld_sctp_src_port; + if (nfc->data & rxh_l4_b_2_3) + hfld |= ice_flow_hash_fld_sctp_dst_port; + break; + default: + break; + } + } + + return hfld; +} + +/** + * ice_set_rss_hash_opt - enable/disable flow types for rss hash + * @vsi: the vsi being configured + * @nfc: ethtool rxnfc command + * + * returns success if the flow input set is supported. + */ +static int +ice_set_rss_hash_opt(struct ice_vsi *vsi, struct ethtool_rxnfc *nfc) +{ + struct ice_pf *pf = vsi->back; + enum ice_status status; + struct device *dev; + u64 hashed_flds; + u32 hdrs; + + dev = ice_pf_to_dev(pf); + if (ice_is_safe_mode(pf)) { + dev_dbg(dev, "advanced rss disabled. package download failed, vsi num = %d ", + vsi->vsi_num); + return -einval; + } + + hashed_flds = ice_parse_hash_flds(nfc); + if (hashed_flds == ice_hash_invalid) { + dev_dbg(dev, "invalid hash fields, vsi num = %d ", + vsi->vsi_num); + return -einval; + } + + hdrs = ice_parse_hdrs(nfc); + if (hdrs == ice_flow_seg_hdr_none) { + dev_dbg(dev, "header type is not valid, vsi num = %d ", + vsi->vsi_num); + return -einval; + } + + status = ice_add_rss_cfg(&pf->hw, vsi->idx, hashed_flds, hdrs); + if (status) { + dev_dbg(dev, "ice_add_rss_cfg failed, vsi num = %d, error = %d ", + vsi->vsi_num, status); + return -einval; + } + + return 0; +} + +/** + * ice_get_rss_hash_opt - retrieve hash fields for a given flow-type + * @vsi: the vsi being configured + * @nfc: ethtool rxnfc command + */ +static void +ice_get_rss_hash_opt(struct ice_vsi *vsi, struct ethtool_rxnfc *nfc) +{ + struct ice_pf *pf = vsi->back; + struct device *dev; + u64 hash_flds; + u32 hdrs; + + dev = ice_pf_to_dev(pf); + + nfc->data = 0; + if (ice_is_safe_mode(pf)) { + dev_dbg(dev, "advanced rss disabled. package download failed, vsi num = %d ", + vsi->vsi_num); + return; + } + + hdrs = ice_parse_hdrs(nfc); + if (hdrs == ice_flow_seg_hdr_none) { + dev_dbg(dev, "header type is not valid, vsi num = %d ", + vsi->vsi_num); + return; + } + + hash_flds = ice_get_rss_cfg(&pf->hw, vsi->idx, hdrs); + if (hash_flds == ice_hash_invalid) { + dev_dbg(dev, "no hash fields found for the given header type, vsi num = %d ", + vsi->vsi_num); + return; + } + + if (hash_flds & ice_flow_hash_fld_ipv4_sa || + hash_flds & ice_flow_hash_fld_ipv6_sa) + nfc->data |= (u64)rxh_ip_src; + + if (hash_flds & ice_flow_hash_fld_ipv4_da || + hash_flds & ice_flow_hash_fld_ipv6_da) + nfc->data |= (u64)rxh_ip_dst; + + if (hash_flds & ice_flow_hash_fld_tcp_src_port || + hash_flds & ice_flow_hash_fld_udp_src_port || + hash_flds & ice_flow_hash_fld_sctp_src_port) + nfc->data |= (u64)rxh_l4_b_0_1; + + if (hash_flds & ice_flow_hash_fld_tcp_dst_port || + hash_flds & ice_flow_hash_fld_udp_dst_port || + hash_flds & ice_flow_hash_fld_sctp_dst_port) + nfc->data |= (u64)rxh_l4_b_2_3; +} + +/** + * ice_set_rxnfc - command to set rx flow rules. + * @netdev: network interface device structure + * @cmd: ethtool rxnfc command + * + * returns 0 for success and negative values for errors + */ +static int ice_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd) +{ + struct ice_netdev_priv *np = netdev_priv(netdev); + struct ice_vsi *vsi = np->vsi; + + switch (cmd->cmd) { + case ethtool_srxfh: + return ice_set_rss_hash_opt(vsi, cmd); + default: + break; + } + return -eopnotsupp; +} + + case ethtool_grxfh: + ice_get_rss_hash_opt(vsi, cmd); + ret = 0; + break; + .set_rxnfc = ice_set_rxnfc, diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c --- a/drivers/net/ethernet/intel/ice/ice_flow.c +++ b/drivers/net/ethernet/intel/ice/ice_flow.c + +/** + * ice_get_rss_cfg - returns hashed fields for the given header types + * @hw: pointer to the hardware structure + * @vsi_handle: software vsi handle + * @hdrs: protocol header type + * + * this function will return the match fields of the first instance of flow + * profile having the given header types and containing input vsi + */ +u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs) +{ + struct ice_rss_cfg *r, *rss_cfg = null; + + /* verify if the protocol header is non zero and vsi is valid */ + if (hdrs == ice_flow_seg_hdr_none || !ice_is_vsi_valid(hw, vsi_handle)) + return ice_hash_invalid; + + mutex_lock(&hw->rss_locks); + list_for_each_entry(r, &hw->rss_list_head, l_entry) + if (test_bit(vsi_handle, r->vsis) && + r->packet_hdr == hdrs) { + rss_cfg = r; + break; + } + mutex_unlock(&hw->rss_locks); + + return rss_cfg ? rss_cfg->hashed_flds : ice_hash_invalid; +} diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h --- a/drivers/net/ethernet/intel/ice/ice_flow.h +++ b/drivers/net/ethernet/intel/ice/ice_flow.h +u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
|
Networking
|
6876fb6404a50d764cc1409870207b62f6e21dff
|
md fahad iqbal polash andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: bump version
|
bump version to 0.8.2-k
|
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.
|
enable the driver to write the filtering hardware tables to allow for changing of rss rules
|
['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']
|
['ice ']
|
['c']
| 1
| 1
| 1
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c -#define drv_version_build 1 +#define drv_version_build 2
|
Networking
|
18a8d3586310743d451c94db46319797e72727da
|
tony nguyen andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
ice: enable ip link show on the pf to display vf unicast mac(s)
|
currently when there are sr-iov vf(s) and the user does "ip link show <pf interface>" the vf unicast mac addresses all show 00:00:00:00:00:00 if the unicast mac was set via virtchnl (i.e. not administratively set by the host 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.
|
enable ip link show on the pf to display vf unicast mac(s)
|
['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']
|
['ice ']
|
['c']
| 1
| 99
| 100
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c -/** - * ice_err_to_virt err - translate errors for vf return code - * @ice_err: error return code - */ -static enum virtchnl_status_code ice_err_to_virt_err(enum ice_status ice_err) -{ - switch (ice_err) { - case ice_success: - return virtchnl_status_success; - case ice_err_bad_ptr: - case ice_err_inval_size: - case ice_err_device_not_supported: - case ice_err_param: - case ice_err_cfg: - return virtchnl_status_err_param; - case ice_err_no_memory: - return virtchnl_status_err_no_memory; - case ice_err_not_ready: - case ice_err_reset_failed: - case ice_err_fw_api_ver: - case ice_err_aq_error: - case ice_err_aq_timeout: - case ice_err_aq_full: - case ice_err_aq_no_work: - case ice_err_aq_empty: - return virtchnl_status_err_admin_queue_error; - default: - return virtchnl_status_err_not_supported; - } -} - +/** + * ice_vc_add_mac_addr - attempt to add the mac address passed in + * @vf: pointer to the vf info + * @vsi: pointer to the vf's vsi + * @mac_addr: mac address to add + */ +static int +ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, u8 *mac_addr) +{ + struct device *dev = ice_pf_to_dev(vf->pf); + enum ice_status status; + + /* default unicast mac already added */ + if (ether_addr_equal(mac_addr, vf->dflt_lan_addr.addr)) + return 0; + + if (is_unicast_ether_addr(mac_addr) && !ice_can_vf_change_mac(vf)) { + dev_err(dev, "vf attempting to override administratively set mac address, bring down and up the vf interface to resume normal operation "); + return -eperm; + } + + status = ice_vsi_cfg_mac_fltr(vsi, mac_addr, true); + if (status == ice_err_already_exists) { + dev_err(dev, "mac %pm already exists for vf %d ", mac_addr, + vf->vf_id); + return -eexist; + } else if (status) { + dev_err(dev, "failed to add mac %pm for vf %d , error %d ", + mac_addr, vf->vf_id, status); + return -eio; + } + + /* only set dflt_lan_addr once */ + if (is_zero_ether_addr(vf->dflt_lan_addr.addr) && + is_unicast_ether_addr(mac_addr)) + ether_addr_copy(vf->dflt_lan_addr.addr, mac_addr); + + vf->num_mac++; + + return 0; +} + +/** + * ice_vc_del_mac_addr - attempt to delete the mac address passed in + * @vf: pointer to the vf info + * @vsi: pointer to the vf's vsi + * @mac_addr: mac address to delete + */ +static int +ice_vc_del_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, u8 *mac_addr) +{ + struct device *dev = ice_pf_to_dev(vf->pf); + enum ice_status status; + + if (!ice_can_vf_change_mac(vf) && + ether_addr_equal(mac_addr, vf->dflt_lan_addr.addr)) + return 0; + + status = ice_vsi_cfg_mac_fltr(vsi, mac_addr, false); + if (status == ice_err_does_not_exist) { + dev_err(dev, "mac %pm does not exist for vf %d ", mac_addr, + vf->vf_id); + return -enoent; + } else if (status) { + dev_err(dev, "failed to delete mac %pm for vf %d, error %d ", + mac_addr, vf->vf_id, status); + return -eio; + } + + if (ether_addr_equal(mac_addr, vf->dflt_lan_addr.addr)) + eth_zero_addr(vf->dflt_lan_addr.addr); + + vf->num_mac--; + + return 0; +} + + int (*ice_vc_cfg_mac) + (struct ice_vf *vf, struct ice_vsi *vsi, u8 *mac_addr); - enum ice_status status; - struct device *dev; - int mac_count = 0; - dev = ice_pf_to_dev(pf); - - if (set) + if (set) { - else + ice_vc_cfg_mac = ice_vc_add_mac_addr; + } else { + ice_vc_cfg_mac = ice_vc_del_mac_addr; + } + /* if this vf is not privileged, then we can't add more than a + * limited number of addresses. check to make sure that the + * additions do not push us over the limit. + */ - dev_err(dev, + dev_err(ice_pf_to_dev(pf), - /* there is no need to let vf know about not being trusted - * to add more mac addr, so we can just return success message. - */ - u8 *maddr = al->list[i].addr; + u8 *mac_addr = al->list[i].addr; + int result; - if (ether_addr_equal(maddr, vf->dflt_lan_addr.addr) || - is_broadcast_ether_addr(maddr)) { - if (set) { - /* vf is trying to add filters that the pf - * already added. just continue. - */ - dev_info(dev, - "mac %pm already set for vf %d ", - maddr, vf->vf_id); - continue; - } else { - /* vf can't remove dflt_lan_addr/bcast mac */ - dev_err(dev, - "vf can't remove default mac address or mac %pm programmed by pf for vf %d ", - maddr, vf->vf_id); - continue; - } - } - - /* check for the invalid cases and bail if necessary */ - if (is_zero_ether_addr(maddr)) { - dev_err(dev, - "invalid mac %pm provided for vf %d ", - maddr, vf->vf_id); - v_ret = virtchnl_status_err_param; - goto handle_mac_exit; - } - - if (is_unicast_ether_addr(maddr) && - !ice_can_vf_change_mac(vf)) { - dev_err(dev, - "can't change unicast mac for untrusted vf %d ", - vf->vf_id); - v_ret = virtchnl_status_err_param; - goto handle_mac_exit; - } + if (is_broadcast_ether_addr(mac_addr) || + is_zero_ether_addr(mac_addr)) + continue; - /* program the updated filter list */ - status = ice_vsi_cfg_mac_fltr(vsi, maddr, set); - if (status == ice_err_does_not_exist || - status == ice_err_already_exists) { - dev_info(dev, - "can't %s mac filters %pm for vf %d, error %d ", - set ? "add" : "remove", maddr, vf->vf_id, - status); - } else if (status) { - dev_err(dev, - "can't %s mac filters for vf %d, error %d ", - set ? "add" : "remove", vf->vf_id, status); - v_ret = ice_err_to_virt_err(status); + result = ice_vc_cfg_mac(vf, vsi, mac_addr); + if (result == -eexist || result == -enoent) { + continue; + } else if (result) { + v_ret = virtchnl_status_err_admin_queue_error; - - mac_count++; - /* track number of mac filters programmed for the vf vsi */ - if (set) - vf->num_mac += mac_count; - else - vf->num_mac -= mac_count; -
|
Networking
|
ed4c068d46f69f6f248c6e5a22f69cc84bdb5bb6
|
brett creeley
|
drivers
|
net
|
ethernet, ice, intel
|
ice: support udp segmentation offload
|
based on the work done by alex duyck on other intel drivers, add code to support udp segmentation offload (uso) for the ice 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.
|
support udp segmentation 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']
|
['ice ']
|
['c']
| 2
| 14
| 4
|
--- diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c - tso_features = netif_f_tso; + tso_features = netif_f_tso | + netif_f_gso_udp_l4; diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c --- a/drivers/net/ethernet/intel/ice/ice_txrx.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c + struct udphdr *udp; - csum_replace_by_diff(&l4.tcp->check, (__force __wsum)htonl(paylen)); - /* compute length of segmentation header */ - off->header_len = (l4.tcp->doff * 4) + l4_start; + if (skb_shinfo(skb)->gso_type & skb_gso_udp_l4) { + csum_replace_by_diff(&l4.udp->check, + (__force __wsum)htonl(paylen)); + /* compute length of udp segmentation header */ + off->header_len = sizeof(l4.udp) + l4_start; + } else { + csum_replace_by_diff(&l4.tcp->check, + (__force __wsum)htonl(paylen)); + /* compute length of tcp segmentation header */ + off->header_len = (l4.tcp->doff * 4) + l4_start; + }
|
Networking
|
a54e3b8cffd6d2f12c7fcf14f6d13ab997c0f160
|
brett creeley andrew bowers andrewx bowers intel com
|
drivers
|
net
|
ethernet, ice, intel
|
igc: add phy power management control
|
phy power management control should provide a reliable and accurate indication of phy reset completion and decrease the delay time after a phy reset
|
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 power management control
|
['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']
|
['igc ']
|
['h', 'c']
| 3
| 17
| 1
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +#define igc_phy_rst_comp 0x0100 /* internal phy reset completion */ diff --git a/drivers/net/ethernet/intel/igc/igc_phy.c b/drivers/net/ethernet/intel/igc/igc_phy.c --- a/drivers/net/ethernet/intel/igc/igc_phy.c +++ b/drivers/net/ethernet/intel/igc/igc_phy.c + u32 phpm = 0, timeout = 10000; + phpm = rd32(igc_i225_phpm); + - usleep_range(1500, 2000); + /* sw should guarantee 100us for the completion of the phy reset */ + usleep_range(100, 150); + do { + phpm = rd32(igc_i225_phpm); + timeout--; + udelay(1); + } while (!(phpm & igc_phy_rst_comp) && timeout); + + if (!timeout) + hw_dbg("timeout is expired after a phy reset "); + + usleep_range(100, 150); diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h b/drivers/net/ethernet/intel/igc/igc_regs.h --- a/drivers/net/ethernet/intel/igc/igc_regs.h +++ b/drivers/net/ethernet/intel/igc/igc_regs.h +#define igc_i225_phpm 0x00e14 /* i225 phy power management */
|
Networking
|
bcb3244ccdc4cebb6ed3d47d973da7b1a03837c0
|
sasha neftin aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add sku for i225 device
|
add support for blank nvm sku
|
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 sku for i225 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']
|
['igc ']
|
['c', 'h']
| 3
| 3
| 0
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc_base.c b/drivers/net/ethernet/intel/igc/igc_base.c --- a/drivers/net/ethernet/intel/igc/igc_base.c +++ b/drivers/net/ethernet/intel/igc/igc_base.c + case igc_dev_id_i225_blank_nvm: diff --git a/drivers/net/ethernet/intel/igc/igc_hw.h b/drivers/net/ethernet/intel/igc/igc_hw.h --- a/drivers/net/ethernet/intel/igc/igc_hw.h +++ b/drivers/net/ethernet/intel/igc/igc_hw.h +#define igc_dev_id_i225_blank_nvm 0x15fd diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c + { pci_vdevice(intel, igc_dev_id_i225_blank_nvm), board_base },
|
Networking
|
0e7d4b93b0de94386be44d2a7ffa417a5c4adc1b
|
sasha neftin aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add basic skeleton for ptp
|
this allows the creation of the /dev/ptpx device for i225, and reading and writing the 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 basic support for timestamping/ptp
|
['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']
|
['igc ']
|
['h', 'c', 'makefile']
| 6
| 439
| 1
|
--- diff --git a/drivers/net/ethernet/intel/igc/makefile b/drivers/net/ethernet/intel/igc/makefile --- a/drivers/net/ethernet/intel/igc/makefile +++ b/drivers/net/ethernet/intel/igc/makefile -igc_ethtool.o +igc_ethtool.o igc_ptp.o diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h +#include <linux/ptp_clock_kernel.h> +#include <linux/timecounter.h> +#include <linux/net_tstamp.h> +/* flags controlling ptp/1588 function */ +#define igc_ptp_enabled bit(0) + +#define igc_flag_ptp bit(8) + + struct ptp_clock *ptp_clock; + struct ptp_clock_info ptp_caps; + struct work_struct ptp_tx_work; + struct sk_buff *ptp_tx_skb; + struct hwtstamp_config tstamp_config; + unsigned long ptp_tx_start; + unsigned long last_rx_ptp_check; + unsigned long last_rx_timestamp; + unsigned int ptp_flags; + /* system time value lock */ + spinlock_t tmreg_lock; + struct cyclecounter cc; + struct timecounter tc; +void igc_ptp_init(struct igc_adapter *adapter); +void igc_ptp_reset(struct igc_adapter *adapter); +void igc_ptp_stop(struct igc_adapter *adapter); +int igc_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr); +int igc_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr); diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +#define igc_icr_ts bit(19) /* time sync interrupt */ +#define igc_ims_ts igc_icr_ts /* time sync interrupt */ +/* time sync interrupt causes */ +#define igc_tsicr_sys_wrap bit(0) /* systim wrap around. */ +#define igc_tsicr_txts bit(1) /* transmit timestamp. */ +#define igc_tsicr_tt0 bit(3) /* target time 0 trigger. */ +#define igc_tsicr_tt1 bit(4) /* target time 1 trigger. */ +#define igc_tsicr_autt0 bit(5) /* auxiliary timestamp 0 taken. */ +#define igc_tsicr_autt1 bit(6) /* auxiliary timestamp 1 taken. */ + +#define igc_tsicr_interrupts igc_tsicr_txts + diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c + /* re-enable ptp, where applicable. */ + igc_ptp_reset(adapter); + +/** + * igc_ioctl - access the hwtstamp interface + * @netdev: network interface device structure + * @ifreq: interface request data + * @cmd: ioctl command + **/ +static int igc_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) +{ + switch (cmd) { + case siocghwtstamp: + return igc_ptp_get_ts_config(netdev, ifr); + case siocshwtstamp: + return igc_ptp_set_ts_config(netdev, ifr); + default: + return -eopnotsupp; + } +} + + .ndo_do_ioctl = igc_ioctl, + /* do hw tstamp init after resetting */ + igc_ptp_init(adapter); + + igc_ptp_stop(adapter); + diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c --- /dev/null +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c +// spdx-license-identifier: gpl-2.0 +/* copyright (c) 2019 intel corporation */ + +#include "igc.h" + +#include <linux/module.h> +#include <linux/device.h> +#include <linux/pci.h> +#include <linux/ptp_classify.h> +#include <linux/clocksource.h> + +#define incvalue_mask 0x7fffffff +#define isgn 0x80000000 + +#define igc_systim_overflow_period (hz * 60 * 9) +#define igc_ptp_tx_timeout (hz * 15) + +/* systim read access for i225 */ +static void igc_ptp_read_i225(struct igc_adapter *adapter, + struct timespec64 *ts) +{ + struct igc_hw *hw = &adapter->hw; + u32 sec, nsec; + + /* the timestamp latches on lowest register read. for i210/i211, the + * lowest register is systimr. since we only need to provide nanosecond + * resolution, we can ignore it. + */ + rd32(igc_systimr); + nsec = rd32(igc_systiml); + sec = rd32(igc_systimh); + + ts->tv_sec = sec; + ts->tv_nsec = nsec; +} + +static void igc_ptp_write_i225(struct igc_adapter *adapter, + const struct timespec64 *ts) +{ + struct igc_hw *hw = &adapter->hw; + + /* writing the systimr register is not necessary as it only + * provides sub-nanosecond resolution. + */ + wr32(igc_systiml, ts->tv_nsec); + wr32(igc_systimh, ts->tv_sec); +} + +static int igc_ptp_adjfine_i225(struct ptp_clock_info *ptp, long scaled_ppm) +{ + struct igc_adapter *igc = container_of(ptp, struct igc_adapter, + ptp_caps); + struct igc_hw *hw = &igc->hw; + int neg_adj = 0; + u64 rate; + u32 inca; + + if (scaled_ppm < 0) { + neg_adj = 1; + scaled_ppm = -scaled_ppm; + } + rate = scaled_ppm; + rate <<= 14; + rate = div_u64(rate, 78125); + + inca = rate & incvalue_mask; + if (neg_adj) + inca |= isgn; + + wr32(igc_timinca, inca); + + return 0; +} + +static int igc_ptp_adjtime_i225(struct ptp_clock_info *ptp, s64 delta) +{ + struct igc_adapter *igc = container_of(ptp, struct igc_adapter, + ptp_caps); + struct timespec64 now, then = ns_to_timespec64(delta); + unsigned long flags; + + spin_lock_irqsave(&igc->tmreg_lock, flags); + + igc_ptp_read_i225(igc, &now); + now = timespec64_add(now, then); + igc_ptp_write_i225(igc, (const struct timespec64 *)&now); + + spin_unlock_irqrestore(&igc->tmreg_lock, flags); + + return 0; +} + +static int igc_ptp_gettimex64_i225(struct ptp_clock_info *ptp, + struct timespec64 *ts, + struct ptp_system_timestamp *sts) +{ + struct igc_adapter *igc = container_of(ptp, struct igc_adapter, + ptp_caps); + struct igc_hw *hw = &igc->hw; + unsigned long flags; + + spin_lock_irqsave(&igc->tmreg_lock, flags); + + ptp_read_system_prets(sts); + rd32(igc_systimr); + ptp_read_system_postts(sts); + ts->tv_nsec = rd32(igc_systiml); + ts->tv_sec = rd32(igc_systimh); + + spin_unlock_irqrestore(&igc->tmreg_lock, flags); + + return 0; +} + +static int igc_ptp_settime_i225(struct ptp_clock_info *ptp, + const struct timespec64 *ts) +{ + struct igc_adapter *igc = container_of(ptp, struct igc_adapter, + ptp_caps); + unsigned long flags; + + spin_lock_irqsave(&igc->tmreg_lock, flags); + + igc_ptp_write_i225(igc, ts); + + spin_unlock_irqrestore(&igc->tmreg_lock, flags); + + return 0; +} + +static int igc_ptp_feature_enable_i225(struct ptp_clock_info *ptp, + struct ptp_clock_request *rq, int on) +{ + return -eopnotsupp; +} + +static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter, + struct hwtstamp_config *config) +{ + return 0; +} + +void igc_ptp_tx_hang(struct igc_adapter *adapter) +{ + bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + + igc_ptp_tx_timeout); + struct igc_hw *hw = &adapter->hw; + + if (!adapter->ptp_tx_skb) + return; + + if (!test_bit(__igc_ptp_tx_in_progress, &adapter->state)) + return; + + /* if we haven't received a timestamp within the timeout, it is + * reasonable to assume that it will never occur, so we can unlock the + * timestamp bit when this occurs. + */ + if (timeout) { + cancel_work_sync(&adapter->ptp_tx_work); + dev_kfree_skb_any(adapter->ptp_tx_skb); + adapter->ptp_tx_skb = null; + clear_bit_unlock(__igc_ptp_tx_in_progress, &adapter->state); + adapter->tx_hwtstamp_timeouts++; + /* clear the tx valid bit in tsynctxctl register to enable + * interrupt + */ + rd32(igc_txstmph); + dev_warn(&adapter->pdev->dev, "clearing tx timestamp hang "); + } +} + +void igc_ptp_tx_work(struct work_struct *work) +{ +} + +/** + * igc_ptp_set_ts_config - set hardware time stamping config + * @netdev: network interface device structure + * @ifreq: interface request data + * + **/ +int igc_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr) +{ + struct igc_adapter *adapter = netdev_priv(netdev); + struct hwtstamp_config config; + int err; + + if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) + return -efault; + + err = igc_ptp_set_timestamp_mode(adapter, &config); + if (err) + return err; + + /* save these settings for future reference */ + memcpy(&adapter->tstamp_config, &config, + sizeof(adapter->tstamp_config)); + + return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? + -efault : 0; +} + +/** + * igc_ptp_get_ts_config - get hardware time stamping config + * @netdev: network interface device structure + * @ifreq: interface request data + * + * get the hwtstamp_config settings to return to the user. rather than attempt + * to deconstruct the settings from the registers, just return a shadow copy + * of the last known settings. + **/ +int igc_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr) +{ + struct igc_adapter *adapter = netdev_priv(netdev); + struct hwtstamp_config *config = &adapter->tstamp_config; + + return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? + -efault : 0; +} + +/** + * igc_ptp_init - initialize ptp functionality + * @adapter: board private structure + * + * this function is called at device probe to initialize the ptp + * functionality. + */ +void igc_ptp_init(struct igc_adapter *adapter) +{ + struct net_device *netdev = adapter->netdev; + struct igc_hw *hw = &adapter->hw; + + switch (hw->mac.type) { + case igc_i225: + snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr); + adapter->ptp_caps.owner = this_module; + adapter->ptp_caps.max_adj = 62499999; + adapter->ptp_caps.adjfine = igc_ptp_adjfine_i225; + adapter->ptp_caps.adjtime = igc_ptp_adjtime_i225; + adapter->ptp_caps.gettimex64 = igc_ptp_gettimex64_i225; + adapter->ptp_caps.settime64 = igc_ptp_settime_i225; + adapter->ptp_caps.enable = igc_ptp_feature_enable_i225; + break; + default: + adapter->ptp_clock = null; + return; + } + + spin_lock_init(&adapter->tmreg_lock); + init_work(&adapter->ptp_tx_work, igc_ptp_tx_work); + + adapter->tstamp_config.rx_filter = hwtstamp_filter_none; + adapter->tstamp_config.tx_type = hwtstamp_tx_off; + + igc_ptp_reset(adapter); + + adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, + &adapter->pdev->dev); + if (is_err(adapter->ptp_clock)) { + adapter->ptp_clock = null; + dev_err(&adapter->pdev->dev, "ptp_clock_register failed "); + } else if (adapter->ptp_clock) { + dev_info(&adapter->pdev->dev, "added phc on %s ", + adapter->netdev->name); + adapter->ptp_flags |= igc_ptp_enabled; + } +} + +/** + * igc_ptp_suspend - disable ptp work items and prepare for suspend + * @adapter: board private structure + * + * this function stops the overflow check work and ptp tx timestamp work, and + * will prepare the device for os suspend. + */ +void igc_ptp_suspend(struct igc_adapter *adapter) +{ + if (!(adapter->ptp_flags & igc_ptp_enabled)) + return; + + cancel_work_sync(&adapter->ptp_tx_work); + if (adapter->ptp_tx_skb) { + dev_kfree_skb_any(adapter->ptp_tx_skb); + adapter->ptp_tx_skb = null; + clear_bit_unlock(__igc_ptp_tx_in_progress, &adapter->state); + } +} + +/** + * igc_ptp_stop - disable ptp device and stop the overflow check. + * @adapter: board private structure. + * + * this function stops the ptp support and cancels the delayed work. + **/ +void igc_ptp_stop(struct igc_adapter *adapter) +{ + igc_ptp_suspend(adapter); + + if (adapter->ptp_clock) { + ptp_clock_unregister(adapter->ptp_clock); + dev_info(&adapter->pdev->dev, "removed phc on %s ", + adapter->netdev->name); + adapter->ptp_flags &= ~igc_ptp_enabled; + } +} + +/** + * igc_ptp_reset - re-enable the adapter for ptp following a reset. + * @adapter: board private structure. + * + * this function handles the reset work required to re-enable the ptp device. + **/ +void igc_ptp_reset(struct igc_adapter *adapter) +{ + struct igc_hw *hw = &adapter->hw; + unsigned long flags; + + /* reset the tstamp_config */ + igc_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config); + + spin_lock_irqsave(&adapter->tmreg_lock, flags); + + switch (adapter->hw.mac.type) { + case igc_i225: + wr32(igc_tsauxc, 0x0); + wr32(igc_tssdp, 0x0); + wr32(igc_tsim, igc_tsicr_interrupts); + wr32(igc_ims, igc_ims_ts); + break; + default: + /* no work to do. */ + goto out; + } + + /* re-initialize the timer. */ + if (hw->mac.type == igc_i225) { + struct timespec64 ts64 = ktime_to_timespec64(ktime_get_real()); + + igc_ptp_write_i225(adapter, &ts64); + } else { + timecounter_init(&adapter->tc, &adapter->cc, + ktime_to_ns(ktime_get_real())); + } +out: + spin_unlock_irqrestore(&adapter->tmreg_lock, flags); + + wrfl(); +} diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h b/drivers/net/ethernet/intel/igc/igc_regs.h --- a/drivers/net/ethernet/intel/igc/igc_regs.h +++ b/drivers/net/ethernet/intel/igc/igc_regs.h +/* time sync registers */ +#define igc_tsicr 0x0b66c /* time sync interrupt cause */ +#define igc_tsim 0x0b674 /* time sync interrupt mask register */ +#define igc_tsauxc 0x0b640 /* timesync auxiliary control register */ +#define igc_tsyncrxctl 0x0b620 /* rx time sync control register - rw */ +#define igc_tsynctxctl 0x0b614 /* tx time sync control register - rw */ +#define igc_tsyncrxcfg 0x05f50 /* time sync rx configuration - rw */ +#define igc_tssdp 0x0003c /* time sync sdp configuration register - rw */ + +#define igc_imir(_i) (0x05a80 + ((_i) * 4)) /* immediate interrupt */ +#define igc_imirext(_i) (0x05aa0 + ((_i) * 4)) /* immediate intr ext*/ + +#define igc_ftqf(_n) (0x059e0 + (4 * (_n))) /* 5-tuple queue fltr */ +/* system time registers */ +#define igc_systiml 0x0b600 /* system time register low - ro */ +#define igc_systimh 0x0b604 /* system time register high - ro */ +#define igc_systimr 0x0b6f8 /* system time register residue */ +#define igc_timinca 0x0b608 /* increment attributes register - rw */ + +#define igc_rxstmpl 0x0b624 /* rx timestamp low - ro */ +#define igc_rxstmph 0x0b628 /* rx timestamp high - ro */ +#define igc_txstmpl 0x0b618 /* tx timestamp value low - ro */ +#define igc_txstmph 0x0b61c /* tx timestamp value high - ro */ +
|
Networking
|
5f2958052c5820d0795616fcc299097390cf92a8
|
vinicius costa gomes aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add support for rx timestamping
|
this adds support for timestamping received 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 basic support for timestamping/ptp
|
['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']
|
['igc ']
|
['h', 'c']
| 5
| 340
| 0
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h +/* transmit and receive latency (for ptp timestamps) */ +/* fixme: these values were estimated using the ones that i210 has as + * basis, they seem to provide good numbers with ptp4l/phc2sys, but we + * need to confirm them. + */ +#define igc_i225_tx_latency_10 9542 +#define igc_i225_tx_latency_100 1024 +#define igc_i225_tx_latency_1000 178 +#define igc_i225_tx_latency_2500 64 +#define igc_i225_rx_latency_10 20662 +#define igc_i225_rx_latency_100 2213 +#define igc_i225_rx_latency_1000 448 +#define igc_i225_rx_latency_2500 160 + +void igc_ptp_rx_rgtstamp(struct igc_q_vector *q_vector, struct sk_buff *skb); +void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, void *va, + struct sk_buff *skb); diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +/* split replication receive control */ +#define igc_srrctl_timestamp 0x40000000 +#define igc_srrctl_timer1sel(timer) (((timer) & 0x3) << 14) +#define igc_srrctl_timer0sel(timer) (((timer) & 0x3) << 17) + +/* advanced receive descriptor bit definitions */ +#define igc_rxdadv_stat_tsip 0x08000 /* timestamp in packet */ +#define igc_rxdadv_stat_ts 0x10000 /* pkt was time stamped */ + +#define igc_rxpbs_cfg_ts_en 0x80000000 /* timestamp in rx buffer */ +/* ptp queue filter */ +#define igc_etqf_1588 bit(30) + +#define igc_ftqf_vf_bp 0x00008000 +#define igc_ftqf_1588_time_stamp 0x08000000 +#define igc_ftqf_mask 0xf0000000 +#define igc_ftqf_mask_proto_bp 0x10000000 + +/* time sync receive control bit definitions */ +#define igc_tsyncrxctl_valid 0x00000001 /* rx timestamp valid */ +#define igc_tsyncrxctl_type_mask 0x0000000e /* rx type mask */ +#define igc_tsyncrxctl_type_l2_v2 0x00 +#define igc_tsyncrxctl_type_l4_v1 0x02 +#define igc_tsyncrxctl_type_l2_l4_v2 0x04 +#define igc_tsyncrxctl_type_all 0x08 +#define igc_tsyncrxctl_type_event_v2 0x0a +#define igc_tsyncrxctl_enabled 0x00000010 /* enable rx timestamping */ +#define igc_tsyncrxctl_syscfi 0x00000020 /* sys clock frequency */ + +/* time sync receive configuration */ +#define igc_tsyncrxcfg_ptp_v1_ctrlt_mask 0x000000ff +#define igc_tsyncrxcfg_ptp_v1_sync_message 0x00 +#define igc_tsyncrxcfg_ptp_v1_delay_req_message 0x01 + +/* immediate interrupt receive extended */ +#define igc_imirext_ctrl_bp 0x00080000 /* bypass check of ctrl bits */ +#define igc_imirext_size_bp 0x00001000 /* packet size bypass */ + diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c + if (igc_test_staterr(rx_desc, igc_rxdadv_stat_ts) && + !igc_test_staterr(rx_desc, igc_rxdadv_stat_tsip)) + igc_ptp_rx_rgtstamp(rx_ring->q_vector, skb); + + if (unlikely(igc_test_staterr(rx_desc, igc_rxdadv_stat_tsip))) { + igc_ptp_rx_pktstamp(rx_ring->q_vector, va, skb); + va += igc_ts_hdr_len; + size -= igc_ts_hdr_len; + } + diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c +/** + * igc_ptp_systim_to_hwtstamp - convert system time value to hw timestamp + * @adapter: board private structure + * @hwtstamps: timestamp structure to update + * @systim: unsigned 64bit system time value + * + * we need to convert the system time value stored in the rx/txstmp registers + * into a hwtstamp which can be used by the upper level timestamping functions. + **/ +static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter, + struct skb_shared_hwtstamps *hwtstamps, + u64 systim) +{ + switch (adapter->hw.mac.type) { + case igc_i225: + memset(hwtstamps, 0, sizeof(*hwtstamps)); + /* upper 32 bits contain s, lower 32 bits contain ns. */ + hwtstamps->hwtstamp = ktime_set(systim >> 32, + systim & 0xffffffff); + break; + default: + break; + } +} + +/** + * igc_ptp_rx_pktstamp - retrieve rx per packet timestamp + * @q_vector: pointer to interrupt specific structure + * @va: pointer to address containing rx buffer + * @skb: buffer containing timestamp and packet + * + * this function is meant to retrieve the first timestamp from the + * first buffer of an incoming frame. the value is stored in little + * endian format starting on byte 0. there's a second timestamp + * starting on byte 8. + **/ +void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, void *va, + struct sk_buff *skb) +{ + struct igc_adapter *adapter = q_vector->adapter; + __le64 *regval = (__le64 *)va; + int adjust = 0; + + /* the timestamp is recorded in little endian format. + * dword: | 0 | 1 | 2 | 3 + * field: | timer0 low | timer0 high | timer1 low | timer1 high + */ + igc_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), + le64_to_cpu(regval[0])); + + /* adjust timestamp for the rx latency based on link speed */ + if (adapter->hw.mac.type == igc_i225) { + switch (adapter->link_speed) { + case speed_10: + adjust = igc_i225_rx_latency_10; + break; + case speed_100: + adjust = igc_i225_rx_latency_100; + break; + case speed_1000: + adjust = igc_i225_rx_latency_1000; + break; + case speed_2500: + adjust = igc_i225_rx_latency_2500; + break; + } + } + skb_hwtstamps(skb)->hwtstamp = + ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp, adjust); +} + +/** + * igc_ptp_rx_rgtstamp - retrieve rx timestamp stored in register + * @q_vector: pointer to interrupt specific structure + * @skb: buffer containing timestamp and packet + * + * this function is meant to retrieve a timestamp from the internal registers + * of the adapter and store it in the skb. + */ +void igc_ptp_rx_rgtstamp(struct igc_q_vector *q_vector, + struct sk_buff *skb) +{ + struct igc_adapter *adapter = q_vector->adapter; + struct igc_hw *hw = &adapter->hw; + u64 regval; + + /* if this bit is set, then the rx registers contain the time + * stamp. no other packet will be time stamped until we read + * these registers, so read the registers to make them + * available again. because only one packet can be time + * stamped at a time, we know that the register values must + * belong to this one here and therefore we don't need to + * compare any of the additional attributes stored for it. + * + * if nothing went wrong, then it should have a shared + * tx_flags that we can turn into a skb_shared_hwtstamps. + */ + if (!(rd32(igc_tsyncrxctl) & igc_tsyncrxctl_valid)) + return; + + regval = rd32(igc_rxstmpl); + regval |= (u64)rd32(igc_rxstmph) << 32; + + igc_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval); + + /* update the last_rx_timestamp timer in order to enable watchdog check + * for error case of latched timestamp on a dropped packet. + */ + adapter->last_rx_timestamp = jiffies; +} + +/** + * igc_ptp_enable_tstamp_rxqueue - enable rx timestamp for a queue + * @rx_ring: pointer to rx queue + * @timer: index for timer + * + * this function enables rx timestamping for a queue, and selects + * which 1588 timer will provide the timestamp. + */ +static void igc_ptp_enable_tstamp_rxqueue(struct igc_adapter *adapter, + struct igc_ring *rx_ring, u8 timer) +{ + struct igc_hw *hw = &adapter->hw; + int reg_idx = rx_ring->reg_idx; + u32 srrctl = rd32(igc_srrctl(reg_idx)); + + srrctl |= igc_srrctl_timestamp; + srrctl |= igc_srrctl_timer1sel(timer); + srrctl |= igc_srrctl_timer0sel(timer); + + wr32(igc_srrctl(reg_idx), srrctl); +} + +static void igc_ptp_enable_tstamp_all_rxqueues(struct igc_adapter *adapter, + u8 timer) +{ + int i; + + for (i = 0; i < adapter->num_rx_queues; i++) { + struct igc_ring *ring = adapter->rx_ring[i]; + + igc_ptp_enable_tstamp_rxqueue(adapter, ring, timer); + } +} + +/** + * igc_ptp_set_timestamp_mode - setup hardware for timestamping + * @adapter: networking device structure + * @config: hwtstamp configuration + * + * incoming time stamping has to be configured via the hardware + * filters. not all combinations are supported, in particular event + * type has to be specified. matching the kind of event packet is + * not supported, with the exception of "all v2 events regardless of + * level 2 or 4". + * + */ + u32 tsync_rx_ctl = igc_tsyncrxctl_enabled; + struct igc_hw *hw = &adapter->hw; + u32 tsync_rx_cfg = 0; + bool is_l4 = false; + bool is_l2 = false; + u32 regval; + + /* reserved for future extensions */ + if (config->flags) + return -einval; + + switch (config->rx_filter) { + case hwtstamp_filter_none: + tsync_rx_ctl = 0; + break; + case hwtstamp_filter_ptp_v1_l4_sync: + tsync_rx_ctl |= igc_tsyncrxctl_type_l4_v1; + tsync_rx_cfg = igc_tsyncrxcfg_ptp_v1_sync_message; + is_l4 = true; + break; + case hwtstamp_filter_ptp_v1_l4_delay_req: + tsync_rx_ctl |= igc_tsyncrxctl_type_l4_v1; + tsync_rx_cfg = igc_tsyncrxcfg_ptp_v1_delay_req_message; + is_l4 = true; + break; + case hwtstamp_filter_ptp_v2_event: + case hwtstamp_filter_ptp_v2_l2_event: + case hwtstamp_filter_ptp_v2_l4_event: + case hwtstamp_filter_ptp_v2_sync: + case hwtstamp_filter_ptp_v2_l2_sync: + case hwtstamp_filter_ptp_v2_l4_sync: + case hwtstamp_filter_ptp_v2_delay_req: + case hwtstamp_filter_ptp_v2_l2_delay_req: + case hwtstamp_filter_ptp_v2_l4_delay_req: + tsync_rx_ctl |= igc_tsyncrxctl_type_event_v2; + config->rx_filter = hwtstamp_filter_ptp_v2_event; + is_l2 = true; + is_l4 = true; + break; + case hwtstamp_filter_ptp_v1_l4_event: + case hwtstamp_filter_ntp_all: + case hwtstamp_filter_all: + tsync_rx_ctl |= igc_tsyncrxctl_type_all; + config->rx_filter = hwtstamp_filter_all; + break; + /* fall through */ + default: + config->rx_filter = hwtstamp_filter_none; + return -erange; + } + + /* per-packet timestamping only works if all packets are + * timestamped, so enable timestamping in all packets as long + * as one rx filter was configured. + */ + if (tsync_rx_ctl) { + tsync_rx_ctl = igc_tsyncrxctl_enabled; + tsync_rx_ctl |= igc_tsyncrxctl_type_all; + config->rx_filter = hwtstamp_filter_all; + is_l2 = true; + is_l4 = true; + + if (hw->mac.type == igc_i225) { + regval = rd32(igc_rxpbs); + regval |= igc_rxpbs_cfg_ts_en; + wr32(igc_rxpbs, regval); + + /* fixme: for now, only support retrieving rx + * timestamps from timer 0 + */ + igc_ptp_enable_tstamp_all_rxqueues(adapter, 0); + } + } + + /* enable/disable rx */ + regval = rd32(igc_tsyncrxctl); + regval &= ~(igc_tsyncrxctl_enabled | igc_tsyncrxctl_type_mask); + regval |= tsync_rx_ctl; + wr32(igc_tsyncrxctl, regval); + + /* define which ptp packets are time stamped */ + wr32(igc_tsyncrxcfg, tsync_rx_cfg); + + /* define ethertype filter for timestamped packets */ + if (is_l2) + wr32(igc_etqf(3), + (igc_etqf_filter_enable | /* enable filter */ + igc_etqf_1588 | /* enable timestamping */ + eth_p_1588)); /* 1588 eth protocol type */ + else + wr32(igc_etqf(3), 0); + + /* l4 queue filter[3]: filter by destination port and protocol */ + if (is_l4) { + u32 ftqf = (ipproto_udp /* udp */ + | igc_ftqf_vf_bp /* vf not compared */ + | igc_ftqf_1588_time_stamp /* enable timestamp */ + | igc_ftqf_mask); /* mask all inputs */ + ftqf &= ~igc_ftqf_mask_proto_bp; /* enable protocol check */ + + wr32(igc_imir(3), htons(ptp_ev_port)); + wr32(igc_imirext(3), + (igc_imirext_size_bp | igc_imirext_ctrl_bp)); + wr32(igc_ftqf(3), ftqf); + } else { + wr32(igc_ftqf(3), igc_ftqf_mask); + } + wrfl(); + + /* clear tx/rx time stamp registers, just to be sure */ + regval = rd32(igc_txstmpl); + regval = rd32(igc_txstmph); + regval = rd32(igc_rxstmpl); + regval = rd32(igc_rxstmph); + diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h b/drivers/net/ethernet/intel/igc/igc_regs.h --- a/drivers/net/ethernet/intel/igc/igc_regs.h +++ b/drivers/net/ethernet/intel/igc/igc_regs.h + +#define igc_rxpbs 0x02404 /* rx packet buffer size - rw */ +
|
Networking
|
81b055205e8ba2d400c8fa5845ba540a4a880a3a
|
vinicius costa gomes
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add support for tx timestamping
|
this adds support for timestamping packets being 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 basic support for timestamping/ptp
|
['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']
|
['igc ']
|
['h', 'c']
| 4
| 158
| 0
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h +void igc_ptp_tx_hang(struct igc_adapter *adapter); + diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +/* immediate interrupt receive */ +#define igc_imir_clear_mask 0xf001ffff /* imir reg clear mask */ +#define igc_imir_port_bypass 0x20000 /* imir port bypass bit */ +#define igc_imir_priority_shift 29 /* imir priority shift */ +#define igc_imirext_clear_mask 0x7ffff /* imirext reg clear mask */ + +/* time sync transmit control bit definitions */ +#define igc_tsynctxctl_valid 0x00000001 /* tx timestamp valid */ +#define igc_tsynctxctl_enabled 0x00000010 /* enable tx timestamping */ +#define igc_tsynctxctl_max_allowed_dly_mask 0x0000f000 /* max delay */ +#define igc_tsynctxctl_sync_comp_err 0x20000000 /* sync err */ +#define igc_tsynctxctl_sync_comp 0x40000000 /* sync complete */ +#define igc_tsynctxctl_start_sync 0x80000000 /* initiate sync */ + diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c +#define igc_set_flag(_input, _flag, _result) \ + (((_flag) <= (_result)) ? \ + ((u32)((_input) & (_flag)) * ((_result) / (_flag))) : \ + ((u32)((_input) & (_flag)) / ((_flag) / (_result)))) + + /* set timestamp bit if present */ + cmd_type |= igc_set_flag(tx_flags, igc_tx_flags_tstamp, + (igc_advtxd_mac_tstamp)); + + if (unlikely(skb_shinfo(skb)->tx_flags & skbtx_hw_tstamp)) { + struct igc_adapter *adapter = netdev_priv(tx_ring->netdev); + + /* fixme: add support for retrieving timestamps from + * the other timer registers before skipping the + * timestamping request. + */ + if (adapter->tstamp_config.tx_type == hwtstamp_tx_on && + !test_and_set_bit_lock(__igc_ptp_tx_in_progress, + &adapter->state)) { + skb_shinfo(skb)->tx_flags |= skbtx_in_progress; + tx_flags |= igc_tx_flags_tstamp; + + adapter->ptp_tx_skb = skb_get(skb); + adapter->ptp_tx_start = jiffies; + } else { + adapter->tx_hwtstamp_skipped++; + } + } + +static void igc_tsync_interrupt(struct igc_adapter *adapter) +{ + struct igc_hw *hw = &adapter->hw; + u32 tsicr = rd32(igc_tsicr); + u32 ack = 0; + + if (tsicr & igc_tsicr_txts) { + /* retrieve hardware timestamp */ + schedule_work(&adapter->ptp_tx_work); + ack |= igc_tsicr_txts; + } + + /* acknowledge the interrupts */ + wr32(igc_tsicr, ack); +} + + if (icr & igc_icr_ts) + igc_tsync_interrupt(adapter); + + igc_ptp_tx_hang(adapter); + diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c + * outgoing time stamping can be enabled and disabled. play nice and + * disable it when requested, although it shouldn't case any overhead + * when no packet needs it. at most one packet in the queue may be + * marked for time stamping, otherwise it would be impossible to tell + * for sure to which packet the hardware time stamp belongs. + * + u32 tsync_tx_ctl = igc_tsynctxctl_enabled; + switch (config->tx_type) { + case hwtstamp_tx_off: + tsync_tx_ctl = 0; + case hwtstamp_tx_on: + break; + default: + return -erange; + } + + if (tsync_tx_ctl) + tsync_tx_ctl = igc_tsynctxctl_enabled; + + /* enable/disable tx */ + regval = rd32(igc_tsynctxctl); + regval &= ~igc_tsynctxctl_enabled; + regval |= tsync_tx_ctl; + wr32(igc_tsynctxctl, regval); + +/** + * igc_ptp_tx_hwtstamp - utility function which checks for tx time stamp + * @adapter: board private structure + * + * if we were asked to do hardware stamping and such a time stamp is + * available, then it must have been for this skb here because we only + * allow only one such packet into the queue. + */ +static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) +{ + struct sk_buff *skb = adapter->ptp_tx_skb; + struct skb_shared_hwtstamps shhwtstamps; + struct igc_hw *hw = &adapter->hw; + u64 regval; + + regval = rd32(igc_txstmpl); + regval |= (u64)rd32(igc_txstmph) << 32; + igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval); + + /* clear the lock early before calling skb_tstamp_tx so that + * applications are not woken up before the lock bit is clear. we use + * a copy of the skb pointer to ensure other threads can't change it + * while we're notifying the stack. + */ + adapter->ptp_tx_skb = null; + clear_bit_unlock(__igc_ptp_tx_in_progress, &adapter->state); + + /* notify the stack and free the skb after we've unlocked */ + skb_tstamp_tx(skb, &shhwtstamps); + dev_kfree_skb_any(skb); +} + +/** + * igc_ptp_tx_work + * @work: pointer to work struct + * + * this work function polls the tsynctxctl valid bit to determine when a + * timestamp has been taken for the current stored skb. + */ + struct igc_adapter *adapter = container_of(work, struct igc_adapter, + ptp_tx_work); + struct igc_hw *hw = &adapter->hw; + u32 tsynctxctl; + + if (!adapter->ptp_tx_skb) + return; + + if (time_is_before_jiffies(adapter->ptp_tx_start + + igc_ptp_tx_timeout)) { + dev_kfree_skb_any(adapter->ptp_tx_skb); + adapter->ptp_tx_skb = null; + clear_bit_unlock(__igc_ptp_tx_in_progress, &adapter->state); + adapter->tx_hwtstamp_timeouts++; + /* clear the tx valid bit in tsynctxctl register to enable + * interrupt + */ + rd32(igc_txstmph); + dev_warn(&adapter->pdev->dev, "clearing tx timestamp hang "); + return; + } + + tsynctxctl = rd32(igc_tsynctxctl); + if (tsynctxctl & igc_tsynctxctl_valid) + igc_ptp_tx_hwtstamp(adapter); + else + /* reschedule to check later */ + schedule_work(&adapter->ptp_tx_work);
|
Networking
|
2c344ae24501558b14341247abef41e0b420c090
|
vinicius costa gomes
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add support for ethtool get_ts_info command
|
this command allows igc to report what types of timestamping are supported. ptp4l uses this to detect if the hardware supports timestamping.
|
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 basic support for timestamping/ptp
|
['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']
|
['igc ']
|
['c']
| 1
| 34
| 0
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c +static int igc_get_ts_info(struct net_device *dev, + struct ethtool_ts_info *info) +{ + struct igc_adapter *adapter = netdev_priv(dev); + + if (adapter->ptp_clock) + info->phc_index = ptp_clock_index(adapter->ptp_clock); + else + info->phc_index = -1; + + switch (adapter->hw.mac.type) { + case igc_i225: + info->so_timestamping = + sof_timestamping_tx_software | + sof_timestamping_rx_software | + sof_timestamping_software | + sof_timestamping_tx_hardware | + sof_timestamping_rx_hardware | + sof_timestamping_raw_hardware; + + info->tx_types = + bit(hwtstamp_tx_off) | + bit(hwtstamp_tx_on); + + info->rx_filters = bit(hwtstamp_filter_none); + info->rx_filters |= bit(hwtstamp_filter_all); + + return 0; + default: + return -eopnotsupp; + } +} + + .get_ts_info = igc_get_ts_info,
|
Networking
|
60dbede0c4f3d7b1a1f56d1f91bbca3c5a73f7f5
|
vinicius costa gomes aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
igc: use start of packet signal from phy for timestamping
|
for better accuracy, i225 is able to do timestamping using the start of packet signal from the phy.
|
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 basic support for timestamping/ptp
|
['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']
|
['igc ']
|
['h', 'c']
| 2
| 6
| 1
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +#define igc_tsyncrxctl_rxsynsig 0x00000400 /* sample rx tstamp in phy sop */ +#define igc_tsynctxctl_txsynsig 0x00000020 /* sample tx tstamp in phy sop */ diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c + tsync_rx_ctl |= igc_tsyncrxctl_rxsynsig; - if (tsync_tx_ctl) + if (tsync_tx_ctl) { + tsync_tx_ctl |= igc_tsynctxctl_txsynsig; + }
|
Networking
|
a299df3524eabc1def8e93bf005b07ea396ff2bd
|
vinicius costa gomes aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add support for tso
|
tcp segmentation offload allows a device to segment a single frame into multiple frames with a data payload size specified in socket buffer. as a result we can now send data approximately up to seven percents fast than was previously possible on my system.
|
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 tso
|
['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']
|
['igc ']
|
['h', 'c']
| 2
| 116
| 1
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +/* ipsec encrypt enable */ +#define igc_advtxd_l4len_shift 8 /* adv ctxt l4len shift */ +#define igc_advtxd_mss_shift 16 /* adv ctxt mss shift */ + diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c + /* set segmentation bits for tso */ + cmd_type |= igc_set_flag(tx_flags, igc_tx_flags_tso, + (igc_advtxd_dcmd_tse)); + +static int igc_tso(struct igc_ring *tx_ring, + struct igc_tx_buffer *first, + u8 *hdr_len) +{ + u32 vlan_macip_lens, type_tucmd, mss_l4len_idx; + struct sk_buff *skb = first->skb; + union { + struct iphdr *v4; + struct ipv6hdr *v6; + unsigned char *hdr; + } ip; + union { + struct tcphdr *tcp; + struct udphdr *udp; + unsigned char *hdr; + } l4; + u32 paylen, l4_offset; + int err; + + if (skb->ip_summed != checksum_partial) + return 0; + + if (!skb_is_gso(skb)) + return 0; + + err = skb_cow_head(skb, 0); + if (err < 0) + return err; + + ip.hdr = skb_network_header(skb); + l4.hdr = skb_checksum_start(skb); + + /* adv dtyp tucmd mkrloc/iscsihedlen */ + type_tucmd = igc_advtxd_tucmd_l4t_tcp; + + /* initialize outer ip header fields */ + if (ip.v4->version == 4) { + unsigned char *csum_start = skb_checksum_start(skb); + unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); + + /* ip header will have to cancel out any data that + * is not a part of the outer ip header + */ + ip.v4->check = csum_fold(csum_partial(trans_start, + csum_start - trans_start, + 0)); + type_tucmd |= igc_advtxd_tucmd_ipv4; + + ip.v4->tot_len = 0; + first->tx_flags |= igc_tx_flags_tso | + igc_tx_flags_csum | + igc_tx_flags_ipv4; + } else { + ip.v6->payload_len = 0; + first->tx_flags |= igc_tx_flags_tso | + igc_tx_flags_csum; + } + + /* determine offset of inner transport header */ + l4_offset = l4.hdr - skb->data; + + /* remove payload length from inner checksum */ + paylen = skb->len - l4_offset; + if (type_tucmd & igc_advtxd_tucmd_l4t_tcp) { + /* compute length of segmentation header */ + *hdr_len = (l4.tcp->doff * 4) + l4_offset; + csum_replace_by_diff(&l4.tcp->check, + (__force __wsum)htonl(paylen)); + } else { + /* compute length of segmentation header */ + *hdr_len = sizeof(*l4.udp) + l4_offset; + csum_replace_by_diff(&l4.udp->check, + (__force __wsum)htonl(paylen)); + } + + /* update gso size and bytecount with header size */ + first->gso_segs = skb_shinfo(skb)->gso_segs; + first->bytecount += (first->gso_segs - 1) * *hdr_len; + + /* mss l4len idx */ + mss_l4len_idx = (*hdr_len - l4_offset) << igc_advtxd_l4len_shift; + mss_l4len_idx |= skb_shinfo(skb)->gso_size << igc_advtxd_mss_shift; + + /* vlan maclen iplen */ + vlan_macip_lens = l4.hdr - ip.hdr; + vlan_macip_lens |= (ip.hdr - skb->data) << igc_advtxd_maclen_shift; + vlan_macip_lens |= first->tx_flags & igc_tx_flags_vlan_mask; + + igc_tx_ctxtdesc(tx_ring, first, vlan_macip_lens, + type_tucmd, mss_l4len_idx); + + return 1; +} + + int tso = 0; - igc_tx_csum(tx_ring, first); + tso = igc_tso(tx_ring, first, &hdr_len); + if (tso < 0) + goto out_drop; + else if (!tso) + igc_tx_csum(tx_ring, first); + return netdev_tx_ok; + +out_drop: + dev_kfree_skb_any(first->skb); + first->skb = null; + + netdev->features |= netif_f_tso; + netdev->features |= netif_f_tso6;
|
Networking
|
f38b782dccabb2ada5c5b3c0dfb5ef0758a67ce0
|
sasha neftin aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
igc: add legacy power management support
|
add suspend, resume, runtime_suspend, runtime_resume and runtime_idle callbacks implementation.
|
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 legacy power management 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']
|
['igc ']
|
['h', 'c']
| 4
| 246
| 0
|
--- diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h + u32 wol; + u32 en_mng_pt; diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h +/* definitions for power management and wakeup registers */ +/* wake up control */ +#define igc_wuc_pme_en 0x00000002 /* pme enable */ + +/* wake up filter control */ +#define igc_wufc_lnkc 0x00000001 /* link status change wakeup enable */ +#define igc_wufc_mc 0x00000008 /* directed multicast wakeup enable */ + +#define igc_ctrl_advd3wuc 0x00100000 /* d3 wuc */ + +/* wake up status */ +#define igc_wus_ex 0x00000004 /* directed exact */ +#define igc_wus_arpd 0x00000020 /* directed arp request */ +#define igc_wus_ipv4 0x00000040 /* directed ipv4 */ +#define igc_wus_ipv6 0x00000080 /* directed ipv6 */ +#define igc_wus_nsd 0x00000400 /* directed ipv6 neighbor solicitation */ + +/* packet types that are enabled for wake packet delivery */ +#define wake_pkt_wus ( \ + igc_wus_ex | \ + igc_wus_arpd | \ + igc_wus_ipv4 | \ + igc_wus_ipv6 | \ + igc_wus_nsd) + +/* wake up packet length */ +#define igc_wupl_mask 0x00000fff + +/* wake up packet memory stores the first 128 bytes of the wake up packet */ +#define igc_wupm_bytes 128 + diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c +#include <linux/pm_runtime.h> +static int __igc_shutdown(struct pci_dev *pdev, bool *enable_wake, + bool runtime) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + struct igc_adapter *adapter = netdev_priv(netdev); + u32 wufc = runtime ? igc_wufc_lnkc : adapter->wol; + struct igc_hw *hw = &adapter->hw; + u32 ctrl, rctl, status; + bool wake; + + rtnl_lock(); + netif_device_detach(netdev); + + if (netif_running(netdev)) + __igc_close(netdev, true); + + igc_clear_interrupt_scheme(adapter); + rtnl_unlock(); + + status = rd32(igc_status); + if (status & igc_status_lu) + wufc &= ~igc_wufc_lnkc; + + if (wufc) { + igc_setup_rctl(adapter); + igc_set_rx_mode(netdev); + + /* turn on all-multi mode if wake on multicast is enabled */ + if (wufc & igc_wufc_mc) { + rctl = rd32(igc_rctl); + rctl |= igc_rctl_mpe; + wr32(igc_rctl, rctl); + } + + ctrl = rd32(igc_ctrl); + ctrl |= igc_ctrl_advd3wuc; + wr32(igc_ctrl, ctrl); + + /* allow time for pending master requests to run */ + igc_disable_pcie_master(hw); + + wr32(igc_wuc, igc_wuc_pme_en); + wr32(igc_wufc, wufc); + } else { + wr32(igc_wuc, 0); + wr32(igc_wufc, 0); + } + + wake = wufc || adapter->en_mng_pt; + if (!wake) + igc_power_down_link(adapter); + else + igc_power_up_link(adapter); + + if (enable_wake) + *enable_wake = wake; + + /* release control of h/w to f/w. if f/w is amt enabled, this + * would have already happened in close and is redundant. + */ + igc_release_hw_control(adapter); + + pci_disable_device(pdev); + + return 0; +} + +#ifdef config_pm +static int __maybe_unused igc_runtime_suspend(struct device *dev) +{ + return __igc_shutdown(to_pci_dev(dev), null, 1); +} + +static void igc_deliver_wake_packet(struct net_device *netdev) +{ + struct igc_adapter *adapter = netdev_priv(netdev); + struct igc_hw *hw = &adapter->hw; + struct sk_buff *skb; + u32 wupl; + + wupl = rd32(igc_wupl) & igc_wupl_mask; + + /* wupm stores only the first 128 bytes of the wake packet. + * read the packet only if we have the whole thing. + */ + if (wupl == 0 || wupl > igc_wupm_bytes) + return; + + skb = netdev_alloc_skb_ip_align(netdev, igc_wupm_bytes); + if (!skb) + return; + + skb_put(skb, wupl); + + /* ensure reads are 32-bit aligned */ + wupl = roundup(wupl, 4); + + memcpy_fromio(skb->data, hw->hw_addr + igc_wupm_reg(0), wupl); + + skb->protocol = eth_type_trans(skb, netdev); + netif_rx(skb); +} + +static int __maybe_unused igc_resume(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct net_device *netdev = pci_get_drvdata(pdev); + struct igc_adapter *adapter = netdev_priv(netdev); + struct igc_hw *hw = &adapter->hw; + u32 err, val; + + pci_set_power_state(pdev, pci_d0); + pci_restore_state(pdev); + pci_save_state(pdev); + + if (!pci_device_is_present(pdev)) + return -enodev; + err = pci_enable_device_mem(pdev); + if (err) { + dev_err(&pdev->dev, + "igc: cannot enable pci device from suspend "); + return err; + } + pci_set_master(pdev); + + pci_enable_wake(pdev, pci_d3hot, 0); + pci_enable_wake(pdev, pci_d3cold, 0); + + if (igc_init_interrupt_scheme(adapter, true)) { + dev_err(&pdev->dev, "unable to allocate memory for queues "); + return -enomem; + } + + igc_reset(adapter); + + /* let the f/w know that the h/w is now under the control of the + * driver. + */ + igc_get_hw_control(adapter); + + val = rd32(igc_wus); + if (val & wake_pkt_wus) + igc_deliver_wake_packet(netdev); + + wr32(igc_wus, ~0); + + rtnl_lock(); + if (!err && netif_running(netdev)) + err = __igc_open(netdev, true); + + if (!err) + netif_device_attach(netdev); + rtnl_unlock(); + + return err; +} + +static int __maybe_unused igc_runtime_resume(struct device *dev) +{ + return igc_resume(dev); +} + +static int __maybe_unused igc_suspend(struct device *dev) +{ + return __igc_shutdown(to_pci_dev(dev), null, 0); +} + +static int __maybe_unused igc_runtime_idle(struct device *dev) +{ + struct net_device *netdev = dev_get_drvdata(dev); + struct igc_adapter *adapter = netdev_priv(netdev); + + if (!igc_has_link(adapter)) + pm_schedule_suspend(dev, msec_per_sec * 5); + + return -ebusy; +} +#endif /* config_pm */ + +static void igc_shutdown(struct pci_dev *pdev) +{ + bool wake; + + __igc_shutdown(pdev, &wake, 0); + + if (system_state == system_power_off) { + pci_wake_from_d3(pdev, wake); + pci_set_power_state(pdev, pci_d3hot); + } +} + +#ifdef config_pm +static const struct dev_pm_ops igc_pm_ops = { + set_system_sleep_pm_ops(igc_suspend, igc_resume) + set_runtime_pm_ops(igc_runtime_suspend, igc_runtime_resume, + igc_runtime_idle) +}; +#endif + +#ifdef config_pm + .driver.pm = &igc_pm_ops, +#endif + .shutdown = igc_shutdown, diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h b/drivers/net/ethernet/intel/igc/igc_regs.h --- a/drivers/net/ethernet/intel/igc/igc_regs.h +++ b/drivers/net/ethernet/intel/igc/igc_regs.h +/* wake up registers */ +#define igc_wuc 0x05800 /* wakeup control - rw */ +#define igc_wufc 0x05808 /* wakeup filter control - rw */ +#define igc_wus 0x05810 /* wakeup status - r/w1c */ +#define igc_wupl 0x05900 /* wakeup packet length - rw */ + +/* wake up packet memory */ +#define igc_wupm_reg(_i) (0x05a00 + ((_i) * 4)) +
|
Networking
|
9513d2a5dc7f3f2c037bfd2ea35264cc783b954e
|
sasha neftin aaron brown aaron f brown intel com
|
drivers
|
net
|
ethernet, igc, intel
|
ionic: add rx dropped packet counter
|
add a counter for packets dropped by the driver, typically for bad size or a receive error seen by the device.
|
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 rx dropped packet counter
|
['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']
|
['ionic ']
|
['h', 'c']
| 3
| 11
| 3
|
--- diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h + u64 dropped; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c + ionic_rx_stat_desc(dropped), diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c - if (comp->status) + if (comp->status) { + stats->dropped++; + } - if (unlikely(test_bit(ionic_lif_queue_reset, q->lif->state))) + if (unlikely(test_bit(ionic_lif_queue_reset, q->lif->state))) { + stats->dropped++; + } - if (unlikely(!skb)) + if (unlikely(!skb)) { + stats->dropped++; + }
|
Networking
|
24cfa8c76278d48fe521a363b74e36861b4462d6
|
shannon nelson
|
drivers
|
net
|
ethernet, ionic, pensando
|
ionic: support sr-iov operations
|
add the netdev ops for managing vfs. since most of the management work happens in the nic firmware, the driver becomes mostly a pass-through for the network stack commands that want to control and configure the vfs.
|
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 sriov 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']
|
['ionic ']
|
['h', 'c']
| 6
| 438
| 8
|
--- diff --git a/drivers/net/ethernet/pensando/ionic/ionic.h b/drivers/net/ethernet/pensando/ionic/ionic.h --- a/drivers/net/ethernet/pensando/ionic/ionic.h +++ b/drivers/net/ethernet/pensando/ionic/ionic.h -#define ionic_drv_version "0.18.0-k" +#define ionic_drv_version "0.20.0-k" +struct ionic_vf { + u16 index; + u8 macaddr[6]; + __le32 maxrate; + __le16 vlanid; + u8 spoofchk; + u8 trusted; + u8 linkstate; + dma_addr_t stats_pa; + struct ionic_lif_stats stats; +}; + + struct rw_semaphore vf_op_lock; /* lock for vf operations */ + struct ionic_vf *vfs; + int num_vfs; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c --- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +static void ionic_vf_dealloc_locked(struct ionic *ionic) +{ + struct ionic_vf *v; + dma_addr_t dma = 0; + int i; + + if (!ionic->vfs) + return; + + for (i = ionic->num_vfs - 1; i >= 0; i--) { + v = &ionic->vfs[i]; + + if (v->stats_pa) { + (void)ionic_set_vf_config(ionic, i, + ionic_vf_attr_statsaddr, + (u8 *)&dma); + dma_unmap_single(ionic->dev, v->stats_pa, + sizeof(v->stats), dma_from_device); + v->stats_pa = 0; + } + } + + kfree(ionic->vfs); + ionic->vfs = null; + ionic->num_vfs = 0; +} + +static void ionic_vf_dealloc(struct ionic *ionic) +{ + down_write(&ionic->vf_op_lock); + ionic_vf_dealloc_locked(ionic); + up_write(&ionic->vf_op_lock); +} + +static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) +{ + struct ionic_vf *v; + int err = 0; + int i; + + down_write(&ionic->vf_op_lock); + + ionic->vfs = kcalloc(num_vfs, sizeof(struct ionic_vf), gfp_kernel); + if (!ionic->vfs) { + err = -enomem; + goto out; + } + + for (i = 0; i < num_vfs; i++) { + v = &ionic->vfs[i]; + v->stats_pa = dma_map_single(ionic->dev, &v->stats, + sizeof(v->stats), dma_from_device); + if (dma_mapping_error(ionic->dev, v->stats_pa)) { + v->stats_pa = 0; + err = -enodev; + goto out; + } + + /* ignore failures from older fw, we just won't get stats */ + (void)ionic_set_vf_config(ionic, i, ionic_vf_attr_statsaddr, + (u8 *)&v->stats_pa); + ionic->num_vfs++; + } + +out: + if (err) + ionic_vf_dealloc_locked(ionic); + up_write(&ionic->vf_op_lock); + return err; +} + +static int ionic_sriov_configure(struct pci_dev *pdev, int num_vfs) +{ + struct ionic *ionic = pci_get_drvdata(pdev); + struct device *dev = ionic->dev; + int ret = 0; + + if (num_vfs > 0) { + ret = pci_enable_sriov(pdev, num_vfs); + if (ret) { + dev_err(dev, "cannot enable sriov: %d ", ret); + goto out; + } + + ret = ionic_vf_alloc(ionic, num_vfs); + if (ret) { + dev_err(dev, "cannot alloc vfs: %d ", ret); + pci_disable_sriov(pdev); + goto out; + } + + ret = num_vfs; + } else { + pci_disable_sriov(pdev); + ionic_vf_dealloc(ionic); + } + +out: + return ret; +} + + int num_vfs; + init_rwsem(&ionic->vf_op_lock); + num_vfs = pci_num_vf(pdev); + if (num_vfs) { + dev_info(dev, "%d vfs found already enabled ", num_vfs); + err = ionic_vf_alloc(ionic, num_vfs); + if (err) + dev_err(dev, "cannot enable existing vfs: %d ", err); + } + + ionic_vf_dealloc(ionic); + .sriov_configure = ionic_sriov_configure, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c +/* vf commands */ +int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data) +{ + union ionic_dev_cmd cmd = { + .vf_setattr.opcode = ionic_cmd_vf_setattr, + .vf_setattr.attr = attr, + .vf_setattr.vf_index = vf, + }; + int err; + + switch (attr) { + case ionic_vf_attr_spoofchk: + cmd.vf_setattr.spoofchk = *data; + dev_dbg(ionic->dev, "%s: vf %d spoof %d ", + __func__, vf, *data); + break; + case ionic_vf_attr_trust: + cmd.vf_setattr.trust = *data; + dev_dbg(ionic->dev, "%s: vf %d trust %d ", + __func__, vf, *data); + break; + case ionic_vf_attr_linkstate: + cmd.vf_setattr.linkstate = *data; + dev_dbg(ionic->dev, "%s: vf %d linkstate %d ", + __func__, vf, *data); + break; + case ionic_vf_attr_mac: + ether_addr_copy(cmd.vf_setattr.macaddr, data); + dev_dbg(ionic->dev, "%s: vf %d macaddr %pm ", + __func__, vf, data); + break; + case ionic_vf_attr_vlan: + cmd.vf_setattr.vlanid = cpu_to_le16(*(u16 *)data); + dev_dbg(ionic->dev, "%s: vf %d vlan %d ", + __func__, vf, *(u16 *)data); + break; + case ionic_vf_attr_rate: + cmd.vf_setattr.maxrate = cpu_to_le32(*(u32 *)data); + dev_dbg(ionic->dev, "%s: vf %d maxrate %d ", + __func__, vf, *(u32 *)data); + break; + case ionic_vf_attr_statsaddr: + cmd.vf_setattr.stats_pa = cpu_to_le64(*(u64 *)data); + dev_dbg(ionic->dev, "%s: vf %d stats_pa 0x%08llx ", + __func__, vf, *(u64 *)data); + break; + default: + return -einval; + } + + mutex_lock(&ionic->dev_cmd_lock); + ionic_dev_cmd_go(&ionic->idev, &cmd); + err = ionic_dev_cmd_wait(ionic, devcmd_timeout); + mutex_unlock(&ionic->dev_cmd_lock); + + return err; +} + diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h +/* sr/iov */ +static_assert(sizeof(struct ionic_vf_setattr_cmd) == 64); +static_assert(sizeof(struct ionic_vf_setattr_comp) == 16); +static_assert(sizeof(struct ionic_vf_getattr_cmd) == 64); +static_assert(sizeof(struct ionic_vf_getattr_comp) == 16); + +int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c +static int ionic_get_vf_config(struct net_device *netdev, + int vf, struct ifla_vf_info *ivf) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + int ret = 0; + + down_read(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ivf->vf = vf; + ivf->vlan = ionic->vfs[vf].vlanid; + ivf->qos = 0; + ivf->spoofchk = ionic->vfs[vf].spoofchk; + ivf->linkstate = ionic->vfs[vf].linkstate; + ivf->max_tx_rate = ionic->vfs[vf].maxrate; + ivf->trusted = ionic->vfs[vf].trusted; + ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr); + } + + up_read(&ionic->vf_op_lock); + return ret; +} + +static int ionic_get_vf_stats(struct net_device *netdev, int vf, + struct ifla_vf_stats *vf_stats) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + struct ionic_lif_stats *vs; + int ret = 0; + + down_read(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + memset(vf_stats, 0, sizeof(*vf_stats)); + vs = &ionic->vfs[vf].stats; + + vf_stats->rx_packets = le64_to_cpu(vs->rx_ucast_packets); + vf_stats->tx_packets = le64_to_cpu(vs->tx_ucast_packets); + vf_stats->rx_bytes = le64_to_cpu(vs->rx_ucast_bytes); + vf_stats->tx_bytes = le64_to_cpu(vs->tx_ucast_bytes); + vf_stats->broadcast = le64_to_cpu(vs->rx_bcast_packets); + vf_stats->multicast = le64_to_cpu(vs->rx_mcast_packets); + vf_stats->rx_dropped = le64_to_cpu(vs->rx_ucast_drop_packets) + + le64_to_cpu(vs->rx_mcast_drop_packets) + + le64_to_cpu(vs->rx_bcast_drop_packets); + vf_stats->tx_dropped = le64_to_cpu(vs->tx_ucast_drop_packets) + + le64_to_cpu(vs->tx_mcast_drop_packets) + + le64_to_cpu(vs->tx_bcast_drop_packets); + } + + up_read(&ionic->vf_op_lock); + return ret; +} + +static int ionic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + int ret; + + if (!(is_zero_ether_addr(mac) || is_valid_ether_addr(mac))) + return -einval; + + down_read(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ret = ionic_set_vf_config(ionic, vf, ionic_vf_attr_mac, mac); + if (!ret) + ether_addr_copy(ionic->vfs[vf].macaddr, mac); + } + + up_read(&ionic->vf_op_lock); + return ret; +} + +static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, + u8 qos, __be16 proto) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + int ret; + + /* until someday when we support qos */ + if (qos) + return -einval; + + if (vlan > 4095) + return -einval; + + if (proto != htons(eth_p_8021q)) + return -eprotonosupport; + + down_read(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ret = ionic_set_vf_config(ionic, vf, + ionic_vf_attr_vlan, (u8 *)&vlan); + if (!ret) + ionic->vfs[vf].vlanid = vlan; + } + + up_read(&ionic->vf_op_lock); + return ret; +} + +static int ionic_set_vf_rate(struct net_device *netdev, int vf, + int tx_min, int tx_max) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + int ret; + + /* setting the min just seems silly */ + if (tx_min) + return -einval; + + down_write(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ret = ionic_set_vf_config(ionic, vf, + ionic_vf_attr_rate, (u8 *)&tx_max); + if (!ret) + lif->ionic->vfs[vf].maxrate = tx_max; + } + + up_write(&ionic->vf_op_lock); + return ret; +} + +static int ionic_set_vf_spoofchk(struct net_device *netdev, int vf, bool set) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + u8 data = set; /* convert to u8 for config */ + int ret; + + down_write(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ret = ionic_set_vf_config(ionic, vf, + ionic_vf_attr_spoofchk, &data); + if (!ret) + ionic->vfs[vf].spoofchk = data; + } + + up_write(&ionic->vf_op_lock); + return ret; +} + +static int ionic_set_vf_trust(struct net_device *netdev, int vf, bool set) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + u8 data = set; /* convert to u8 for config */ + int ret; + + down_write(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ret = ionic_set_vf_config(ionic, vf, + ionic_vf_attr_trust, &data); + if (!ret) + ionic->vfs[vf].trusted = data; + } + + up_write(&ionic->vf_op_lock); + return ret; +} + +static int ionic_set_vf_link_state(struct net_device *netdev, int vf, int set) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic *ionic = lif->ionic; + u8 data; + int ret; + + switch (set) { + case ifla_vf_link_state_enable: + data = ionic_vf_link_status_up; + break; + case ifla_vf_link_state_disable: + data = ionic_vf_link_status_down; + break; + case ifla_vf_link_state_auto: + data = ionic_vf_link_status_auto; + break; + default: + return -einval; + } + + down_write(&ionic->vf_op_lock); + + if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { + ret = -einval; + } else { + ret = ionic_set_vf_config(ionic, vf, + ionic_vf_attr_linkstate, &data); + if (!ret) + ionic->vfs[vf].linkstate = set; + } + + up_write(&ionic->vf_op_lock); + return ret; +} + + .ndo_set_vf_vlan = ionic_set_vf_vlan, + .ndo_set_vf_trust = ionic_set_vf_trust, + .ndo_set_vf_mac = ionic_set_vf_mac, + .ndo_set_vf_rate = ionic_set_vf_rate, + .ndo_set_vf_spoofchk = ionic_set_vf_spoofchk, + .ndo_get_vf_config = ionic_get_vf_config, + .ndo_set_vf_link_state = ionic_set_vf_link_state, + .ndo_get_vf_stats = ionic_get_vf_stats, + if (is_zero_ether_addr(ctx.comp.lif_getattr.mac)) + return 0; + - if (err) - return err; - - if (!is_zero_ether_addr(netdev->dev_addr)) { - netdev_dbg(lif->netdev, "deleting station mac addr %pm ", - netdev->dev_addr); - ionic_lif_addr(lif, netdev->dev_addr, false); + if (err) { + netdev_warn(lif->netdev, "ignoring bad mac addr from nic %pm ", + addr.sa_data); + return 0; + netdev_dbg(lif->netdev, "deleting station mac addr %pm ", + netdev->dev_addr); + ionic_lif_addr(lif, netdev->dev_addr, false); + diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c + case ionic_cmd_vf_getattr: + return "ionic_cmd_vf_getattr"; + case ionic_cmd_vf_setattr: + return "ionic_cmd_vf_setattr";
|
Networking
|
fbb39807e9ae0f60e2f6a0a628aadab73554fbbe
|
shannon nelson
|
drivers
|
net
|
ethernet, ionic, pensando
|
ionic: ionic_if bits for sr-iov support
|
adds new adminq calls and their related structs for supporting pf controls on vfs: cmd_opcode_vf_getattr cmd_opcode_vf_setattr
|
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 sriov 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']
|
['ionic ']
|
['h']
| 1
| 97
| 0
|
--- diff --git a/drivers/net/ethernet/pensando/ionic/ionic_if.h b/drivers/net/ethernet/pensando/ionic/ionic_if.h --- a/drivers/net/ethernet/pensando/ionic/ionic_if.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_if.h + /* sr/iov commands */ + ionic_cmd_vf_getattr = 60, + ionic_cmd_vf_setattr = 61, + +enum ionic_vf_attr { + ionic_vf_attr_spoofchk = 1, + ionic_vf_attr_trust = 2, + ionic_vf_attr_mac = 3, + ionic_vf_attr_linkstate = 4, + ionic_vf_attr_vlan = 5, + ionic_vf_attr_rate = 6, + ionic_vf_attr_statsaddr = 7, +}; + +/** + * vf link status + */ +enum ionic_vf_link_status { + ionic_vf_link_status_auto = 0, /* link state of the uplink */ + ionic_vf_link_status_up = 1, /* link is always up */ + ionic_vf_link_status_down = 2, /* link is always down */ +}; + +/** + * struct ionic_vf_setattr_cmd - set vf attributes on the nic + * @opcode: opcode + * @index: vf index + * @attr: attribute type (enum ionic_vf_attr) + * macaddr mac address + * vlanid vlan id + * maxrate max tx rate in mbps + * spoofchk enable address spoof checking + * trust enable vf trust + * linkstate set link up or down + * stats_pa set dma address for vf stats + */ +struct ionic_vf_setattr_cmd { + u8 opcode; + u8 attr; + __le16 vf_index; + union { + u8 macaddr[6]; + __le16 vlanid; + __le32 maxrate; + u8 spoofchk; + u8 trust; + u8 linkstate; + __le64 stats_pa; + u8 pad[60]; + }; +}; + +struct ionic_vf_setattr_comp { + u8 status; + u8 attr; + __le16 vf_index; + __le16 comp_index; + u8 rsvd[9]; + u8 color; +}; + +/** + * struct ionic_vf_getattr_cmd - get vf attributes from the nic + * @opcode: opcode + * @index: vf index + * @attr: attribute type (enum ionic_vf_attr) + */ +struct ionic_vf_getattr_cmd { + u8 opcode; + u8 attr; + __le16 vf_index; + u8 rsvd[60]; +}; + +struct ionic_vf_getattr_comp { + u8 status; + u8 attr; + __le16 vf_index; + union { + u8 macaddr[6]; + __le16 vlanid; + __le32 maxrate; + u8 spoofchk; + u8 trust; + u8 linkstate; + __le64 stats_pa; + u8 pad[11]; + }; + u8 color; +}; + + struct ionic_vf_setattr_cmd vf_setattr; + struct ionic_vf_getattr_cmd vf_getattr; + + struct ionic_vf_setattr_comp vf_setattr; + struct ionic_vf_getattr_comp vf_getattr; +
|
Networking
|
3d462ce2a11784e278d4f425bf5c4cadeab2af3a
|
shannon nelson
|
drivers
|
net
|
ethernet, ionic, pensando
|
iwlwifi: mvm: add support for location range request version 8
|
the new api requires the driver to set the frame format (legacy, ht, vht etc.) to be used for the measurement.
|
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 location range request version 8
|
['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']
|
['ionic ', 'mvm']
|
['h', 'c']
| 2
| 290
| 53
|
--- diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h --- a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h - * struct iwl_tof_range_req_ap_entry - ap configuration parameters + * struct iwl_tof_range_req_ap_entry_v3 - ap configuration parameters -struct iwl_tof_range_req_ap_entry { +struct iwl_tof_range_req_ap_entry_v3 { +/** + * enum iwl_location_frame_format - location frame formats + * @iwl_location_frame_format_legacy: legacy + * @iwl_location_frame_format_ht: ht + * @iwl_location_frame_format_vht: vht + * @iwl_location_frame_format_he: he + */ +enum iwl_location_frame_format { + iwl_location_frame_format_legacy, + iwl_location_frame_format_ht, + iwl_location_frame_format_vht, + iwl_location_frame_format_he, +}; + +/** + * enum iwl_location_bw - location bandwidth selection + * @iwl_location_bw_20mhz: 20mhz + * @iwl_location_bw_40mhz: 40mhz + * @iwl_location_bw_80mhz: 80mhz + */ +enum iwl_location_bw { + iwl_location_bw_20mhz, + iwl_location_bw_40mhz, + iwl_location_bw_80mhz, +}; + +#define hltk_11az_len 32 +#define tk_11az_len 32 + +#define location_bw_pos 4 + +/** + * struct iwl_tof_range_req_ap_entry - ap configuration parameters + * @initiator_ap_flags: see &enum iwl_initiator_ap_flags. + * @channel_num: ap channel number + * @format_bw: bits 0 - 3: &enum iwl_location_frame_format. + * bits 4 - 7: &enum iwl_location_bw. + * @ctrl_ch_position: coding of the control channel position relative to the + * center frequency, see iwl_mvm_get_ctrl_pos(). + * @ftmr_max_retries: max number of retries to send the ftmr in case of no + * reply from the ap. + * @bssid: ap's bssid + * @burst_period: recommended value to be sent to the ap. measurement + * periodicity in units of 100ms. ignored if num_of_bursts_exp = 0 + * @samples_per_burst: the number of ftms pairs in single burst (1-31); + * @num_of_bursts: recommended value to be sent to the ap. 2s exponent of + * the number of measurement iterations (min 2^0 = 1, max 2^14) + * @reserved: for alignment and future use + * @hltk: hltk to be used for secured 11az measurement + * @tk: tk to be used for secured 11az measurement + */ +struct iwl_tof_range_req_ap_entry { + __le32 initiator_ap_flags; + u8 channel_num; + u8 format_bw; + u8 ctrl_ch_position; + u8 ftmr_max_retries; + u8 bssid[eth_alen]; + __le16 burst_period; + u8 samples_per_burst; + u8 num_of_bursts; + __le16 reserved; + u8 hltk[hltk_11az_len]; + u8 tk[tk_11az_len]; +} __packed; /* location_range_req_ap_entry_cmd_api_s_ver_4 */ + +/** + * struct iwl_tof_range_req_cmd_v7 - start measurement cmd + * @initiator_flags: see flags @ iwl_tof_initiator_flags + * @request_id: a token incremented per request. the same token will be + * sent back in the range response + * @num_of_ap: number of aps to measure (error if > iwl_mvm_tof_max_aps) + * @range_req_bssid: ranging request bssid + * @macaddr_mask: bits set to 0 shall be copied from the mac address template. + * bits set to 1 shall be randomized by the umac + * @macaddr_template: mac address template to use for non-randomized bits + * @req_timeout_ms: requested timeout of the response in units of milliseconds. + * this is the session time for completing the measurement. + * @tsf_mac_id: report the measurement start time for each ap in terms of the + * tsf of this mac id. 0xff to disable tsf reporting. + * @common_calib: the common calib value to inject to this measurement calc + * @specific_calib: the specific calib value to inject to this measurement calc + * @ap: per-ap request data, see &struct iwl_tof_range_req_ap_entry_v2. + */ +struct iwl_tof_range_req_cmd_v7 { + __le32 initiator_flags; + u8 request_id; + u8 num_of_ap; + u8 range_req_bssid[eth_alen]; + u8 macaddr_mask[eth_alen]; + u8 macaddr_template[eth_alen]; + __le32 req_timeout_ms; + __le32 tsf_mac_id; + __le16 common_calib; + __le16 specific_calib; + struct iwl_tof_range_req_ap_entry_v3 ap[iwl_mvm_tof_max_aps]; +} __packed; /* location_range_req_cmd_api_s_ver_7 */ + -} __packed; /* location_range_req_cmd_api_s_ver_7 */ +} __packed; /* location_range_req_cmd_api_s_ver_8 */ diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c --- a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c -static int iwl_mvm_ftm_target_chandef(struct iwl_mvm *mvm, - struct cfg80211_pmsr_request_peer *peer, - u8 *channel, u8 *bandwidth, - u8 *ctrl_ch_position) +static int +iwl_mvm_ftm_target_chandef_v1(struct iwl_mvm *mvm, + struct cfg80211_pmsr_request_peer *peer, + u8 *channel, u8 *bandwidth, + u8 *ctrl_ch_position) +static int +iwl_mvm_ftm_target_chandef_v2(struct iwl_mvm *mvm, + struct cfg80211_pmsr_request_peer *peer, + u8 *channel, u8 *format_bw, + u8 *ctrl_ch_position) +{ + u32 freq = peer->chandef.chan->center_freq; + + *channel = ieee80211_frequency_to_channel(freq); + + switch (peer->chandef.width) { + case nl80211_chan_width_20_noht: + *format_bw = iwl_location_frame_format_legacy; + *format_bw |= iwl_location_bw_20mhz << location_bw_pos; + break; + case nl80211_chan_width_20: + *format_bw = iwl_location_frame_format_ht; + *format_bw |= iwl_location_bw_20mhz << location_bw_pos; + break; + case nl80211_chan_width_40: + *format_bw = iwl_location_frame_format_ht; + *format_bw |= iwl_location_bw_40mhz << location_bw_pos; + break; + case nl80211_chan_width_80: + *format_bw = iwl_location_frame_format_vht; + *format_bw |= iwl_location_bw_80mhz << location_bw_pos; + break; + default: + iwl_err(mvm, "unsupported bw in ftm request (%d) ", + peer->chandef.width); + return -einval; + } + + *ctrl_ch_position = (peer->chandef.width > nl80211_chan_width_20) ? + iwl_mvm_get_ctrl_pos(&peer->chandef) : 0; + + return 0; +} + - ret = iwl_mvm_ftm_target_chandef(mvm, peer, &target->channel_num, - &target->bandwidth, - &target->ctrl_ch_position); + ret = iwl_mvm_ftm_target_chandef_v1(mvm, peer, &target->channel_num, + &target->bandwidth, + &target->ctrl_ch_position); -static int iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, - struct cfg80211_pmsr_request_peer *peer, - struct iwl_tof_range_req_ap_entry *target) +static void +iwl_mvm_ftm_put_target_common(struct iwl_mvm *mvm, + struct cfg80211_pmsr_request_peer *peer, + struct iwl_tof_range_req_ap_entry *target) - int ret; - - ret = iwl_mvm_ftm_target_chandef(mvm, peer, &target->channel_num, - &target->bandwidth, - &target->ctrl_ch_position); - if (ret) - return ret; - +} + +static int +iwl_mvm_ftm_put_target_v3(struct iwl_mvm *mvm, + struct cfg80211_pmsr_request_peer *peer, + struct iwl_tof_range_req_ap_entry_v3 *target) +{ + int ret; + + ret = iwl_mvm_ftm_target_chandef_v1(mvm, peer, &target->channel_num, + &target->bandwidth, + &target->ctrl_ch_position); + if (ret) + return ret; + + /* + * versions 3 and 4 has some common fields, so + * iwl_mvm_ftm_put_target_common() can be used for version 7 too. + */ + iwl_mvm_ftm_put_target_common(mvm, peer, (void *)target); -int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, - struct cfg80211_pmsr_request *req) +static int iwl_mvm_ftm_put_target_v4(struct iwl_mvm *mvm, + struct cfg80211_pmsr_request_peer *peer, + struct iwl_tof_range_req_ap_entry *target) +{ + int ret; + + ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num, + &target->format_bw, + &target->ctrl_ch_position); + if (ret) + return ret; + + iwl_mvm_ftm_put_target_common(mvm, peer, target); + + return 0; +} + +static int iwl_mvm_ftm_send_cmd(struct iwl_mvm *mvm, struct iwl_host_cmd *hcmd) +{ + u32 status; + int err = iwl_mvm_send_cmd_status(mvm, hcmd, &status); + + if (!err && status) { + iwl_err(mvm, "ftm range request command failure, status: %u ", + status); + err = iwl_ftm_range_request_status_to_err(status); + } + + return err; +} + +static int iwl_mvm_ftm_start_v5(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + struct cfg80211_pmsr_request *req) - struct iwl_tof_range_req_cmd cmd; - bool new_api = fw_has_api(&mvm->fw->ucode_capa, - iwl_ucode_tlv_api_ftm_new_range_req); - u8 num_of_ap; + .data[0] = &cmd_v5, + .len[0] = sizeof(cmd_v5), - u32 status = 0; - int err, i; + u8 i; + int err; - lockdep_assert_held(&mvm->mutex); + iwl_mvm_ftm_cmd_v5(mvm, vif, &cmd_v5, req); - if (mvm->ftm_initiator.req) - return -ebusy; + for (i = 0; i < cmd_v5.num_of_ap; i++) { + struct cfg80211_pmsr_request_peer *peer = &req->peers[i]; - if (new_api) { - iwl_mvm_ftm_cmd(mvm, vif, &cmd, req); - hcmd.data[0] = &cmd; - hcmd.len[0] = sizeof(cmd); - num_of_ap = cmd.num_of_ap; - } else { - iwl_mvm_ftm_cmd_v5(mvm, vif, &cmd_v5, req); - hcmd.data[0] = &cmd_v5; - hcmd.len[0] = sizeof(cmd_v5); - num_of_ap = cmd_v5.num_of_ap; + err = iwl_mvm_ftm_put_target_v2(mvm, peer, &cmd_v5.ap[i]); + if (err) + return err; - for (i = 0; i < num_of_ap; i++) { + return iwl_mvm_ftm_send_cmd(mvm, &hcmd); +} + +static int iwl_mvm_ftm_start_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + struct cfg80211_pmsr_request *req) +{ + struct iwl_tof_range_req_cmd_v7 cmd_v7; + struct iwl_host_cmd hcmd = { + .id = iwl_cmd_id(tof_range_req_cmd, location_group, 0), + .dataflags[0] = iwl_hcmd_dfl_dup, + .data[0] = &cmd_v7, + .len[0] = sizeof(cmd_v7), + }; + u8 i; + int err; + + /* + * versions 7 and 8 has the same structure except from the responders + * list, so iwl_mvm_ftm_cmd() can be used for version 7 too. + */ + iwl_mvm_ftm_cmd(mvm, vif, (void *)&cmd_v7, req); + + for (i = 0; i < cmd_v7.num_of_ap; i++) { - if (new_api) - err = iwl_mvm_ftm_put_target(mvm, peer, &cmd.ap[i]); - else - err = iwl_mvm_ftm_put_target_v2(mvm, peer, - &cmd_v5.ap[i]); + err = iwl_mvm_ftm_put_target_v3(mvm, peer, &cmd_v7.ap[i]); + if (err) + return err; + } + + return iwl_mvm_ftm_send_cmd(mvm, &hcmd); +} +static int iwl_mvm_ftm_start_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + struct cfg80211_pmsr_request *req) +{ + struct iwl_tof_range_req_cmd cmd; + struct iwl_host_cmd hcmd = { + .id = iwl_cmd_id(tof_range_req_cmd, location_group, 0), + .dataflags[0] = iwl_hcmd_dfl_dup, + .data[0] = &cmd, + .len[0] = sizeof(cmd), + }; + u8 i; + int err; + + iwl_mvm_ftm_cmd(mvm, vif, &cmd, req); + + for (i = 0; i < cmd.num_of_ap; i++) { + struct cfg80211_pmsr_request_peer *peer = &req->peers[i]; + + err = iwl_mvm_ftm_put_target_v4(mvm, peer, &cmd.ap[i]); - err = iwl_mvm_send_cmd_status(mvm, &hcmd, &status); - if (!err && status) { - iwl_err(mvm, "ftm range request command failure, status: %u ", - status); - err = iwl_ftm_range_request_status_to_err(status); + return iwl_mvm_ftm_send_cmd(mvm, &hcmd); +} + +int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + struct cfg80211_pmsr_request *req) +{ + bool new_api = fw_has_api(&mvm->fw->ucode_capa, + iwl_ucode_tlv_api_ftm_new_range_req); + int err; + + lockdep_assert_held(&mvm->mutex); + + if (mvm->ftm_initiator.req) + return -ebusy; + + if (new_api) { + u8 cmd_ver = iwl_mvm_lookup_cmd_ver(mvm->fw, location_group, + tof_range_req_cmd); + + if (cmd_ver == 8) + err = iwl_mvm_ftm_start_v8(mvm, vif, req); + else + err = iwl_mvm_ftm_start_v7(mvm, vif, req); + + } else { + err = iwl_mvm_ftm_start_v5(mvm, vif, req);
|
Networking
|
b59ec4cac5160370d908c60934e799bc6da7d784
|
avraham stern
|
drivers
|
net
|
api, fw, intel, iwlwifi, mvm, wireless
|
iwlwifi: mvm: add support for responder config command version 7
|
the new api requires the driver to config the supported frame format (legacy, ht, vht etc.).
|
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 responder config command version 7
|
['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']
|
['ionic ', 'mvm']
|
['h', 'c']
| 2
| 113
| 22
|
--- diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h --- a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h - * struct iwl_tof_responder_config_cmd - tof ap mode (for debug) + * struct iwl_tof_responder_config_cmd_v6 - tof ap mode (for debug) -struct iwl_tof_responder_config_cmd { +struct iwl_tof_responder_config_cmd_v6 { +/** + * struct iwl_tof_responder_config_cmd - tof ap mode (for debug) + * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field + * @responder_cfg_flags: &iwl_tof_responder_cfg_flags + * @format_bw: bits 0 - 3: &enum iwl_location_frame_format. + * bits 4 - 7: &enum iwl_location_bw. + * @rate: current ap rate + * @channel_num: current ap channel + * @ctrl_ch_position: coding of the control channel position relative to + * the center frequency, see iwl_mvm_get_ctrl_pos() + * @sta_id: index of the ap sta when in ap mode + * @reserved1: reserved + * @toa_offset: artificial addition [psec] for the toa - to be used for debug + * purposes, simulating station movement by adding various values + * to this field + * @common_calib: xvt: common calibration value + * @specific_calib: xvt: specific calibration value + * @bssid: current ap bssid + * @reserved2: reserved + */ +struct iwl_tof_responder_config_cmd { + __le32 cmd_valid_fields; + __le32 responder_cfg_flags; + u8 format_bw; + u8 rate; + u8 channel_num; + u8 ctrl_ch_position; + u8 sta_id; + u8 reserved1; + __le16 toa_offset; + __le16 common_calib; + __le16 specific_calib; + u8 bssid[eth_alen]; + __le16 reserved2; +} __packed; /* tof_responder_config_cmd_api_s_ver_6 */ + diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-responder.c b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-responder.c --- a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-responder.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-responder.c - * copyright (c) 2018 intel corporation + * copyright (c) 2018 - 2019 intel corporation - * copyright (c) 2018 intel corporation + * copyright (c) 2018 - 2019 intel corporation +static int iwl_mvm_ftm_responder_set_bw_v1(struct cfg80211_chan_def *chandef, + u8 *bw, u8 *ctrl_ch_position) +{ + switch (chandef->width) { + case nl80211_chan_width_20_noht: + *bw = iwl_tof_bw_20_legacy; + break; + case nl80211_chan_width_20: + *bw = iwl_tof_bw_20_ht; + break; + case nl80211_chan_width_40: + *bw = iwl_tof_bw_40; + *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef); + break; + case nl80211_chan_width_80: + *bw = iwl_tof_bw_80; + *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef); + break; + default: + return -enotsupp; + } + + return 0; +} + +static int iwl_mvm_ftm_responder_set_bw_v2(struct cfg80211_chan_def *chandef, + u8 *format_bw, + u8 *ctrl_ch_position) +{ + switch (chandef->width) { + case nl80211_chan_width_20_noht: + *format_bw = iwl_location_frame_format_legacy; + *format_bw |= iwl_location_bw_20mhz << location_bw_pos; + break; + case nl80211_chan_width_20: + *format_bw = iwl_location_frame_format_ht; + *format_bw |= iwl_location_bw_20mhz << location_bw_pos; + break; + case nl80211_chan_width_40: + *format_bw = iwl_location_frame_format_ht; + *format_bw |= iwl_location_bw_40mhz << location_bw_pos; + *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef); + break; + case nl80211_chan_width_80: + *format_bw = iwl_location_frame_format_vht; + *format_bw |= iwl_location_bw_80mhz << location_bw_pos; + *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef); + break; + default: + return -enotsupp; + } + + return 0; +} + + /* + * the command structure is the same for versions 6 and 7, (only the + * field interpretation is different), so the same struct can be use + * for all cases. + */ + u8 cmd_ver = iwl_mvm_lookup_cmd_ver(mvm->fw, location_group, + tof_responder_config_cmd); + int err; - switch (chandef->width) { - case nl80211_chan_width_20_noht: - cmd.bandwidth = iwl_tof_bw_20_legacy; - break; - case nl80211_chan_width_20: - cmd.bandwidth = iwl_tof_bw_20_ht; - break; - case nl80211_chan_width_40: - cmd.bandwidth = iwl_tof_bw_40; - cmd.ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef); - break; - case nl80211_chan_width_80: - cmd.bandwidth = iwl_tof_bw_80; - cmd.ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef); - break; - default: - warn_on(1); - return -einval; + if (cmd_ver == 7) + err = iwl_mvm_ftm_responder_set_bw_v2(chandef, &cmd.format_bw, + &cmd.ctrl_ch_position); + else + err = iwl_mvm_ftm_responder_set_bw_v1(chandef, &cmd.format_bw, + &cmd.ctrl_ch_position); + + if (err) { + iwl_err(mvm, "failed to set responder bandwidth "); + return err;
|
Networking
|
b1a6db1320e94bc8e924918fc236b5df97c1cca7
|
avraham stern
|
drivers
|
net
|
api, fw, intel, iwlwifi, mvm, wireless
|
net: macsec: move some definitions in a dedicated header
|
this patch moves some structure, type and identifier definitions into a macsec specific header. this patch does not modify how the macsec code is running and only move things around. this is a preparation for the future macsec hardware offloading support, which will re-use those definitions outside macsec.c.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c', 'h']
| 2
| 178
| 163
|
--- diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c +#include <net/macsec.h> -typedef u64 __bitwise sci_t; - -#define macsec_num_an 4 /* 2 bits for the association number */ - -/** - * struct macsec_key - sa key - * @id: user-provided key identifier - * @tfm: crypto struct, key storage - */ -struct macsec_key { - u8 id[macsec_keyid_len]; - struct crypto_aead *tfm; -}; - -struct macsec_rx_sc_stats { - __u64 inoctetsvalidated; - __u64 inoctetsdecrypted; - __u64 inpktsunchecked; - __u64 inpktsdelayed; - __u64 inpktsok; - __u64 inpktsinvalid; - __u64 inpktslate; - __u64 inpktsnotvalid; - __u64 inpktsnotusingsa; - __u64 inpktsunusedsa; -}; - -struct macsec_rx_sa_stats { - __u32 inpktsok; - __u32 inpktsinvalid; - __u32 inpktsnotvalid; - __u32 inpktsnotusingsa; - __u32 inpktsunusedsa; -}; - -struct macsec_tx_sa_stats { - __u32 outpktsprotected; - __u32 outpktsencrypted; -}; - -struct macsec_tx_sc_stats { - __u64 outpktsprotected; - __u64 outpktsencrypted; - __u64 outoctetsprotected; - __u64 outoctetsencrypted; -}; - -/** - * struct macsec_rx_sa - receive secure association - * @active: - * @next_pn: packet number expected for the next packet - * @lock: protects next_pn manipulations - * @key: key structure - * @stats: per-sa stats - */ -struct macsec_rx_sa { - struct macsec_key key; - spinlock_t lock; - u32 next_pn; - refcount_t refcnt; - bool active; - struct macsec_rx_sa_stats __percpu *stats; - struct macsec_rx_sc *sc; - struct rcu_head rcu; -}; - -struct pcpu_rx_sc_stats { - struct macsec_rx_sc_stats stats; - struct u64_stats_sync syncp; -}; - -/** - * struct macsec_rx_sc - receive secure channel - * @sci: secure channel identifier for this sc - * @active: channel is active - * @sa: array of secure associations - * @stats: per-sc stats - */ -struct macsec_rx_sc { - struct macsec_rx_sc __rcu *next; - sci_t sci; - bool active; - struct macsec_rx_sa __rcu *sa[macsec_num_an]; - struct pcpu_rx_sc_stats __percpu *stats; - refcount_t refcnt; - struct rcu_head rcu_head; -}; - -/** - * struct macsec_tx_sa - transmit secure association - * @active: - * @next_pn: packet number to use for the next packet - * @lock: protects next_pn manipulations - * @key: key structure - * @stats: per-sa stats - */ -struct macsec_tx_sa { - struct macsec_key key; - spinlock_t lock; - u32 next_pn; - refcount_t refcnt; - bool active; - struct macsec_tx_sa_stats __percpu *stats; - struct rcu_head rcu; -}; - -struct pcpu_tx_sc_stats { - struct macsec_tx_sc_stats stats; - struct u64_stats_sync syncp; -}; - -/** - * struct macsec_tx_sc - transmit secure channel - * @active: - * @encoding_sa: association number of the sa currently in use - * @encrypt: encrypt packets on transmit, or authenticate only - * @send_sci: always include the sci in the sectag - * @end_station: - * @scb: single copy broadcast flag - * @sa: array of secure associations - * @stats: stats for this txsc - */ -struct macsec_tx_sc { - bool active; - u8 encoding_sa; - bool encrypt; - bool send_sci; - bool end_station; - bool scb; - struct macsec_tx_sa __rcu *sa[macsec_num_an]; - struct pcpu_tx_sc_stats __percpu *stats; -}; - -/** - * struct macsec_secy - macsec security entity - * @netdev: netdevice for this secy - * @n_rx_sc: number of receive secure channels configured on this secy - * @sci: secure channel identifier used for tx - * @key_len: length of keys used by the cipher suite - * @icv_len: length of icv used by the cipher suite - * @validate_frames: validation mode - * @operational: mac_operational flag - * @protect_frames: enable protection for this secy - * @replay_protect: enable packet number checks on receive - * @replay_window: size of the replay window - * @tx_sc: transmit secure channel - * @rx_sc: linked list of receive secure channels - */ -struct macsec_secy { - struct net_device *netdev; - unsigned int n_rx_sc; - sci_t sci; - u16 key_len; - u16 icv_len; - enum macsec_validation_type validate_frames; - bool operational; - bool protect_frames; - bool replay_protect; - u32 replay_window; - struct macsec_tx_sc tx_sc; - struct macsec_rx_sc __rcu *rx_sc; -}; - diff --git a/include/net/macsec.h b/include/net/macsec.h --- /dev/null +++ b/include/net/macsec.h +/* spdx-license-identifier: gpl-2.0+ */ +/* + * macsec netdev header, used for h/w accelerated implementations. + * + * copyright (c) 2015 sabrina dubroca <sd@queasysnail.net> + */ +#ifndef _net_macsec_h_ +#define _net_macsec_h_ + +#include <linux/u64_stats_sync.h> +#include <uapi/linux/if_link.h> +#include <uapi/linux/if_macsec.h> + +typedef u64 __bitwise sci_t; + +#define macsec_num_an 4 /* 2 bits for the association number */ + +/** + * struct macsec_key - sa key + * @id: user-provided key identifier + * @tfm: crypto struct, key storage + */ +struct macsec_key { + u8 id[macsec_keyid_len]; + struct crypto_aead *tfm; +}; + +struct macsec_rx_sc_stats { + __u64 inoctetsvalidated; + __u64 inoctetsdecrypted; + __u64 inpktsunchecked; + __u64 inpktsdelayed; + __u64 inpktsok; + __u64 inpktsinvalid; + __u64 inpktslate; + __u64 inpktsnotvalid; + __u64 inpktsnotusingsa; + __u64 inpktsunusedsa; +}; + +struct macsec_rx_sa_stats { + __u32 inpktsok; + __u32 inpktsinvalid; + __u32 inpktsnotvalid; + __u32 inpktsnotusingsa; + __u32 inpktsunusedsa; +}; + +struct macsec_tx_sa_stats { + __u32 outpktsprotected; + __u32 outpktsencrypted; +}; + +struct macsec_tx_sc_stats { + __u64 outpktsprotected; + __u64 outpktsencrypted; + __u64 outoctetsprotected; + __u64 outoctetsencrypted; +}; + +/** + * struct macsec_rx_sa - receive secure association + * @active: + * @next_pn: packet number expected for the next packet + * @lock: protects next_pn manipulations + * @key: key structure + * @stats: per-sa stats + */ +struct macsec_rx_sa { + struct macsec_key key; + spinlock_t lock; + u32 next_pn; + refcount_t refcnt; + bool active; + struct macsec_rx_sa_stats __percpu *stats; + struct macsec_rx_sc *sc; + struct rcu_head rcu; +}; + +struct pcpu_rx_sc_stats { + struct macsec_rx_sc_stats stats; + struct u64_stats_sync syncp; +}; + +struct pcpu_tx_sc_stats { + struct macsec_tx_sc_stats stats; + struct u64_stats_sync syncp; +}; + +/** + * struct macsec_rx_sc - receive secure channel + * @sci: secure channel identifier for this sc + * @active: channel is active + * @sa: array of secure associations + * @stats: per-sc stats + */ +struct macsec_rx_sc { + struct macsec_rx_sc __rcu *next; + sci_t sci; + bool active; + struct macsec_rx_sa __rcu *sa[macsec_num_an]; + struct pcpu_rx_sc_stats __percpu *stats; + refcount_t refcnt; + struct rcu_head rcu_head; +}; + +/** + * struct macsec_tx_sa - transmit secure association + * @active: + * @next_pn: packet number to use for the next packet + * @lock: protects next_pn manipulations + * @key: key structure + * @stats: per-sa stats + */ +struct macsec_tx_sa { + struct macsec_key key; + spinlock_t lock; + u32 next_pn; + refcount_t refcnt; + bool active; + struct macsec_tx_sa_stats __percpu *stats; + struct rcu_head rcu; +}; + +/** + * struct macsec_tx_sc - transmit secure channel + * @active: + * @encoding_sa: association number of the sa currently in use + * @encrypt: encrypt packets on transmit, or authenticate only + * @send_sci: always include the sci in the sectag + * @end_station: + * @scb: single copy broadcast flag + * @sa: array of secure associations + * @stats: stats for this txsc + */ +struct macsec_tx_sc { + bool active; + u8 encoding_sa; + bool encrypt; + bool send_sci; + bool end_station; + bool scb; + struct macsec_tx_sa __rcu *sa[macsec_num_an]; + struct pcpu_tx_sc_stats __percpu *stats; +}; + +/** + * struct macsec_secy - macsec security entity + * @netdev: netdevice for this secy + * @n_rx_sc: number of receive secure channels configured on this secy + * @sci: secure channel identifier used for tx + * @key_len: length of keys used by the cipher suite + * @icv_len: length of icv used by the cipher suite + * @validate_frames: validation mode + * @operational: mac_operational flag + * @protect_frames: enable protection for this secy + * @replay_protect: enable packet number checks on receive + * @replay_window: size of the replay window + * @tx_sc: transmit secure channel + * @rx_sc: linked list of receive secure channels + */ +struct macsec_secy { + struct net_device *netdev; + unsigned int n_rx_sc; + sci_t sci; + u16 key_len; + u16 icv_len; + enum macsec_validation_type validate_frames; + bool operational; + bool protect_frames; + bool replay_protect; + u32 replay_window; + struct macsec_tx_sc tx_sc; + struct macsec_rx_sc __rcu *rx_sc; +}; + +#endif /* _net_macsec_h_ */
|
Networking
|
c0e4eadfb8daf2e9557c7450f9b237c08b404419
|
antoine tenart
|
drivers
|
net
| |
net: macsec: introduce the macsec_context structure
|
this patch introduces the macsec_context structure. it will be used in the kernel to exchange information between the common macsec implementation (macsec.c) and the macsec hardware offloading implementations. this structure contains pointers to macsec specific structures which contain the actual macsec configuration, and to the underlying device (phydev 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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['h']
| 4
| 37
| 0
|
--- diff --git a/include/linux/phy.h b/include/linux/phy.h --- a/include/linux/phy.h +++ b/include/linux/phy.h +struct macsec_context; + diff --git a/include/net/macsec.h b/include/net/macsec.h --- a/include/net/macsec.h +++ b/include/net/macsec.h +/** + * struct macsec_context - macsec context for hardware offloading + */ +struct macsec_context { + struct phy_device *phydev; + enum macsec_offload offload; + + struct macsec_secy *secy; + struct macsec_rx_sc *rx_sc; + struct { + unsigned char assoc_num; + u8 key[macsec_keyid_len]; + union { + struct macsec_rx_sa *rx_sa; + struct macsec_tx_sa *tx_sa; + }; + } sa; + + u8 prepare:1; +}; + diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h +enum macsec_offload { + macsec_offload_off = 0, + macsec_offload_phy = 1, + __macsec_offload_end, + macsec_offload_max = __macsec_offload_end - 1, +}; + diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h +enum macsec_offload { + macsec_offload_off = 0, + macsec_offload_phy = 1, + __macsec_offload_end, + macsec_offload_max = __macsec_offload_end - 1, +}; +
|
Networking
|
76564261a7db80c5f5c624e0122a28787f266bdf
|
antoine tenart
|
include
|
uapi
|
linux, uapi
|
net: macsec: introduce macsec ops
|
this patch introduces macsec ops for drivers to support offloading macsec operations.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['h']
| 1
| 24
| 0
|
--- diff --git a/include/net/macsec.h b/include/net/macsec.h --- a/include/net/macsec.h +++ b/include/net/macsec.h +/** + * struct macsec_ops - macsec offloading operations + */ +struct macsec_ops { + /* device wide */ + int (*mdo_dev_open)(struct macsec_context *ctx); + int (*mdo_dev_stop)(struct macsec_context *ctx); + /* secy */ + int (*mdo_add_secy)(struct macsec_context *ctx); + int (*mdo_upd_secy)(struct macsec_context *ctx); + int (*mdo_del_secy)(struct macsec_context *ctx); + /* security channels */ + int (*mdo_add_rxsc)(struct macsec_context *ctx); + int (*mdo_upd_rxsc)(struct macsec_context *ctx); + int (*mdo_del_rxsc)(struct macsec_context *ctx); + /* security associations */ + int (*mdo_add_rxsa)(struct macsec_context *ctx); + int (*mdo_upd_rxsa)(struct macsec_context *ctx); + int (*mdo_del_rxsa)(struct macsec_context *ctx); + int (*mdo_add_txsa)(struct macsec_context *ctx); + int (*mdo_upd_txsa)(struct macsec_context *ctx); + int (*mdo_del_txsa)(struct macsec_context *ctx); +}; +
|
Networking
|
0830e20b62ad156f7df5ff5b9c4cea280ebe8fef
|
antoine tenart
|
include
|
net
| |
net: phy: add macsec ops in phy_device
|
this patch adds a reference to macsec ops in the phy_device, to allow phys to support offloading macsec operations. the phydev lock will be held while calling those 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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['h']
| 1
| 7
| 0
|
--- diff --git a/include/linux/phy.h b/include/linux/phy.h --- a/include/linux/phy.h +++ b/include/linux/phy.h +struct macsec_ops; + * macsec_ops: macsec offloading ops. + +#if is_enabled(config_macsec) + /* macsec management functions */ + const struct macsec_ops *macsec_ops; +#endif
|
Networking
|
2e18135845b359f26c37df38ba56565496517c10
|
antoine tenart
|
include
|
linux
| |
net: macsec: hardware offloading infrastructure
|
this patch introduces the macsec hardware offloading infrastructure.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c']
| 1
| 441
| 12
|
--- diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c +#include <linux/netdevice.h> +#include <linux/phy.h> + * @offload: status of offloading on the macsec device + enum macsec_offload offload; +/* checks if a macsec interface is being offloaded to an hardware engine */ +static bool macsec_is_offloaded(struct macsec_dev *macsec) +{ + if (macsec->offload == macsec_offload_phy) + return true; + + return false; +} + +/* checks if underlying layers implement macsec offloading functions. */ +static bool macsec_check_offload(enum macsec_offload offload, + struct macsec_dev *macsec) +{ + if (!macsec || !macsec->real_dev) + return false; + + if (offload == macsec_offload_phy) + return macsec->real_dev->phydev && + macsec->real_dev->phydev->macsec_ops; + + return false; +} + +static const struct macsec_ops *__macsec_get_ops(enum macsec_offload offload, + struct macsec_dev *macsec, + struct macsec_context *ctx) +{ + if (ctx) { + memset(ctx, 0, sizeof(*ctx)); + ctx->offload = offload; + + if (offload == macsec_offload_phy) + ctx->phydev = macsec->real_dev->phydev; + } + + return macsec->real_dev->phydev->macsec_ops; +} + +/* returns a pointer to the macsec ops struct if any and updates the macsec + * context device reference if provided. + */ +static const struct macsec_ops *macsec_get_ops(struct macsec_dev *macsec, + struct macsec_context *ctx) +{ + if (!macsec_check_offload(macsec->offload, macsec)) + return null; + + return __macsec_get_ops(macsec->offload, macsec, ctx); +} + -static void handle_not_macsec(struct sk_buff *skb) +static enum rx_handler_result handle_not_macsec(struct sk_buff *skb) + /* deliver to the uncontrolled port by default */ + enum rx_handler_result ret = rx_handler_pass; - if (macsec->secy.validate_frames == macsec_validate_strict) { + if (!macsec_is_offloaded(macsec) && + macsec->secy.validate_frames == macsec_validate_strict) { + + if (netif_running(macsec->secy.netdev) && + macsec_is_offloaded(macsec)) { + ret = rx_handler_exact; + goto out; + } +out: + return ret; - if (hdr->eth.h_proto != htons(eth_p_macsec)) { - handle_not_macsec(skb); - - /* and deliver to the uncontrolled port */ - return rx_handler_pass; - } + if (hdr->eth.h_proto != htons(eth_p_macsec)) + return handle_not_macsec(skb); +/* offloads an operation to a device driver */ +static int macsec_offload(int (* const func)(struct macsec_context *), + struct macsec_context *ctx) +{ + int ret; + + if (unlikely(!func)) + return 0; + + if (ctx->offload == macsec_offload_phy) + mutex_lock(&ctx->phydev->lock); + + /* phase i: prepare. the drive should fail here if there are going to be + * issues in the commit phase. + */ + ctx->prepare = true; + ret = (*func)(ctx); + if (ret) + goto phy_unlock; + + /* phase ii: commit. this step cannot fail. */ + ctx->prepare = false; + ret = (*func)(ctx); + /* this should never happen: commit is not allowed to fail */ + if (unlikely(ret)) + warn(1, "macsec offloading commit failed (%d) ", ret); + +phy_unlock: + if (ctx->offload == macsec_offload_phy) + mutex_unlock(&ctx->phydev->lock); + + return ret; +} + - nla_memcpy(rx_sa->key.id, tb_sa[macsec_sa_attr_keyid], macsec_keyid_len); + + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + err = -eopnotsupp; + goto cleanup; + } + + ctx.sa.assoc_num = assoc_num; + ctx.sa.rx_sa = rx_sa; + memcpy(ctx.sa.key, nla_data(tb_sa[macsec_sa_attr_key]), + macsec_keyid_len); + + err = macsec_offload(ops->mdo_add_rxsa, &ctx); + if (err) + goto cleanup; + } + + nla_memcpy(rx_sa->key.id, tb_sa[macsec_sa_attr_keyid], macsec_keyid_len); + +cleanup: + kfree(rx_sa); + rtnl_unlock(); + return err; + bool was_active; + int ret; + was_active = rx_sc->active; + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.rx_sc = rx_sc; + + ret = macsec_offload(ops->mdo_add_rxsc, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + rx_sc->active = was_active; + rtnl_unlock(); + return ret; + bool was_operational; - nla_memcpy(tx_sa->key.id, tb_sa[macsec_sa_attr_keyid], macsec_keyid_len); - + was_operational = secy->operational; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + err = -eopnotsupp; + goto cleanup; + } + + ctx.sa.assoc_num = assoc_num; + ctx.sa.tx_sa = tx_sa; + memcpy(ctx.sa.key, nla_data(tb_sa[macsec_sa_attr_key]), + macsec_keyid_len); + + err = macsec_offload(ops->mdo_add_txsa, &ctx); + if (err) + goto cleanup; + } + + nla_memcpy(tx_sa->key.id, tb_sa[macsec_sa_attr_keyid], macsec_keyid_len); + +cleanup: + secy->operational = was_operational; + kfree(tx_sa); + rtnl_unlock(); + return err; + int ret; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.sa.assoc_num = assoc_num; + ctx.sa.rx_sa = rx_sa; + + ret = macsec_offload(ops->mdo_del_rxsa, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + rtnl_unlock(); + return ret; + int ret; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.rx_sc = rx_sc; + ret = macsec_offload(ops->mdo_del_rxsc, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + rtnl_unlock(); + return ret; + int ret; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.sa.assoc_num = assoc_num; + ctx.sa.tx_sa = tx_sa; + + ret = macsec_offload(ops->mdo_del_txsa, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + rtnl_unlock(); + return ret; + bool was_operational, was_active; + u32 prev_pn = 0; + int ret = 0; + prev_pn = tx_sa->next_pn; + was_active = tx_sa->active; + was_operational = secy->operational; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.sa.assoc_num = assoc_num; + ctx.sa.tx_sa = tx_sa; + + ret = macsec_offload(ops->mdo_upd_txsa, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + if (tb_sa[macsec_sa_attr_pn]) { + spin_lock_bh(&tx_sa->lock); + tx_sa->next_pn = prev_pn; + spin_unlock_bh(&tx_sa->lock); + } + tx_sa->active = was_active; + secy->operational = was_operational; + rtnl_unlock(); + return ret; + bool was_active; + u32 prev_pn = 0; + int ret = 0; + prev_pn = rx_sa->next_pn; + was_active = rx_sa->active; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.sa.assoc_num = assoc_num; + ctx.sa.rx_sa = rx_sa; + + ret = macsec_offload(ops->mdo_upd_rxsa, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + if (tb_sa[macsec_sa_attr_pn]) { + spin_lock_bh(&rx_sa->lock); + rx_sa->next_pn = prev_pn; + spin_unlock_bh(&rx_sa->lock); + } + rx_sa->active = was_active; + rtnl_unlock(); + return ret; + unsigned int prev_n_rx_sc; + bool was_active; + int ret; + was_active = rx_sc->active; + prev_n_rx_sc = secy->n_rx_sc; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(netdev_priv(dev))) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.rx_sc = rx_sc; + + ret = macsec_offload(ops->mdo_upd_rxsc, &ctx); + if (ret) + goto cleanup; + } + + +cleanup: + secy->n_rx_sc = prev_n_rx_sc; + rx_sc->active = was_active; + rtnl_unlock(); + return ret; + if (macsec_is_offloaded(netdev_priv(dev))) { + skb->dev = macsec->real_dev; + return dev_queue_xmit(skb); + } + + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(macsec)) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + err = -eopnotsupp; + goto clear_allmulti; + } + + err = macsec_offload(ops->mdo_dev_open, &ctx); + if (err) + goto clear_allmulti; + } + + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(macsec)) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(macsec, &ctx); + if (ops) + macsec_offload(ops->mdo_dev_stop, &ctx); + } + + struct macsec_dev *macsec = macsec_priv(dev); + struct macsec_tx_sa tx_sc; + struct macsec_secy secy; + int ret; + - return macsec_changelink_common(dev, data); + /* keep a copy of unmodified secy and tx_sc, in case the offload + * propagation fails, to revert macsec_changelink_common. + */ + memcpy(&secy, &macsec->secy, sizeof(secy)); + memcpy(&tx_sc, &macsec->secy.tx_sc, sizeof(tx_sc)); + + ret = macsec_changelink_common(dev, data); + if (ret) + return ret; + + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(macsec)) { + const struct macsec_ops *ops; + struct macsec_context ctx; + int ret; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (!ops) { + ret = -eopnotsupp; + goto cleanup; + } + + ctx.secy = &macsec->secy; + ret = macsec_offload(ops->mdo_upd_secy, &ctx); + if (ret) + goto cleanup; + } + + return 0; + +cleanup: + memcpy(&macsec->secy.tx_sc, &tx_sc, sizeof(tx_sc)); + memcpy(&macsec->secy, &secy, sizeof(secy)); + + return ret; + /* if h/w offloading is available, propagate to the device */ + if (macsec_is_offloaded(macsec)) { + const struct macsec_ops *ops; + struct macsec_context ctx; + + ops = macsec_get_ops(netdev_priv(dev), &ctx); + if (ops) { + ctx.secy = &macsec->secy; + macsec_offload(ops->mdo_del_secy, &ctx); + } + } + + /* macsec offloading is off by default */ + macsec->offload = macsec_offload_off; +
|
Networking
|
3cf3227a21d1fb020fe26128e60321bd2151e922
|
antoine tenart
|
drivers
|
net
| |
net: macsec: add nla support for changing the offloading selection
|
macsec offloading to underlying hardware devices is disabled by default (the software implementation is used). this patch adds support for changing this setting through the macsec netlink interface. many checks are done when enabling offloading on a given macsec interface as there are limitations (it must be supported by the hardware, only a single interface can be offloaded on a given physical device at a time, rules can't be moved 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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c', 'h']
| 2
| 153
| 3
|
--- diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c + [macsec_attr_offload] = { .type = nla_nested }, +static const struct nla_policy macsec_genl_offload_policy[num_macsec_offload_attr] = { + [macsec_offload_attr_type] = { .type = nla_u8 }, +}; + +static bool macsec_is_configured(struct macsec_dev *macsec) +{ + struct macsec_secy *secy = &macsec->secy; + struct macsec_tx_sc *tx_sc = &secy->tx_sc; + int i; + + if (secy->n_rx_sc > 0) + return true; + + for (i = 0; i < macsec_num_an; i++) + if (tx_sc->sa[i]) + return true; + + return false; +} + +static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info) +{ + struct nlattr *tb_offload[macsec_offload_attr_max + 1]; + enum macsec_offload offload, prev_offload; + int (*func)(struct macsec_context *ctx); + struct nlattr **attrs = info->attrs; + struct net_device *dev, *loop_dev; + const struct macsec_ops *ops; + struct macsec_context ctx; + struct macsec_dev *macsec; + struct net *loop_net; + int ret; + + if (!attrs[macsec_attr_ifindex]) + return -einval; + + if (!attrs[macsec_attr_offload]) + return -einval; + + if (nla_parse_nested_deprecated(tb_offload, macsec_offload_attr_max, + attrs[macsec_attr_offload], + macsec_genl_offload_policy, null)) + return -einval; + + dev = get_dev_from_nl(genl_info_net(info), attrs); + if (is_err(dev)) + return ptr_err(dev); + macsec = macsec_priv(dev); + + offload = nla_get_u8(tb_offload[macsec_offload_attr_type]); + if (macsec->offload == offload) + return 0; + + /* check if the offloading mode is supported by the underlying layers */ + if (offload != macsec_offload_off && + !macsec_check_offload(offload, macsec)) + return -eopnotsupp; + + if (offload == macsec_offload_off) + goto skip_limitation; + + /* check the physical interface isn't offloading another interface + * first. + */ + for_each_net(loop_net) { + for_each_netdev(loop_net, loop_dev) { + struct macsec_dev *priv; + + if (!netif_is_macsec(loop_dev)) + continue; + + priv = macsec_priv(loop_dev); + + if (priv->real_dev == macsec->real_dev && + priv->offload != macsec_offload_off) + return -ebusy; + } + } + +skip_limitation: + /* check if the net device is busy. */ + if (netif_running(dev)) + return -ebusy; + + rtnl_lock(); + + prev_offload = macsec->offload; + macsec->offload = offload; + + /* check if the device already has rules configured: we do not support + * rules migration. + */ + if (macsec_is_configured(macsec)) { + ret = -ebusy; + goto rollback; + } + + ops = __macsec_get_ops(offload == macsec_offload_off ? prev_offload : offload, + macsec, &ctx); + if (!ops) { + ret = -eopnotsupp; + goto rollback; + } + + if (prev_offload == macsec_offload_off) + func = ops->mdo_add_secy; + else + func = ops->mdo_del_secy; + + ctx.secy = &macsec->secy; + ret = macsec_offload(func, &ctx); + if (ret) + goto rollback; + + rtnl_unlock(); + return 0; + +rollback: + macsec->offload = prev_offload; + + rtnl_unlock(); + return ret; +} + - struct macsec_rx_sc *rx_sc; + struct macsec_dev *macsec = netdev_priv(dev); - int i, j; - void *hdr; + struct macsec_rx_sc *rx_sc; + void *hdr; + int i, j; + attr = nla_nest_start_noflag(skb, macsec_attr_offload); + if (!attr) + goto nla_put_failure; + if (nla_put_u8(skb, macsec_offload_attr_type, macsec->offload)) + goto nla_put_failure; + nla_nest_end(skb, attr); + + { + .cmd = macsec_cmd_upd_offload, + .validate = genl_dont_validate_strict | genl_dont_validate_dump, + .doit = macsec_upd_offload, + .flags = genl_admin_perm, + }, diff --git a/include/uapi/linux/if_macsec.h b/include/uapi/linux/if_macsec.h --- a/include/uapi/linux/if_macsec.h +++ b/include/uapi/linux/if_macsec.h + macsec_attr_offload, /* config, nested, macsec_offload_attrs */ +enum macsec_offload_attrs { + macsec_offload_attr_unspec, + macsec_offload_attr_type, /* config/dump, u8 0..2 */ + macsec_offload_attr_pad, + __macsec_offload_attr_end, + num_macsec_offload_attr = __macsec_offload_attr_end, + macsec_offload_attr_max = __macsec_offload_attr_end - 1, +}; + + macsec_cmd_upd_offload,
|
Networking
|
dcb780fb279514f268826f2e9f4df3bc75610703
|
antoine tenart
|
include
|
uapi
|
linux
|
net: phy: mscc: macsec initialization
|
this patch adds support for initializing the macsec engine found within some microsemi phys. the engine is initialized in a passthrough mode and does not modify any incoming or outgoing packet. but thanks to this it now can be configured to perform macsec transformations on packets, which will be supported by a future patch.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c', 'h']
| 4
| 865
| 0
|
--- diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c +#include "mscc_macsec.h" +#include "mscc_mac.h" +#include "mscc_fc_buffer.h" + +#define mscc_ext_page_macsec_17 17 +#define mscc_ext_page_macsec_18 18 + +#define mscc_ext_page_macsec_19 19 +#define mscc_phy_macsec_19_reg_addr(x) (x) +#define mscc_phy_macsec_19_target(x) ((x) << 12) +#define mscc_phy_macsec_19_read bit(14) +#define mscc_phy_macsec_19_cmd bit(15) + +#define mscc_ext_page_macsec_20 20 +#define mscc_phy_macsec_20_target(x) (x) +enum macsec_bank { + fc_buffer = 0x04, + host_mac = 0x05, + line_mac = 0x06, + ip_1588 = 0x0e, + macsec_ingr = 0x38, + macsec_egr = 0x3c, +}; + +#define mscc_phy_page_macsec mscc_phy_page_extended_4 +#if is_enabled(config_macsec) +static u32 vsc8584_macsec_phy_read(struct phy_device *phydev, + enum macsec_bank bank, u32 reg) +{ + u32 val, val_l = 0, val_h = 0; + unsigned long deadline; + int rc; + + rc = phy_select_page(phydev, mscc_phy_page_macsec); + if (rc < 0) + goto failed; + + __phy_write(phydev, mscc_ext_page_macsec_20, + mscc_phy_macsec_20_target(bank >> 2)); + + if (bank >> 2 == 0x1) + /* non-macsec access */ + bank &= 0x3; + else + bank = 0; + + __phy_write(phydev, mscc_ext_page_macsec_19, + mscc_phy_macsec_19_cmd | mscc_phy_macsec_19_read | + mscc_phy_macsec_19_reg_addr(reg) | + mscc_phy_macsec_19_target(bank)); + + deadline = jiffies + msecs_to_jiffies(proc_cmd_ncompleted_timeout_ms); + do { + val = __phy_read(phydev, mscc_ext_page_macsec_19); + } while (time_before(jiffies, deadline) && !(val & mscc_phy_macsec_19_cmd)); + + val_l = __phy_read(phydev, mscc_ext_page_macsec_17); + val_h = __phy_read(phydev, mscc_ext_page_macsec_18); + +failed: + phy_restore_page(phydev, rc, rc); + + return (val_h << 16) | val_l; +} + +static void vsc8584_macsec_phy_write(struct phy_device *phydev, + enum macsec_bank bank, u32 reg, u32 val) +{ + unsigned long deadline; + int rc; + + rc = phy_select_page(phydev, mscc_phy_page_macsec); + if (rc < 0) + goto failed; + + __phy_write(phydev, mscc_ext_page_macsec_20, + mscc_phy_macsec_20_target(bank >> 2)); + + if ((bank >> 2 == 0x1) || (bank >> 2 == 0x3)) + bank &= 0x3; + else + /* macsec access */ + bank = 0; + + __phy_write(phydev, mscc_ext_page_macsec_17, (u16)val); + __phy_write(phydev, mscc_ext_page_macsec_18, (u16)(val >> 16)); + + __phy_write(phydev, mscc_ext_page_macsec_19, + mscc_phy_macsec_19_cmd | mscc_phy_macsec_19_reg_addr(reg) | + mscc_phy_macsec_19_target(bank)); + + deadline = jiffies + msecs_to_jiffies(proc_cmd_ncompleted_timeout_ms); + do { + val = __phy_read(phydev, mscc_ext_page_macsec_19); + } while (time_before(jiffies, deadline) && !(val & mscc_phy_macsec_19_cmd)); + +failed: + phy_restore_page(phydev, rc, rc); +} + +static void vsc8584_macsec_classification(struct phy_device *phydev, + enum macsec_bank bank) +{ + /* enable vlan tag parsing */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_cp_tag, + mscc_ms_sam_cp_tag_parse_stag | + mscc_ms_sam_cp_tag_parse_qtag | + mscc_ms_sam_cp_tag_parse_qinq); +} + +static void vsc8584_macsec_flow_default_action(struct phy_device *phydev, + enum macsec_bank bank, + bool block) +{ + u32 port = (bank == macsec_ingr) ? + mscc_ms_port_uncontrolled : mscc_ms_port_common; + u32 action = mscc_ms_flow_bypass; + + if (block) + action = mscc_ms_flow_drop; + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_nm_flow_ncp, + /* macsec untagged */ + mscc_ms_sam_nm_flow_ncp_untagged_flow_type(action) | + mscc_ms_sam_nm_flow_ncp_untagged_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_ncp_untagged_dest_port(port) | + /* macsec tagged */ + mscc_ms_sam_nm_flow_ncp_tagged_flow_type(action) | + mscc_ms_sam_nm_flow_ncp_tagged_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_ncp_tagged_dest_port(port) | + /* bad tag */ + mscc_ms_sam_nm_flow_ncp_badtag_flow_type(action) | + mscc_ms_sam_nm_flow_ncp_badtag_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_ncp_badtag_dest_port(port) | + /* kay tag */ + mscc_ms_sam_nm_flow_ncp_kay_flow_type(action) | + mscc_ms_sam_nm_flow_ncp_kay_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_ncp_kay_dest_port(port)); + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_nm_flow_cp, + /* macsec untagged */ + mscc_ms_sam_nm_flow_ncp_untagged_flow_type(action) | + mscc_ms_sam_nm_flow_cp_untagged_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_cp_untagged_dest_port(port) | + /* macsec tagged */ + mscc_ms_sam_nm_flow_ncp_tagged_flow_type(action) | + mscc_ms_sam_nm_flow_cp_tagged_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_cp_tagged_dest_port(port) | + /* bad tag */ + mscc_ms_sam_nm_flow_ncp_badtag_flow_type(action) | + mscc_ms_sam_nm_flow_cp_badtag_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_cp_badtag_dest_port(port) | + /* kay tag */ + mscc_ms_sam_nm_flow_ncp_kay_flow_type(action) | + mscc_ms_sam_nm_flow_cp_kay_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_nm_flow_cp_kay_dest_port(port)); +} + +static void vsc8584_macsec_integrity_checks(struct phy_device *phydev, + enum macsec_bank bank) +{ + u32 val; + + if (bank != macsec_ingr) + return; + + /* set default rules to pass unmatched frames */ + val = vsc8584_macsec_phy_read(phydev, bank, + mscc_ms_params2_ig_cc_control); + val |= mscc_ms_params2_ig_cc_control_non_match_ctrl_act | + mscc_ms_params2_ig_cc_control_non_match_act; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_params2_ig_cc_control, + val); + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_params2_ig_cp_tag, + mscc_ms_params2_ig_cp_tag_parse_stag | + mscc_ms_params2_ig_cp_tag_parse_qtag | + mscc_ms_params2_ig_cp_tag_parse_qinq); +} + +static void vsc8584_macsec_block_init(struct phy_device *phydev, + enum macsec_bank bank) +{ + u32 val; + int i; + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_ena_cfg, + mscc_ms_ena_cfg_sw_rst | + mscc_ms_ena_cfg_macsec_bypass_ena); + + /* set the macsec block out of s/w reset and enable clocks */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_ena_cfg, + mscc_ms_ena_cfg_clk_ena); + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_status_context_ctrl, + bank == macsec_ingr ? 0xe5880214 : 0xe5880218); + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_misc_control, + mscc_ms_misc_control_mc_latency_fix(bank == macsec_ingr ? 57 : 40) | + mscc_ms_misc_control_xform_rec_size(bank == macsec_ingr ? 1 : 2)); + + /* clear the counters */ + val = vsc8584_macsec_phy_read(phydev, bank, mscc_ms_count_control); + val |= mscc_ms_count_control_auto_cntr_reset; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_count_control, val); + + /* enable octet increment mode */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_pp_ctrl, + mscc_ms_pp_ctrl_macsec_octet_incr_mode); + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_block_ctx_update, 0x3); + + val = vsc8584_macsec_phy_read(phydev, bank, mscc_ms_count_control); + val |= mscc_ms_count_control_reset_all; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_count_control, val); + + /* set the mtu */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_non_vlan_mtu_check, + mscc_ms_non_vlan_mtu_check_nv_mtu_compare(32761) | + mscc_ms_non_vlan_mtu_check_nv_mtu_comp_drop); + + for (i = 0; i < 8; i++) + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_vlan_mtu_check(i), + mscc_ms_vlan_mtu_check_mtu_compare(32761) | + mscc_ms_vlan_mtu_check_mtu_comp_drop); + + if (bank == macsec_egr) { + val = vsc8584_macsec_phy_read(phydev, bank, mscc_ms_intr_ctrl_status); + val &= ~mscc_ms_intr_ctrl_status_intr_enable_m; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_intr_ctrl_status, val); + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_fc_cfg, + mscc_ms_fc_cfg_fcbuf_ena | + mscc_ms_fc_cfg_low_thresh(0x1) | + mscc_ms_fc_cfg_high_thresh(0x4) | + mscc_ms_fc_cfg_low_bytes_val(0x4) | + mscc_ms_fc_cfg_high_bytes_val(0x6)); + } + + vsc8584_macsec_classification(phydev, bank); + vsc8584_macsec_flow_default_action(phydev, bank, false); + vsc8584_macsec_integrity_checks(phydev, bank); + + /* enable the macsec block */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_ena_cfg, + mscc_ms_ena_cfg_clk_ena | + mscc_ms_ena_cfg_macsec_ena | + mscc_ms_ena_cfg_macsec_speed_mode(0x5)); +} + +static void vsc8584_macsec_mac_init(struct phy_device *phydev, + enum macsec_bank bank) +{ + u32 val; + int i; + + /* clear host & line stats */ + for (i = 0; i < 36; i++) + vsc8584_macsec_phy_write(phydev, bank, 0x1c + i, 0); + + val = vsc8584_macsec_phy_read(phydev, bank, + mscc_mac_pause_cfg_tx_frame_ctrl); + val &= ~mscc_mac_pause_cfg_tx_frame_ctrl_pause_mode_m; + val |= mscc_mac_pause_cfg_tx_frame_ctrl_pause_mode(2) | + mscc_mac_pause_cfg_tx_frame_ctrl_pause_value(0xffff); + vsc8584_macsec_phy_write(phydev, bank, + mscc_mac_pause_cfg_tx_frame_ctrl, val); + + val = vsc8584_macsec_phy_read(phydev, bank, + mscc_mac_pause_cfg_tx_frame_ctrl_2); + val |= 0xffff; + vsc8584_macsec_phy_write(phydev, bank, + mscc_mac_pause_cfg_tx_frame_ctrl_2, val); + + val = vsc8584_macsec_phy_read(phydev, bank, + mscc_mac_pause_cfg_rx_frame_ctrl); + if (bank == host_mac) + val |= mscc_mac_pause_cfg_rx_frame_ctrl_pause_timer_ena | + mscc_mac_pause_cfg_rx_frame_ctrl_pause_frame_drop_ena; + else + val |= mscc_mac_pause_cfg_rx_frame_ctrl_pause_react_ena | + mscc_mac_pause_cfg_rx_frame_ctrl_pause_frame_drop_ena | + mscc_mac_pause_cfg_rx_frame_ctrl_pause_mode | + mscc_mac_pause_cfg_rx_frame_ctrl_early_pause_detect_ena; + vsc8584_macsec_phy_write(phydev, bank, + mscc_mac_pause_cfg_rx_frame_ctrl, val); + + vsc8584_macsec_phy_write(phydev, bank, mscc_mac_cfg_pktinf_cfg, + mscc_mac_cfg_pktinf_cfg_strip_fcs_ena | + mscc_mac_cfg_pktinf_cfg_insert_fcs_ena | + mscc_mac_cfg_pktinf_cfg_lpi_relay_ena | + mscc_mac_cfg_pktinf_cfg_strip_preamble_ena | + mscc_mac_cfg_pktinf_cfg_insert_preamble_ena | + (bank == host_mac ? + mscc_mac_cfg_pktinf_cfg_enable_tx_padding : 0)); + + val = vsc8584_macsec_phy_read(phydev, bank, mscc_mac_cfg_mode_cfg); + val &= ~mscc_mac_cfg_mode_cfg_disable_dic; + vsc8584_macsec_phy_write(phydev, bank, mscc_mac_cfg_mode_cfg, val); + + val = vsc8584_macsec_phy_read(phydev, bank, mscc_mac_cfg_maxlen_cfg); + val &= ~mscc_mac_cfg_maxlen_cfg_max_len_m; + val |= mscc_mac_cfg_maxlen_cfg_max_len(10240); + vsc8584_macsec_phy_write(phydev, bank, mscc_mac_cfg_maxlen_cfg, val); + + vsc8584_macsec_phy_write(phydev, bank, mscc_mac_cfg_adv_chk_cfg, + mscc_mac_cfg_adv_chk_cfg_sfd_chk_ena | + mscc_mac_cfg_adv_chk_cfg_prm_chk_ena | + mscc_mac_cfg_adv_chk_cfg_oor_err_ena | + mscc_mac_cfg_adv_chk_cfg_inr_err_ena); + + val = vsc8584_macsec_phy_read(phydev, bank, mscc_mac_cfg_lfs_cfg); + val &= ~mscc_mac_cfg_lfs_cfg_lfs_mode_ena; + vsc8584_macsec_phy_write(phydev, bank, mscc_mac_cfg_lfs_cfg, val); + + vsc8584_macsec_phy_write(phydev, bank, mscc_mac_cfg_ena_cfg, + mscc_mac_cfg_ena_cfg_rx_clk_ena | + mscc_mac_cfg_ena_cfg_tx_clk_ena | + mscc_mac_cfg_ena_cfg_rx_ena | + mscc_mac_cfg_ena_cfg_tx_ena); +} + +/* must be called with mdio_lock taken */ +static int vsc8584_macsec_init(struct phy_device *phydev) +{ + u32 val; + + vsc8584_macsec_block_init(phydev, macsec_ingr); + vsc8584_macsec_block_init(phydev, macsec_egr); + vsc8584_macsec_mac_init(phydev, host_mac); + vsc8584_macsec_mac_init(phydev, line_mac); + + vsc8584_macsec_phy_write(phydev, fc_buffer, + mscc_fcbuf_fc_read_thresh_cfg, + mscc_fcbuf_fc_read_thresh_cfg_tx_thresh(4) | + mscc_fcbuf_fc_read_thresh_cfg_rx_thresh(5)); + + val = vsc8584_macsec_phy_read(phydev, fc_buffer, mscc_fcbuf_mode_cfg); + val |= mscc_fcbuf_mode_cfg_pause_gen_ena | + mscc_fcbuf_mode_cfg_rx_ppm_rate_adapt_ena | + mscc_fcbuf_mode_cfg_tx_ppm_rate_adapt_ena; + vsc8584_macsec_phy_write(phydev, fc_buffer, mscc_fcbuf_mode_cfg, val); + + vsc8584_macsec_phy_write(phydev, fc_buffer, mscc_fcbuf_ppm_rate_adapt_thresh_cfg, + mscc_fcbuf_ppm_rate_adapt_thresh_cfg_tx_thresh(8) | + mscc_fcbuf_ppm_rate_adapt_thresh_cfg_tx_offset(9)); + + val = vsc8584_macsec_phy_read(phydev, fc_buffer, + mscc_fcbuf_tx_data_queue_cfg); + val &= ~(mscc_fcbuf_tx_data_queue_cfg_start_m | + mscc_fcbuf_tx_data_queue_cfg_end_m); + val |= mscc_fcbuf_tx_data_queue_cfg_start(0) | + mscc_fcbuf_tx_data_queue_cfg_end(5119); + vsc8584_macsec_phy_write(phydev, fc_buffer, + mscc_fcbuf_tx_data_queue_cfg, val); + + val = vsc8584_macsec_phy_read(phydev, fc_buffer, mscc_fcbuf_ena_cfg); + val |= mscc_fcbuf_ena_cfg_tx_ena | mscc_fcbuf_ena_cfg_rx_ena; + vsc8584_macsec_phy_write(phydev, fc_buffer, mscc_fcbuf_ena_cfg, val); + + val = vsc8584_macsec_phy_read(phydev, ip_1588, + mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl); + val &= ~mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl_protocol_mode_m; + val |= mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl_protocol_mode(4); + vsc8584_macsec_phy_write(phydev, ip_1588, + mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl, val); + + return 0; +} +#endif /* config_macsec */ + +#if is_enabled(config_macsec) + /* macsec */ + switch (phydev->phy_id & phydev->drv->phy_id_mask) { + case phy_id_vsc856x: + case phy_id_vsc8575: + case phy_id_vsc8582: + case phy_id_vsc8584: + ret = vsc8584_macsec_init(phydev); + if (ret) + goto err; + } +#endif + diff --git a/drivers/net/phy/mscc_fc_buffer.h b/drivers/net/phy/mscc_fc_buffer.h --- /dev/null +++ b/drivers/net/phy/mscc_fc_buffer.h +/* spdx-license-identifier: (gpl-2.0 or mit) */ +/* + * microsemi ocelot switch driver + * + * copyright (c) 2019 microsemi corporation + */ + +#ifndef _mscc_ocelot_fc_buffer_h_ +#define _mscc_ocelot_fc_buffer_h_ + +#define mscc_fcbuf_ena_cfg 0x00 +#define mscc_fcbuf_mode_cfg 0x01 +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg 0x02 +#define mscc_fcbuf_tx_ctrl_queue_cfg 0x03 +#define mscc_fcbuf_tx_data_queue_cfg 0x04 +#define mscc_fcbuf_rx_data_queue_cfg 0x05 +#define mscc_fcbuf_tx_buff_xon_xoff_thresh_cfg 0x06 +#define mscc_fcbuf_fc_read_thresh_cfg 0x07 +#define mscc_fcbuf_tx_frm_gap_comp 0x08 + +#define mscc_fcbuf_ena_cfg_tx_ena bit(0) +#define mscc_fcbuf_ena_cfg_rx_ena bit(4) + +#define mscc_fcbuf_mode_cfg_drop_behaviour bit(4) +#define mscc_fcbuf_mode_cfg_pause_react_ena bit(8) +#define mscc_fcbuf_mode_cfg_rx_ppm_rate_adapt_ena bit(12) +#define mscc_fcbuf_mode_cfg_tx_ppm_rate_adapt_ena bit(16) +#define mscc_fcbuf_mode_cfg_tx_ctrl_queue_ena bit(20) +#define mscc_fcbuf_mode_cfg_pause_gen_ena bit(24) +#define mscc_fcbuf_mode_cfg_include_pause_rcvd_in_pause_gen bit(28) + +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg_tx_thresh(x) (x) +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg_tx_thresh_m genmask(15, 0) +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg_tx_offset(x) ((x) << 16) +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg_tx_offset_m genmask(19, 16) +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg_rx_thresh(x) ((x) << 20) +#define mscc_fcbuf_ppm_rate_adapt_thresh_cfg_rx_thresh_m genmask(31, 20) + +#define mscc_fcbuf_tx_ctrl_queue_cfg_start(x) (x) +#define mscc_fcbuf_tx_ctrl_queue_cfg_start_m genmask(15, 0) +#define mscc_fcbuf_tx_ctrl_queue_cfg_end(x) ((x) << 16) +#define mscc_fcbuf_tx_ctrl_queue_cfg_end_m genmask(31, 16) + +#define mscc_fcbuf_tx_data_queue_cfg_start(x) (x) +#define mscc_fcbuf_tx_data_queue_cfg_start_m genmask(15, 0) +#define mscc_fcbuf_tx_data_queue_cfg_end(x) ((x) << 16) +#define mscc_fcbuf_tx_data_queue_cfg_end_m genmask(31, 16) + +#define mscc_fcbuf_rx_data_queue_cfg_start(x) (x) +#define mscc_fcbuf_rx_data_queue_cfg_start_m genmask(15, 0) +#define mscc_fcbuf_rx_data_queue_cfg_end(x) ((x) << 16) +#define mscc_fcbuf_rx_data_queue_cfg_end_m genmask(31, 16) + +#define mscc_fcbuf_tx_buff_xon_xoff_thresh_cfg_xoff_thresh(x) (x) +#define mscc_fcbuf_tx_buff_xon_xoff_thresh_cfg_xoff_thresh_m genmask(15, 0) +#define mscc_fcbuf_tx_buff_xon_xoff_thresh_cfg_xon_thresh(x) ((x) << 16) +#define mscc_fcbuf_tx_buff_xon_xoff_thresh_cfg_xon_thresh_m genmask(31, 16) + +#define mscc_fcbuf_fc_read_thresh_cfg_tx_thresh(x) (x) +#define mscc_fcbuf_fc_read_thresh_cfg_tx_thresh_m genmask(15, 0) +#define mscc_fcbuf_fc_read_thresh_cfg_rx_thresh(x) ((x) << 16) +#define mscc_fcbuf_fc_read_thresh_cfg_rx_thresh_m genmask(31, 16) + +#endif diff --git a/drivers/net/phy/mscc_mac.h b/drivers/net/phy/mscc_mac.h --- /dev/null +++ b/drivers/net/phy/mscc_mac.h +/* spdx-license-identifier: (gpl-2.0 or mit) */ +/* + * microsemi ocelot switch driver + * + * copyright (c) 2017 microsemi corporation + */ + +#ifndef _mscc_ocelot_line_mac_h_ +#define _mscc_ocelot_line_mac_h_ + +#define mscc_mac_cfg_ena_cfg 0x00 +#define mscc_mac_cfg_mode_cfg 0x01 +#define mscc_mac_cfg_maxlen_cfg 0x02 +#define mscc_mac_cfg_num_tags_cfg 0x03 +#define mscc_mac_cfg_tags_cfg 0x04 +#define mscc_mac_cfg_adv_chk_cfg 0x07 +#define mscc_mac_cfg_lfs_cfg 0x08 +#define mscc_mac_cfg_lb_cfg 0x09 +#define mscc_mac_cfg_pktinf_cfg 0x0a +#define mscc_mac_pause_cfg_tx_frame_ctrl 0x0b +#define mscc_mac_pause_cfg_tx_frame_ctrl_2 0x0c +#define mscc_mac_pause_cfg_rx_frame_ctrl 0x0d +#define mscc_mac_pause_cfg_state 0x0e +#define mscc_mac_pause_cfg_mac_address_lsb 0x0f +#define mscc_mac_pause_cfg_mac_address_msb 0x10 +#define mscc_mac_status_rx_lane_sticky_0 0x11 +#define mscc_mac_status_rx_lane_sticky_1 0x12 +#define mscc_mac_status_tx_monitor_sticky 0x13 +#define mscc_mac_status_tx_monitor_sticky_mask 0x14 +#define mscc_mac_status_sticky 0x15 +#define mscc_mac_status_sticky_mask 0x16 +#define mscc_mac_stats_32bit_rx_hih_cksm_err_cnt 0x17 +#define mscc_mac_stats_32bit_rx_xgmii_prot_err_cnt 0x18 +#define mscc_mac_stats_32bit_rx_symbol_err_cnt 0x19 +#define mscc_mac_stats_32bit_rx_pause_cnt 0x1a +#define mscc_mac_stats_32bit_rx_unsup_opcode_cnt 0x1b +#define mscc_mac_stats_32bit_rx_uc_cnt 0x1c +#define mscc_mac_stats_32bit_rx_mc_cnt 0x1d +#define mscc_mac_stats_32bit_rx_bc_cnt 0x1e +#define mscc_mac_stats_32bit_rx_crc_err_cnt 0x1f +#define mscc_mac_stats_32bit_rx_undersize_cnt 0x20 +#define mscc_mac_stats_32bit_rx_fragments_cnt 0x21 +#define mscc_mac_stats_32bit_rx_in_range_len_err_cnt 0x22 +#define mscc_mac_stats_32bit_rx_out_of_range_len_err_cnt 0x23 +#define mscc_mac_stats_32bit_rx_oversize_cnt 0x24 +#define mscc_mac_stats_32bit_rx_jabbers_cnt 0x25 +#define mscc_mac_stats_32bit_rx_size64_cnt 0x26 +#define mscc_mac_stats_32bit_rx_size65to127_cnt 0x27 +#define mscc_mac_stats_32bit_rx_size128to255_cnt 0x28 +#define mscc_mac_stats_32bit_rx_size256to511_cnt 0x29 +#define mscc_mac_stats_32bit_rx_size512to1023_cnt 0x2a +#define mscc_mac_stats_32bit_rx_size1024to1518_cnt 0x2b +#define mscc_mac_stats_32bit_rx_size1519tomax_cnt 0x2c +#define mscc_mac_stats_32bit_rx_ipg_shrink_cnt 0x2d +#define mscc_mac_stats_32bit_tx_pause_cnt 0x2e +#define mscc_mac_stats_32bit_tx_uc_cnt 0x2f +#define mscc_mac_stats_32bit_tx_mc_cnt 0x30 +#define mscc_mac_stats_32bit_tx_bc_cnt 0x31 +#define mscc_mac_stats_32bit_tx_size64_cnt 0x32 +#define mscc_mac_stats_32bit_tx_size65to127_cnt 0x33 +#define mscc_mac_stats_32bit_tx_size128to255_cnt 0x34 +#define mscc_mac_stats_32bit_tx_size256to511_cnt 0x35 +#define mscc_mac_stats_32bit_tx_size512to1023_cnt 0x36 +#define mscc_mac_stats_32bit_tx_size1024to1518_cnt 0x37 +#define mscc_mac_stats_32bit_tx_size1519tomax_cnt 0x38 +#define mscc_mac_stats_40bit_rx_bad_bytes_cnt 0x39 +#define mscc_mac_stats_40bit_rx_bad_bytes_msb_cnt 0x3a +#define mscc_mac_stats_40bit_rx_ok_bytes_cnt 0x3b +#define mscc_mac_stats_40bit_rx_ok_bytes_msb_cnt 0x3c +#define mscc_mac_stats_40bit_rx_in_bytes_cnt 0x3d +#define mscc_mac_stats_40bit_rx_in_bytes_msb_cnt 0x3e +#define mscc_mac_stats_40bit_tx_ok_bytes_cnt 0x3f +#define mscc_mac_stats_40bit_tx_ok_bytes_msb_cnt 0x40 +#define mscc_mac_stats_40bit_tx_out_bytes_cnt 0x41 +#define mscc_mac_stats_40bit_tx_out_bytes_msb_cnt 0x42 + +#define mscc_mac_cfg_ena_cfg_rx_clk_ena bit(0) +#define mscc_mac_cfg_ena_cfg_tx_clk_ena bit(4) +#define mscc_mac_cfg_ena_cfg_rx_sw_rst bit(8) +#define mscc_mac_cfg_ena_cfg_tx_sw_rst bit(12) +#define mscc_mac_cfg_ena_cfg_rx_ena bit(16) +#define mscc_mac_cfg_ena_cfg_tx_ena bit(20) + +#define mscc_mac_cfg_mode_cfg_force_cw_update_interval(x) ((x) << 20) +#define mscc_mac_cfg_mode_cfg_force_cw_update_interval_m genmask(29, 20) +#define mscc_mac_cfg_mode_cfg_force_cw_update bit(16) +#define mscc_mac_cfg_mode_cfg_tunnel_pause_frames bit(14) +#define mscc_mac_cfg_mode_cfg_mac_preamble_cfg(x) ((x) << 10) +#define mscc_mac_cfg_mode_cfg_mac_preamble_cfg_m genmask(12, 10) +#define mscc_mac_cfg_mode_cfg_mac_ipg_cfg bit(6) +#define mscc_mac_cfg_mode_cfg_xgmii_gen_mode_ena bit(4) +#define mscc_mac_cfg_mode_cfg_hih_crc_check bit(2) +#define mscc_mac_cfg_mode_cfg_undersized_frame_drop_dis bit(1) +#define mscc_mac_cfg_mode_cfg_disable_dic bit(0) + +#define mscc_mac_cfg_maxlen_cfg_max_len_tag_chk bit(16) +#define mscc_mac_cfg_maxlen_cfg_max_len(x) (x) +#define mscc_mac_cfg_maxlen_cfg_max_len_m genmask(15, 0) + +#define mscc_mac_cfg_tags_cfg_rsz 0x4 +#define mscc_mac_cfg_tags_cfg_tag_id(x) ((x) << 16) +#define mscc_mac_cfg_tags_cfg_tag_id_m genmask(31, 16) +#define mscc_mac_cfg_tags_cfg_tag_ena bit(4) + +#define mscc_mac_cfg_adv_chk_cfg_ext_eop_chk_ena bit(24) +#define mscc_mac_cfg_adv_chk_cfg_ext_sop_chk_ena bit(20) +#define mscc_mac_cfg_adv_chk_cfg_sfd_chk_ena bit(16) +#define mscc_mac_cfg_adv_chk_cfg_prm_shk_chk_dis bit(12) +#define mscc_mac_cfg_adv_chk_cfg_prm_chk_ena bit(8) +#define mscc_mac_cfg_adv_chk_cfg_oor_err_ena bit(4) +#define mscc_mac_cfg_adv_chk_cfg_inr_err_ena bit(0) + +#define mscc_mac_cfg_lfs_cfg_lfs_inh_tx bit(8) +#define mscc_mac_cfg_lfs_cfg_lfs_dis_tx bit(4) +#define mscc_mac_cfg_lfs_cfg_lfs_unidir_ena bit(3) +#define mscc_mac_cfg_lfs_cfg_use_leading_edge_detect bit(2) +#define mscc_mac_cfg_lfs_cfg_spurious_q_dis bit(1) +#define mscc_mac_cfg_lfs_cfg_lfs_mode_ena bit(0) + +#define mscc_mac_cfg_lb_cfg_xgmii_host_lb_ena bit(4) +#define mscc_mac_cfg_lb_cfg_xgmii_phy_lb_ena bit(0) + +#define mscc_mac_cfg_pktinf_cfg_strip_fcs_ena bit(0) +#define mscc_mac_cfg_pktinf_cfg_insert_fcs_ena bit(4) +#define mscc_mac_cfg_pktinf_cfg_strip_preamble_ena bit(8) +#define mscc_mac_cfg_pktinf_cfg_insert_preamble_ena bit(12) +#define mscc_mac_cfg_pktinf_cfg_lpi_relay_ena bit(16) +#define mscc_mac_cfg_pktinf_cfg_lf_relay_ena bit(20) +#define mscc_mac_cfg_pktinf_cfg_rf_relay_ena bit(24) +#define mscc_mac_cfg_pktinf_cfg_enable_tx_padding bit(25) +#define mscc_mac_cfg_pktinf_cfg_enable_rx_padding bit(26) +#define mscc_mac_cfg_pktinf_cfg_enable_4byte_preamble bit(27) +#define mscc_mac_cfg_pktinf_cfg_macsec_bypass_num_ptp_stall_clks(x) ((x) << 28) +#define mscc_mac_cfg_pktinf_cfg_macsec_bypass_num_ptp_stall_clks_m genmask(30, 28) + +#define mscc_mac_pause_cfg_tx_frame_ctrl_pause_value(x) ((x) << 16) +#define mscc_mac_pause_cfg_tx_frame_ctrl_pause_value_m genmask(31, 16) +#define mscc_mac_pause_cfg_tx_frame_ctrl_wait_for_lpi_low bit(12) +#define mscc_mac_pause_cfg_tx_frame_ctrl_use_pause_stall_ena bit(8) +#define mscc_mac_pause_cfg_tx_frame_ctrl_pause_repl_mode bit(4) +#define mscc_mac_pause_cfg_tx_frame_ctrl_pause_frc_frame bit(2) +#define mscc_mac_pause_cfg_tx_frame_ctrl_pause_mode(x) (x) +#define mscc_mac_pause_cfg_tx_frame_ctrl_pause_mode_m genmask(1, 0) + +#define mscc_mac_pause_cfg_rx_frame_ctrl_early_pause_detect_ena bit(16) +#define mscc_mac_pause_cfg_rx_frame_ctrl_pre_crc_mode bit(20) +#define mscc_mac_pause_cfg_rx_frame_ctrl_pause_timer_ena bit(12) +#define mscc_mac_pause_cfg_rx_frame_ctrl_pause_react_ena bit(8) +#define mscc_mac_pause_cfg_rx_frame_ctrl_pause_frame_drop_ena bit(4) +#define mscc_mac_pause_cfg_rx_frame_ctrl_pause_mode bit(0) + +#define mscc_mac_pause_cfg_state_pause_state bit(0) +#define mscc_mac_pause_cfg_state_mac_tx_pause_gen bit(4) + +#define mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl 0x2 +#define mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl_protocol_mode(x) (x) +#define mscc_proc_0_ip_1588_top_cfg_stat_mode_ctl_protocol_mode_m genmask(2, 0) + +#endif /* _mscc_ocelot_line_mac_h_ */ diff --git a/drivers/net/phy/mscc_macsec.h b/drivers/net/phy/mscc_macsec.h --- /dev/null +++ b/drivers/net/phy/mscc_macsec.h +/* spdx-license-identifier: (gpl-2.0 or mit) */ +/* + * microsemi ocelot switch driver + * + * copyright (c) 2018 microsemi corporation + */ + +#ifndef _mscc_ocelot_macsec_h_ +#define _mscc_ocelot_macsec_h_ + +#define control_type_egress 0x6 +#define control_type_ingress 0xf +#define control_iv0 bit(5) +#define control_iv1 bit(6) +#define control_iv2 bit(7) +#define control_update_seq bit(13) +#define control_iv_in_seq bit(14) +#define control_encrypt_auth bit(15) +#define control_key_in_ctx bit(16) +#define control_crypto_alg(x) ((x) << 17) +#define ctrypto_alg_aes_ctr_128 0x5 +#define ctrypto_alg_aes_ctr_192 0x6 +#define ctrypto_alg_aes_ctr_256 0x7 +#define control_digest_type(x) ((x) << 21) +#define control_auth_alg(x) ((x) << 23) +#define auth_alg_aes_ghas 0x4 +#define control_an(x) ((x) << 26) +#define control_seq_type(x) ((x) << 28) +#define control_seq_mask bit(30) +#define control_context_id bit(31) + +enum mscc_macsec_destination_ports { + mscc_ms_port_common = 0, + mscc_ms_port_rsvd = 1, + mscc_ms_port_controlled = 2, + mscc_ms_port_uncontrolled = 3, +}; + +enum mscc_macsec_drop_actions { + mscc_ms_action_bypass_crc = 0, + mscc_ms_action_bypass_bad = 1, + mscc_ms_action_drop = 2, + mscc_ms_action_bypass = 3, +}; + +enum mscc_macsec_flow_types { + mscc_ms_flow_bypass = 0, + mscc_ms_flow_drop = 1, + mscc_ms_flow_ingress = 2, + mscc_ms_flow_egress = 3, +}; + +enum mscc_macsec_validate_levels { + mscc_ms_validate_disabled = 0, + mscc_ms_validate_check = 1, + mscc_ms_validate_strict = 2, +}; + +#define mscc_ms_xform_rec(x, y) (((x) << 5) + (y)) +#define mscc_ms_ena_cfg 0x800 +#define mscc_ms_fc_cfg 0x804 +#define mscc_ms_sam_misc_match(x) (0x1004 + ((x) << 4)) +#define mscc_ms_sam_match_sci_lo(x) (0x1005 + ((x) << 4)) +#define mscc_ms_sam_match_sci_hi(x) (0x1006 + ((x) << 4)) +#define mscc_ms_sam_mask(x) (0x1007 + ((x) << 4)) +#define mscc_ms_sam_entry_set1 0x1808 +#define mscc_ms_sam_entry_clear1 0x180c +#define mscc_ms_sam_flow_ctrl(x) (0x1c00 + (x)) +#define mscc_ms_sam_cp_tag 0x1e40 +#define mscc_ms_sam_nm_flow_ncp 0x1e51 +#define mscc_ms_sam_nm_flow_cp 0x1e52 +#define mscc_ms_misc_control 0x1e5f +#define mscc_ms_count_control 0x3204 +#define mscc_ms_params2_ig_cc_control 0x3a10 +#define mscc_ms_params2_ig_cp_tag 0x3a14 +#define mscc_ms_vlan_mtu_check(x) (0x3c40 + (x)) +#define mscc_ms_non_vlan_mtu_check 0x3c48 +#define mscc_ms_pp_ctrl 0x3c4b +#define mscc_ms_status_context_ctrl 0x3d02 +#define mscc_ms_intr_ctrl_status 0x3d04 +#define mscc_ms_block_ctx_update 0x3d0c + +/* macsec_ena_cfg */ +#define mscc_ms_ena_cfg_clk_ena bit(0) +#define mscc_ms_ena_cfg_sw_rst bit(1) +#define mscc_ms_ena_cfg_macsec_bypass_ena bit(8) +#define mscc_ms_ena_cfg_macsec_ena bit(9) +#define mscc_ms_ena_cfg_macsec_speed_mode(x) ((x) << 10) +#define mscc_ms_ena_cfg_macsec_speed_mode_m genmask(12, 10) + +/* macsec_fc_cfg */ +#define mscc_ms_fc_cfg_fcbuf_ena bit(0) +#define mscc_ms_fc_cfg_use_pkt_expansion_indication bit(1) +#define mscc_ms_fc_cfg_low_thresh(x) ((x) << 4) +#define mscc_ms_fc_cfg_low_thresh_m genmask(7, 4) +#define mscc_ms_fc_cfg_high_thresh(x) ((x) << 8) +#define mscc_ms_fc_cfg_high_thresh_m genmask(11, 8) +#define mscc_ms_fc_cfg_low_bytes_val(x) ((x) << 12) +#define mscc_ms_fc_cfg_low_bytes_val_m genmask(14, 12) +#define mscc_ms_fc_cfg_high_bytes_val(x) ((x) << 16) +#define mscc_ms_fc_cfg_high_bytes_val_m genmask(18, 16) + +/* mscc_ms_sam_mac_sa_match_hi */ +#define mscc_ms_sam_mac_sa_match_hi_etype(x) ((x) << 16) +#define mscc_ms_sam_mac_sa_match_hi_etype_m genmask(31, 16) + +/* macsec_sam_misc_match */ +#define mscc_ms_sam_misc_match_vlan_valid bit(0) +#define mscc_ms_sam_misc_match_qinq_found bit(1) +#define mscc_ms_sam_misc_match_stag_valid bit(2) +#define mscc_ms_sam_misc_match_qtag_valid bit(3) +#define mscc_ms_sam_misc_match_vlan_up(x) ((x) << 4) +#define mscc_ms_sam_misc_match_vlan_up_m genmask(6, 4) +#define mscc_ms_sam_misc_match_control_packet bit(7) +#define mscc_ms_sam_misc_match_untagged bit(8) +#define mscc_ms_sam_misc_match_tagged bit(9) +#define mscc_ms_sam_misc_match_bad_tag bit(10) +#define mscc_ms_sam_misc_match_kay_tag bit(11) +#define mscc_ms_sam_misc_match_source_port(x) ((x) << 12) +#define mscc_ms_sam_misc_match_source_port_m genmask(13, 12) +#define mscc_ms_sam_misc_match_priority(x) ((x) << 16) +#define mscc_ms_sam_misc_match_priority_m genmask(19, 16) +#define mscc_ms_sam_misc_match_an(x) ((x) << 24) +#define mscc_ms_sam_misc_match_tci(x) ((x) << 26) + +/* macsec_sam_mask */ +#define mscc_ms_sam_mask_mac_sa_mask(x) (x) +#define mscc_ms_sam_mask_mac_sa_mask_m genmask(5, 0) +#define mscc_ms_sam_mask_mac_da_mask(x) ((x) << 6) +#define mscc_ms_sam_mask_mac_da_mask_m genmask(11, 6) +#define mscc_ms_sam_mask_mac_etype_mask bit(12) +#define mscc_ms_sam_mask_vlan_vld_mask bit(13) +#define mscc_ms_sam_mask_qinq_found_mask bit(14) +#define mscc_ms_sam_mask_stag_vld_mask bit(15) +#define mscc_ms_sam_mask_qtag_vld_mask bit(16) +#define mscc_ms_sam_mask_vlan_up_mask bit(17) +#define mscc_ms_sam_mask_vlan_id_mask bit(18) +#define mscc_ms_sam_mask_source_port_mask bit(19) +#define mscc_ms_sam_mask_ctl_packet_mask bit(20) +#define mscc_ms_sam_mask_vlan_up_inner_mask bit(21) +#define mscc_ms_sam_mask_vlan_id_inner_mask bit(22) +#define mscc_ms_sam_mask_sci_mask bit(23) +#define mscc_ms_sam_mask_an_mask(x) ((x) << 24) +#define mscc_ms_sam_mask_tci_mask(x) ((x) << 26) + +/* macsec_sam_flow_ctrl_egr */ +#define mscc_ms_sam_flow_ctrl_flow_type(x) (x) +#define mscc_ms_sam_flow_ctrl_flow_type_m genmask(1, 0) +#define mscc_ms_sam_flow_ctrl_dest_port(x) ((x) << 2) +#define mscc_ms_sam_flow_ctrl_dest_port_m genmask(3, 2) +#define mscc_ms_sam_flow_ctrl_resv_4 bit(4) +#define mscc_ms_sam_flow_ctrl_flow_crypt_auth bit(5) +#define mscc_ms_sam_flow_ctrl_drop_action(x) ((x) << 6) +#define mscc_ms_sam_flow_ctrl_drop_action_m genmask(7, 6) +#define mscc_ms_sam_flow_ctrl_resv_15_to_8(x) ((x) << 8) +#define mscc_ms_sam_flow_ctrl_resv_15_to_8_m genmask(15, 8) +#define mscc_ms_sam_flow_ctrl_protect_frame bit(16) +#define mscc_ms_sam_flow_ctrl_replay_protect bit(16) +#define mscc_ms_sam_flow_ctrl_sa_in_use bit(17) +#define mscc_ms_sam_flow_ctrl_include_sci bit(18) +#define mscc_ms_sam_flow_ctrl_use_es bit(19) +#define mscc_ms_sam_flow_ctrl_use_scb bit(20) +#define mscc_ms_sam_flow_ctrl_validate_frames(x) ((x) << 19) +#define mscc_ms_sam_flow_ctrl_tag_bypass_size(x) ((x) << 21) +#define mscc_ms_sam_flow_ctrl_tag_bypass_size_m genmask(22, 21) +#define mscc_ms_sam_flow_ctrl_resv_23 bit(23) +#define mscc_ms_sam_flow_ctrl_confidentiality_offset(x) ((x) << 24) +#define mscc_ms_sam_flow_ctrl_confidentiality_offset_m genmask(30, 24) +#define mscc_ms_sam_flow_ctrl_conf_protect bit(31) + +/* macsec_sam_cp_tag */ +#define mscc_ms_sam_cp_tag_map_tbl(x) (x) +#define mscc_ms_sam_cp_tag_map_tbl_m genmask(23, 0) +#define mscc_ms_sam_cp_tag_def_up(x) ((x) << 24) +#define mscc_ms_sam_cp_tag_def_up_m genmask(26, 24) +#define mscc_ms_sam_cp_tag_stag_up_en bit(27) +#define mscc_ms_sam_cp_tag_qtag_up_en bit(28) +#define mscc_ms_sam_cp_tag_parse_qinq bit(29) +#define mscc_ms_sam_cp_tag_parse_stag bit(30) +#define mscc_ms_sam_cp_tag_parse_qtag bit(31) + +/* macsec_sam_nm_flow_ncp */ +#define mscc_ms_sam_nm_flow_ncp_untagged_flow_type(x) (x) +#define mscc_ms_sam_nm_flow_ncp_untagged_dest_port(x) ((x) << 2) +#define mscc_ms_sam_nm_flow_ncp_untagged_drop_action(x) ((x) << 6) +#define mscc_ms_sam_nm_flow_ncp_tagged_flow_type(x) ((x) << 8) +#define mscc_ms_sam_nm_flow_ncp_tagged_dest_port(x) ((x) << 10) +#define mscc_ms_sam_nm_flow_ncp_tagged_drop_action(x) ((x) << 14) +#define mscc_ms_sam_nm_flow_ncp_badtag_flow_type(x) ((x) << 16) +#define mscc_ms_sam_nm_flow_ncp_badtag_dest_port(x) ((x) << 18) +#define mscc_ms_sam_nm_flow_ncp_badtag_drop_action(x) ((x) << 22) +#define mscc_ms_sam_nm_flow_ncp_kay_flow_type(x) ((x) << 24) +#define mscc_ms_sam_nm_flow_ncp_kay_dest_port(x) ((x) << 26) +#define mscc_ms_sam_nm_flow_ncp_kay_drop_action(x) ((x) << 30) + +/* macsec_sam_nm_flow_cp */ +#define mscc_ms_sam_nm_flow_cp_untagged_flow_type(x) (x) +#define mscc_ms_sam_nm_flow_cp_untagged_dest_port(x) ((x) << 2) +#define mscc_ms_sam_nm_flow_cp_untagged_drop_action(x) ((x) << 6) +#define mscc_ms_sam_nm_flow_cp_tagged_flow_type(x) ((x) << 8) +#define mscc_ms_sam_nm_flow_cp_tagged_dest_port(x) ((x) << 10) +#define mscc_ms_sam_nm_flow_cp_tagged_drop_action(x) ((x) << 14) +#define mscc_ms_sam_nm_flow_cp_badtag_flow_type(x) ((x) << 16) +#define mscc_ms_sam_nm_flow_cp_badtag_dest_port(x) ((x) << 18) +#define mscc_ms_sam_nm_flow_cp_badtag_drop_action(x) ((x) << 22) +#define mscc_ms_sam_nm_flow_cp_kay_flow_type(x) ((x) << 24) +#define mscc_ms_sam_nm_flow_cp_kay_dest_port(x) ((x) << 26) +#define mscc_ms_sam_nm_flow_cp_kay_drop_action(x) ((x) << 30) + +/* macsec_misc_control */ +#define mscc_ms_misc_control_mc_latency_fix(x) (x) +#define mscc_ms_misc_control_mc_latency_fix_m genmask(5, 0) +#define mscc_ms_misc_control_static_bypass bit(8) +#define mscc_ms_misc_control_nm_macsec_en bit(9) +#define mscc_ms_misc_control_validate_frames(x) ((x) << 10) +#define mscc_ms_misc_control_validate_frames_m genmask(11, 10) +#define mscc_ms_misc_control_xform_rec_size(x) ((x) << 24) +#define mscc_ms_misc_control_xform_rec_size_m genmask(25, 24) + +/* macsec_count_control */ +#define mscc_ms_count_control_reset_all bit(0) +#define mscc_ms_count_control_debug_access bit(1) +#define mscc_ms_count_control_saturate_cntrs bit(2) +#define mscc_ms_count_control_auto_cntr_reset bit(3) + +/* macsec_params2_ig_cc_control */ +#define mscc_ms_params2_ig_cc_control_non_match_ctrl_act bit(14) +#define mscc_ms_params2_ig_cc_control_non_match_act bit(15) + +/* macsec_params2_ig_cp_tag */ +#define mscc_ms_params2_ig_cp_tag_map_tbl(x) (x) +#define mscc_ms_params2_ig_cp_tag_map_tbl_m genmask(23, 0) +#define mscc_ms_params2_ig_cp_tag_def_up(x) ((x) << 24) +#define mscc_ms_params2_ig_cp_tag_def_up_m genmask(26, 24) +#define mscc_ms_params2_ig_cp_tag_stag_up_en bit(27) +#define mscc_ms_params2_ig_cp_tag_qtag_up_en bit(28) +#define mscc_ms_params2_ig_cp_tag_parse_qinq bit(29) +#define mscc_ms_params2_ig_cp_tag_parse_stag bit(30) +#define mscc_ms_params2_ig_cp_tag_parse_qtag bit(31) + +/* macsec_vlan_mtu_check */ +#define mscc_ms_vlan_mtu_check_mtu_compare(x) (x) +#define mscc_ms_vlan_mtu_check_mtu_compare_m genmask(14, 0) +#define mscc_ms_vlan_mtu_check_mtu_comp_drop bit(15) + +/* macsec_non_vlan_mtu_check */ +#define mscc_ms_non_vlan_mtu_check_nv_mtu_compare(x) (x) +#define mscc_ms_non_vlan_mtu_check_nv_mtu_compare_m genmask(14, 0) +#define mscc_ms_non_vlan_mtu_check_nv_mtu_comp_drop bit(15) + +/* macsec_pp_ctrl */ +#define mscc_ms_pp_ctrl_macsec_octet_incr_mode bit(0) + +/* macsec_intr_ctrl_status */ +#define mscc_ms_intr_ctrl_status_intr_clr_status(x) (x) +#define mscc_ms_intr_ctrl_status_intr_clr_status_m genmask(15, 0) +#define mscc_ms_intr_ctrl_status_intr_enable(x) ((x) << 16) +#define mscc_ms_intr_ctrl_status_intr_enable_m genmask(31, 16) + +#endif
|
Networking
|
1bbe0ecc2a1a008bcfeb7fd2d8f95c8e9a1867c6
|
antoine tenart
|
drivers
|
net
|
phy
|
net: phy: mscc: macsec support
|
this patch adds macsec offloading support to some microsemi phys, to configure flows and transformations so that matched packets can be processed by the macsec engine, either at egress, or at ingress.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c', 'kconfig', 'h']
| 3
| 698
| 0
|
--- diff --git a/drivers/net/phy/kconfig b/drivers/net/phy/kconfig --- a/drivers/net/phy/kconfig +++ b/drivers/net/phy/kconfig + depends on macsec || macsec=n + select crypto_aes + select crypto_ecb ---help--- diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c +#include <linux/scatterlist.h> +#include <crypto/skcipher.h> + +#if is_enabled(config_macsec) +#include <net/macsec.h> +#endif + +#if is_enabled(config_macsec) +struct macsec_flow { + struct list_head list; + enum mscc_macsec_destination_ports port; + enum macsec_bank bank; + u32 index; + int assoc_num; + bool has_transformation; + + /* highest takes precedence [0..15] */ + u8 priority; + + u8 key[macsec_keyid_len]; + + union { + struct macsec_rx_sa *rx_sa; + struct macsec_tx_sa *tx_sa; + }; + + /* matching */ + struct { + u8 sci:1; + u8 tagged:1; + u8 untagged:1; + u8 etype:1; + } match; + + u16 etype; + + /* action */ + struct { + u8 bypass:1; + u8 drop:1; + } action; + +}; +#endif + + +#if is_enabled(config_macsec) + /* macsec fields: + * - one secy per device (enforced at the s/w implementation level) + * - macsec_flows: list of h/w flows + * - ingr_flows: bitmap of ingress flows + * - egr_flows: bitmap of egress flows + */ + struct macsec_secy *secy; + struct list_head macsec_flows; + unsigned long ingr_flows; + unsigned long egr_flows; +#endif + +static void vsc8584_macsec_flow(struct phy_device *phydev, + struct macsec_flow *flow) +{ + struct vsc8531_private *priv = phydev->priv; + enum macsec_bank bank = flow->bank; + u32 val, match = 0, mask = 0, action = 0, idx = flow->index; + + if (flow->match.tagged) + match |= mscc_ms_sam_misc_match_tagged; + if (flow->match.untagged) + match |= mscc_ms_sam_misc_match_untagged; + + if (bank == macsec_ingr && flow->assoc_num >= 0) { + match |= mscc_ms_sam_misc_match_an(flow->assoc_num); + mask |= mscc_ms_sam_mask_an_mask(0x3); + } + + if (bank == macsec_ingr && flow->match.sci && flow->rx_sa->sc->sci) { + match |= mscc_ms_sam_misc_match_tci(bit(3)); + mask |= mscc_ms_sam_mask_tci_mask(bit(3)) | + mscc_ms_sam_mask_sci_mask; + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_match_sci_lo(idx), + lower_32_bits(flow->rx_sa->sc->sci)); + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_match_sci_hi(idx), + upper_32_bits(flow->rx_sa->sc->sci)); + } + + if (flow->match.etype) { + mask |= mscc_ms_sam_mask_mac_etype_mask; + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_mac_sa_match_hi(idx), + mscc_ms_sam_mac_sa_match_hi_etype(htons(flow->etype))); + } + + match |= mscc_ms_sam_misc_match_priority(flow->priority); + + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_misc_match(idx), match); + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_mask(idx), mask); + + /* action for matching packets */ + if (flow->action.drop) + action = mscc_ms_flow_drop; + else if (flow->action.bypass || flow->port == mscc_ms_port_uncontrolled) + action = mscc_ms_flow_bypass; + else + action = (bank == macsec_ingr) ? + mscc_ms_flow_ingress : mscc_ms_flow_egress; + + val = mscc_ms_sam_flow_ctrl_flow_type(action) | + mscc_ms_sam_flow_ctrl_drop_action(mscc_ms_action_drop) | + mscc_ms_sam_flow_ctrl_dest_port(flow->port); + + if (action == mscc_ms_flow_bypass) + goto write_ctrl; + + if (bank == macsec_ingr) { + if (priv->secy->replay_protect) + val |= mscc_ms_sam_flow_ctrl_replay_protect; + if (priv->secy->validate_frames == macsec_validate_strict) + val |= mscc_ms_sam_flow_ctrl_validate_frames(mscc_ms_validate_strict); + else if (priv->secy->validate_frames == macsec_validate_check) + val |= mscc_ms_sam_flow_ctrl_validate_frames(mscc_ms_validate_check); + } else if (bank == macsec_egr) { + if (priv->secy->protect_frames) + val |= mscc_ms_sam_flow_ctrl_protect_frame; + if (priv->secy->tx_sc.encrypt) + val |= mscc_ms_sam_flow_ctrl_conf_protect; + if (priv->secy->tx_sc.send_sci) + val |= mscc_ms_sam_flow_ctrl_include_sci; + } + +write_ctrl: + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_flow_ctrl(idx), val); +} + +static struct macsec_flow *vsc8584_macsec_find_flow(struct macsec_context *ctx, + enum macsec_bank bank) +{ + struct vsc8531_private *priv = ctx->phydev->priv; + struct macsec_flow *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, &priv->macsec_flows, list) + if (pos->assoc_num == ctx->sa.assoc_num && pos->bank == bank) + return pos; + + return err_ptr(-enoent); +} + +static void vsc8584_macsec_flow_enable(struct phy_device *phydev, + struct macsec_flow *flow) +{ + enum macsec_bank bank = flow->bank; + u32 val, idx = flow->index; + + if ((flow->bank == macsec_ingr && flow->rx_sa && !flow->rx_sa->active) || + (flow->bank == macsec_egr && flow->tx_sa && !flow->tx_sa->active)) + return; + + /* enable */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_entry_set1, bit(idx)); + + /* set in-use */ + val = vsc8584_macsec_phy_read(phydev, bank, mscc_ms_sam_flow_ctrl(idx)); + val |= mscc_ms_sam_flow_ctrl_sa_in_use; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_flow_ctrl(idx), val); +} + +static void vsc8584_macsec_flow_disable(struct phy_device *phydev, + struct macsec_flow *flow) +{ + enum macsec_bank bank = flow->bank; + u32 val, idx = flow->index; + + /* disable */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_entry_clear1, bit(idx)); + + /* clear in-use */ + val = vsc8584_macsec_phy_read(phydev, bank, mscc_ms_sam_flow_ctrl(idx)); + val &= ~mscc_ms_sam_flow_ctrl_sa_in_use; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_sam_flow_ctrl(idx), val); +} + +static u32 vsc8584_macsec_flow_context_id(struct macsec_flow *flow) +{ + if (flow->bank == macsec_ingr) + return flow->index + mscc_ms_max_flows; + + return flow->index; +} + +/* derive the aes key to get a key for the hash autentication */ +static int vsc8584_macsec_derive_key(const u8 key[macsec_keyid_len], + u16 key_len, u8 hkey[16]) +{ + struct crypto_skcipher *tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0); + struct skcipher_request *req = null; + struct scatterlist src, dst; + declare_crypto_wait(wait); + u32 input[4] = {0}; + int ret; + + if (is_err(tfm)) + return ptr_err(tfm); + + req = skcipher_request_alloc(tfm, gfp_kernel); + if (!req) { + ret = -enomem; + goto out; + } + + skcipher_request_set_callback(req, crypto_tfm_req_may_backlog | + crypto_tfm_req_may_sleep, crypto_req_done, + &wait); + ret = crypto_skcipher_setkey(tfm, key, key_len); + if (ret < 0) + goto out; + + sg_init_one(&src, input, 16); + sg_init_one(&dst, hkey, 16); + skcipher_request_set_crypt(req, &src, &dst, 16, null); + + ret = crypto_wait_req(crypto_skcipher_encrypt(req), &wait); + +out: + skcipher_request_free(req); + crypto_free_skcipher(tfm); + return ret; +} + +static int vsc8584_macsec_transformation(struct phy_device *phydev, + struct macsec_flow *flow) +{ + struct vsc8531_private *priv = phydev->priv; + enum macsec_bank bank = flow->bank; + int i, ret, index = flow->index; + u32 rec = 0, control = 0; + u8 hkey[16]; + sci_t sci; + + ret = vsc8584_macsec_derive_key(flow->key, priv->secy->key_len, hkey); + if (ret) + return ret; + + switch (priv->secy->key_len) { + case 16: + control |= control_crypto_alg(ctrypto_alg_aes_ctr_128); + break; + case 32: + control |= control_crypto_alg(ctrypto_alg_aes_ctr_256); + break; + default: + return -einval; + } + + control |= (bank == macsec_egr) ? + (control_type_egress | control_an(priv->secy->tx_sc.encoding_sa)) : + (control_type_ingress | control_seq_mask); + + control |= control_update_seq | control_encrypt_auth | control_key_in_ctx | + control_iv0 | control_iv1 | control_iv_in_seq | + control_digest_type(0x2) | control_seq_type(0x1) | + control_auth_alg(auth_alg_aes_ghas) | control_context_id; + + /* set the control word */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_xform_rec(index, rec++), + control); + + /* set the context id. must be unique. */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_xform_rec(index, rec++), + vsc8584_macsec_flow_context_id(flow)); + + /* set the encryption/decryption key */ + for (i = 0; i < priv->secy->key_len / sizeof(u32); i++) + vsc8584_macsec_phy_write(phydev, bank, + mscc_ms_xform_rec(index, rec++), + ((u32 *)flow->key)[i]); + + /* set the authentication key */ + for (i = 0; i < 4; i++) + vsc8584_macsec_phy_write(phydev, bank, + mscc_ms_xform_rec(index, rec++), + ((u32 *)hkey)[i]); + + /* initial sequence number */ + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_xform_rec(index, rec++), + bank == macsec_ingr ? + flow->rx_sa->next_pn : flow->tx_sa->next_pn); + + if (bank == macsec_ingr) + /* set the mask (replay window size) */ + vsc8584_macsec_phy_write(phydev, bank, + mscc_ms_xform_rec(index, rec++), + priv->secy->replay_window); + + /* set the input vectors */ + sci = bank == macsec_ingr ? flow->rx_sa->sc->sci : priv->secy->sci; + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_xform_rec(index, rec++), + lower_32_bits(sci)); + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_xform_rec(index, rec++), + upper_32_bits(sci)); + + while (rec < 20) + vsc8584_macsec_phy_write(phydev, bank, mscc_ms_xform_rec(index, rec++), + 0); + + flow->has_transformation = true; + return 0; +} + +static struct macsec_flow *vsc8584_macsec_alloc_flow(struct vsc8531_private *priv, + enum macsec_bank bank) +{ + unsigned long *bitmap = bank == macsec_ingr ? + &priv->ingr_flows : &priv->egr_flows; + struct macsec_flow *flow; + int index; + + index = find_first_zero_bit(bitmap, mscc_ms_max_flows); + + if (index == mscc_ms_max_flows) + return err_ptr(-enomem); + + flow = kzalloc(sizeof(*flow), gfp_kernel); + if (!flow) + return err_ptr(-enomem); + + set_bit(index, bitmap); + flow->index = index; + flow->bank = bank; + flow->priority = 8; + flow->assoc_num = -1; + + list_add_tail(&flow->list, &priv->macsec_flows); + return flow; +} + +static void vsc8584_macsec_free_flow(struct vsc8531_private *priv, + struct macsec_flow *flow) +{ + unsigned long *bitmap = flow->bank == macsec_ingr ? + &priv->ingr_flows : &priv->egr_flows; + + list_del(&flow->list); + clear_bit(flow->index, bitmap); + kfree(flow); +} + +static int vsc8584_macsec_add_flow(struct phy_device *phydev, + struct macsec_flow *flow, bool update) +{ + int ret; + + flow->port = mscc_ms_port_controlled; + vsc8584_macsec_flow(phydev, flow); + + if (update) + return 0; + + ret = vsc8584_macsec_transformation(phydev, flow); + if (ret) { + vsc8584_macsec_free_flow(phydev->priv, flow); + return ret; + } + + return 0; +} + +static int vsc8584_macsec_default_flows(struct phy_device *phydev) +{ + struct macsec_flow *flow; + + /* add a rule to let the mka traffic go through, ingress */ + flow = vsc8584_macsec_alloc_flow(phydev->priv, macsec_ingr); + if (is_err(flow)) + return ptr_err(flow); + + flow->priority = 15; + flow->port = mscc_ms_port_uncontrolled; + flow->match.tagged = 1; + flow->match.untagged = 1; + flow->match.etype = 1; + flow->etype = eth_p_pae; + flow->action.bypass = 1; + + vsc8584_macsec_flow(phydev, flow); + vsc8584_macsec_flow_enable(phydev, flow); + + /* add a rule to let the mka traffic go through, egress */ + flow = vsc8584_macsec_alloc_flow(phydev->priv, macsec_egr); + if (is_err(flow)) + return ptr_err(flow); + + flow->priority = 15; + flow->port = mscc_ms_port_common; + flow->match.untagged = 1; + flow->match.etype = 1; + flow->etype = eth_p_pae; + flow->action.bypass = 1; + + vsc8584_macsec_flow(phydev, flow); + vsc8584_macsec_flow_enable(phydev, flow); + + return 0; +} + +static void vsc8584_macsec_del_flow(struct phy_device *phydev, + struct macsec_flow *flow) +{ + vsc8584_macsec_flow_disable(phydev, flow); + vsc8584_macsec_free_flow(phydev->priv, flow); +} + +static int __vsc8584_macsec_add_rxsa(struct macsec_context *ctx, + struct macsec_flow *flow, bool update) +{ + struct phy_device *phydev = ctx->phydev; + struct vsc8531_private *priv = phydev->priv; + + if (!flow) { + flow = vsc8584_macsec_alloc_flow(priv, macsec_ingr); + if (is_err(flow)) + return ptr_err(flow); + + memcpy(flow->key, ctx->sa.key, priv->secy->key_len); + } + + flow->assoc_num = ctx->sa.assoc_num; + flow->rx_sa = ctx->sa.rx_sa; + + /* always match tagged packets on ingress */ + flow->match.tagged = 1; + flow->match.sci = 1; + + if (priv->secy->validate_frames != macsec_validate_disabled) + flow->match.untagged = 1; + + return vsc8584_macsec_add_flow(phydev, flow, update); +} + +static int __vsc8584_macsec_add_txsa(struct macsec_context *ctx, + struct macsec_flow *flow, bool update) +{ + struct phy_device *phydev = ctx->phydev; + struct vsc8531_private *priv = phydev->priv; + + if (!flow) { + flow = vsc8584_macsec_alloc_flow(priv, macsec_egr); + if (is_err(flow)) + return ptr_err(flow); + + memcpy(flow->key, ctx->sa.key, priv->secy->key_len); + } + + flow->assoc_num = ctx->sa.assoc_num; + flow->tx_sa = ctx->sa.tx_sa; + + /* always match untagged packets on egress */ + flow->match.untagged = 1; + + return vsc8584_macsec_add_flow(phydev, flow, update); +} + +static int vsc8584_macsec_dev_open(struct macsec_context *ctx) +{ + struct vsc8531_private *priv = ctx->phydev->priv; + struct macsec_flow *flow, *tmp; + + /* no operation to perform before the commit step */ + if (ctx->prepare) + return 0; + + list_for_each_entry_safe(flow, tmp, &priv->macsec_flows, list) + vsc8584_macsec_flow_enable(ctx->phydev, flow); + + return 0; +} + +static int vsc8584_macsec_dev_stop(struct macsec_context *ctx) +{ + struct vsc8531_private *priv = ctx->phydev->priv; + struct macsec_flow *flow, *tmp; + + /* no operation to perform before the commit step */ + if (ctx->prepare) + return 0; + + list_for_each_entry_safe(flow, tmp, &priv->macsec_flows, list) + vsc8584_macsec_flow_disable(ctx->phydev, flow); + + return 0; +} + +static int vsc8584_macsec_add_secy(struct macsec_context *ctx) +{ + struct vsc8531_private *priv = ctx->phydev->priv; + struct macsec_secy *secy = ctx->secy; + + if (ctx->prepare) { + if (priv->secy) + return -eexist; + + return 0; + } + + priv->secy = secy; + + vsc8584_macsec_flow_default_action(ctx->phydev, macsec_egr, + secy->validate_frames != macsec_validate_disabled); + vsc8584_macsec_flow_default_action(ctx->phydev, macsec_ingr, + secy->validate_frames != macsec_validate_disabled); + + return vsc8584_macsec_default_flows(ctx->phydev); +} + +static int vsc8584_macsec_del_secy(struct macsec_context *ctx) +{ + struct vsc8531_private *priv = ctx->phydev->priv; + struct macsec_flow *flow, *tmp; + + /* no operation to perform before the commit step */ + if (ctx->prepare) + return 0; + + list_for_each_entry_safe(flow, tmp, &priv->macsec_flows, list) + vsc8584_macsec_del_flow(ctx->phydev, flow); + + vsc8584_macsec_flow_default_action(ctx->phydev, macsec_egr, false); + vsc8584_macsec_flow_default_action(ctx->phydev, macsec_ingr, false); + + priv->secy = null; + return 0; +} + +static int vsc8584_macsec_upd_secy(struct macsec_context *ctx) +{ + /* no operation to perform before the commit step */ + if (ctx->prepare) + return 0; + + vsc8584_macsec_del_secy(ctx); + return vsc8584_macsec_add_secy(ctx); +} + +static int vsc8584_macsec_add_rxsc(struct macsec_context *ctx) +{ + /* nothing to do */ + return 0; +} + +static int vsc8584_macsec_upd_rxsc(struct macsec_context *ctx) +{ + return -eopnotsupp; +} + +static int vsc8584_macsec_del_rxsc(struct macsec_context *ctx) +{ + struct vsc8531_private *priv = ctx->phydev->priv; + struct macsec_flow *flow, *tmp; + + /* no operation to perform before the commit step */ + if (ctx->prepare) + return 0; + + list_for_each_entry_safe(flow, tmp, &priv->macsec_flows, list) { + if (flow->bank == macsec_ingr && flow->rx_sa && + flow->rx_sa->sc->sci == ctx->rx_sc->sci) + vsc8584_macsec_del_flow(ctx->phydev, flow); + } + + return 0; +} + +static int vsc8584_macsec_add_rxsa(struct macsec_context *ctx) +{ + struct macsec_flow *flow = null; + + if (ctx->prepare) + return __vsc8584_macsec_add_rxsa(ctx, flow, false); + + flow = vsc8584_macsec_find_flow(ctx, macsec_ingr); + if (is_err(flow)) + return ptr_err(flow); + + vsc8584_macsec_flow_enable(ctx->phydev, flow); + return 0; +} + +static int vsc8584_macsec_upd_rxsa(struct macsec_context *ctx) +{ + struct macsec_flow *flow; + + flow = vsc8584_macsec_find_flow(ctx, macsec_ingr); + if (is_err(flow)) + return ptr_err(flow); + + if (ctx->prepare) { + /* make sure the flow is disabled before updating it */ + vsc8584_macsec_flow_disable(ctx->phydev, flow); + + return __vsc8584_macsec_add_rxsa(ctx, flow, true); + } + + vsc8584_macsec_flow_enable(ctx->phydev, flow); + return 0; +} + +static int vsc8584_macsec_del_rxsa(struct macsec_context *ctx) +{ + struct macsec_flow *flow; + + flow = vsc8584_macsec_find_flow(ctx, macsec_ingr); + + if (is_err(flow)) + return ptr_err(flow); + if (ctx->prepare) + return 0; + + vsc8584_macsec_del_flow(ctx->phydev, flow); + return 0; +} + +static int vsc8584_macsec_add_txsa(struct macsec_context *ctx) +{ + struct macsec_flow *flow = null; + + if (ctx->prepare) + return __vsc8584_macsec_add_txsa(ctx, flow, false); + + flow = vsc8584_macsec_find_flow(ctx, macsec_egr); + if (is_err(flow)) + return ptr_err(flow); + + vsc8584_macsec_flow_enable(ctx->phydev, flow); + return 0; +} + +static int vsc8584_macsec_upd_txsa(struct macsec_context *ctx) +{ + struct macsec_flow *flow; + + flow = vsc8584_macsec_find_flow(ctx, macsec_egr); + if (is_err(flow)) + return ptr_err(flow); + + if (ctx->prepare) { + /* make sure the flow is disabled before updating it */ + vsc8584_macsec_flow_disable(ctx->phydev, flow); + + return __vsc8584_macsec_add_txsa(ctx, flow, true); + } + + vsc8584_macsec_flow_enable(ctx->phydev, flow); + return 0; +} + +static int vsc8584_macsec_del_txsa(struct macsec_context *ctx) +{ + struct macsec_flow *flow; + + flow = vsc8584_macsec_find_flow(ctx, macsec_egr); + + if (is_err(flow)) + return ptr_err(flow); + if (ctx->prepare) + return 0; + + vsc8584_macsec_del_flow(ctx->phydev, flow); + return 0; +} + +static struct macsec_ops vsc8584_macsec_ops = { + .mdo_dev_open = vsc8584_macsec_dev_open, + .mdo_dev_stop = vsc8584_macsec_dev_stop, + .mdo_add_secy = vsc8584_macsec_add_secy, + .mdo_upd_secy = vsc8584_macsec_upd_secy, + .mdo_del_secy = vsc8584_macsec_del_secy, + .mdo_add_rxsc = vsc8584_macsec_add_rxsc, + .mdo_upd_rxsc = vsc8584_macsec_upd_rxsc, + .mdo_del_rxsc = vsc8584_macsec_del_rxsc, + .mdo_add_rxsa = vsc8584_macsec_add_rxsa, + .mdo_upd_rxsa = vsc8584_macsec_upd_rxsa, + .mdo_del_rxsa = vsc8584_macsec_del_rxsa, + .mdo_add_txsa = vsc8584_macsec_add_txsa, + .mdo_upd_txsa = vsc8584_macsec_upd_txsa, + .mdo_del_txsa = vsc8584_macsec_del_txsa, +}; + init_list_head(&vsc8531->macsec_flows); + vsc8531->secy = null; + + phydev->macsec_ops = &vsc8584_macsec_ops; + diff --git a/drivers/net/phy/mscc_macsec.h b/drivers/net/phy/mscc_macsec.h --- a/drivers/net/phy/mscc_macsec.h +++ b/drivers/net/phy/mscc_macsec.h +#define mscc_ms_max_flows 16 + +#define mscc_ms_sam_mac_sa_match_lo(x) (0x1000 + ((x) << 4)) +#define mscc_ms_sam_mac_sa_match_hi(x) (0x1001 + ((x) << 4))
|
Networking
|
28c5107aa904ef9db6b023039d20b6b4c4181675
|
antoine tenart
|
drivers
|
net
|
phy
|
net: macsec: pn wrap callback
|
allow to call macsec_pn_wrapped from hardware drivers to notify when a pn rolls over. some drivers might used an interrupt to implement this.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c', 'h']
| 2
| 21
| 6
|
--- diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c +static void __macsec_pn_wrapped(struct macsec_secy *secy, + struct macsec_tx_sa *tx_sa) +{ + pr_debug("pn wrapped, transitioning to !oper "); + tx_sa->active = false; + if (secy->protect_frames) + secy->operational = false; +} + +void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa) +{ + spin_lock_bh(&tx_sa->lock); + __macsec_pn_wrapped(secy, tx_sa); + spin_unlock_bh(&tx_sa->lock); +} +export_symbol_gpl(macsec_pn_wrapped); + - if (tx_sa->next_pn == 0) { - pr_debug("pn wrapped, transitioning to !oper "); - tx_sa->active = false; - if (secy->protect_frames) - secy->operational = false; - } + if (tx_sa->next_pn == 0) + __macsec_pn_wrapped(secy, tx_sa); diff --git a/include/net/macsec.h b/include/net/macsec.h --- a/include/net/macsec.h +++ b/include/net/macsec.h +void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa); +
|
Networking
|
5c937de78b39e47ce9924fc4b863c5b727edc328
|
antoine tenart
|
drivers
|
net
| |
net: phy: mscc: pn rollover support
|
this patch adds support for handling macsec pn rollover in the mscc phy driver. when a flow rolls over, an interrupt is fired. this patch adds the logic to check all flows and identify the one rolling over in the handle_interrupt phy helper, then disables the flow and report the event to the macsec core.
|
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.
|
initial support for hardware offloading
|
['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']
|
['macsec']
|
['c', 'h']
| 2
| 61
| 1
|
--- diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c -#define mii_vsc85xx_int_mask_mask 0xa000 +#define mii_vsc85xx_int_mask_mask 0xa020 +#define mscc_phy_extended_int 28 +#define mscc_phy_extended_int_ms_egr bit(9) + +static int vsc8584_handle_interrupt(struct phy_device *phydev) +{ +#if is_enabled(config_macsec) + struct vsc8531_private *priv = phydev->priv; + struct macsec_flow *flow, *tmp; + u32 cause, rec; + + /* check macsec pn rollover */ + cause = vsc8584_macsec_phy_read(phydev, macsec_egr, + mscc_ms_intr_ctrl_status); + cause &= mscc_ms_intr_ctrl_status_intr_clr_status_m; + if (!(cause & macsec_intr_ctrl_status_rollover)) + goto skip_rollover; + + rec = 6 + priv->secy->key_len / sizeof(u32); + list_for_each_entry_safe(flow, tmp, &priv->macsec_flows, list) { + u32 val; + + if (flow->bank != macsec_egr || !flow->has_transformation) + continue; + + val = vsc8584_macsec_phy_read(phydev, macsec_egr, + mscc_ms_xform_rec(flow->index, rec)); + if (val == 0xffffffff) { + vsc8584_macsec_flow_disable(phydev, flow); + macsec_pn_wrapped(priv->secy, flow->tx_sa); + break; + } + } + +skip_rollover: +#endif + + phy_mac_interrupt(phydev); + return 0; +} + +#if is_enabled(config_macsec) + phy_write(phydev, mscc_ext_page_access, + mscc_phy_page_extended_2); + phy_write(phydev, mscc_phy_extended_int, + mscc_phy_extended_int_ms_egr); + phy_write(phydev, mscc_ext_page_access, + mscc_phy_page_standard); + + vsc8584_macsec_phy_write(phydev, macsec_egr, + mscc_ms_aic_ctrl, 0xf); + vsc8584_macsec_phy_write(phydev, macsec_egr, + mscc_ms_intr_ctrl_status, + mscc_ms_intr_ctrl_status_intr_enable(macsec_intr_ctrl_status_rollover)); +#endif + .handle_interrupt = &vsc8584_handle_interrupt, + .handle_interrupt = &vsc8584_handle_interrupt, + .handle_interrupt = &vsc8584_handle_interrupt, + .handle_interrupt = &vsc8584_handle_interrupt, diff --git a/drivers/net/phy/mscc_macsec.h b/drivers/net/phy/mscc_macsec.h --- a/drivers/net/phy/mscc_macsec.h +++ b/drivers/net/phy/mscc_macsec.h +#define mscc_ms_aic_ctrl 0x3e02 +#define macsec_intr_ctrl_status_rollover bit(5)
|
Networking
|
781449a4ae3b381950ee9aec4d8a54e35f66ab9b
|
antoine tenart
|
drivers
|
net
|
phy
|
net: sfp: remove incomplete 100base-fx and 100base-lx support
|
the 100base-fx and 100base-lx support assumes a phy is present; this is probably an incorrect assumption. in any case, sfp_parse_support() will fail such a module. let's stop pretending we support these modules.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 2
| 2
| 15
|
--- diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c - if (id->base.e1000_base_t || - id->base.e100_base_lx || - id->base.e100_base_fx) + if (id->base.e1000_base_t) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c - /* setting the serdes link mode is guesswork: there's no - * field in the eeprom which indicates what mode should - * be used. - * - * if it's a gigabit-only fiber module, it probably does - * not have a phy, so switch to 802.3z negotiation mode. - * otherwise, switch to sgmii mode (which is required to - * support non-gigabit speeds) and probe for a phy. - */ - if (sfp->id.base.e1000_base_t || - sfp->id.base.e100_base_lx || - sfp->id.base.e100_base_fx) + if (sfp->id.base.e1000_base_t)
|
Networking
|
fa2de660a8d001fdce6209534b60b85b87cda84f
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: sfp: derive interface mode from ethtool link modes
|
we don't need the eeprom id to derive the phy interface mode as we can derive it merely from the ethtool link modes. remove the eeprom id argument to sfp_select_interface().
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c', 'h']
| 4
| 6
| 11
|
--- diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c - iface = sfp_select_interface(phydev->sfp_bus, id, support); + iface = sfp_select_interface(phydev->sfp_bus, support); 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 - iface = sfp_select_interface(pl->sfp_bus, id, config.advertising); + iface = sfp_select_interface(pl->sfp_bus, config.advertising); diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c - * @id: a pointer to the module's &struct sfp_eeprom_id - * derive the phy_interface_t mode for the information found in the - * module's identifying eeprom and the link modes mask. there is no - * standard or defined way to derive this information, so we decide - * based upon the link mode mask. + * derive the phy_interface_t mode for the sfp module from the link + * modes mask. - const struct sfp_eeprom_id *id, - if (id->base.e1000_base_t) + if (phylink_test(link_modes, 1000baset_half) || + phylink_test(link_modes, 1000baset_full)) diff --git a/include/linux/sfp.h b/include/linux/sfp.h --- a/include/linux/sfp.h +++ b/include/linux/sfp.h - const struct sfp_eeprom_id *id, - const struct sfp_eeprom_id *id,
|
Networking
|
a4516c7053b96fed98a0439a9226983b5275474b
|
russell king andrew lunn andrew lunn ch
|
include
|
linux
|
phy
|
net: sfp: add more extended compliance codes
|
sff-8024 is used to define various constants re-used in several sff sfp-related specifications. split these constants from the enum, and rename them to indicate that they're defined by sff-8024.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c', 'h']
| 3
| 93
| 53
|
--- diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c - case sfp_connector_sc: - case sfp_connector_fiberjack: - case sfp_connector_lc: - case sfp_connector_mt_rj: - case sfp_connector_mu: - case sfp_connector_optical_pigtail: + case sff8024_connector_sc: + case sff8024_connector_fiberjack: + case sff8024_connector_lc: + case sff8024_connector_mt_rj: + case sff8024_connector_mu: + case sff8024_connector_optical_pigtail: + case sff8024_connector_mpo_1x12: + case sff8024_connector_mpo_2x16: - case sfp_connector_rj45: + case sff8024_connector_rj45: - case sfp_connector_copper_pigtail: + case sff8024_connector_copper_pigtail: - case sfp_connector_unspec: + case sff8024_connector_unspec: - case sfp_connector_sg: /* guess */ - case sfp_connector_mpo_1x12: - case sfp_connector_mpo_2x16: - case sfp_connector_hssdc_ii: - case sfp_connector_noseparate: - case sfp_connector_mxc_2x16: + case sff8024_connector_sg: /* guess */ + case sff8024_connector_hssdc_ii: + case sff8024_connector_noseparate: + case sff8024_connector_mxc_2x16: - case 0x00: /* unspecified */ + case sff8024_ecc_unspec: - case 0x02: /* 100gbase-sr4 or 25gbase-sr */ + case sff8024_ecc_100gbase_sr4_25gbase_sr: - case 0x03: /* 100gbase-lr4 or 25gbase-lr */ - case 0x04: /* 100gbase-er4 or 25gbase-er */ + case sff8024_ecc_100gbase_lr4_25gbase_lr: + case sff8024_ecc_100gbase_er4_25gbase_er: - case 0x0b: /* 100gbase-cr4 or 25gbase-cr ca-l */ - case 0x0c: /* 25gbase-cr ca-s */ - case 0x0d: /* 25gbase-cr ca-n */ + case sff8024_ecc_100gbase_cr4: + /* fallthrough */ + case sff8024_ecc_25gbase_cr_s: + case sff8024_ecc_25gbase_cr_n: + case sff8024_ecc_10gbase_t_sfi: + case sff8024_ecc_10gbase_t_sr: + phylink_set(modes, 10000baset_full); + break; + case sff8024_ecc_5gbase_t: + phylink_set(modes, 5000baset_full); + break; + case sff8024_ecc_2_5gbase_t: + phylink_set(modes, 2500baset_full); + break; - if (id->base.encoding == sfp_encoding_8b10b && br_nom && + if (id->base.encoding == sff8024_encoding_8b10b && br_nom && - phylink_test(link_modes, 10000baseer_full)) + phylink_test(link_modes, 10000baseer_full) || + phylink_test(link_modes, 10000baset_full)) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c - return id->base.phys_id == sfp_phys_id_sff && + return id->base.phys_id == sff8024_id_sff_8472 && - return id->base.phys_id == sfp_phys_id_sfp && + return id->base.phys_id == sff8024_id_sfp && diff --git a/include/linux/sfp.h b/include/linux/sfp.h --- a/include/linux/sfp.h +++ b/include/linux/sfp.h +/* sff8024 defined constants */ +enum { + sff8024_id_unk = 0x00, + sff8024_id_sff_8472 = 0x02, + sff8024_id_sfp = 0x03, + sff8024_id_dwdm_sfp = 0x0b, + sff8024_id_qsfp_8438 = 0x0c, + sff8024_id_qsfp_8436_8636 = 0x0d, + sff8024_id_qsfp28_8636 = 0x11, + + sff8024_encoding_unspec = 0x00, + sff8024_encoding_8b10b = 0x01, + sff8024_encoding_4b5b = 0x02, + sff8024_encoding_nrz = 0x03, + sff8024_encoding_8472_manchester= 0x04, + sff8024_encoding_8472_sonet = 0x05, + sff8024_encoding_8472_64b66b = 0x06, + sff8024_encoding_8436_manchester= 0x06, + sff8024_encoding_8436_sonet = 0x04, + sff8024_encoding_8436_64b66b = 0x05, + sff8024_encoding_256b257b = 0x07, + sff8024_encoding_pam4 = 0x08, + + sff8024_connector_unspec = 0x00, + /* codes 01-05 not supportable on sfp, but some modules have single sc */ + sff8024_connector_sc = 0x01, + sff8024_connector_fiberjack = 0x06, + sff8024_connector_lc = 0x07, + sff8024_connector_mt_rj = 0x08, + sff8024_connector_mu = 0x09, + sff8024_connector_sg = 0x0a, + sff8024_connector_optical_pigtail= 0x0b, + sff8024_connector_mpo_1x12 = 0x0c, + sff8024_connector_mpo_2x16 = 0x0d, + sff8024_connector_hssdc_ii = 0x20, + sff8024_connector_copper_pigtail= 0x21, + sff8024_connector_rj45 = 0x22, + sff8024_connector_noseparate = 0x23, + sff8024_connector_mxc_2x16 = 0x24, + + sff8024_ecc_unspec = 0x00, + sff8024_ecc_100g_25gaui_c2m_aoc = 0x01, + sff8024_ecc_100gbase_sr4_25gbase_sr = 0x02, + sff8024_ecc_100gbase_lr4_25gbase_lr = 0x03, + sff8024_ecc_100gbase_er4_25gbase_er = 0x04, + sff8024_ecc_100gbase_sr10 = 0x05, + sff8024_ecc_100gbase_cr4 = 0x0b, + sff8024_ecc_25gbase_cr_s = 0x0c, + sff8024_ecc_25gbase_cr_n = 0x0d, + sff8024_ecc_10gbase_t_sfi = 0x16, + sff8024_ecc_10gbase_t_sr = 0x1c, + sff8024_ecc_5gbase_t = 0x1d, + sff8024_ecc_2_5gbase_t = 0x1e, +}; + - sfp_phys_id_sff = 0x02, - sfp_phys_id_sfp = 0x03, - sfp_connector_unspec = 0x00, - /* codes 01-05 not supportable on sfp, but some modules have single sc */ - sfp_connector_sc = 0x01, - sfp_connector_fiberjack = 0x06, - sfp_connector_lc = 0x07, - sfp_connector_mt_rj = 0x08, - sfp_connector_mu = 0x09, - sfp_connector_sg = 0x0a, - sfp_connector_optical_pigtail = 0x0b, - sfp_connector_mpo_1x12 = 0x0c, - sfp_connector_mpo_2x16 = 0x0d, - sfp_connector_hssdc_ii = 0x20, - sfp_connector_copper_pigtail = 0x21, - sfp_connector_rj45 = 0x22, - sfp_connector_noseparate = 0x23, - sfp_connector_mxc_2x16 = 0x24, - sfp_encoding_unspec = 0x00, - sfp_encoding_8b10b = 0x01, - sfp_encoding_4b5b = 0x02, - sfp_encoding_nrz = 0x03, - sfp_encoding_8472_manchester = 0x04, - sfp_encoding_8472_sonet = 0x05, - sfp_encoding_8472_64b66b = 0x06, - sfp_encoding_256b257b = 0x07, - sfp_encoding_pam4 = 0x08,
|
Networking
|
0fbd26a9fb6875b98fcfff523831fec47bc5e9a2
|
russell king
|
include
|
linux
|
phy
|
net: sfp: add module start/stop upstream notifications
|
when dealing with some copper modules, we can't positively know the module capabilities are until we have probed the phy. without the full capabilities, we may end up failing a module that we could otherwise drive with a restricted set of capabilities.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c', 'h']
| 4
| 35
| 0
|
--- diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c +int sfp_module_start(struct sfp_bus *bus) +{ + const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); + int ret = 0; + + if (ops && ops->module_start) + ret = ops->module_start(bus->upstream); + + return ret; +} +export_symbol_gpl(sfp_module_start); + +void sfp_module_stop(struct sfp_bus *bus) +{ + const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); + + if (ops && ops->module_stop) + ops->module_stop(bus->upstream); +} +export_symbol_gpl(sfp_module_stop); + diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c + sfp_s_fail, + [sfp_s_fail] = "fail", + if (sfp->sm_state > sfp_s_init) + sfp_module_stop(sfp->sfp_bus); + if (sfp_module_start(sfp->sfp_bus)) { + sfp_sm_next(sfp, sfp_s_fail, 0); + break; + } diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h --- a/drivers/net/phy/sfp.h +++ b/drivers/net/phy/sfp.h +int sfp_module_start(struct sfp_bus *bus); +void sfp_module_stop(struct sfp_bus *bus); diff --git a/include/linux/sfp.h b/include/linux/sfp.h --- a/include/linux/sfp.h +++ b/include/linux/sfp.h + * @module_start: called after the phy probe step + * @module_stop: called before the phy is removed + int (*module_start)(void *priv); + void (*module_stop)(void *priv);
|
Networking
|
74c551ca5a0edcc9cf66a3b73fd95b9a8615bfd0
|
russell king
|
include
|
linux
|
phy
|
net: sfp: move phy_start()/phy_stop() to phylink
|
move phy_start() and phy_stop() into the module_start and module_stop notifications in phylink, rather than having them in the sfp code. this gives phylink responsibility for controlling the phy, rather than having sfp start and stop the phy state machine.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 2
| 22
| 2
|
--- 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 +static int phylink_sfp_module_start(void *upstream) +{ + struct phylink *pl = upstream; + + /* if this sfp module has a phy, start the phy now. */ + if (pl->phydev) + phy_start(pl->phydev); + + return 0; +} + +static void phylink_sfp_module_stop(void *upstream) +{ + struct phylink *pl = upstream; + + /* if this sfp module has a phy, stop it. */ + if (pl->phydev) + phy_stop(pl->phydev); +} + + .module_start = phylink_sfp_module_start, + .module_stop = phylink_sfp_module_stop, diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c - phy_stop(sfp->mod_phy); - phy_start(phy);
|
Networking
|
4882057ad434e8a6434fce20dc7b7315d40a9d4a
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: mdio-i2c: add support for clause 45 accesses
|
some sfp+ modules have phys on them just like sfp modules do, except they are clause 45 phys. the i2c protocol used to access them is modified slightly in order to send the device address and 16-bit register index.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 20
| 8
|
--- diff --git a/drivers/net/phy/mdio-i2c.c b/drivers/net/phy/mdio-i2c.c --- a/drivers/net/phy/mdio-i2c.c +++ b/drivers/net/phy/mdio-i2c.c - u8 data[2], dev_addr = reg; + u8 addr[3], data[2], *p; + p = addr; + if (reg & mii_addr_c45) { + *p++ = 0x20 | ((reg >> 16) & 31); + *p++ = reg >> 8; + } + *p++ = reg; + - msgs[0].len = 1; - msgs[0].buf = &dev_addr; + msgs[0].len = p - addr; + msgs[0].buf = addr; - u8 data[3]; + u8 data[5], *p; - data[0] = reg; - data[1] = val >> 8; - data[2] = val; + p = data; + if (reg & mii_addr_c45) { + *p++ = (reg >> 16) & 31; + *p++ = reg >> 8; + } + *p++ = reg; + *p++ = val >> 8; + *p++ = val; - msg.len = 3; + msg.len = p - data;
|
Networking
|
6912b712cd75aaa1c8d90b291ec7d2504f17f263
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: phylink: re-split __phylink_connect_phy()
|
in order to support clause 45 phys on sfp+ modules, which have an indeterminant phy interface mode, we need to be able to call phylink_bringup_phy() with a different interface mode to that used when binding the phy. reduce __phylink_connect_phy() to an attach operation, and move the call to phylink_bringup_phy() to its call sites.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 24
| 15
|
--- 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 -static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy, - phy_interface_t interface) +static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, + phy_interface_t interface) - int ret; - - ret = phy_attach_direct(pl->netdev, phy, 0, interface); - if (ret) - return ret; - - ret = phylink_bringup_phy(pl, phy); - if (ret) - phy_detach(phy); - - return ret; + return phy_attach_direct(pl->netdev, phy, 0, interface); + int ret; + - return __phylink_connect_phy(pl, phy, pl->link_interface); + ret = phylink_attach_phy(pl, phy, pl->link_interface); + if (ret < 0) + return ret; + + ret = phylink_bringup_phy(pl, phy); + if (ret) + phy_detach(phy); + + return ret; + int ret; - return __phylink_connect_phy(upstream, phy, pl->link_config.interface); + ret = phylink_attach_phy(pl, phy, pl->link_config.interface); + if (ret < 0) + return ret; + + ret = phylink_bringup_phy(pl, phy); + if (ret) + phy_detach(phy); + + return ret;
|
Networking
|
938d44c2b502ba421a785683653e24b685f5d637
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: phylink: support clause 45 phys on sfp+ modules
|
some sfp+ modules have clause 45 phys embedded on them, which need a little more handling in order to ensure that they are correctly setup, as they switch the phy link mode according to the negotiated speed.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 16
| 5
|
--- 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 -static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy) +static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, + phy_interface_t interface) - config.interface = pl->link_config.interface; + config.interface = interface; + pl->phy_state.interface = interface; - ret = phylink_bringup_phy(pl, phy); + ret = phylink_bringup_phy(pl, phy, pl->link_config.interface); - ret = phylink_bringup_phy(pl, phy_dev); + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); + phy_interface_t interface = pl->link_config.interface; - ret = phylink_bringup_phy(pl, phy); + /* clause 45 phys switch their serdes lane between several different + * modes, normally 10gbase-r, sgmii. some use 2500base-x for 2.5g + * speeds. we really need to know which interface modes the phy and + * mac supports to properly work out which linkmodes can be supported. + */ + if (phy->is_c45) + interface = phy_interface_mode_na; + + ret = phylink_bringup_phy(pl, phy, interface);
|
Networking
|
e45d1f5288b81e77eb87288ae2d0a0d00e0989d3
|
russell king
|
drivers
|
net
|
phy
|
net: phylink: split link_an_mode configured and current settings
|
split link_an_mode between the configured setting and the current operating setting. this is an important distinction to make when we need to configure phy mode for a plugged sfp+ module that does not use in-band signalling.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 31
| 28
|
--- 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 - u8 link_an_mode; /* mlo_an_xxx */ + u8 cfg_link_an_mode; /* mlo_an_xxx */ + u8 cur_link_an_mode; - pl->link_an_mode = mlo_an_fixed; + pl->cfg_link_an_mode = mlo_an_fixed; - if (pl->link_an_mode == mlo_an_fixed) { + if (pl->cfg_link_an_mode == mlo_an_fixed) { - pl->link_an_mode = mlo_an_inband; + pl->cfg_link_an_mode = mlo_an_inband; - __func__, phylink_an_mode_str(pl->link_an_mode), + __func__, phylink_an_mode_str(pl->cur_link_an_mode), - pl->ops->mac_config(pl->config, pl->link_an_mode, state); + pl->ops->mac_config(pl->config, pl->cur_link_an_mode, state); - pl->ops->mac_link_up(pl->config, pl->link_an_mode, + pl->ops->mac_link_up(pl->config, pl->cur_link_an_mode, - pl->ops->mac_link_down(pl->config, pl->link_an_mode, + pl->ops->mac_link_down(pl->config, pl->cur_link_an_mode, - switch (pl->link_an_mode) { + switch (pl->cur_link_an_mode) { - if (pl->link_an_mode == mlo_an_fixed) { + if (pl->cfg_link_an_mode == mlo_an_fixed) { + pl->cur_link_an_mode = pl->cfg_link_an_mode; + - if (warn_on(pl->link_an_mode == mlo_an_fixed || - (pl->link_an_mode == mlo_an_inband && + if (warn_on(pl->cfg_link_an_mode == mlo_an_fixed || + (pl->cfg_link_an_mode == mlo_an_inband && - if (pl->link_an_mode == mlo_an_fixed || - (pl->link_an_mode == mlo_an_inband && + if (pl->cfg_link_an_mode == mlo_an_fixed || + (pl->cfg_link_an_mode == mlo_an_inband && - if (pl->link_an_mode == mlo_an_phy) + if (pl->cfg_link_an_mode == mlo_an_phy) - if (pl->link_an_mode != mlo_an_fixed) + if (pl->cfg_link_an_mode != mlo_an_fixed) - phylink_an_mode_str(pl->link_an_mode), + phylink_an_mode_str(pl->cur_link_an_mode), - if (pl->link_an_mode == mlo_an_fixed && pl->link_gpio) { + if (pl->cfg_link_an_mode == mlo_an_fixed && pl->link_gpio) { - if (pl->link_an_mode == mlo_an_fixed && pl->get_fixed_state) + if (pl->cfg_link_an_mode == mlo_an_fixed && pl->get_fixed_state) - switch (pl->link_an_mode) { + switch (pl->cur_link_an_mode) { - if (pl->link_an_mode == mlo_an_fixed && + if (pl->cur_link_an_mode == mlo_an_fixed && - if (pl->link_an_mode == mlo_an_fixed) + if (pl->cur_link_an_mode == mlo_an_fixed) - if (pl->link_an_mode == mlo_an_inband && + if (pl->cur_link_an_mode == mlo_an_inband && - switch (pl->link_an_mode) { + switch (pl->cur_link_an_mode) { - switch (pl->link_an_mode) { + switch (pl->cur_link_an_mode) { - switch (pl->link_an_mode) { + switch (pl->cur_link_an_mode) { - if (pl->link_an_mode != mlo_an_inband || + if (pl->cur_link_an_mode != mlo_an_inband || - pl->link_an_mode = mlo_an_inband; + pl->cur_link_an_mode = mlo_an_inband;
|
Networking
|
24cf0e693bb50a61e3281009a329f7553a4fbd96
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: phylink: split phylink_sfp_module_insert()
|
split out the configuration step from phylink_sfp_module_insert() so we can re-use this later.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 28
| 19
|
--- 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 -static int phylink_sfp_module_insert(void *upstream, - const struct sfp_eeprom_id *id) +static int phylink_sfp_config(struct phylink *pl, u8 mode, u8 port, + const unsigned long *supported, + const unsigned long *advertising) - struct phylink *pl = upstream; - __ethtool_declare_link_mode_mask(support) = { 0, }; + __ethtool_declare_link_mode_mask(support); - int ret = 0; - u8 port; - - assert_rtnl(); + int ret; - sfp_parse_support(pl->sfp_bus, id, support); - port = sfp_parse_port(pl->sfp_bus, id, support); + linkmode_copy(support, supported); - linkmode_copy(config.advertising, support); + linkmode_copy(config.advertising, advertising); - linkmode_copy(support1, support); - + linkmode_copy(support1, support); - phylink_an_mode_str(mlo_an_inband), + phylink_an_mode_str(mode), - phylink_an_mode_str(mlo_an_inband), - phy_modes(config.interface), + phylink_an_mode_str(mode), phy_modes(config.interface), - if (pl->cur_link_an_mode != mlo_an_inband || + if (pl->cur_link_an_mode != mode || - pl->cur_link_an_mode = mlo_an_inband; + pl->cur_link_an_mode = mode; - phylink_an_mode_str(mlo_an_inband), + phylink_an_mode_str(mode), +static int phylink_sfp_module_insert(void *upstream, + const struct sfp_eeprom_id *id) +{ + struct phylink *pl = upstream; + __ethtool_declare_link_mode_mask(support) = { 0, }; + u8 port; + + assert_rtnl(); + + sfp_parse_support(pl->sfp_bus, id, support); + port = sfp_parse_port(pl->sfp_bus, id, support); + + return phylink_sfp_config(pl, mlo_an_inband, port, support, support); +} +
|
Networking
|
c0de2f47202941d936f0482ccd5b010b642a0008
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net: phylink: delay mac configuration for copper sfp modules
|
knowing whether we need to delay the mac configuration because a module may have a phy is useful to phylink to allow nbase-t modules to work on systems supporting no more than 2.5g speeds.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c', 'h']
| 3
| 78
| 10
|
--- 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 + bool sfp_may_have_phy; + __ethtool_declare_link_mode_mask(sfp_support); + u8 sfp_port; -static int phylink_sfp_config(struct phylink *pl, u8 mode, u8 port, +static int phylink_sfp_config(struct phylink *pl, u8 mode, - pl->link_port = port; + pl->link_port = pl->sfp_port; - __ethtool_declare_link_mode_mask(support) = { 0, }; - u8 port; + unsigned long *support = pl->sfp_support; + linkmode_zero(support); - port = sfp_parse_port(pl->sfp_bus, id, support); + pl->sfp_port = sfp_parse_port(pl->sfp_bus, id, support); - return phylink_sfp_config(pl, mlo_an_inband, port, support, support); + /* if this module may have a phy connecting later, defer until later */ + pl->sfp_may_have_phy = sfp_may_have_phy(pl->sfp_bus, id); + if (pl->sfp_may_have_phy) + return 0; + + return phylink_sfp_config(pl, mlo_an_inband, support, support); - if (pl->phydev) + if (pl->phydev) { + return 0; + } - return 0; + /* if the module may have a phy but we didn't detect one we + * need to configure the mac here. + */ + if (!pl->sfp_may_have_phy) + return 0; + + return phylink_sfp_config(pl, mlo_an_inband, + pl->sfp_support, pl->sfp_support); - phy_interface_t interface = pl->link_config.interface; + phy_interface_t interface; - ret = phylink_attach_phy(pl, phy, pl->link_config.interface); + /* + * this is the new way of dealing with flow control for phys, + * as described by timur tabi in commit 529ed1275263 ("net: phy: + * phy drivers should not set supported_[asym_]pause") except + * using our validate call to the mac, we rely upon the mac + * clearing the bits from both supported and advertising fields. + */ + phy_support_asym_pause(phy); + + /* do the initial configuration */ + ret = phylink_sfp_config(pl, mlo_an_inband, phy->supported, + phy->advertising); + if (ret < 0) + return ret; + + interface = pl->link_config.interface; + ret = phylink_attach_phy(pl, phy, interface); diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c + +/** + * sfp_may_have_phy() - indicate whether the module may have a phy + * @bus: a pointer to the &struct sfp_bus structure for the sfp module + * @id: a pointer to the module's &struct sfp_eeprom_id + * + * parse the eeprom identification given in @id, and return whether + * this module may have a phy. + */ +bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) +{ + if (id->base.e1000_base_t) + return true; + + if (id->base.phys_id != sff8024_id_dwdm_sfp) { + switch (id->base.extended_cc) { + case sff8024_ecc_10gbase_t_sfi: + case sff8024_ecc_10gbase_t_sr: + case sff8024_ecc_5gbase_t: + case sff8024_ecc_2_5gbase_t: + return true; + } + } + + return false; +} +export_symbol_gpl(sfp_may_have_phy); + diff --git a/include/linux/sfp.h b/include/linux/sfp.h --- a/include/linux/sfp.h +++ b/include/linux/sfp.h +bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id); +static inline bool sfp_may_have_phy(struct sfp_bus *bus, + const struct sfp_eeprom_id *id) +{ + return false; +} +
|
Networking
|
52c956003a9d5bcae1f445f9dfd42b624adb6e87
|
russell king
|
include
|
linux
|
phy
|
net: phylink: make broadcom bcm84881 based sfps work
|
the broadcom bcm84881 does not appear to send the sgmii control word when operating in sgmii mode, which causes network adapters to fail to link with the phy, or decide to operate at fixed 1g speed, even if the phy negotiated 100m.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 16
| 2
|
--- 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 +/* the broadcom bcm84881 in the methode dm7052 is unable to provide a sgmii + * or 802.3z control word, so inband will not work. + */ +static bool phylink_phy_no_inband(struct phy_device *phy) +{ + return phy->is_c45 && + (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150; +} + + u8 mode; + if (phylink_phy_no_inband(phy)) + mode = mlo_an_phy; + else + mode = mlo_an_inband; + - ret = phylink_sfp_config(pl, mlo_an_inband, phy->supported, - phy->advertising); + ret = phylink_sfp_config(pl, mode, phy->supported, phy->advertising);
|
Networking
|
7adb5b2126bc013f0964ddaefad6ad1b132e86c3
|
russell king
|
drivers
|
net
|
phy
|
net: phy: add broadcom bcm84881 phy driver
|
add a rudimentary clause 45 driver for the bcm84881 phy, found on methode dm7052 sfps.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c', 'kconfig', 'makefile']
| 3
| 276
| 0
|
--- diff --git a/drivers/net/phy/kconfig b/drivers/net/phy/kconfig --- a/drivers/net/phy/kconfig +++ b/drivers/net/phy/kconfig +config bcm84881_phy + bool "broadcom bcm84881 phy" + depends on phylib=y + ---help--- + support the broadcom bcm84881 phy. + ---help--- diff --git a/drivers/net/phy/makefile b/drivers/net/phy/makefile --- a/drivers/net/phy/makefile +++ b/drivers/net/phy/makefile +obj-$(config_bcm84881_phy) += bcm84881.o diff --git a/drivers/net/phy/bcm84881.c b/drivers/net/phy/bcm84881.c --- /dev/null +++ b/drivers/net/phy/bcm84881.c +// spdx-license-identifier: gpl-2.0 +// broadcom bcm84881 nbase-t phy driver, as found on a sfp+ module. +// copyright (c) 2019 russell king, deep blue solutions ltd. +// +// like the marvell 88x3310, the broadcom 84881 changes its host-side +// interface according to the operating speed between 10gbase-r, +// 2500base-x and sgmii (but unlike the 88x3310, without the control +// word). +// +// this driver only supports those aspects of the phy that i'm able to +// observe and test with the sfp+ module, which is an incomplete subset +// of what this phy is able to support. for example, i only assume it +// supports a single lane serdes connection, but it may be that the phy +// is able to support more than that. +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/phy.h> + +enum { + mdio_an_c22 = 0xffe0, +}; + +static int bcm84881_wait_init(struct phy_device *phydev) +{ + unsigned int tries = 20; + int ret, val; + + do { + val = phy_read_mmd(phydev, mdio_mmd_pmapmd, mdio_ctrl1); + if (val < 0) { + ret = val; + break; + } + if (!(val & mdio_ctrl1_reset)) { + ret = 0; + break; + } + if (!--tries) { + ret = -etimedout; + break; + } + msleep(100); + } while (1); + + if (ret) + phydev_err(phydev, "%s failed: %d ", __func__, ret); + + return ret; +} + +static int bcm84881_config_init(struct phy_device *phydev) +{ + switch (phydev->interface) { + case phy_interface_mode_sgmii: + case phy_interface_mode_2500basex: + case phy_interface_mode_10gkr: + break; + default: + return -enodev; + } + return 0; +} + +static int bcm84881_probe(struct phy_device *phydev) +{ + /* this driver requires pmapmd and an blocks */ + const u32 mmd_mask = mdio_devs_pmapmd | mdio_devs_an; + + if (!phydev->is_c45 || + (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask) + return -enodev; + + return 0; +} + +static int bcm84881_get_features(struct phy_device *phydev) +{ + int ret; + + ret = genphy_c45_pma_read_abilities(phydev); + if (ret) + return ret; + + /* although the phy sets bit 1.11.8, it does not support 10m modes */ + linkmode_clear_bit(ethtool_link_mode_10baset_half_bit, + phydev->supported); + linkmode_clear_bit(ethtool_link_mode_10baset_full_bit, + phydev->supported); + + return 0; +} + +static int bcm84881_config_aneg(struct phy_device *phydev) +{ + bool changed = false; + u32 adv; + int ret; + + /* wait for the phy to finish initialising, otherwise our + * advertisement may be overwritten. + */ + ret = bcm84881_wait_init(phydev); + if (ret) + return ret; + + /* we don't support manual mdi control */ + phydev->mdix_ctrl = eth_tp_mdi_auto; + + /* disabled autoneg doesn't seem to work with this phy */ + if (phydev->autoneg == autoneg_disable) + return -einval; + + ret = genphy_c45_an_config_aneg(phydev); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); + ret = phy_modify_mmd_changed(phydev, mdio_mmd_an, + mdio_an_c22 + mii_ctrl1000, + advertise_1000full | advertise_1000half, + adv); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + return genphy_c45_check_and_restart_aneg(phydev, changed); +} + +static int bcm84881_aneg_done(struct phy_device *phydev) +{ + int bmsr, val; + + val = phy_read_mmd(phydev, mdio_mmd_an, mdio_stat1); + if (val < 0) + return val; + + bmsr = phy_read_mmd(phydev, mdio_mmd_an, mdio_an_c22 + mii_bmsr); + if (bmsr < 0) + return val; + + return !!(val & mdio_an_stat1_complete) && + !!(bmsr & bmsr_anegcomplete); +} + +static int bcm84881_read_status(struct phy_device *phydev) +{ + unsigned int mode; + int bmsr, val; + + val = phy_read_mmd(phydev, mdio_mmd_an, mdio_ctrl1); + if (val < 0) + return val; + + if (val & mdio_an_ctrl1_restart) { + phydev->link = 0; + return 0; + } + + val = phy_read_mmd(phydev, mdio_mmd_an, mdio_stat1); + if (val < 0) + return val; + + bmsr = phy_read_mmd(phydev, mdio_mmd_an, mdio_an_c22 + mii_bmsr); + if (bmsr < 0) + return val; + + phydev->autoneg_complete = !!(val & mdio_an_stat1_complete) && + !!(bmsr & bmsr_anegcomplete); + phydev->link = !!(val & mdio_stat1_lstatus) && + !!(bmsr & bmsr_lstatus); + if (phydev->autoneg == autoneg_enable && !phydev->autoneg_complete) + phydev->link = false; + + if (!phydev->link) + return 0; + + linkmode_zero(phydev->lp_advertising); + phydev->speed = speed_unknown; + phydev->duplex = duplex_unknown; + phydev->pause = 0; + phydev->asym_pause = 0; + phydev->mdix = 0; + + if (phydev->autoneg_complete) { + val = genphy_c45_read_lpa(phydev); + if (val < 0) + return val; + + val = phy_read_mmd(phydev, mdio_mmd_an, + mdio_an_c22 + mii_stat1000); + if (val < 0) + return val; + + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); + + if (phydev->autoneg == autoneg_enable) + phy_resolve_aneg_linkmode(phydev); + } + + if (phydev->autoneg == autoneg_disable) { + /* disabled autoneg doesn't seem to work, so force the link + * down. + */ + phydev->link = 0; + return 0; + } + + /* set the host link mode - we set the phy interface mode and + * the speed according to this register so that downshift works. + * we leave the duplex setting as per the resolution from the + * above. + */ + val = phy_read_mmd(phydev, mdio_mmd_vend1, 0x4011); + mode = (val & 0x1e) >> 1; + if (mode == 1 || mode == 2) + phydev->interface = phy_interface_mode_sgmii; + else if (mode == 3) + phydev->interface = phy_interface_mode_10gkr; + else if (mode == 4) + phydev->interface = phy_interface_mode_2500basex; + switch (mode & 7) { + case 1: + phydev->speed = speed_100; + break; + case 2: + phydev->speed = speed_1000; + break; + case 3: + phydev->speed = speed_10000; + break; + case 4: + phydev->speed = speed_2500; + break; + case 5: + phydev->speed = speed_5000; + break; + } + + return genphy_c45_read_mdix(phydev); +} + +static struct phy_driver bcm84881_drivers[] = { + { + .phy_id = 0xae025150, + .phy_id_mask = 0xfffffff0, + .name = "broadcom bcm84881", + .config_init = bcm84881_config_init, + .probe = bcm84881_probe, + .get_features = bcm84881_get_features, + .config_aneg = bcm84881_config_aneg, + .aneg_done = bcm84881_aneg_done, + .read_status = bcm84881_read_status, + }, +}; + +module_phy_driver(bcm84881_drivers); + +/* fixme: module auto-loading for clause 45 phys seems non-functional */ +static struct mdio_device_id __maybe_unused bcm84881_tbl[] = { + { 0xae025150, 0xfffffff0 }, + { }, +}; +module_author("russell king"); +module_description("broadcom bcm84881 phy driver"); +module_device_table(mdio, bcm84881_tbl); +module_license("gpl");
|
Networking
|
75f4d8d10e016f7428c268424483a927ee7a78bb
|
russell king florian fainelli f fainelli gmail com
|
drivers
|
net
|
phy
|
net: sfp: add support for clause 45 phys
|
some sfp+ modules have a clause 45 phy onboard, which is accessible via the normal i2c address. detect 10g base-t phys which may have an accessible phy and probe for it.
|
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.
|
adds support for copper sfp+ modules with clause 45 phys
|
['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']
|
[]
|
['c']
| 1
| 40
| 4
|
--- diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c -static void sfp_sm_probe_phy(struct sfp *sfp) +static void sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) - phy = mdiobus_scan(sfp->i2c_mii, sfp_phy_addr); + phy = get_phy_device(sfp->i2c_mii, sfp_phy_addr, is_c45); + err = phy_device_register(phy); + if (err) { + phy_device_free(phy); + dev_err(sfp->dev, "phy_device_register failed: %d ", err); + return; + } + +/* probe a sfp for a phy device if the module supports copper - the phy + * normally sits at i2c bus address 0x56, and may either be a clause 22 + * or clause 45 phy. + * + * clause 22 copper sfp modules normally operate in cisco sgmii mode with + * negotiation enabled, but some may be in 1000base-x - which is for the + * phy driver to determine. + * + * clause 45 copper sfp+ modules (10g) appear to switch their interface + * mode according to the negotiated line speed. + */ - if (sfp->id.base.e1000_base_t) - sfp_sm_probe_phy(sfp); + switch (sfp->id.base.extended_cc) { + case sff8024_ecc_10gbase_t_sfi: + case sff8024_ecc_10gbase_t_sr: + case sff8024_ecc_5gbase_t: + case sff8024_ecc_2_5gbase_t: + sfp_sm_probe_phy(sfp, true); + break; + + default: + if (sfp->id.base.e1000_base_t) + sfp_sm_probe_phy(sfp, false); + break; + } + /* dm7052 reports as a high power module, responds to reads (with + * all bytes 0xff) at 0x51 but does not accept writes. in any case, + * if the bit is already set, we're already in high power mode. + */ + if (!!(val & bit(0)) == enable) + return 0; +
|
Networking
|
9a484621e88ac8386f131596ce8d76668daf7996
|
russell king andrew lunn andrew lunn ch
|
drivers
|
net
|
phy
|
net/mlx5: add virtio emulation related device capabilities
|
add virtio emulation related fields to the device capabilities.
|
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.
|
virtio_net emulation 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']
|
['mlx5 ']
|
['h']
| 1
| 15
| 0
|
--- diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h + mlx5_general_obj_types_cap_virtio_net_q = (1ull << 13), +struct mlx5_ifc_device_virtio_emulation_cap_bits { + u8 reserved_at_0[0x20]; + + u8 reserved_at_20[0x13]; + u8 log_doorbell_stride[0x5]; + u8 reserved_at_38[0x3]; + u8 log_doorbell_bar_size[0x5]; + + u8 doorbell_bar_offset[0x40]; + + u8 reserved_at_80[0x780]; +}; + + struct mlx5_ifc_device_virtio_emulation_cap_bits virtio_emulation_cap;
|
Networking
|
90fbca5952436e7817910b33eb4464ddd77a8964
|
yishai hadas
|
include
|
linux
|
mlx5
|
net/mlx5: expose vdpa emulation device capabilities
|
expose vdpa emulation device capabilities from the core layer. it includes reading the capabilities from the firmware and exposing helper functions to access the data.
|
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.
|
virtio_net emulation 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']
|
['mlx5 ']
|
['c', 'h']
| 2
| 16
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c --- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c + if (mlx5_cap_gen_64(dev, general_obj_types) & + mlx5_general_obj_types_cap_virtio_net_q) { + err = mlx5_core_get_caps(dev, mlx5_cap_vdpa_emulation); + if (err) + return err; + } + diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h + mlx5_cap_vdpa_emulation = 0x13, +#define mlx5_cap_dev_vdpa_emulation(mdev, cap)\ + mlx5_get(device_virtio_emulation_cap, \ + (mdev)->caps.hca_cur[mlx5_cap_vdpa_emulation], cap) + +#define mlx5_cap64_dev_vdpa_emulation(mdev, cap)\ + mlx5_get64(device_virtio_emulation_cap, \ + (mdev)->caps.hca_cur[mlx5_cap_vdpa_emulation], cap) +
|
Networking
|
ca1992c62cadb6c8e1e1b47e197b550f3cd89b76
|
yishai hadas shahaf shuler shahafs mellanox com
|
drivers
|
net
|
core, ethernet, mellanox, mlx5
|
ib/mlx5: extend caps stage to handle var capabilities
|
extend caps stage to handle var capabilities.
|
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.
|
virtio_net emulation 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']
|
['mlx5 ']
|
['c', 'h']
| 2
| 48
| 2
|
--- diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c +static int mlx5_ib_init_var_table(struct mlx5_ib_dev *dev) +{ + struct mlx5_core_dev *mdev = dev->mdev; + struct mlx5_var_table *var_table = &dev->var_table; + u8 log_doorbell_bar_size; + u8 log_doorbell_stride; + u64 bar_size; + + log_doorbell_bar_size = mlx5_cap_dev_vdpa_emulation(mdev, + log_doorbell_bar_size); + log_doorbell_stride = mlx5_cap_dev_vdpa_emulation(mdev, + log_doorbell_stride); + var_table->hw_start_addr = dev->mdev->bar_addr + + mlx5_cap64_dev_vdpa_emulation(mdev, + doorbell_bar_offset); + bar_size = (1ull << log_doorbell_bar_size) * 4096; + var_table->stride_size = 1ull << log_doorbell_stride; + var_table->num_var_hw_entries = bar_size / var_table->stride_size; + mutex_init(&var_table->bitmap_lock); + var_table->bitmap = bitmap_zalloc(var_table->num_var_hw_entries, + gfp_kernel); + return (var_table->bitmap) ? 0 : -enomem; +} + +static void mlx5_ib_stage_caps_cleanup(struct mlx5_ib_dev *dev) +{ + bitmap_free(dev->var_table.bitmap); +} + + if (mlx5_cap_gen_64(dev->mdev, general_obj_types) & + mlx5_general_obj_types_cap_virtio_net_q) { + err = mlx5_ib_init_var_table(dev); + if (err) + return err; + } + - null), + mlx5_ib_stage_caps_cleanup), - null), + mlx5_ib_stage_caps_cleanup), diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h +struct mlx5_var_table { + /* serialize updating the bitmap */ + struct mutex bitmap_lock; + unsigned long *bitmap; + u64 hw_start_addr; + u32 stride_size; + u64 num_var_hw_entries; +}; + + struct mlx5_var_table var_table;
|
Networking
|
f164be8c03663034416d019c355fbbd2dbd189d7
|
yishai hadas
|
drivers
|
infiniband
|
hw, mlx5
|
ib/mlx5: introduce var object and its alloc/destroy methods
|
introduce var object and its alloc/destroy kabi methods. the internal implementation uses the ib core api to manage mmap/munamp calls.
|
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.
|
virtio_net emulation 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']
|
['mlx5 ']
|
['c', 'h']
| 3
| 181
| 0
|
--- diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c + struct mlx5_var_table *var_table = &dev->var_table; + case mlx5_ib_mmap_type_var: + mutex_lock(&var_table->bitmap_lock); + clear_bit(mentry->page_idx, var_table->bitmap); + mutex_unlock(&var_table->bitmap_lock); + kfree(mentry); + break; +static u64 mlx5_entry_to_mmap_offset(struct mlx5_user_mmap_entry *entry) +{ + u16 cmd = entry->rdma_entry.start_pgoff >> 16; + u16 index = entry->rdma_entry.start_pgoff & 0xffff; + + return (((index >> 8) << 16) | (cmd << mlx5_ib_mmap_cmd_shift) | + (index & 0xff)) << page_shift; +} + +static int var_obj_cleanup(struct ib_uobject *uobject, + enum rdma_remove_reason why, + struct uverbs_attr_bundle *attrs) +{ + struct mlx5_user_mmap_entry *obj = uobject->object; + + rdma_user_mmap_entry_remove(&obj->rdma_entry); + return 0; +} + +static struct mlx5_user_mmap_entry * +alloc_var_entry(struct mlx5_ib_ucontext *c) +{ + struct mlx5_user_mmap_entry *entry; + struct mlx5_var_table *var_table; + u32 page_idx; + int err; + + var_table = &to_mdev(c->ibucontext.device)->var_table; + entry = kzalloc(sizeof(*entry), gfp_kernel); + if (!entry) + return err_ptr(-enomem); + + mutex_lock(&var_table->bitmap_lock); + page_idx = find_first_zero_bit(var_table->bitmap, + var_table->num_var_hw_entries); + if (page_idx >= var_table->num_var_hw_entries) { + err = -enospc; + mutex_unlock(&var_table->bitmap_lock); + goto end; + } + + set_bit(page_idx, var_table->bitmap); + mutex_unlock(&var_table->bitmap_lock); + + entry->address = var_table->hw_start_addr + + (page_idx * var_table->stride_size); + entry->page_idx = page_idx; + entry->mmap_flag = mlx5_ib_mmap_type_var; + + err = rdma_user_mmap_entry_insert_range( + &c->ibucontext, &entry->rdma_entry, var_table->stride_size, + mlx5_ib_mmap_offset_start << 16, + (mlx5_ib_mmap_offset_end << 16) + (1ul << 16) - 1); + if (err) + goto err_insert; + + return entry; + +err_insert: + mutex_lock(&var_table->bitmap_lock); + clear_bit(page_idx, var_table->bitmap); + mutex_unlock(&var_table->bitmap_lock); +end: + kfree(entry); + return err_ptr(err); +} + +static int uverbs_handler(mlx5_ib_method_var_obj_alloc)( + struct uverbs_attr_bundle *attrs) +{ + struct ib_uobject *uobj = uverbs_attr_get_uobject( + attrs, mlx5_ib_attr_var_obj_alloc_handle); + struct mlx5_ib_ucontext *c; + struct mlx5_user_mmap_entry *entry; + u64 mmap_offset; + u32 length; + int err; + + c = to_mucontext(ib_uverbs_get_ucontext(attrs)); + if (is_err(c)) + return ptr_err(c); + + entry = alloc_var_entry(c); + if (is_err(entry)) + return ptr_err(entry); + + mmap_offset = mlx5_entry_to_mmap_offset(entry); + length = entry->rdma_entry.npages * page_size; + uobj->object = entry; + + err = uverbs_copy_to(attrs, mlx5_ib_attr_var_obj_alloc_mmap_offset, + &mmap_offset, sizeof(mmap_offset)); + if (err) + goto err; + + err = uverbs_copy_to(attrs, mlx5_ib_attr_var_obj_alloc_page_id, + &entry->page_idx, sizeof(entry->page_idx)); + if (err) + goto err; + + err = uverbs_copy_to(attrs, mlx5_ib_attr_var_obj_alloc_mmap_length, + &length, sizeof(length)); + if (err) + goto err; + + return 0; + +err: + rdma_user_mmap_entry_remove(&entry->rdma_entry); + return err; +} + +declare_uverbs_named_method( + mlx5_ib_method_var_obj_alloc, + uverbs_attr_idr(mlx5_ib_attr_var_obj_alloc_handle, + mlx5_ib_object_var, + uverbs_access_new, + ua_mandatory), + uverbs_attr_ptr_out(mlx5_ib_attr_var_obj_alloc_page_id, + uverbs_attr_type(u32), + ua_mandatory), + uverbs_attr_ptr_out(mlx5_ib_attr_var_obj_alloc_mmap_length, + uverbs_attr_type(u32), + ua_mandatory), + uverbs_attr_ptr_out(mlx5_ib_attr_var_obj_alloc_mmap_offset, + uverbs_attr_type(u64), + ua_mandatory)); + +declare_uverbs_named_method_destroy( + mlx5_ib_method_var_obj_destroy, + uverbs_attr_idr(mlx5_ib_attr_var_obj_destroy_handle, + mlx5_ib_object_var, + uverbs_access_destroy, + ua_mandatory)); + +declare_uverbs_named_object(mlx5_ib_object_var, + uverbs_type_alloc_idr(var_obj_cleanup), + &uverbs_method(mlx5_ib_method_var_obj_alloc), + &uverbs_method(mlx5_ib_method_var_obj_destroy)); + +static bool var_is_supported(struct ib_device *device) +{ + struct mlx5_ib_dev *dev = to_mdev(device); + + return (mlx5_cap_gen_64(dev->mdev, general_obj_types) & + mlx5_general_obj_types_cap_virtio_net_q); +} + + uapi_def_chain_obj_tree_named(mlx5_ib_object_var, + uapi_def_is_obj_supported(var_is_supported)), diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h +enum { + mlx5_ib_mmap_offset_start = 9, + mlx5_ib_mmap_offset_end = 255, +}; + + mlx5_ib_mmap_type_var = 2, + u32 page_idx; diff --git a/include/uapi/rdma/mlx5_user_ioctl_cmds.h b/include/uapi/rdma/mlx5_user_ioctl_cmds.h --- a/include/uapi/rdma/mlx5_user_ioctl_cmds.h +++ b/include/uapi/rdma/mlx5_user_ioctl_cmds.h +enum mlx5_ib_var_alloc_attrs { + mlx5_ib_attr_var_obj_alloc_handle = (1u << uverbs_id_ns_shift), + mlx5_ib_attr_var_obj_alloc_mmap_offset, + mlx5_ib_attr_var_obj_alloc_mmap_length, + mlx5_ib_attr_var_obj_alloc_page_id, +}; + +enum mlx5_ib_var_obj_destroy_attrs { + mlx5_ib_attr_var_obj_destroy_handle = (1u << uverbs_id_ns_shift), +}; + +enum mlx5_ib_var_obj_methods { + mlx5_ib_method_var_obj_alloc = (1u << uverbs_id_ns_shift), + mlx5_ib_method_var_obj_destroy, +}; + + mlx5_ib_object_var,
|
Networking
|
7be76bef320b1f1d1b8dc87d3d5a03f3a2421a43
|
yishai hadas
|
drivers
|
infiniband
|
hw, mlx5, rdma
|
ib/mlx5: add mmap support for var
|
add mmap support for var, it uses the 'offset' command mode with involvement of ib core apis to find the previously allocated mmap entry.
|
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.
|
virtio_net emulation 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']
|
['mlx5 ']
|
['c']
| 1
| 4
| 1
|
--- diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c - prot = pgprot_writecombine(vma->vm_page_prot); + if (mentry->mmap_flag == mlx5_ib_mmap_type_var) + prot = pgprot_noncached(vma->vm_page_prot); + else + prot = pgprot_writecombine(vma->vm_page_prot);
|
Networking
|
3f59b6c3e600f9665dcf5b8e566cd7b778f03045
|
yishai hadas
|
drivers
|
infiniband
|
hw, mlx5
|
net/mlx5: add roce accelerator counters
|
add roce accelerator definitions.
|
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 roce accelerator counters
|
['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']
|
['mlx5 ']
|
['h']
| 1
| 15
| 2
|
--- diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h - u8 reserved_at_140[0xa]; + u8 reserved_at_140[0x9]; + u8 roce_accl[0x1]; - u8 reserved_at_620[0x1e0]; + u8 reserved_at_620[0x20]; + + u8 roce_adp_retrans[0x20]; + + u8 roce_adp_retrans_to[0x20]; + + u8 roce_slow_restart[0x20]; + + u8 roce_slow_restart_cnps[0x20]; + + u8 roce_slow_restart_trans[0x20]; + + u8 reserved_at_6e0[0x120];
|
Networking
|
8fd5b75d979bd8483b7e015c85834fbc82d499ac
|
leon romanovsky
|
include
|
linux
|
mlx5
|
ib/mlx5: expose roce accelerator counters
|
introduce the following roce accelerator counters: * roce_adp_retrans - number of adaptive retransmission for roce traffic. * roce_adp_retrans_to - number of times roce traffic reached time out due to adaptive retransmission. * roce_slow_restart - number of times roce slow restart was used. * roce_slow_restart_cnps - number of times roce slow restart generate cnp packets. * roce_slow_restart_trans - number of times roce slow restart change state to slow restart.
|
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 roce accelerator counters
|
['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']
|
['mlx5 ']
|
['c']
| 1
| 18
| 0
|
--- diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c +static const struct mlx5_ib_counter roce_accl_cnts[] = { + init_q_counter(roce_adp_retrans), + init_q_counter(roce_adp_retrans_to), + init_q_counter(roce_slow_restart), + init_q_counter(roce_slow_restart_cnps), + init_q_counter(roce_slow_restart_trans), +}; + + if (mlx5_cap_gen(dev->mdev, roce_accl)) + num_counters += array_size(roce_accl_cnts); + + if (mlx5_cap_gen(dev->mdev, roce_accl)) { + for (i = 0; i < array_size(roce_accl_cnts); i++, j++) { + names[j] = roce_accl_cnts[i].name; + offsets[j] = roce_accl_cnts[i].offset; + } + } +
|
Networking
|
d7fab916374c8f5488ca792c57ea8b72e8631213
|
avihai horon maor gottlieb maorg mellanox com
|
drivers
|
infiniband
|
hw, mlx5
|
net/mlx5: dr, create fte entry in the fw from sw-steering
|
implement the fw command to setup a fte (flow table entry) into the fw managed flow tables.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 2
| 242
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c + +static int mlx5dr_cmd_set_extended_dest(struct mlx5_core_dev *dev, + struct mlx5dr_cmd_fte_info *fte, + bool *extended_dest) +{ + int fw_log_max_fdb_encap_uplink = mlx5_cap_esw(dev, log_max_fdb_encap_uplink); + int num_fwd_destinations = 0; + int num_encap = 0; + int i; + + *extended_dest = false; + if (!(fte->action.action & mlx5_flow_context_action_fwd_dest)) + return 0; + for (i = 0; i < fte->dests_size; i++) { + if (fte->dest_arr[i].type == mlx5_flow_destination_type_counter) + continue; + if (fte->dest_arr[i].type == mlx5_flow_destination_type_vport && + fte->dest_arr[i].vport.flags & mlx5_flow_dest_vport_reformat_id) + num_encap++; + num_fwd_destinations++; + } + + if (num_fwd_destinations > 1 && num_encap > 0) + *extended_dest = true; + + if (*extended_dest && !fw_log_max_fdb_encap_uplink) { + mlx5_core_warn(dev, "fw does not support extended destination"); + return -eopnotsupp; + } + if (num_encap > (1 << fw_log_max_fdb_encap_uplink)) { + mlx5_core_warn(dev, "fw does not support more than %d encaps", + 1 << fw_log_max_fdb_encap_uplink); + return -eopnotsupp; + } + + return 0; +} + +int mlx5dr_cmd_set_fte(struct mlx5_core_dev *dev, + int opmod, int modify_mask, + struct mlx5dr_cmd_ft_info *ft, + u32 group_id, + struct mlx5dr_cmd_fte_info *fte) +{ + u32 out[mlx5_st_sz_dw(set_fte_out)] = {}; + void *in_flow_context, *vlan; + bool extended_dest = false; + void *in_match_value; + unsigned int inlen; + int dst_cnt_size; + void *in_dests; + u32 *in; + int err; + int i; + + if (mlx5dr_cmd_set_extended_dest(dev, fte, &extended_dest)) + return -eopnotsupp; + + if (!extended_dest) + dst_cnt_size = mlx5_st_sz_bytes(dest_format_struct); + else + dst_cnt_size = mlx5_st_sz_bytes(extended_dest_format); + + inlen = mlx5_st_sz_bytes(set_fte_in) + fte->dests_size * dst_cnt_size; + in = kvzalloc(inlen, gfp_kernel); + if (!in) + return -enomem; + + mlx5_set(set_fte_in, in, opcode, mlx5_cmd_op_set_flow_table_entry); + mlx5_set(set_fte_in, in, op_mod, opmod); + mlx5_set(set_fte_in, in, modify_enable_mask, modify_mask); + mlx5_set(set_fte_in, in, table_type, ft->type); + mlx5_set(set_fte_in, in, table_id, ft->id); + mlx5_set(set_fte_in, in, flow_index, fte->index); + if (ft->vport) { + mlx5_set(set_fte_in, in, vport_number, ft->vport); + mlx5_set(set_fte_in, in, other_vport, 1); + } + + in_flow_context = mlx5_addr_of(set_fte_in, in, flow_context); + mlx5_set(flow_context, in_flow_context, group_id, group_id); + + mlx5_set(flow_context, in_flow_context, flow_tag, + fte->flow_context.flow_tag); + mlx5_set(flow_context, in_flow_context, flow_source, + fte->flow_context.flow_source); + + mlx5_set(flow_context, in_flow_context, extended_destination, + extended_dest); + if (extended_dest) { + u32 action; + + action = fte->action.action & + ~mlx5_flow_context_action_packet_reformat; + mlx5_set(flow_context, in_flow_context, action, action); + } else { + mlx5_set(flow_context, in_flow_context, action, + fte->action.action); + if (fte->action.pkt_reformat) + mlx5_set(flow_context, in_flow_context, packet_reformat_id, + fte->action.pkt_reformat->id); + } + if (fte->action.modify_hdr) + mlx5_set(flow_context, in_flow_context, modify_header_id, + fte->action.modify_hdr->id); + + vlan = mlx5_addr_of(flow_context, in_flow_context, push_vlan); + + mlx5_set(vlan, vlan, ethtype, fte->action.vlan[0].ethtype); + mlx5_set(vlan, vlan, vid, fte->action.vlan[0].vid); + mlx5_set(vlan, vlan, prio, fte->action.vlan[0].prio); + + vlan = mlx5_addr_of(flow_context, in_flow_context, push_vlan_2); + + mlx5_set(vlan, vlan, ethtype, fte->action.vlan[1].ethtype); + mlx5_set(vlan, vlan, vid, fte->action.vlan[1].vid); + mlx5_set(vlan, vlan, prio, fte->action.vlan[1].prio); + + in_match_value = mlx5_addr_of(flow_context, in_flow_context, + match_value); + memcpy(in_match_value, fte->val, sizeof(u32) * mlx5_st_sz_dw_match_param); + + in_dests = mlx5_addr_of(flow_context, in_flow_context, destination); + if (fte->action.action & mlx5_flow_context_action_fwd_dest) { + int list_size = 0; + + for (i = 0; i < fte->dests_size; i++) { + unsigned int id, type = fte->dest_arr[i].type; + + if (type == mlx5_flow_destination_type_counter) + continue; + + switch (type) { + case mlx5_flow_destination_type_flow_table_num: + id = fte->dest_arr[i].ft_num; + type = mlx5_flow_destination_type_flow_table; + break; + case mlx5_flow_destination_type_flow_table: + id = fte->dest_arr[i].ft_id; + break; + case mlx5_flow_destination_type_vport: + id = fte->dest_arr[i].vport.num; + mlx5_set(dest_format_struct, in_dests, + destination_eswitch_owner_vhca_id_valid, + !!(fte->dest_arr[i].vport.flags & + mlx5_flow_dest_vport_vhca_id)); + mlx5_set(dest_format_struct, in_dests, + destination_eswitch_owner_vhca_id, + fte->dest_arr[i].vport.vhca_id); + if (extended_dest && (fte->dest_arr[i].vport.flags & + mlx5_flow_dest_vport_reformat_id)) { + mlx5_set(dest_format_struct, in_dests, + packet_reformat, + !!(fte->dest_arr[i].vport.flags & + mlx5_flow_dest_vport_reformat_id)); + mlx5_set(extended_dest_format, in_dests, + packet_reformat_id, + fte->dest_arr[i].vport.reformat_id); + } + break; + default: + id = fte->dest_arr[i].tir_num; + } + + mlx5_set(dest_format_struct, in_dests, destination_type, + type); + mlx5_set(dest_format_struct, in_dests, destination_id, id); + in_dests += dst_cnt_size; + list_size++; + } + + mlx5_set(flow_context, in_flow_context, destination_list_size, + list_size); + } + + if (fte->action.action & mlx5_flow_context_action_count) { + int max_list_size = bit(mlx5_cap_flowtable_type(dev, + log_max_flow_counter, + ft->type)); + int list_size = 0; + + for (i = 0; i < fte->dests_size; i++) { + if (fte->dest_arr[i].type != + mlx5_flow_destination_type_counter) + continue; + + mlx5_set(flow_counter_list, in_dests, flow_counter_id, + fte->dest_arr[i].counter_id); + in_dests += dst_cnt_size; + list_size++; + } + if (list_size > max_list_size) { + err = -einval; + goto err_out; + } + + mlx5_set(flow_context, in_flow_context, flow_counter_list_size, + list_size); + } + + err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); +err_out: + kvfree(in); + return err; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +struct mlx5dr_cmd_ft_info { + u32 id; + u16 vport; + enum fs_flow_table_type type; +}; + +struct mlx5dr_cmd_flow_destination_hw_info { + enum mlx5_flow_destination_type type; + union { + u32 tir_num; + u32 ft_num; + u32 ft_id; + u32 counter_id; + struct { + u16 num; + u16 vhca_id; + u32 reformat_id; + u8 flags; + } vport; + }; +}; + +struct mlx5dr_cmd_fte_info { + u32 dests_size; + u32 index; + struct mlx5_flow_context flow_context; + u32 *val; + struct mlx5_flow_act action; + struct mlx5dr_cmd_flow_destination_hw_info *dest_arr; +}; + +int mlx5dr_cmd_set_fte(struct mlx5_core_dev *dev, + int opmod, int modify_mask, + struct mlx5dr_cmd_ft_info *ft, + u32 group_id, + struct mlx5dr_cmd_fte_info *fte); +
|
Networking
|
6de03d2dcb0ec53e5862ae5844563bbbccde74bb
|
erez shitrit
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, create multi-destination table for sw-steering use
|
currently sw steering doesn't have the means to access hw iterators to support multi-destination (ftes) flow table entries.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 2
| 75
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c + +int mlx5dr_fw_create_md_tbl(struct mlx5dr_domain *dmn, + struct mlx5dr_cmd_flow_destination_hw_info *dest, + int num_dest, + bool reformat_req, + u32 *tbl_id, + u32 *group_id) +{ + struct mlx5dr_cmd_create_flow_table_attr ft_attr = {}; + struct mlx5dr_cmd_fte_info fte_info = {}; + u32 val[mlx5_st_sz_dw_match_param] = {}; + struct mlx5dr_cmd_ft_info ft_info = {}; + int ret; + + ft_attr.table_type = mlx5_flow_table_type_fdb; + ft_attr.level = dmn->info.caps.max_ft_level - 2; + ft_attr.reformat_en = reformat_req; + ft_attr.decap_en = reformat_req; + + ret = mlx5dr_cmd_create_flow_table(dmn->mdev, &ft_attr, null, tbl_id); + if (ret) { + mlx5dr_err(dmn, "failed creating multi dest fw flow table %d ", ret); + return ret; + } + + ret = mlx5dr_cmd_create_empty_flow_group(dmn->mdev, + mlx5_flow_table_type_fdb, + *tbl_id, group_id); + if (ret) { + mlx5dr_err(dmn, "failed creating multi dest fw flow group %d ", ret); + goto free_flow_table; + } + + ft_info.id = *tbl_id; + ft_info.type = fs_ft_fdb; + fte_info.action.action = mlx5_flow_context_action_fwd_dest; + fte_info.dests_size = num_dest; + fte_info.val = val; + fte_info.dest_arr = dest; + + ret = mlx5dr_cmd_set_fte(dmn->mdev, 0, 0, &ft_info, *group_id, &fte_info); + if (ret) { + mlx5dr_err(dmn, "failed setting fte into table %d ", ret); + goto free_flow_group; + } + + return 0; + +free_flow_group: + mlx5dr_cmd_destroy_flow_group(dmn->mdev, mlx5_flow_table_type_fdb, + *tbl_id, *group_id); +free_flow_table: + mlx5dr_cmd_destroy_flow_table(dmn->mdev, *tbl_id, + mlx5_flow_table_type_fdb); + return ret; +} + +void mlx5dr_fw_destroy_md_tbl(struct mlx5dr_domain *dmn, + u32 tbl_id, u32 group_id) +{ + mlx5dr_cmd_del_flow_table_entry(dmn->mdev, fs_ft_fdb, tbl_id); + mlx5dr_cmd_destroy_flow_group(dmn->mdev, + mlx5_flow_table_type_fdb, + tbl_id, group_id); + mlx5dr_cmd_destroy_flow_table(dmn->mdev, tbl_id, + mlx5_flow_table_type_fdb); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +int mlx5dr_fw_create_md_tbl(struct mlx5dr_domain *dmn, + struct mlx5dr_cmd_flow_destination_hw_info *dest, + int num_dest, + bool reformat_req, + u32 *tbl_id, + u32 *group_id); +void mlx5dr_fw_destroy_md_tbl(struct mlx5dr_domain *dmn, u32 tbl_id, + u32 group_id);
|
Networking
|
34583beea4b741589793ce3ad5436b0a7c6d0cdb
|
erez shitrit
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, pass table flags at creation to lower layer
|
we need to have the flow-table flags when creation sw-steering tables, this parameter exists in the layer between fs_core to sw_steering, this patch gives it to the creation function.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 4
| 10
| 4
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c + bool en_encap = !!(tbl->flags & mlx5_flow_table_tunnel_en_reformat); + bool en_decap = !!(tbl->flags & mlx5_flow_table_tunnel_en_decap); + ft_attr.decap_en = en_decap; + ft_attr.reformat_en = en_encap; -struct mlx5dr_table *mlx5dr_table_create(struct mlx5dr_domain *dmn, u32 level) +struct mlx5dr_table *mlx5dr_table_create(struct mlx5dr_domain *dmn, u32 level, u32 flags) + tbl->flags = flags; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h + u32 flags; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c - ft->level); + ft->level, ft->flags); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h -mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level); +mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags); -mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level) { return null; } +mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags) { return null; }
|
Networking
|
988fd6b32d07400bd66259603ac9e08c33c02a05
|
erez shitrit
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, align dest ft action creation to api
|
function prefix was changed to be similar to other action apis. in order to support other fw tables the mlx5_flow_table struct was replaced with table id and type.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 4
| 23
| 17
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c - ret = mlx5dr_cmd_query_flow_table(action->dest_tbl.fw_tbl.mdev, - action->dest_tbl.fw_tbl.ft->type, - action->dest_tbl.fw_tbl.ft->id, + ret = mlx5dr_cmd_query_flow_table(dmn->mdev, + action->dest_tbl.fw_tbl.type, + action->dest_tbl.fw_tbl.id, -mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft, - struct mlx5_core_dev *mdev) +mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *dmn, + struct mlx5_flow_table *ft) - action->dest_tbl.fw_tbl.ft = ft; - action->dest_tbl.fw_tbl.mdev = mdev; + action->dest_tbl.fw_tbl.type = ft->type; + action->dest_tbl.fw_tbl.id = ft->id; + action->dest_tbl.fw_tbl.dmn = dmn; + + refcount_inc(&dmn->refcount); - if (!action->dest_tbl.is_fw_tbl) + if (action->dest_tbl.is_fw_tbl) + refcount_dec(&action->dest_tbl.fw_tbl.dmn->refcount); + else diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h - struct mlx5_flow_table *ft; + struct mlx5dr_domain *dmn; + u32 id; + enum fs_flow_table_type type; - struct mlx5_core_dev *mdev; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c -static struct mlx5dr_action *create_ft_action(struct mlx5_core_dev *dev, +static struct mlx5dr_action *create_ft_action(struct mlx5dr_domain *domain, - return mlx5dr_create_action_dest_flow_fw_table(dest_ft, dev); + return mlx5dr_action_create_dest_flow_fw_table(domain, dest_ft); - tmp_action = create_ft_action(dev, dst); + tmp_action = create_ft_action(domain, dst); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h -mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft, - struct mlx5_core_dev *mdev); +mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain, + struct mlx5_flow_table *ft); -mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft, - struct mlx5_core_dev *mdev) { return null; } +mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain, + struct mlx5_flow_table *ft) { return null; }
|
Networking
|
aec292ee6f290920fc77907dfe1b94baa600484d
|
alex vesker erez shitrit erezsh mellanox com
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, add support for multiple destination table action
|
a multiple destination table action allows hw packet duplication to multiple destinations, this is useful for multicast or mirroring traffic for debug. duplicating is done using a fw flow table with multiple destinations.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 3
| 132
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +struct mlx5dr_action * +mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn, + struct mlx5dr_action_dest *dests, + u32 num_of_dests) +{ + struct mlx5dr_cmd_flow_destination_hw_info *hw_dests; + struct mlx5dr_action **ref_actions; + struct mlx5dr_action *action; + bool reformat_req = false; + u32 num_of_ref = 0; + int ret; + int i; + + if (dmn->type != mlx5dr_domain_type_fdb) { + mlx5dr_err(dmn, "multiple destination support is for fdb only "); + return null; + } + + hw_dests = kzalloc(sizeof(*hw_dests) * num_of_dests, gfp_kernel); + if (!hw_dests) + return null; + + ref_actions = kzalloc(sizeof(*ref_actions) * num_of_dests * 2, gfp_kernel); + if (!ref_actions) + goto free_hw_dests; + + for (i = 0; i < num_of_dests; i++) { + struct mlx5dr_action *reformat_action = dests[i].reformat; + struct mlx5dr_action *dest_action = dests[i].dest; + + ref_actions[num_of_ref++] = dest_action; + + switch (dest_action->action_type) { + case dr_action_typ_vport: + hw_dests[i].vport.flags = mlx5_flow_dest_vport_vhca_id; + hw_dests[i].type = mlx5_flow_destination_type_vport; + hw_dests[i].vport.num = dest_action->vport.caps->num; + hw_dests[i].vport.vhca_id = dest_action->vport.caps->vhca_gvmi; + if (reformat_action) { + reformat_req = true; + hw_dests[i].vport.reformat_id = + reformat_action->reformat.reformat_id; + ref_actions[num_of_ref++] = reformat_action; + hw_dests[i].vport.flags |= mlx5_flow_dest_vport_reformat_id; + } + break; + + case dr_action_typ_ft: + hw_dests[i].type = mlx5_flow_destination_type_flow_table; + if (dest_action->dest_tbl.is_fw_tbl) + hw_dests[i].ft_id = dest_action->dest_tbl.fw_tbl.id; + else + hw_dests[i].ft_id = dest_action->dest_tbl.tbl->table_id; + break; + + default: + mlx5dr_dbg(dmn, "invalid multiple destinations action "); + goto free_ref_actions; + } + } + + action = dr_action_create_generic(dr_action_typ_ft); + if (!action) + goto free_ref_actions; + + ret = mlx5dr_fw_create_md_tbl(dmn, + hw_dests, + num_of_dests, + reformat_req, + &action->dest_tbl.fw_tbl.id, + &action->dest_tbl.fw_tbl.group_id); + if (ret) + goto free_action; + + refcount_inc(&dmn->refcount); + + for (i = 0; i < num_of_ref; i++) + refcount_inc(&ref_actions[i]->refcount); + + action->dest_tbl.is_fw_tbl = true; + action->dest_tbl.fw_tbl.dmn = dmn; + action->dest_tbl.fw_tbl.type = fs_ft_fdb; + action->dest_tbl.fw_tbl.ref_actions = ref_actions; + action->dest_tbl.fw_tbl.num_of_ref_actions = num_of_ref; + + kfree(hw_dests); + + return action; + +free_action: + kfree(action); +free_ref_actions: + kfree(ref_actions); +free_hw_dests: + kfree(hw_dests); + return null; +} + + + if (action->dest_tbl.is_fw_tbl && + action->dest_tbl.fw_tbl.num_of_ref_actions) { + struct mlx5dr_action **ref_actions; + int i; + + ref_actions = action->dest_tbl.fw_tbl.ref_actions; + for (i = 0; i < action->dest_tbl.fw_tbl.num_of_ref_actions; i++) + refcount_dec(&ref_actions[i]->refcount); + + kfree(ref_actions); + + mlx5dr_fw_destroy_md_tbl(action->dest_tbl.fw_tbl.dmn, + action->dest_tbl.fw_tbl.id, + action->dest_tbl.fw_tbl.group_id); + } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h + u32 group_id; + struct mlx5dr_action **ref_actions; + u32 num_of_ref_actions; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +struct mlx5dr_action_dest { + struct mlx5dr_action *dest; + struct mlx5dr_action *reformat; +}; + +struct mlx5dr_action * +mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn, + struct mlx5dr_action_dest *dests, + u32 num_of_dests); + +static inline struct mlx5dr_action * +mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn, + struct mlx5dr_action_dest *dests, + u32 num_of_dests) { return null; } +
|
Networking
|
b8853c969f406bfb682740b7646ee8b4623ee955
|
alex vesker
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, create multiple destination action from dr_create_fte
|
until now it was possible to pass a packet to a single destination such as vport or flow table. with the new support if multiple vports or multiple tables are provided as destinations, fs_dr will create a multiple destination table action, this action should replace other destination actions provided to mlx5dr_create_rule. each vport destination can be provided with a reformat actions which will be done before forwarding the packet to the vport.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c']
| 1
| 72
| 16
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +static bool contain_vport_reformat_action(struct mlx5_flow_rule *dst) +{ + return dst->dest_attr.type == mlx5_flow_destination_type_vport && + dst->dest_attr.vport.flags & mlx5_flow_dest_vport_reformat_id; +} + - struct mlx5dr_action *term_action = null; + struct mlx5dr_action_dest *term_actions; + int num_term_actions = 0; - if (!actions) - return -enomem; + if (!actions) { + err = -enomem; + goto out_err; + } - kfree(actions); - return -enomem; + err = -enomem; + goto free_actions_alloc; + } + + term_actions = kcalloc(mlx5_flow_context_action_max, + sizeof(*term_actions), gfp_kernel); + if (!term_actions) { + err = -enomem; + goto free_fs_dr_actions_alloc; + /* drop reformat action bit if destination vport set with reformat */ + if (fte->action.action & mlx5_flow_context_action_fwd_dest) { + list_for_each_entry(dst, &fte->node.children, node.list) { + if (!contain_vport_reformat_action(dst)) + continue; + + fte->action.action &= ~mlx5_flow_context_action_packet_reformat; + break; + } + } + - term_action = tmp_action; + term_actions[num_term_actions++].dest = tmp_action; - if (num_actions == mlx5_flow_context_action_max) { + if (num_actions == mlx5_flow_context_action_max || + num_term_actions >= mlx5_flow_context_action_max) { - term_action = tmp_action; + term_actions[num_term_actions++].dest = tmp_action; - term_action = tmp_action; + term_actions[num_term_actions].dest = tmp_action; + + if (dst->dest_attr.vport.flags & + mlx5_flow_dest_vport_reformat_id) + term_actions[num_term_actions].reformat = + dst->dest_attr.vport.pkt_reformat->action.dr_action; + + num_term_actions++; - - if (term_action) - actions[num_actions++] = term_action; + if (num_term_actions == 1) { + if (term_actions->reformat) + actions[num_actions++] = term_actions->reformat; + + actions[num_actions++] = term_actions->dest; + } else if (num_term_actions > 1) { + tmp_action = mlx5dr_action_create_mult_dest_tbl(domain, + term_actions, + num_term_actions); + if (!tmp_action) { + err = -eopnotsupp; + goto free_actions; + } + fs_dr_actions[fs_dr_num_actions++] = tmp_action; + actions[num_actions++] = tmp_action; + } + kfree(term_actions); + - for (i = 0; i < fs_dr_num_actions; i++) + /* free in reverse order to handle action dependencies */ + for (i = fs_dr_num_actions - 1; i >= 0; i--) - mlx5_core_err(dev, "failed to create dr rule err(%d) ", err); - kfree(actions); + kfree(term_actions); +free_fs_dr_actions_alloc: +free_actions_alloc: + kfree(actions); +out_err: + mlx5_core_err(dev, "failed to create dr rule err(%d) ", err); - for (i = 0; i < rule->num_actions; i++) + /* free in reverse order to handle action dependencies */ + for (i = rule->num_actions - 1; i >= 0; i--)
|
Networking
|
7ee3f6d2486e25d96d2309da4d53fe10a58e2b63
|
alex vesker
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, allow connecting flow table to a lower/same level table
|
allow connecting sw steering source table to a lower/same level destination table. lifting this limitation is required to support connection tracking.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c']
| 1
| 5
| 2
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c + mlx5_core_warn_once(dmn->mdev, + "connecting table to a lower/same level destination table "); - "destination table level should be higher than source table "); - goto out_invalid_arg; + "connecting table at level %d to a destination table at level %d ", + matcher->tbl->level, + action->dest_tbl.tbl->level);
|
Networking
|
4c7cea2f31f1dde9c578e4729e0d34f340052037
|
yevgeny kliteynik
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, modify header copy support
|
modify header supports add/set and from this patch also copy. copy allows to copy header fields and metadata.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 2
| 151
| 15
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +static int +dr_action_modify_sw_to_hw_copy(struct mlx5dr_domain *dmn, + __be64 *sw_action, + __be64 *hw_action, + const struct dr_action_modify_field_conv **ret_dst_hw_info, + const struct dr_action_modify_field_conv **ret_src_hw_info) +{ + u8 src_offset, dst_offset, src_max_length, dst_max_length, length; + const struct dr_action_modify_field_conv *hw_dst_action_info; + const struct dr_action_modify_field_conv *hw_src_action_info; + u16 src_field, dst_field; + + /* get sw modify action data */ + src_field = mlx5_get(copy_action_in, sw_action, src_field); + dst_field = mlx5_get(copy_action_in, sw_action, dst_field); + src_offset = mlx5_get(copy_action_in, sw_action, src_offset); + dst_offset = mlx5_get(copy_action_in, sw_action, dst_offset); + length = mlx5_get(copy_action_in, sw_action, length); + + /* convert sw data to hw modify action format */ + hw_src_action_info = dr_action_modify_get_hw_info(src_field); + hw_dst_action_info = dr_action_modify_get_hw_info(dst_field); + if (!hw_src_action_info || !hw_dst_action_info) { + mlx5dr_dbg(dmn, "modify copy action invalid field given "); + return -einval; + } + + /* prm defines that length zero specific length of 32bits */ + length = length ? length : 32; + + src_max_length = hw_src_action_info->end - + hw_src_action_info->start + 1; + dst_max_length = hw_dst_action_info->end - + hw_dst_action_info->start + 1; + + if (length + src_offset > src_max_length || + length + dst_offset > dst_max_length) { + mlx5dr_dbg(dmn, "modify action length + offset exceeds limit "); + return -einval; + } + + mlx5_set(dr_action_hw_copy, hw_action, + opcode, mlx5dr_action_mdfy_hw_op_copy); + + mlx5_set(dr_action_hw_copy, hw_action, destination_field_code, + hw_dst_action_info->hw_field); + + mlx5_set(dr_action_hw_copy, hw_action, destination_left_shifter, + hw_dst_action_info->start + dst_offset); + + mlx5_set(dr_action_hw_copy, hw_action, destination_length, + length == 32 ? 0 : length); + + mlx5_set(dr_action_hw_copy, hw_action, source_field_code, + hw_src_action_info->hw_field); + + mlx5_set(dr_action_hw_copy, hw_action, source_left_shifter, + hw_src_action_info->start + dst_offset); + + *ret_dst_hw_info = hw_dst_action_info; + *ret_src_hw_info = hw_src_action_info; + + return 0; +} + - const struct dr_action_modify_field_conv **ret_hw_info) + const struct dr_action_modify_field_conv **ret_dst_hw_info, + const struct dr_action_modify_field_conv **ret_src_hw_info) + *ret_src_hw_info = null; - ret_hw_info); + ret_dst_hw_info); - ret_hw_info); + ret_dst_hw_info); + break; + + case mlx5_action_type_copy: + ret = dr_action_modify_sw_to_hw_copy(dmn, sw_action, + hw_action, + ret_dst_hw_info, + ret_src_hw_info); +static int +dr_action_modify_check_copy_field_limitation(struct mlx5dr_action *action, + const __be64 *sw_action) +{ + struct mlx5dr_domain *dmn = action->rewrite.dmn; + u16 sw_fields[2]; + int i; + + sw_fields[0] = mlx5_get(copy_action_in, sw_action, src_field); + sw_fields[1] = mlx5_get(copy_action_in, sw_action, dst_field); + + for (i = 0; i < 2; i++) { + if (sw_fields[i] == mlx5_action_in_field_metadata_reg_a) { + action->rewrite.allow_rx = 0; + if (dmn->type != mlx5dr_domain_type_nic_tx) { + mlx5dr_dbg(dmn, "unsupported field %d for rx/fdb set action ", + sw_fields[i]); + return -einval; + } + } else if (sw_fields[i] == mlx5_action_in_field_metadata_reg_b) { + action->rewrite.allow_tx = 0; + if (dmn->type != mlx5dr_domain_type_nic_rx) { + mlx5dr_dbg(dmn, "unsupported field %d for tx/fdb set action ", + sw_fields[i]); + return -einval; + } + } + } + + if (!action->rewrite.allow_rx && !action->rewrite.allow_tx) { + mlx5dr_dbg(dmn, "modify copy actions not supported on both rx and tx "); + return -einval; + } + + return 0; +} + + case mlx5_action_type_copy: + ret = dr_action_modify_check_copy_field_limitation(action, + sw_action); + break; + - const struct dr_action_modify_field_conv *hw_action_info; + const struct dr_action_modify_field_conv *hw_dst_action_info; + const struct dr_action_modify_field_conv *hw_src_action_info; - &hw_action_info); + &hw_dst_action_info, + &hw_src_action_info); - if (l3_type && hw_action_info->l3_type && - hw_action_info->l3_type != l3_type) { + if (l3_type && hw_dst_action_info->l3_type && + hw_dst_action_info->l3_type != l3_type) { - if (hw_action_info->l3_type) - l3_type = hw_action_info->l3_type; + if (hw_dst_action_info->l3_type) + l3_type = hw_dst_action_info->l3_type; - if (l4_type && hw_action_info->l4_type && - hw_action_info->l4_type != l4_type) { + if (l4_type && hw_dst_action_info->l4_type && + hw_dst_action_info->l4_type != l4_type) { - if (hw_action_info->l4_type) - l4_type = hw_action_info->l4_type; + if (hw_dst_action_info->l4_type) + l4_type = hw_dst_action_info->l4_type; - if ((hw_idx % 2) && hw_field == hw_action_info->hw_field) { + if ((hw_idx % 2) && (hw_field == hw_dst_action_info->hw_field || + (hw_src_action_info && + hw_field == hw_src_action_info->hw_field))) { - hw_field = hw_action_info->hw_field; + hw_field = hw_dst_action_info->hw_field; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5_ifc_dr.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5_ifc_dr.h --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5_ifc_dr.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5_ifc_dr.h + mlx5dr_action_mdfy_hw_op_copy = 0x1, +struct mlx5_ifc_dr_action_hw_copy_bits { + u8 opcode[0x8]; + u8 destination_field_code[0x8]; + u8 reserved_at_10[0x2]; + u8 destination_left_shifter[0x6]; + u8 reserved_at_18[0x2]; + u8 destination_length[0x6]; + + u8 reserved_at_20[0x8]; + u8 source_field_code[0x8]; + u8 reserved_at_30[0x2]; + u8 source_left_shifter[0x6]; + u8 reserved_at_38[0x8]; +}; +
|
Networking
|
c21a49b360e16657f42f1a9269c3aa714738fec7
|
hamdan igbaria
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: dr, modify set action limitation extension
|
modify set actions are not supported on both tx and rx, added a check for that. also refactored the code in a way that every modify action has his own functions, this needed so in the future we could add copy action more smoothly.
|
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.
|
software steering support for multi destination steering rules
|
['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']
|
['mlx5 ']
|
['c']
| 1
| 165
| 61
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c -dr_action_modify_sw_to_hw(struct mlx5dr_domain *dmn, - __be64 *sw_action, - __be64 *hw_action, - const struct dr_action_modify_field_conv **ret_hw_info) +dr_action_modify_sw_to_hw_add(struct mlx5dr_domain *dmn, + __be64 *sw_action, + __be64 *hw_action, + const struct dr_action_modify_field_conv **ret_hw_info) - u8 offset, length, max_length, action; + u8 max_length; - u8 hw_opcode; - action = mlx5_get(set_action_in, sw_action, action_type); - length = mlx5_get(set_action_in, sw_action, length); - offset = mlx5_get(set_action_in, sw_action, offset); - mlx5dr_dbg(dmn, "modify action invalid field given "); + mlx5dr_dbg(dmn, "modify add action invalid field given "); - switch (action) { - case mlx5_action_type_set: - hw_opcode = mlx5dr_action_mdfy_hw_op_set; - /* prm defines that length zero specific length of 32bits */ - if (!length) - length = 32; + mlx5_set(dr_action_hw_set, hw_action, + opcode, mlx5dr_action_mdfy_hw_op_add); - if (length + offset > max_length) { - mlx5dr_dbg(dmn, "modify action length + offset exceeds limit "); - return -einval; - } - break; + mlx5_set(dr_action_hw_set, hw_action, destination_field_code, + hw_action_info->hw_field); - case mlx5_action_type_add: - hw_opcode = mlx5dr_action_mdfy_hw_op_add; - offset = 0; - length = max_length; - break; + mlx5_set(dr_action_hw_set, hw_action, destination_left_shifter, + hw_action_info->start); - default: - mlx5dr_info(dmn, "unsupported action_type for modify action "); - return -eopnotsupp; + /* prm defines that length zero specific length of 32bits */ + mlx5_set(dr_action_hw_set, hw_action, destination_length, + max_length == 32 ? 0 : max_length); + + mlx5_set(dr_action_hw_set, hw_action, inline_data, data); + + *ret_hw_info = hw_action_info; + + return 0; +} + +static int +dr_action_modify_sw_to_hw_set(struct mlx5dr_domain *dmn, + __be64 *sw_action, + __be64 *hw_action, + const struct dr_action_modify_field_conv **ret_hw_info) +{ + const struct dr_action_modify_field_conv *hw_action_info; + u8 offset, length, max_length; + u16 sw_field; + u32 data; + + /* get sw modify action data */ + length = mlx5_get(set_action_in, sw_action, length); + offset = mlx5_get(set_action_in, sw_action, offset); + sw_field = mlx5_get(set_action_in, sw_action, field); + data = mlx5_get(set_action_in, sw_action, data); + + /* convert sw data to hw modify action format */ + hw_action_info = dr_action_modify_get_hw_info(sw_field); + if (!hw_action_info) { + mlx5dr_dbg(dmn, "modify set action invalid field given "); + return -einval; - mlx5_set(dr_action_hw_set, hw_action, opcode, hw_opcode); + /* prm defines that length zero specific length of 32bits */ + length = length ? length : 32; + + max_length = hw_action_info->end - hw_action_info->start + 1; + + if (length + offset > max_length) { + mlx5dr_dbg(dmn, "modify action length + offset exceeds limit "); + return -einval; + } + + mlx5_set(dr_action_hw_set, hw_action, + opcode, mlx5dr_action_mdfy_hw_op_set); -dr_action_modify_check_field_limitation(struct mlx5dr_domain *dmn, - const __be64 *sw_action) +dr_action_modify_sw_to_hw(struct mlx5dr_domain *dmn, + __be64 *sw_action, + __be64 *hw_action, + const struct dr_action_modify_field_conv **ret_hw_info) - u16 sw_field; + int ret; - sw_field = mlx5_get(set_action_in, sw_action, field); + *hw_action = 0; + + /* get sw modify action type */ - /* check if sw field is supported in current domain (rx/tx) */ - if (action == mlx5_action_type_set) { - if (sw_field == mlx5_action_in_field_metadata_reg_a) { - if (dmn->type != mlx5dr_domain_type_nic_tx) { - mlx5dr_dbg(dmn, "unsupported field %d for rx/fdb set action ", - sw_field); - return -einval; - } - } + switch (action) { + case mlx5_action_type_set: + ret = dr_action_modify_sw_to_hw_set(dmn, sw_action, + hw_action, + ret_hw_info); + break; - if (sw_field == mlx5_action_in_field_metadata_reg_b) { - if (dmn->type != mlx5dr_domain_type_nic_rx) { - mlx5dr_dbg(dmn, "unsupported field %d for tx/fdb set action ", - sw_field); - return -einval; - } + case mlx5_action_type_add: + ret = dr_action_modify_sw_to_hw_add(dmn, sw_action, + hw_action, + ret_hw_info); + break; + + default: + mlx5dr_info(dmn, "unsupported action_type for modify action "); + ret = -eopnotsupp; + } + + return ret; +} + +static int +dr_action_modify_check_set_field_limitation(struct mlx5dr_action *action, + const __be64 *sw_action) +{ + u16 sw_field = mlx5_get(set_action_in, sw_action, field); + struct mlx5dr_domain *dmn = action->rewrite.dmn; + + if (sw_field == mlx5_action_in_field_metadata_reg_a) { + action->rewrite.allow_rx = 0; + if (dmn->type != mlx5dr_domain_type_nic_tx) { + mlx5dr_dbg(dmn, "unsupported field %d for rx/fdb set action ", + sw_field); + return -einval; - } else if (action == mlx5_action_type_add) { - if (sw_field != mlx5_action_in_field_out_ip_ttl && - sw_field != mlx5_action_in_field_out_ipv6_hoplimit && - sw_field != mlx5_action_in_field_out_tcp_seq_num && - sw_field != mlx5_action_in_field_out_tcp_ack_num) { - mlx5dr_dbg(dmn, "unsupported field %d for add action ", sw_field); + } else if (sw_field == mlx5_action_in_field_metadata_reg_b) { + action->rewrite.allow_tx = 0; + if (dmn->type != mlx5dr_domain_type_nic_rx) { + mlx5dr_dbg(dmn, "unsupported field %d for tx/fdb set action ", + sw_field); - } else { - mlx5dr_info(dmn, "unsupported action %d modify action ", action); - return -eopnotsupp; + } + + if (!action->rewrite.allow_rx && !action->rewrite.allow_tx) { + mlx5dr_dbg(dmn, "modify set actions not supported on both rx and tx "); + return -einval; +static int +dr_action_modify_check_add_field_limitation(struct mlx5dr_action *action, + const __be64 *sw_action) +{ + u16 sw_field = mlx5_get(set_action_in, sw_action, field); + struct mlx5dr_domain *dmn = action->rewrite.dmn; + + if (sw_field != mlx5_action_in_field_out_ip_ttl && + sw_field != mlx5_action_in_field_out_ipv6_hoplimit && + sw_field != mlx5_action_in_field_out_tcp_seq_num && + sw_field != mlx5_action_in_field_out_tcp_ack_num) { + mlx5dr_dbg(dmn, "unsupported field %d for add action ", + sw_field); + return -einval; + } + + return 0; +} + +static int +dr_action_modify_check_field_limitation(struct mlx5dr_action *action, + const __be64 *sw_action) +{ + struct mlx5dr_domain *dmn = action->rewrite.dmn; + u8 action_type; + int ret; + + action_type = mlx5_get(set_action_in, sw_action, action_type); + + switch (action_type) { + case mlx5_action_type_set: + ret = dr_action_modify_check_set_field_limitation(action, + sw_action); + break; + + case mlx5_action_type_add: + ret = dr_action_modify_check_add_field_limitation(action, + sw_action); + break; + + default: + mlx5dr_info(dmn, "unsupported action %d modify action ", + action_type); + ret = -eopnotsupp; + } + + return ret; +} + -static int dr_actions_convert_modify_header(struct mlx5dr_domain *dmn, +static int dr_actions_convert_modify_header(struct mlx5dr_action *action, + struct mlx5dr_domain *dmn = action->rewrite.dmn; + action->rewrite.allow_rx = 1; + action->rewrite.allow_tx = 1; + - ret = dr_action_modify_check_field_limitation(dmn, sw_action); + ret = dr_action_modify_check_field_limitation(action, + sw_action); - ret = dr_actions_convert_modify_header(dmn, + ret = dr_actions_convert_modify_header(action,
|
Networking
|
a51dcc10a04ac476240befb875b0a21388a429cd
|
hamdan igbaria
|
drivers
|
net
|
core, ethernet, mellanox, mlx5, steering
|
net/mlx5: e-switch, refactor chains and priorities
|
to support the entire chain and prio range (32bit + 16bit), instead of a using a static array of chains/prios of limited size, create them dynamically, and use a rhashtable to search for existing chains/prio combinations.
|
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.
|
increase the number of chains and prios
|
['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']
|
['mlx5 ']
|
['c', 'makefile', 'h']
| 7
| 637
| 292
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/makefile b/drivers/net/ethernet/mellanox/mlx5/core/makefile --- a/drivers/net/ethernet/mellanox/mlx5/core/makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/makefile - ecpf.o rdma.o + ecpf.o rdma.o eswitch_offloads_chains.o diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +#include "eswitch_offloads_chains.h" - if (!mlx5_eswitch_prios_supported(esw) || + if (!mlx5_esw_chains_prios_supported(esw) || - * ft offload can use prio range [0, int_max], so we - * normalize it to range [1, mlx5_eswitch_get_prio_range(esw)] + * ft offload can use prio range [0, int_max], so we normalize + * it to range [1, mlx5_esw_chains_get_prio_range(esw)] - if (tmp.common.prio >= mlx5_eswitch_get_prio_range(esw)) + if (tmp.common.prio >= mlx5_esw_chains_get_prio_range(esw)) - tmp.common.chain_index = mlx5_eswitch_get_ft_chain(esw); + tmp.common.chain_index = mlx5_esw_chains_get_ft_chain(esw); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +#include "eswitch_offloads_chains.h" - slow_attr->dest_chain = fdb_tc_slow_path_chain; + slow_attr->flags |= mlx5_esw_attr_flag_slow_path; - slow_attr->dest_chain = fdb_tc_slow_path_chain; + slow_attr->flags |= mlx5_esw_attr_flag_slow_path; - u32 max_chain = mlx5_eswitch_get_chain_range(esw); - u16 max_prio = mlx5_eswitch_get_prio_range(esw); + u32 max_prio, max_chain; - if (!mlx5_eswitch_prios_supported(esw) && attr->prio != 1) { + if (!mlx5_esw_chains_prios_supported(esw) && attr->prio != 1) { + max_chain = mlx5_esw_chains_get_chain_range(esw); + max_prio = mlx5_esw_chains_get_prio_range(esw); - u32 max_chain = mlx5_eswitch_get_chain_range(esw); + u32 max_chain = mlx5_esw_chains_get_chain_range(esw); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h -extern const unsigned int esw_pools[4]; +struct mlx5_esw_chains_priv; - struct { - struct mlx5_flow_table *fdb; - u32 num_rules; - } fdb_prio[fdb_num_chains][fdb_tc_max_prio + 1][fdb_tc_levels_per_prio]; - /* protects fdb_prio table */ - struct mutex fdb_prio_lock; - - int fdb_left[array_size(esw_pools)]; + struct mlx5_esw_chains_priv *esw_chains_priv; -bool -mlx5_eswitch_prios_supported(struct mlx5_eswitch *esw); - -u16 -mlx5_eswitch_get_prio_range(struct mlx5_eswitch *esw); - -u32 -mlx5_eswitch_get_chain_range(struct mlx5_eswitch *esw); - -unsigned int -mlx5_eswitch_get_ft_chain(struct mlx5_eswitch *esw); - +enum { + mlx5_esw_attr_flag_vlan_handled = bit(0), + mlx5_esw_attr_flag_slow_path = bit(1), +}; + - bool vlan_handled; + u32 flags; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +#include "eswitch_offloads_chains.h" - -#define fdb_prio_table(esw, chain, prio, level) \ - (esw)->fdb_table.offloads.fdb_prio[(chain)][(prio)][(level)] - -static struct mlx5_flow_table * -esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level); -static void -esw_put_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level); - -bool mlx5_eswitch_prios_supported(struct mlx5_eswitch *esw) -{ - return (!!(esw->fdb_table.flags & esw_fdb_chains_and_prios_supported)); -} - -u32 mlx5_eswitch_get_chain_range(struct mlx5_eswitch *esw) -{ - if (esw->fdb_table.flags & esw_fdb_chains_and_prios_supported) - return fdb_tc_max_chain; - - return 0; -} - -u32 mlx5_eswitch_get_ft_chain(struct mlx5_eswitch *esw) -{ - return mlx5_eswitch_get_chain_range(esw) + 1; -} - -u16 mlx5_eswitch_get_prio_range(struct mlx5_eswitch *esw) -{ - if (esw->fdb_table.flags & esw_fdb_chains_and_prios_supported) - return fdb_tc_max_prio; - - return 1; -} - - if (attr->dest_chain) { - struct mlx5_flow_table *ft; + struct mlx5_flow_table *ft; - ft = esw_get_prio_table(esw, attr->dest_chain, 1, 0); + if (attr->flags & mlx5_esw_attr_flag_slow_path) { + flow_act.flags |= flow_act_ignore_flow_level; + dest[i].type = mlx5_flow_destination_type_flow_table; + dest[i].ft = esw->fdb_table.offloads.slow_fdb; + i++; + } else if (attr->dest_chain) { + flow_act.flags |= flow_act_ignore_flow_level; + ft = mlx5_esw_chains_get_table(esw, attr->dest_chain, + 1, 0); - fdb = esw_get_prio_table(esw, attr->chain, attr->prio, !!split); + fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio, + !!split); - esw_put_prio_table(esw, attr->chain, attr->prio, !!split); + mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, !!split); - if (attr->dest_chain) - esw_put_prio_table(esw, attr->dest_chain, 1, 0); + if (!(attr->flags & mlx5_esw_attr_flag_slow_path) && attr->dest_chain) + mlx5_esw_chains_put_table(esw, attr->dest_chain, 1, 0); - fast_fdb = esw_get_prio_table(esw, attr->chain, attr->prio, 0); + fast_fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio, 0); - fwd_fdb = esw_get_prio_table(esw, attr->chain, attr->prio, 1); + fwd_fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio, 1); - esw_put_prio_table(esw, attr->chain, attr->prio, 1); + mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 1); - esw_put_prio_table(esw, attr->chain, attr->prio, 0); + mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 0); - esw_put_prio_table(esw, attr->chain, attr->prio, 1); - esw_put_prio_table(esw, attr->chain, attr->prio, 0); + mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 1); + mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 0); - esw_put_prio_table(esw, attr->chain, attr->prio, !!split); + mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, + !!split); - esw_put_prio_table(esw, attr->dest_chain, 1, 0); + mlx5_esw_chains_put_table(esw, attr->dest_chain, 1, 0); - attr->vlan_handled = false; + attr->flags &= ~mlx5_esw_attr_flag_vlan_handled; - attr->vlan_handled = true; + attr->flags |= mlx5_esw_attr_flag_vlan_handled; - attr->vlan_handled = true; + attr->flags |= mlx5_esw_attr_flag_vlan_handled; - if (!attr->vlan_handled) + if (!(attr->flags & mlx5_esw_attr_flag_vlan_handled)) - flow_rule = mlx5_add_flow_rules(esw->fdb_table.offloads.slow_fdb, spec, - &flow_act, &dest, 1); + flow_rule = mlx5_add_flow_rules(esw->fdb_table.offloads.slow_fdb, + spec, &flow_act, &dest, 1); - flow_rule = mlx5_add_flow_rules(esw->fdb_table.offloads.slow_fdb, spec, - &flow_act, &dest, 1); + flow_rule = mlx5_add_flow_rules(esw->fdb_table.offloads.slow_fdb, + spec, &flow_act, &dest, 1); - flow_rule = mlx5_add_flow_rules(esw->fdb_table.offloads.slow_fdb, spec, - &flow_act, &dest, 1); + flow_rule = mlx5_add_flow_rules(esw->fdb_table.offloads.slow_fdb, + spec, &flow_act, &dest, 1); -#define esw_offloads_num_groups 4 - -/* firmware currently has 4 pool of 4 sizes that it supports (esw_pools), - * and a virtual memory region of 16m (esw_size), this region is duplicated - * for each flow table pool. we can allocate up to 16m of each pool, - * and we keep track of how much we used via put/get_sz_to_pool. - * firmware doesn't report any of this for now. - * esw_pool is expected to be sorted from large to small - */ -#define esw_size (16 * 1024 * 1024) -const unsigned int esw_pools[4] = { 4 * 1024 * 1024, 1 * 1024 * 1024, - 64 * 1024, 4 * 1024 }; - -static int -get_sz_from_pool(struct mlx5_eswitch *esw) -{ - int sz = 0, i; - - for (i = 0; i < array_size(esw_pools); i++) { - if (esw->fdb_table.offloads.fdb_left[i]) { - --esw->fdb_table.offloads.fdb_left[i]; - sz = esw_pools[i]; - break; - } - } - - return sz; -} - -static void -put_sz_to_pool(struct mlx5_eswitch *esw, int sz) -{ - int i; - - for (i = 0; i < array_size(esw_pools); i++) { - if (sz >= esw_pools[i]) { - ++esw->fdb_table.offloads.fdb_left[i]; - break; - } - } -} - -static struct mlx5_flow_table * -create_next_size_table(struct mlx5_eswitch *esw, - struct mlx5_flow_namespace *ns, - u16 table_prio, - int level, - u32 flags) -{ - struct mlx5_flow_table_attr ft_attr = {}; - struct mlx5_flow_table *fdb; - int sz; - - sz = get_sz_from_pool(esw); - if (!sz) - return err_ptr(-enospc); - - ft_attr.max_fte = sz; - ft_attr.prio = table_prio; - ft_attr.level = level; - ft_attr.flags = flags; - ft_attr.autogroup.max_num_groups = esw_offloads_num_groups; - fdb = mlx5_create_auto_grouped_flow_table(ns, &ft_attr); - if (is_err(fdb)) { - esw_warn(esw->dev, "failed to create fdb table err %d (table prio: %d, level: %d, size: %d) ", - (int)ptr_err(fdb), table_prio, level, sz); - put_sz_to_pool(esw, sz); - } - - return fdb; -} - -static struct mlx5_flow_table * -esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level) -{ - struct mlx5_core_dev *dev = esw->dev; - struct mlx5_flow_table *fdb = null; - struct mlx5_flow_namespace *ns; - int table_prio, l = 0; - u32 flags = 0; - - if (chain == fdb_tc_slow_path_chain) - return esw->fdb_table.offloads.slow_fdb; - - mutex_lock(&esw->fdb_table.offloads.fdb_prio_lock); - - fdb = fdb_prio_table(esw, chain, prio, level).fdb; - if (fdb) { - /* take ref on earlier levels as well */ - while (level >= 0) - fdb_prio_table(esw, chain, prio, level--).num_rules++; - mutex_unlock(&esw->fdb_table.offloads.fdb_prio_lock); - return fdb; - } - - ns = mlx5_get_fdb_sub_ns(dev, chain); - if (!ns) { - esw_warn(dev, "failed to get fdb sub namespace "); - mutex_unlock(&esw->fdb_table.offloads.fdb_prio_lock); - return err_ptr(-eopnotsupp); - } - - if (esw->offloads.encap != devlink_eswitch_encap_mode_none) - flags |= (mlx5_flow_table_tunnel_en_reformat | - mlx5_flow_table_tunnel_en_decap); - - table_prio = prio - 1; - - /* create earlier levels for correct fs_core lookup when - * connecting tables - */ - for (l = 0; l <= level; l++) { - if (fdb_prio_table(esw, chain, prio, l).fdb) { - fdb_prio_table(esw, chain, prio, l).num_rules++; - continue; - } - - fdb = create_next_size_table(esw, ns, table_prio, l, flags); - if (is_err(fdb)) { - l--; - goto err_create_fdb; - } - - fdb_prio_table(esw, chain, prio, l).fdb = fdb; - fdb_prio_table(esw, chain, prio, l).num_rules = 1; - } - - mutex_unlock(&esw->fdb_table.offloads.fdb_prio_lock); - return fdb; - -err_create_fdb: - mutex_unlock(&esw->fdb_table.offloads.fdb_prio_lock); - if (l >= 0) - esw_put_prio_table(esw, chain, prio, l); - - return fdb; -} - -static void -esw_put_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level) -{ - int l; - - if (chain == fdb_tc_slow_path_chain) - return; - - mutex_lock(&esw->fdb_table.offloads.fdb_prio_lock); - - for (l = level; l >= 0; l--) { - if (--(fdb_prio_table(esw, chain, prio, l).num_rules) > 0) - continue; - - put_sz_to_pool(esw, fdb_prio_table(esw, chain, prio, l).fdb->max_fte); - mlx5_destroy_flow_table(fdb_prio_table(esw, chain, prio, l).fdb); - fdb_prio_table(esw, chain, prio, l).fdb = null; - } - - mutex_unlock(&esw->fdb_table.offloads.fdb_prio_lock); -} - -static void esw_destroy_offloads_fast_fdb_tables(struct mlx5_eswitch *esw) -{ - /* if lazy creation isn't supported, deref the fast path tables */ - if (!(esw->fdb_table.flags & esw_fdb_chains_and_prios_supported)) { - esw_put_prio_table(esw, 0, 1, 1); - esw_put_prio_table(esw, 0, 1, 0); - } -} - - u32 *flow_group_in, max_flow_counter; - int table_size, ix, err = 0, i; + u32 flags = 0, *flow_group_in; + int table_size, ix, err = 0; - u32 flags = 0, fdb_max; + - max_flow_counter = (mlx5_cap_gen(dev, max_flow_counter_31_16) << 16) | - mlx5_cap_gen(dev, max_flow_counter_15_0); - fdb_max = 1 << mlx5_cap_esw_flowtable_fdb(dev, log_max_ft_size); - - esw_debug(dev, "create offloads fdb table, min (max esw size(2^%d), max counters(%d), groups(%d), max flow table size(%d)) ", - mlx5_cap_esw_flowtable_fdb(dev, log_max_ft_size), - max_flow_counter, esw_offloads_num_groups, - fdb_max); - - for (i = 0; i < array_size(esw_pools); i++) - esw->fdb_table.offloads.fdb_left[i] = - esw_pools[i] <= fdb_max ? esw_size / esw_pools[i] : 0; - - /* if lazy creation isn't supported, open the fast path tables now */ - if (!mlx5_cap_esw_flowtable(esw->dev, multi_fdb_encap) && - esw->offloads.encap != devlink_eswitch_encap_mode_none) { - esw->fdb_table.flags &= ~esw_fdb_chains_and_prios_supported; - esw_warn(dev, "lazy creation of flow tables isn't supported, ignoring priorities "); - esw_get_prio_table(esw, 0, 1, 0); - esw_get_prio_table(esw, 0, 1, 1); - } else { - esw_debug(dev, "lazy creation of flow tables supported, deferring table opening "); - esw->fdb_table.flags |= esw_fdb_chains_and_prios_supported; + err = mlx5_esw_chains_create(esw); + if (err) { + esw_warn(dev, "failed to create fdb chains err(%d) ", err); + goto fdb_chains_err; - esw_destroy_offloads_fast_fdb_tables(esw); + mlx5_esw_chains_destroy(esw); +fdb_chains_err: + mlx5_esw_chains_destroy(esw); - esw_destroy_offloads_fast_fdb_tables(esw); - mutex_init(&esw->fdb_table.offloads.fdb_prio_lock); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c +// spdx-license-identifier: gpl-2.0 or linux-openib +// copyright (c) 2020 mellanox technologies. + +#include <linux/mlx5/driver.h> +#include <linux/mlx5/mlx5_ifc.h> +#include <linux/mlx5/fs.h> + +#include "eswitch_offloads_chains.h" +#include "mlx5_core.h" +#include "fs_core.h" +#include "eswitch.h" +#include "en.h" + +#define esw_chains_priv(esw) ((esw)->fdb_table.offloads.esw_chains_priv) +#define esw_chains_lock(esw) (esw_chains_priv(esw)->lock) +#define esw_chains_ht(esw) (esw_chains_priv(esw)->chains_ht) +#define esw_prios_ht(esw) (esw_chains_priv(esw)->prios_ht) +#define fdb_pool_left(esw) (esw_chains_priv(esw)->fdb_left) + +#define esw_offloads_num_groups 4 + +/* firmware currently has 4 pool of 4 sizes that it supports (esw_pools), + * and a virtual memory region of 16m (esw_size), this region is duplicated + * for each flow table pool. we can allocate up to 16m of each pool, + * and we keep track of how much we used via get_next_avail_sz_from_pool. + * firmware doesn't report any of this for now. + * esw_pool is expected to be sorted from large to small and match firmware + * pools. + */ +#define esw_size (16 * 1024 * 1024) +const unsigned int esw_pools[] = { 4 * 1024 * 1024, + 1 * 1024 * 1024, + 64 * 1024, + 4 * 1024, }; + +struct mlx5_esw_chains_priv { + struct rhashtable chains_ht; + struct rhashtable prios_ht; + /* protects above chains_ht and prios_ht */ + struct mutex lock; + + int fdb_left[array_size(esw_pools)]; +}; + +struct fdb_chain { + struct rhash_head node; + + u32 chain; + + int ref; + + struct mlx5_eswitch *esw; +}; + +struct fdb_prio_key { + u32 chain; + u32 prio; + u32 level; +}; + +struct fdb_prio { + struct rhash_head node; + + struct fdb_prio_key key; + + int ref; + + struct fdb_chain *fdb_chain; + struct mlx5_flow_table *fdb; +}; + +static const struct rhashtable_params chain_params = { + .head_offset = offsetof(struct fdb_chain, node), + .key_offset = offsetof(struct fdb_chain, chain), + .key_len = sizeof_field(struct fdb_chain, chain), + .automatic_shrinking = true, +}; + +static const struct rhashtable_params prio_params = { + .head_offset = offsetof(struct fdb_prio, node), + .key_offset = offsetof(struct fdb_prio, key), + .key_len = sizeof_field(struct fdb_prio, key), + .automatic_shrinking = true, +}; + +bool mlx5_esw_chains_prios_supported(struct mlx5_eswitch *esw) +{ + return esw->fdb_table.flags & esw_fdb_chains_and_prios_supported; +} + +u32 mlx5_esw_chains_get_chain_range(struct mlx5_eswitch *esw) +{ + if (!mlx5_esw_chains_prios_supported(esw)) + return 1; + + return fdb_tc_max_chain; +} + +u32 mlx5_esw_chains_get_ft_chain(struct mlx5_eswitch *esw) +{ + return mlx5_esw_chains_get_chain_range(esw) + 1; +} + +u32 mlx5_esw_chains_get_prio_range(struct mlx5_eswitch *esw) +{ + if (!mlx5_esw_chains_prios_supported(esw)) + return 1; + + return fdb_tc_max_prio; +} + +static unsigned int mlx5_esw_chains_get_level_range(struct mlx5_eswitch *esw) +{ + return fdb_tc_levels_per_prio; +} + +#define pool_next_size 0 +static int +mlx5_esw_chains_get_avail_sz_from_pool(struct mlx5_eswitch *esw, + int desired_size) +{ + int i, found_i = -1; + + for (i = array_size(esw_pools) - 1; i >= 0; i--) { + if (fdb_pool_left(esw)[i] && esw_pools[i] > desired_size) { + found_i = i; + if (desired_size != pool_next_size) + break; + } + } + + if (found_i != -1) { + --fdb_pool_left(esw)[found_i]; + return esw_pools[found_i]; + } + + return 0; +} + +static void +mlx5_esw_chains_put_sz_to_pool(struct mlx5_eswitch *esw, int sz) +{ + int i; + + for (i = array_size(esw_pools) - 1; i >= 0; i--) { + if (sz == esw_pools[i]) { + ++fdb_pool_left(esw)[i]; + return; + } + } + + warn_once(1, "couldn't find size %d in fdb size pool", sz); +} + +static void +mlx5_esw_chains_init_sz_pool(struct mlx5_eswitch *esw) +{ + u32 fdb_max; + int i; + + fdb_max = 1 << mlx5_cap_esw_flowtable_fdb(esw->dev, log_max_ft_size); + + for (i = array_size(esw_pools) - 1; i >= 0; i--) + fdb_pool_left(esw)[i] = + esw_pools[i] <= fdb_max ? esw_size / esw_pools[i] : 0; +} + +static struct mlx5_flow_table * +mlx5_esw_chains_create_fdb_table(struct mlx5_eswitch *esw, + u32 chain, u32 prio, u32 level) +{ + struct mlx5_flow_table_attr ft_attr = {}; + struct mlx5_flow_namespace *ns; + struct mlx5_flow_table *fdb; + int sz; + + if (esw->offloads.encap != devlink_eswitch_encap_mode_none) + ft_attr.flags |= (mlx5_flow_table_tunnel_en_reformat | + mlx5_flow_table_tunnel_en_decap); + + sz = mlx5_esw_chains_get_avail_sz_from_pool(esw, pool_next_size); + if (!sz) + return err_ptr(-enospc); + + ft_attr.max_fte = sz; + ft_attr.level = level; + ft_attr.prio = prio - 1; + ft_attr.autogroup.max_num_groups = esw_offloads_num_groups; + ns = mlx5_get_fdb_sub_ns(esw->dev, chain); + + fdb = mlx5_create_auto_grouped_flow_table(ns, &ft_attr); + if (is_err(fdb)) { + esw_warn(esw->dev, + "failed to create fdb table err %d (chain: %d, prio: %d, level: %d, size: %d) ", + (int)ptr_err(fdb), chain, prio, level, sz); + mlx5_esw_chains_put_sz_to_pool(esw, sz); + return fdb; + } + + return fdb; +} + +static void +mlx5_esw_chains_destroy_fdb_table(struct mlx5_eswitch *esw, + struct mlx5_flow_table *fdb) +{ + mlx5_esw_chains_put_sz_to_pool(esw, fdb->max_fte); + mlx5_destroy_flow_table(fdb); +} + +static struct fdb_chain * +mlx5_esw_chains_create_fdb_chain(struct mlx5_eswitch *esw, u32 chain) +{ + struct fdb_chain *fdb_chain = null; + int err; + + fdb_chain = kvzalloc(sizeof(*fdb_chain), gfp_kernel); + if (!fdb_chain) + return err_ptr(-enomem); + + fdb_chain->esw = esw; + fdb_chain->chain = chain; + + err = rhashtable_insert_fast(&esw_chains_ht(esw), &fdb_chain->node, + chain_params); + if (err) + goto err_insert; + + return fdb_chain; + +err_insert: + kvfree(fdb_chain); + return err_ptr(err); +} + +static void +mlx5_esw_chains_destroy_fdb_chain(struct fdb_chain *fdb_chain) +{ + struct mlx5_eswitch *esw = fdb_chain->esw; + + rhashtable_remove_fast(&esw_chains_ht(esw), &fdb_chain->node, + chain_params); + kvfree(fdb_chain); +} + +static struct fdb_chain * +mlx5_esw_chains_get_fdb_chain(struct mlx5_eswitch *esw, u32 chain) +{ + struct fdb_chain *fdb_chain; + + fdb_chain = rhashtable_lookup_fast(&esw_chains_ht(esw), &chain, + chain_params); + if (!fdb_chain) { + fdb_chain = mlx5_esw_chains_create_fdb_chain(esw, chain); + if (is_err(fdb_chain)) + return fdb_chain; + } + + fdb_chain->ref++; + + return fdb_chain; +} + +static void +mlx5_esw_chains_put_fdb_chain(struct fdb_chain *fdb_chain) +{ + if (--fdb_chain->ref == 0) + mlx5_esw_chains_destroy_fdb_chain(fdb_chain); +} + +static struct fdb_prio * +mlx5_esw_chains_create_fdb_prio(struct mlx5_eswitch *esw, + u32 chain, u32 prio, u32 level) +{ + struct fdb_prio *fdb_prio = null; + struct fdb_chain *fdb_chain; + struct mlx5_flow_table *fdb; + int err; + + fdb_chain = mlx5_esw_chains_get_fdb_chain(esw, chain); + if (is_err(fdb_chain)) + return err_cast(fdb_chain); + + fdb_prio = kvzalloc(sizeof(*fdb_prio), gfp_kernel); + if (!fdb_prio) { + err = -enomem; + goto err_alloc; + } + + fdb = mlx5_esw_chains_create_fdb_table(esw, fdb_chain->chain, prio, + level); + if (is_err(fdb)) { + err = ptr_err(fdb); + goto err_create; + } + + fdb_prio->fdb_chain = fdb_chain; + fdb_prio->key.chain = chain; + fdb_prio->key.prio = prio; + fdb_prio->key.level = level; + fdb_prio->fdb = fdb; + + err = rhashtable_insert_fast(&esw_prios_ht(esw), &fdb_prio->node, + prio_params); + if (err) + goto err_insert; + + return fdb_prio; + +err_insert: + mlx5_esw_chains_destroy_fdb_table(esw, fdb); +err_create: + kvfree(fdb_prio); +err_alloc: + mlx5_esw_chains_put_fdb_chain(fdb_chain); + return err_ptr(err); +} + +static void +mlx5_esw_chains_destroy_fdb_prio(struct mlx5_eswitch *esw, + struct fdb_prio *fdb_prio) +{ + struct fdb_chain *fdb_chain = fdb_prio->fdb_chain; + + rhashtable_remove_fast(&esw_prios_ht(esw), &fdb_prio->node, + prio_params); + mlx5_esw_chains_destroy_fdb_table(esw, fdb_prio->fdb); + mlx5_esw_chains_put_fdb_chain(fdb_chain); + kvfree(fdb_prio); +} + +struct mlx5_flow_table * +mlx5_esw_chains_get_table(struct mlx5_eswitch *esw, u32 chain, u32 prio, + u32 level) +{ + struct mlx5_flow_table *prev_fts; + struct fdb_prio *fdb_prio; + struct fdb_prio_key key; + int l = 0; + + if ((chain > mlx5_esw_chains_get_chain_range(esw) && + chain != mlx5_esw_chains_get_ft_chain(esw)) || + prio > mlx5_esw_chains_get_prio_range(esw) || + level > mlx5_esw_chains_get_level_range(esw)) + return err_ptr(-eopnotsupp); + + /* create earlier levels for correct fs_core lookup when + * connecting tables. + */ + for (l = 0; l < level; l++) { + prev_fts = mlx5_esw_chains_get_table(esw, chain, prio, l); + if (is_err(prev_fts)) { + fdb_prio = err_cast(prev_fts); + goto err_get_prevs; + } + } + + key.chain = chain; + key.prio = prio; + key.level = level; + + mutex_lock(&esw_chains_lock(esw)); + fdb_prio = rhashtable_lookup_fast(&esw_prios_ht(esw), &key, + prio_params); + if (!fdb_prio) { + fdb_prio = mlx5_esw_chains_create_fdb_prio(esw, chain, + prio, level); + if (is_err(fdb_prio)) + goto err_create_prio; + } + + ++fdb_prio->ref; + mutex_unlock(&esw_chains_lock(esw)); + + return fdb_prio->fdb; + +err_create_prio: + mutex_unlock(&esw_chains_lock(esw)); +err_get_prevs: + while (--l >= 0) + mlx5_esw_chains_put_table(esw, chain, prio, l); + return err_cast(fdb_prio); +} + +void +mlx5_esw_chains_put_table(struct mlx5_eswitch *esw, u32 chain, u32 prio, + u32 level) +{ + struct fdb_prio *fdb_prio; + struct fdb_prio_key key; + + key.chain = chain; + key.prio = prio; + key.level = level; + + mutex_lock(&esw_chains_lock(esw)); + fdb_prio = rhashtable_lookup_fast(&esw_prios_ht(esw), &key, + prio_params); + if (!fdb_prio) + goto err_get_prio; + + if (--fdb_prio->ref == 0) + mlx5_esw_chains_destroy_fdb_prio(esw, fdb_prio); + mutex_unlock(&esw_chains_lock(esw)); + + while (level-- > 0) + mlx5_esw_chains_put_table(esw, chain, prio, level); + + return; + +err_get_prio: + mutex_unlock(&esw_chains_lock(esw)); + warn_once(1, + "couldn't find table: (chain: %d prio: %d level: %d)", + chain, prio, level); +} + +static int +mlx5_esw_chains_init(struct mlx5_eswitch *esw) +{ + struct mlx5_esw_chains_priv *chains_priv; + struct mlx5_core_dev *dev = esw->dev; + u32 max_flow_counter, fdb_max; + int err; + + chains_priv = kzalloc(sizeof(*chains_priv), gfp_kernel); + if (!chains_priv) + return -enomem; + esw_chains_priv(esw) = chains_priv; + + max_flow_counter = (mlx5_cap_gen(dev, max_flow_counter_31_16) << 16) | + mlx5_cap_gen(dev, max_flow_counter_15_0); + fdb_max = 1 << mlx5_cap_esw_flowtable_fdb(dev, log_max_ft_size); + + esw_debug(dev, + "init esw offloads chains, max counters(%d), groups(%d), max flow table size(%d) ", + max_flow_counter, esw_offloads_num_groups, fdb_max); + + mlx5_esw_chains_init_sz_pool(esw); + + if (!mlx5_cap_esw_flowtable(esw->dev, multi_fdb_encap) && + esw->offloads.encap != devlink_eswitch_encap_mode_none) { + esw->fdb_table.flags &= ~esw_fdb_chains_and_prios_supported; + esw_warn(dev, "tc chains and priorities offload aren't supported, update firmware if needed "); + } else { + esw->fdb_table.flags |= esw_fdb_chains_and_prios_supported; + esw_info(dev, "supported tc offload range - chains: %u, prios: %u ", + mlx5_esw_chains_get_chain_range(esw), + mlx5_esw_chains_get_prio_range(esw)); + } + + err = rhashtable_init(&esw_chains_ht(esw), &chain_params); + if (err) + goto init_chains_ht_err; + + err = rhashtable_init(&esw_prios_ht(esw), &prio_params); + if (err) + goto init_prios_ht_err; + + mutex_init(&esw_chains_lock(esw)); + + return 0; + +init_prios_ht_err: + rhashtable_destroy(&esw_chains_ht(esw)); +init_chains_ht_err: + kfree(chains_priv); + return err; +} + +static void +mlx5_esw_chains_cleanup(struct mlx5_eswitch *esw) +{ + mutex_destroy(&esw_chains_lock(esw)); + rhashtable_destroy(&esw_prios_ht(esw)); + rhashtable_destroy(&esw_chains_ht(esw)); + + kfree(esw_chains_priv(esw)); +} + +static int +mlx5_esw_chains_open(struct mlx5_eswitch *esw) +{ + struct mlx5_flow_table *ft; + int err; + + /* always open the root for fast path */ + ft = mlx5_esw_chains_get_table(esw, 0, 1, 0); + if (is_err(ft)) + return ptr_err(ft); + + /* open level 1 for split rules now if prios isn't supported */ + if (!mlx5_esw_chains_prios_supported(esw)) { + ft = mlx5_esw_chains_get_table(esw, 0, 1, 1); + + if (is_err(ft)) { + err = ptr_err(ft); + goto level_1_err; + } + } + + return 0; + +level_1_err: + mlx5_esw_chains_put_table(esw, 0, 1, 0); + return err; +} + +static void +mlx5_esw_chains_close(struct mlx5_eswitch *esw) +{ + if (!mlx5_esw_chains_prios_supported(esw)) + mlx5_esw_chains_put_table(esw, 0, 1, 1); + mlx5_esw_chains_put_table(esw, 0, 1, 0); +} + +int +mlx5_esw_chains_create(struct mlx5_eswitch *esw) +{ + int err; + + err = mlx5_esw_chains_init(esw); + if (err) + return err; + + err = mlx5_esw_chains_open(esw); + if (err) + goto err_open; + + return 0; + +err_open: + mlx5_esw_chains_cleanup(esw); + return err; +} + +void +mlx5_esw_chains_destroy(struct mlx5_eswitch *esw) +{ + mlx5_esw_chains_close(esw); + mlx5_esw_chains_cleanup(esw); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h +/* spdx-license-identifier: gpl-2.0 or linux-openib */ +/* copyright (c) 2020 mellanox technologies. */ + +#ifndef __ml5_esw_chains_h__ +#define __ml5_esw_chains_h__ + +bool +mlx5_esw_chains_prios_supported(struct mlx5_eswitch *esw); +u32 +mlx5_esw_chains_get_prio_range(struct mlx5_eswitch *esw); +u32 +mlx5_esw_chains_get_chain_range(struct mlx5_eswitch *esw); +u32 +mlx5_esw_chains_get_ft_chain(struct mlx5_eswitch *esw); + +struct mlx5_flow_table * +mlx5_esw_chains_get_table(struct mlx5_eswitch *esw, u32 chain, u32 prio, + u32 level); +void +mlx5_esw_chains_put_table(struct mlx5_eswitch *esw, u32 chain, u32 prio, + u32 level); + +int mlx5_esw_chains_create(struct mlx5_eswitch *esw); +void mlx5_esw_chains_destroy(struct mlx5_eswitch *esw); + +#endif /* __ml5_esw_chains_h__ */ +
|
Networking
|
39ac237ce00968545e7298faa9e07ecb7e440fb5
|
paul blakey
|
drivers
|
net
|
core, ethernet, mellanox, mlx5
|
net/mlx5: e-switch, increase number of chains and priorities
|
increase the number of chains and priorities to support the whole range available in tc.
|
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.
|
increase the number of chains and prios
|
['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']
|
['mlx5 ']
|
['c', 'h']
| 3
| 232
| 12
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c - dest[i].ft = esw->fdb_table.offloads.slow_fdb; + dest[i].ft = mlx5_esw_chains_get_tc_end_ft(esw); + flow_act.flags |= flow_act_ignore_flow_level; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c +#define tc_slow_fdb(esw) ((esw)->fdb_table.offloads.slow_fdb) +#define tc_end_fdb(esw) (esw_chains_priv(esw)->tc_end_fdb) +#define fdb_ignore_flow_level_supported(esw) \ + (mlx5_cap_esw_flowtable_fdb((esw)->dev, ignore_flow_level)) + struct mlx5_flow_table *tc_end_fdb; + + struct list_head prios_list; + struct list_head list; + struct mlx5_flow_table *next_fdb; + struct mlx5_flow_group *miss_group; + struct mlx5_flow_handle *miss_rule; + if (fdb_ignore_flow_level_supported(esw)) + return uint_max - 1; + + if (fdb_ignore_flow_level_supported(esw)) + return uint_max; + + if (fdb_ignore_flow_level_supported(esw)) + return uint_max; + - - ft_attr.level = level; - ft_attr.prio = prio - 1; - ft_attr.autogroup.max_num_groups = esw_offloads_num_groups; - ns = mlx5_get_fdb_sub_ns(esw->dev, chain); + /* we use tc_slow_fdb(esw) as the table's next_ft till + * ignore_flow_level is allowed on ft creation and not just for ftes. + * instead caller should add an explicit miss rule if needed. + */ + ft_attr.next_ft = tc_slow_fdb(esw); + + /* the root table(chain 0, prio 1, level 0) is required to be + * connected to the previous prio (fdb_bypass_path if exists). + * we always create it, as a managed table, in order to align with + * fs_core logic. + */ + if (!fdb_ignore_flow_level_supported(esw) || + (chain == 0 && prio == 1 && level == 0)) { + ft_attr.level = level; + ft_attr.prio = prio - 1; + ns = mlx5_get_fdb_sub_ns(esw->dev, chain); + } else { + ft_attr.flags |= mlx5_flow_table_unmanaged; + ft_attr.prio = fdb_tc_offload; + /* firmware doesn't allow us to create another level 0 table, + * so we create all unmanaged tables as level 1. + * + * to connect them, we use explicit miss rules with + * ignore_flow_level. caller is responsible to create + * these rules (if needed). + */ + ft_attr.level = 1; + ns = mlx5_get_flow_namespace(esw->dev, mlx5_flow_namespace_fdb); + } + + ft_attr.autogroup.num_reserved_entries = 2; + ft_attr.autogroup.max_num_groups = esw_offloads_num_groups; + init_list_head(&fdb_chain->prios_list); +static struct mlx5_flow_handle * +mlx5_esw_chains_add_miss_rule(struct mlx5_flow_table *fdb, + struct mlx5_flow_table *next_fdb) +{ + static const struct mlx5_flow_spec spec = {}; + struct mlx5_flow_destination dest = {}; + struct mlx5_flow_act act = {}; + + act.flags = flow_act_ignore_flow_level | flow_act_no_append; + act.action = mlx5_flow_context_action_fwd_dest; + dest.type = mlx5_flow_destination_type_flow_table; + dest.ft = next_fdb; + + return mlx5_add_flow_rules(fdb, &spec, &act, &dest, 1); +} + +static int +mlx5_esw_chains_update_prio_prevs(struct fdb_prio *fdb_prio, + struct mlx5_flow_table *next_fdb) +{ + struct mlx5_flow_handle *miss_rules[fdb_tc_levels_per_prio + 1] = {}; + struct fdb_chain *fdb_chain = fdb_prio->fdb_chain; + struct fdb_prio *pos; + int n = 0, err; + + if (fdb_prio->key.level) + return 0; + + /* iterate in reverse order until reaching the level 0 rule of + * the previous priority, adding all the miss rules first, so we can + * revert them if any of them fails. + */ + pos = fdb_prio; + list_for_each_entry_continue_reverse(pos, + &fdb_chain->prios_list, + list) { + miss_rules[n] = mlx5_esw_chains_add_miss_rule(pos->fdb, + next_fdb); + if (is_err(miss_rules[n])) { + err = ptr_err(miss_rules[n]); + goto err_prev_rule; + } + + n++; + if (!pos->key.level) + break; + } + + /* success, delete old miss rules, and update the pointers. */ + n = 0; + pos = fdb_prio; + list_for_each_entry_continue_reverse(pos, + &fdb_chain->prios_list, + list) { + mlx5_del_flow_rules(pos->miss_rule); + + pos->miss_rule = miss_rules[n]; + pos->next_fdb = next_fdb; + + n++; + if (!pos->key.level) + break; + } + + return 0; + +err_prev_rule: + while (--n >= 0) + mlx5_del_flow_rules(miss_rules[n]); + + return err; +} + + int inlen = mlx5_st_sz_bytes(create_flow_group_in); + struct mlx5_flow_handle *miss_rule = null; + struct mlx5_flow_group *miss_group; + struct mlx5_flow_table *next_fdb; + struct list_head *pos; + u32 *flow_group_in; - if (!fdb_prio) { + flow_group_in = kvzalloc(inlen, gfp_kernel); + if (!fdb_prio || !flow_group_in) { - fdb = mlx5_esw_chains_create_fdb_table(esw, fdb_chain->chain, prio, - level); + /* chain's prio list is sorted by prio and level. + * and all levels of some prio point to the next prio's level 0. + * example list (prio, level): + * (3,0)->(3,1)->(5,0)->(5,1)->(6,1)->(7,0) + * in hardware, we will we have the following pointers: + * (3,0) -> (5,0) -> (7,0) -> slow path + * (3,1) -> (5,0) + * (5,1) -> (7,0) + * (6,1) -> (7,0) + */ + + /* default miss for each chain: */ + next_fdb = (chain == mlx5_esw_chains_get_ft_chain(esw)) ? + tc_slow_fdb(esw) : + tc_end_fdb(esw); + list_for_each(pos, &fdb_chain->prios_list) { + struct fdb_prio *p = list_entry(pos, struct fdb_prio, list); + + /* exit on first pos that is larger */ + if (prio < p->key.prio || (prio == p->key.prio && + level < p->key.level)) { + /* get next level 0 table */ + next_fdb = p->key.level == 0 ? p->fdb : p->next_fdb; + break; + } + } + + fdb = mlx5_esw_chains_create_fdb_table(esw, chain, prio, level); + mlx5_set(create_flow_group_in, flow_group_in, start_flow_index, + fdb->max_fte - 2); + mlx5_set(create_flow_group_in, flow_group_in, end_flow_index, + fdb->max_fte - 1); + miss_group = mlx5_create_flow_group(fdb, flow_group_in); + if (is_err(miss_group)) { + err = ptr_err(miss_group); + goto err_group; + } + + /* add miss rule to next_fdb */ + miss_rule = mlx5_esw_chains_add_miss_rule(fdb, next_fdb); + if (is_err(miss_rule)) { + err = ptr_err(miss_rule); + goto err_miss_rule; + } + + fdb_prio->miss_group = miss_group; + fdb_prio->miss_rule = miss_rule; + fdb_prio->next_fdb = next_fdb; + list_add(&fdb_prio->list, pos->prev); + + /* table is ready, connect it */ + err = mlx5_esw_chains_update_prio_prevs(fdb_prio, fdb); + if (err) + goto err_update; + + kvfree(flow_group_in); +err_update: + list_del(&fdb_prio->list); + rhashtable_remove_fast(&esw_prios_ht(esw), &fdb_prio->node, + prio_params); + mlx5_del_flow_rules(miss_rule); +err_miss_rule: + mlx5_destroy_flow_group(miss_group); +err_group: - kvfree(fdb_prio); + kvfree(fdb_prio); + kvfree(flow_group_in); + warn_on(mlx5_esw_chains_update_prio_prevs(fdb_prio, + fdb_prio->next_fdb)); + + list_del(&fdb_prio->list); + mlx5_del_flow_rules(fdb_prio->miss_rule); + mlx5_destroy_flow_group(fdb_prio->miss_group); +struct mlx5_flow_table * +mlx5_esw_chains_get_tc_end_ft(struct mlx5_eswitch *esw) +{ + return tc_end_fdb(esw); +} + - /* always open the root for fast path */ - ft = mlx5_esw_chains_get_table(esw, 0, 1, 0); + /* create tc_end_fdb(esw) which is the always created ft chain */ + ft = mlx5_esw_chains_get_table(esw, mlx5_esw_chains_get_ft_chain(esw), + 1, 0); + tc_end_fdb(esw) = ft; + + /* always open the root for fast path */ + ft = mlx5_esw_chains_get_table(esw, 0, 1, 0); + if (is_err(ft)) { + err = ptr_err(ft); + goto level_0_err; + } + +level_0_err: + mlx5_esw_chains_put_table(esw, mlx5_esw_chains_get_ft_chain(esw), 1, 0); + mlx5_esw_chains_put_table(esw, mlx5_esw_chains_get_ft_chain(esw), 1, 0); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h +struct mlx5_flow_table * +mlx5_esw_chains_get_tc_end_ft(struct mlx5_eswitch *esw); +
|
Networking
|
278d51f24330718aefd7fe86996a6da66fd345e7
|
paul blakey
|
drivers
|
net
|
core, ethernet, mellanox, mlx5
|
net/mlx5: increase the max number of channels to 128
|
currently the max number of channels is limited to 64, which is half of the indirection table size to allow some flexibility. but on servers with more than 64 cores, users may want to utilize more queues.
|
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.
|
increase the max number of channels to 128
|
['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']
|
['mlx5 ']
|
['h', 'c']
| 3
| 12
| 10
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h -#define mlx5e_max_num_channels (mlx5e_indir_rqt_size >> 1) +#define mlx5e_max_num_channels mlx5e_indir_rqt_size -void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, +void mlx5e_build_nic_params(struct mlx5e_priv *priv, - u16 max_channels, u16 mtu); + u16 mtu); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c -void mlx5e_build_nic_params(struct mlx5_core_dev *mdev, +void mlx5e_build_nic_params(struct mlx5e_priv *priv, - u16 max_channels, u16 mtu) + u16 mtu) + struct mlx5_core_dev *mdev = priv->mdev; - params->num_channels = max_channels; + params->num_channels = min_t(unsigned int, mlx5e_max_num_channels / 2, + priv->max_nch); - mlx5e_build_nic_params(mdev, &priv->xsk, rss, &priv->channels.params, - priv->max_nch, netdev->mtu); + mlx5e_build_nic_params(priv, &priv->xsk, rss, &priv->channels.params, + netdev->mtu); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c - mlx5e_build_nic_params(mdev, null, &priv->rss_params, &priv->channels.params, - priv->max_nch, netdev->mtu); + mlx5e_build_nic_params(priv, null, &priv->rss_params, &priv->channels.params, + netdev->mtu);
|
Networking
|
57c7fce14b1ad512a42abe33cb721a2ea3520d4b
|
fan li
|
drivers
|
net
|
core, ethernet, ipoib, mellanox, mlx5
|
net/mlx5e: allow tso on vxlan over vlan topologies
|
since mlx5 hardware can segment correctly tso packets on vxlan over vlan topologies, cpu usage can improve significantly if we enable tunnel offloads in dev->vlan_features, like it was done in the past with other nic drivers (e.g. mlx4, be2net and ixgbe).
|
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 tso on vxlan over vlan topologies
|
['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']
|
['mlx5e']
|
['c']
| 1
| 2
| 0
|
--- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c + netdev->vlan_features |= netif_f_gso_udp_tunnel | + netif_f_gso_udp_tunnel_csum;
|
Networking
|
a1718505d7f67ee0ab051322f1cbc7ac42b5da82
|
davide caratti
|
drivers
|
net
|
core, ethernet, mellanox, mlx5
|
mlxsw: add irif and erif disabled traps
|
irif_disabled and erif_disabled are driver specific traps. packets are dropped for these reasons when they need to be routed through/from existing router interfaces (rif) which are disabled.
|
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', 'rst']
| 4
| 51
| 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 + * :doc:'mlxsw' diff --git a/documentation/networking/devlink/mlxsw.rst b/documentation/networking/devlink/mlxsw.rst --- a/documentation/networking/devlink/mlxsw.rst +++ b/documentation/networking/devlink/mlxsw.rst - running - three digit firmware version + +driver-specific traps +===================== + +.. list-table:: list of driver-specific traps registered by ''mlxsw'' + :widths: 5 5 90 + + * - name + - type + - description + * - ''irif_disabled'' + - ''drop'' + - traps packets that the device decided to drop because they need to be + routed from a disabled router interface (rif). this can happen during + rif dismantle, when the rif is first disabled before being removed + completely + * - ''erif_disabled'' + - ''drop'' + - traps packets that the device decided to drop because they need to be + routed through a disabled router interface (rif). this can happen during + rif dismantle, when the rif is first disabled before being removed + completely 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 +/* all driver-specific traps must be documented in + * documentation/networking/devlink/mlxsw.rst + */ +enum { + devlink_mlxsw_trap_id_base = devlink_trap_generic_id_max, + devlink_mlxsw_trap_id_irif_disabled, + devlink_mlxsw_trap_id_erif_disabled, +}; + +#define devlink_mlxsw_trap_name_irif_disabled \ + "irif_disabled" +#define devlink_mlxsw_trap_name_erif_disabled \ + "erif_disabled" + +#define mlxsw_sp_trap_driver_drop(_id, _group_id) \ + devlink_trap_driver(drop, drop, devlink_mlxsw_trap_id_##_id, \ + devlink_mlxsw_trap_name_##_id, \ + devlink_trap_group_generic(_group_id), \ + mlxsw_sp_trap_metadata) + + mlxsw_sp_trap_driver_drop(irif_disabled, l3_drops), + mlxsw_sp_trap_driver_drop(erif_disabled, l3_drops), + mlxsw_sp_rxl_discard(router_irif_en, l3_discards), + mlxsw_sp_rxl_discard(router_erif_en, l3_discards), + devlink_mlxsw_trap_id_irif_disabled, + devlink_mlxsw_trap_id_erif_disabled, 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_router_irif_en = 0x178, + mlxsw_trap_id_discard_router_erif_en = 0x179,
|
Networking
|
5b051621609d535fac6bdcd232530cc5248e791d
|
amit cohen
|
documentation
|
networking
|
devlink, ethernet, mellanox, mlxsw
|
selftests: devlink_trap_l3_drops: add test cases of irif and erif disabled
|
add test cases to check that packets routed through disabled rifs and packets routed from disabled rifs are dropped and devlink counters increase when the 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
| 112
| 0
|
--- diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh + irif_disabled_test + erif_disabled_test +irif_disabled_test() +{ + local trap_name="irif_disabled" + local group_name="l3_drops" + local t0_packets t0_bytes + local t1_packets t1_bytes + local mz_pid + + ret=0 + + ping_check $trap_name + + devlink_trap_action_set $trap_name "trap" + + # when rif of a physical port ("sub-port rif") is destroyed, we first + # block the stp of the {port, vlan} so packets cannot get into the rif. + # using bridge enables us to see this trap because when bridge is + # destroyed, there is a small time window that packets can go into the + # rif, while it is disabled. + ip link add dev br0 type bridge + ip link set dev $rp1 master br0 + ip address flush dev $rp1 + __addr_add_del br0 add 192.0.2.2/24 + ip li set dev br0 up + + t0_packets=$(devlink_trap_rx_packets_get $trap_name) + t0_bytes=$(devlink_trap_rx_bytes_get $trap_name) + + # generate packets to h2 through br0 rif that will be removed later + $mz $h1 -t udp "sp=54321,dp=12345" -c 0 -p 100 -a own -b $rp1mac \ + -b $h2_ipv4 -q & + mz_pid=$! + + # wait before removing br0 rif to allow packets to go into the bridge. + sleep 1 + + # flushing address will dismantle the rif + ip address flush dev br0 + + t1_packets=$(devlink_trap_rx_packets_get $trap_name) + t1_bytes=$(devlink_trap_rx_bytes_get $trap_name) + + if [[ $t0_packets -eq $t1_packets && $t0_bytes -eq $t1_bytes ]]; then + check_err 1 "trap stats idle when packets should be trapped" + fi + + log_test "ingress rif disabled" + + kill $mz_pid && wait $mz_pid &> /dev/null + ip link set dev $rp1 nomaster + __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64 + ip link del dev br0 type bridge + devlink_trap_action_set $trap_name "drop" +} + +erif_disabled_test() +{ + local trap_name="erif_disabled" + local group_name="l3_drops" + local t0_packets t0_bytes + local t1_packets t1_bytes + local mz_pid + + ret=0 + + ping_check $trap_name + + devlink_trap_action_set $trap_name "trap" + ip link add dev br0 type bridge + ip add flush dev $rp1 + ip link set dev $rp1 master br0 + __addr_add_del br0 add 192.0.2.2/24 + ip link set dev br0 up + + t0_packets=$(devlink_trap_rx_packets_get $trap_name) + t0_bytes=$(devlink_trap_rx_bytes_get $trap_name) + + rp2mac=$(mac_get $rp2) + + # generate packets that should go out through br0 rif that will be + # removed later + $mz $h2 -t udp "sp=54321,dp=12345" -c 0 -p 100 -a own -b $rp2mac \ + -b 192.0.2.1 -q & + mz_pid=$! + + sleep 5 + # in order to see this trap we need a route that points to disabled rif. + # when ipv6 address is flushed, there is a delay and the routes are + # deleted before the rif and we cannot get state that we have route + # to disabled rif. + # delete ipv6 address first and then check this trap with flushing ipv4. + ip -6 add flush dev br0 + ip -4 add flush dev br0 + + t1_packets=$(devlink_trap_rx_packets_get $trap_name) + t1_bytes=$(devlink_trap_rx_bytes_get $trap_name) + + if [[ $t0_packets -eq $t1_packets && $t0_bytes -eq $t1_bytes ]]; then + check_err 1 "trap stats idle when packets should be trapped" + fi + + log_test "egress rif disabled" + + kill $mz_pid && wait $mz_pid &> /dev/null + ip link set dev $rp1 nomaster + __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64 + ip link del dev br0 type bridge + devlink_trap_action_set $trap_name "drop" +} +
|
Networking
|
740e87bc3db8fe299e17877b7055e9ae3c33e4e6
|
amit cohen jiri pirko jiri mellanox com
|
tools
|
testing
|
drivers, mlxsw, net, selftests
|
devlink: add non-routable packet trap
|
add packet trap that can report packets that reached the router, but are non-routable. for example, igmp queries can be flooded by the device in layer 2 and reach the router. such packets should not be routed and instead dropped.
|
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
| 10
| 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 - ''exception'' - traps unicast ipv6 packets that did not match any route + * - ''non_routable_packet'' + - ''drop'' + - traps packets that the device decided to drop because they are not + supposed to be routed. for example, igmp queries can be flooded by the + device in layer 2 and reach the router. such packets should not be + routed and instead dropped 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_non_routable, +#define devlink_trap_generic_name_non_routable \ + "non_routable_packet" diff --git a/net/core/devlink.c b/net/core/devlink.c --- a/net/core/devlink.c +++ b/net/core/devlink.c + devlink_trap(non_routable, drop),
|
Networking
|
95f0ead8f04bec18e474594ef585f3734bd85b4c
|
amit cohen
|
documentation
|
networking
|
devlink
|
mlxsw: add non_routable trap
|
add a trap for packets that the device decided to drop because they are not supposed to be routed. for example, igmp queries can be flooded by the device in layer 2 and reach the router. such packets should not be routed and instead dropped.
|
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(non_routable, l3_drops), + mlxsw_sp_rxl_discard(non_routable, l3_discards), + devlink_trap_generic_id_non_routable, 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_non_routable = 0x11a,
|
Networking
|
196442ec5f13751ed0c66d5c4bc9b58288dea430
|
amit cohen
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: reg: add tunneling ipinip encapsulation ecn mapping register
|
this register performs mapping from overlay ecn to underlay ecn during ipinip encapsulation.
|
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']
| 1
| 31
| 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 +/* tieem - tunneling ipinip encapsulation ecn mapping register + * ----------------------------------------------------------- + * the tieem register maps ecn of the ip header at the ingress to the + * encapsulation to the ecn of the underlay network. + */ +#define mlxsw_reg_tieem_id 0xa812 +#define mlxsw_reg_tieem_len 0x0c + +mlxsw_reg_define(tieem, mlxsw_reg_tieem_id, mlxsw_reg_tieem_len); + +/* reg_tieem_overlay_ecn + * ecn of the ip header in the overlay network. + * access: index + */ +mlxsw_item32(reg, tieem, overlay_ecn, 0x04, 24, 2); + +/* reg_tineem_underlay_ecn + * ecn of the ip header in the underlay network. + * access: rw + */ +mlxsw_item32(reg, tieem, underlay_ecn, 0x04, 16, 2); + +static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn, + u8 underlay_ecn) +{ + mlxsw_reg_zero(tieem, payload); + mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn); + mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn); +} + + mlxsw_reg(tieem),
|
Networking
|
20174900ad38cb090616add90665e2ff41c29dc9
|
amit cohen jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
mlxsw: reg: add tunneling ipinip decapsulation ecn mapping register
|
this register configures the actions that are done during ipinip decapsulation based on the ecn bits.
|
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']
| 1
| 57
| 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 +/* tidem - tunneling ipinip decapsulation ecn mapping register + * ----------------------------------------------------------- + * the tidem register configures the actions that are done in the + * decapsulation. + */ +#define mlxsw_reg_tidem_id 0xa813 +#define mlxsw_reg_tidem_len 0x0c + +mlxsw_reg_define(tidem, mlxsw_reg_tidem_id, mlxsw_reg_tidem_len); + +/* reg_tidem_underlay_ecn + * ecn field of the ip header in the underlay network. + * access: index + */ +mlxsw_item32(reg, tidem, underlay_ecn, 0x04, 24, 2); + +/* reg_tidem_overlay_ecn + * ecn field of the ip header in the overlay network. + * access: index + */ +mlxsw_item32(reg, tidem, overlay_ecn, 0x04, 16, 2); + +/* reg_tidem_eip_ecn + * egress ip ecn. ecn field of the ip header of the packet which goes out + * from the decapsulation. + * access: rw + */ +mlxsw_item32(reg, tidem, eip_ecn, 0x04, 8, 2); + +/* reg_tidem_trap_en + * trap enable: + * 0 - no trap due to decap ecn + * 1 - trap enable with trap_id + * access: rw + */ +mlxsw_item32(reg, tidem, trap_en, 0x08, 28, 4); + +/* reg_tidem_trap_id + * trap id. either decap_ecn0 or decap_ecn1. + * reserved when trap_en is '0'. + * access: rw + */ +mlxsw_item32(reg, tidem, trap_id, 0x08, 0, 9); + +static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn, + u8 overlay_ecn, u8 eip_ecn, + bool trap_en, u16 trap_id) +{ + mlxsw_reg_zero(tidem, payload); + mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn); + mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn); + mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn); + mlxsw_reg_tidem_trap_en_set(payload, trap_en); + mlxsw_reg_tidem_trap_id_set(payload, trap_id); +} + + mlxsw_reg(tidem),
|
Networking
|
839607e2ec8dbe7c3e43995921dae487976e8899
|
amit cohen jiri pirko jiri mellanox com
|
drivers
|
net
|
ethernet, mellanox, mlxsw
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.