mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
Core & protocols
----------------
- Continue Netlink conversions to per-namespace RTNL lock
(IPv4 routing, routing rules, routing next hops, ARP ioctls).
- Continue extending the use of netdev instance locks. As a driver
opt-in protect queue operations and (in due course) ethtool
operations with the instance lock and not RTNL lock.
- Support collecting TCP timestamps (data submitted, sent, acked)
in BPF, allowing for transparent (to the application) and lower
overhead tracking of TCP RPC performance.
- Tweak existing networking Rx zero-copy infra to support zero-copy
Rx via io_uring.
- Optimize MPTCP performance in single subflow mode by 29%.
- Enable GRO on packets which went thru XDP CPU redirect (were queued
for processing on a different CPU). Improving TCP stream performance
up to 2x.
- Improve performance of contended connect() by 200% by searching
for an available 4-tuple under RCU rather than a spin lock.
Bring an additional 229% improvement by tweaking hash distribution.
- Avoid unconditionally touching sk_tsflags on RX, improving
performance under UDP flood by as much as 10%.
- Avoid skb_clone() dance in ping_rcv() to improve performance under
ping flood.
- Avoid FIB lookup in netfilter if socket is available, 20% perf win.
- Rework network device creation (in-kernel) API to more clearly
identify network namespaces and their roles.
There are up to 4 namespace roles but we used to have just 2 netns
pointer arguments, interpreted differently based on context.
- Use sysfs_break_active_protection() instead of trylock to avoid
deadlocks between unregistering objects and sysfs access.
- Add a new sysctl and sockopt for capping max retransmit timeout
in TCP.
- Support masking port and DSCP in routing rule matches.
- Support dumping IPv4 multicast addresses with RTM_GETMULTICAST.
- Support specifying at what time packet should be sent on AF_XDP
sockets.
- Expose TCP ULP diagnostic info (for TLS and MPTCP) to non-admin users.
- Add Netlink YAML spec for WiFi (nl80211) and conntrack.
- Introduce EXPORT_IPV6_MOD() and EXPORT_IPV6_MOD_GPL() for symbols
which only need to be exported when IPv6 support is built as a module.
- Age FDB entries based on Rx not Tx traffic in VxLAN, similar
to normal bridging.
- Allow users to specify source port range for GENEVE tunnels.
- netconsole: allow attaching kernel release, CPU ID and task name
to messages as metadata
Driver API
----------
- Continue rework / fixing of Energy Efficient Ethernet (EEE) across
the SW layers. Delegate the responsibilities to phylink where possible.
Improve its handling in phylib.
- Support symmetric OR-XOR RSS hashing algorithm.
- Support tracking and preserving IRQ affinity by NAPI itself.
- Support loopback mode speed selection for interface selftests.
Device drivers
--------------
- Remove the IBM LCS driver for s390.
- Remove the sb1000 cable modem driver.
- Add support for SFP module access over SMBus.
- Add MCTP transport driver for MCTP-over-USB.
- Enable XDP metadata support in multiple drivers.
- Ethernet high-speed NICs:
- Broadcom (bnxt):
- add PCIe TLP Processing Hints (TPH) support for new AMD platforms
- support dumping RoCE queue state for debug
- opt into instance locking
- Intel (100G, ice, idpf):
- ice: rework MSI-X IRQ management and distribution
- ice: support for E830 devices
- iavf: add support for Rx timestamping
- iavf: opt into instance locking
- nVidia/Mellanox:
- mlx4: use page pool memory allocator for Rx
- mlx5: support for one PTP device per hardware clock
- mlx5: support for 200Gbps per-lane link modes
- mlx5: move IPSec policy check after decryption
- AMD/Solarflare:
- support FW flashing via devlink
- Cisco (enic):
- use page pool memory allocator for Rx
- enable 32, 64 byte CQEs
- get max rx/tx ring size from the device
- Meta (fbnic):
- support flow steering and RSS configuration
- report queue stats
- support TCP segmentation
- support IRQ coalescing
- support ring size configuration
- Marvell/Cavium:
- support AF_XDP
- Wangxun:
- support for PTP clock and timestamping
- Huawei (hibmcge):
- checksum offload
- add more statistics
- Ethernet virtual:
- VirtIO net:
- aggressively suppress Tx completions, improve perf by 96% with
1 CPU and 55% with 2 CPUs
- expose NAPI to IRQ mapping and persist NAPI settings
- Google (gve):
- support XDP in DQO RDA Queue Format
- opt into instance locking
- Microsoft vNIC:
- support BIG TCP
- Ethernet NICs consumer, and embedded:
- Synopsys (stmmac):
- cleanup Tx and Tx clock setting and other link-focused cleanups
- enable SGMII and 2500BASEX mode switching for Intel platforms
- support Sophgo SG2044
- Broadcom switches (b53):
- support for BCM53101
- TI:
- iep: add perout configuration support
- icssg: support XDP
- Cadence (macb):
- implement BQL
- Xilinx (axinet):
- support dynamic IRQ moderation and changing coalescing at runtime
- implement BQL
- report standard stats
- MediaTek:
- support phylink managed EEE
- Intel:
- igc: don't restart the interface on every XDP program change
- RealTek (r8169):
- support reading registers of internal PHYs directly
- increase max jumbo packet size on RTL8125/RTL8126
- Airoha:
- support for RISC-V NPU packet processing unit
- enable scatter-gather and support MTU up to 9kB
- Tehuti (tn40xx):
- support cards with TN4010 MAC and an Aquantia AQR105 PHY
- Ethernet PHYs:
- support for TJA1102S, TJA1121
- dp83tg720: add randomized polling intervals for link detection
- dp83822: support changing the transmit amplitude voltage
- support for LEDs on 88q2xxx
- CAN:
- canxl: support Remote Request Substitution bit access
- flexcan: add S32G2/S32G3 SoC
- WiFi:
- remove cooked monitor support
- strict mode for better AP testing
- basic EPCS support
- OMI RX bandwidth reduction support
- batman-adv: add support for jumbo frames
- WiFi drivers:
- RealTek (rtw88):
- support RTL8814AE and RTL8814AU
- RealTek (rtw89):
- switch using wiphy_lock and wiphy_work
- add BB context to manipulate two PHY as preparation of MLO
- improve BT-coexistence mechanism to play A2DP smoothly
- Intel (iwlwifi):
- add new iwlmld sub-driver for latest HW/FW combinations
- MediaTek (mt76):
- preparation for mt7996 Multi-Link Operation (MLO) support
- Qualcomm/Atheros (ath12k):
- continued work on MLO
- Silabs (wfx):
- Wake-on-WLAN support
- Bluetooth:
- add support for skb TX SND/COMPLETION timestamping
- hci_core: enable buffer flow control for SCO/eSCO
- coredump: log devcd dumps into the monitor
- Bluetooth drivers:
- intel: add support to configure TX power
- nxp: handle bootloader error during cmd5 and cmd7
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEE6jPA+I1ugmIBA4hXMUZtbf5SIrsFAmfkLC8ACgkQMUZtbf5S
Irsb5g/+L7oKOf0ALbaV9kxFsoz8AymZfAW9i/27F07omGJGpks8oX6j6rQLgIRO
OQOFcp7XEdDh1+jh82gHVuPrw2/6lchLtW8ARtzdiQKFr5DRjrsbtua6GRc8iBqA
DIRCBFoV2HuMkF39Vr09HMa9AZAT7QR2RLsRGpSq8E8Z8xxKz0X7oujs10PFpMTE
IVKhTrVrk+NDot/IU2hzVpnpup+0ld+T2/ZaBklJGcU8uDffImsqNepHRyCG5UC3
xz74Ju23MAj24Gct+og0yFUooF+lUltKyVm0FYCDCY3bASTwgY01NR3kEH/0NQvM
cywLzd/ngHm/SMD2ggVAHkjZUieiIVHdaZ53dgjDeBOQoVP6p0dgUK7EumXX8Mx4
8ReR2UiGoYRPaq9c4o+IjG4K027MwVK2p+mF1a6MLa+20XcyMbev8FIRbbHtC/V4
z5/FsOAxcuICWkA1hU9bODrrGzIqemmdRgKG8sGuTJCt/kYGAn72/TCATGNSaCJ0
00n2jN1aepa7wtywHJ5MhVzxN9iQX7+geUHXz0BI+lK4e1Pmk+vjGksymb9ai2fk
eQAUV9ekub6q68/J16scD7XeOUM37bTLiMBQeIF8UtZBOJscKiS71zn9QP9Twwxv
P2pm01RDZUI+z5ZX3hc12Pm1vjRHaAh9S1JpAw/pTOVlQ+mAJEM=
=XY0S
-----END PGP SIGNATURE-----
Merge tag 'net-next-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next
Pull networking updates from Jakub Kicinski:
"Core & protocols:
- Continue Netlink conversions to per-namespace RTNL lock
(IPv4 routing, routing rules, routing next hops, ARP ioctls)
- Continue extending the use of netdev instance locks. As a driver
opt-in protect queue operations and (in due course) ethtool
operations with the instance lock and not RTNL lock.
- Support collecting TCP timestamps (data submitted, sent, acked) in
BPF, allowing for transparent (to the application) and lower
overhead tracking of TCP RPC performance.
- Tweak existing networking Rx zero-copy infra to support zero-copy
Rx via io_uring.
- Optimize MPTCP performance in single subflow mode by 29%.
- Enable GRO on packets which went thru XDP CPU redirect (were queued
for processing on a different CPU). Improving TCP stream
performance up to 2x.
- Improve performance of contended connect() by 200% by searching for
an available 4-tuple under RCU rather than a spin lock. Bring an
additional 229% improvement by tweaking hash distribution.
- Avoid unconditionally touching sk_tsflags on RX, improving
performance under UDP flood by as much as 10%.
- Avoid skb_clone() dance in ping_rcv() to improve performance under
ping flood.
- Avoid FIB lookup in netfilter if socket is available, 20% perf win.
- Rework network device creation (in-kernel) API to more clearly
identify network namespaces and their roles. There are up to 4
namespace roles but we used to have just 2 netns pointer arguments,
interpreted differently based on context.
- Use sysfs_break_active_protection() instead of trylock to avoid
deadlocks between unregistering objects and sysfs access.
- Add a new sysctl and sockopt for capping max retransmit timeout in
TCP.
- Support masking port and DSCP in routing rule matches.
- Support dumping IPv4 multicast addresses with RTM_GETMULTICAST.
- Support specifying at what time packet should be sent on AF_XDP
sockets.
- Expose TCP ULP diagnostic info (for TLS and MPTCP) to non-admin
users.
- Add Netlink YAML spec for WiFi (nl80211) and conntrack.
- Introduce EXPORT_IPV6_MOD() and EXPORT_IPV6_MOD_GPL() for symbols
which only need to be exported when IPv6 support is built as a
module.
- Age FDB entries based on Rx not Tx traffic in VxLAN, similar to
normal bridging.
- Allow users to specify source port range for GENEVE tunnels.
- netconsole: allow attaching kernel release, CPU ID and task name to
messages as metadata
Driver API:
- Continue rework / fixing of Energy Efficient Ethernet (EEE) across
the SW layers. Delegate the responsibilities to phylink where
possible. Improve its handling in phylib.
- Support symmetric OR-XOR RSS hashing algorithm.
- Support tracking and preserving IRQ affinity by NAPI itself.
- Support loopback mode speed selection for interface selftests.
Device drivers:
- Remove the IBM LCS driver for s390
- Remove the sb1000 cable modem driver
- Add support for SFP module access over SMBus
- Add MCTP transport driver for MCTP-over-USB
- Enable XDP metadata support in multiple drivers
- Ethernet high-speed NICs:
- Broadcom (bnxt):
- add PCIe TLP Processing Hints (TPH) support for new AMD
platforms
- support dumping RoCE queue state for debug
- opt into instance locking
- Intel (100G, ice, idpf):
- ice: rework MSI-X IRQ management and distribution
- ice: support for E830 devices
- iavf: add support for Rx timestamping
- iavf: opt into instance locking
- nVidia/Mellanox:
- mlx4: use page pool memory allocator for Rx
- mlx5: support for one PTP device per hardware clock
- mlx5: support for 200Gbps per-lane link modes
- mlx5: move IPSec policy check after decryption
- AMD/Solarflare:
- support FW flashing via devlink
- Cisco (enic):
- use page pool memory allocator for Rx
- enable 32, 64 byte CQEs
- get max rx/tx ring size from the device
- Meta (fbnic):
- support flow steering and RSS configuration
- report queue stats
- support TCP segmentation
- support IRQ coalescing
- support ring size configuration
- Marvell/Cavium:
- support AF_XDP
- Wangxun:
- support for PTP clock and timestamping
- Huawei (hibmcge):
- checksum offload
- add more statistics
- Ethernet virtual:
- VirtIO net:
- aggressively suppress Tx completions, improve perf by 96%
with 1 CPU and 55% with 2 CPUs
- expose NAPI to IRQ mapping and persist NAPI settings
- Google (gve):
- support XDP in DQO RDA Queue Format
- opt into instance locking
- Microsoft vNIC:
- support BIG TCP
- Ethernet NICs consumer, and embedded:
- Synopsys (stmmac):
- cleanup Tx and Tx clock setting and other link-focused
cleanups
- enable SGMII and 2500BASEX mode switching for Intel platforms
- support Sophgo SG2044
- Broadcom switches (b53):
- support for BCM53101
- TI:
- iep: add perout configuration support
- icssg: support XDP
- Cadence (macb):
- implement BQL
- Xilinx (axinet):
- support dynamic IRQ moderation and changing coalescing at
runtime
- implement BQL
- report standard stats
- MediaTek:
- support phylink managed EEE
- Intel:
- igc: don't restart the interface on every XDP program change
- RealTek (r8169):
- support reading registers of internal PHYs directly
- increase max jumbo packet size on RTL8125/RTL8126
- Airoha:
- support for RISC-V NPU packet processing unit
- enable scatter-gather and support MTU up to 9kB
- Tehuti (tn40xx):
- support cards with TN4010 MAC and an Aquantia AQR105 PHY
- Ethernet PHYs:
- support for TJA1102S, TJA1121
- dp83tg720: add randomized polling intervals for link detection
- dp83822: support changing the transmit amplitude voltage
- support for LEDs on 88q2xxx
- CAN:
- canxl: support Remote Request Substitution bit access
- flexcan: add S32G2/S32G3 SoC
- WiFi:
- remove cooked monitor support
- strict mode for better AP testing
- basic EPCS support
- OMI RX bandwidth reduction support
- batman-adv: add support for jumbo frames
- WiFi drivers:
- RealTek (rtw88):
- support RTL8814AE and RTL8814AU
- RealTek (rtw89):
- switch using wiphy_lock and wiphy_work
- add BB context to manipulate two PHY as preparation of MLO
- improve BT-coexistence mechanism to play A2DP smoothly
- Intel (iwlwifi):
- add new iwlmld sub-driver for latest HW/FW combinations
- MediaTek (mt76):
- preparation for mt7996 Multi-Link Operation (MLO) support
- Qualcomm/Atheros (ath12k):
- continued work on MLO
- Silabs (wfx):
- Wake-on-WLAN support
- Bluetooth:
- add support for skb TX SND/COMPLETION timestamping
- hci_core: enable buffer flow control for SCO/eSCO
- coredump: log devcd dumps into the monitor
- Bluetooth drivers:
- intel: add support to configure TX power
- nxp: handle bootloader error during cmd5 and cmd7"
* tag 'net-next-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (1681 commits)
unix: fix up for "apparmor: add fine grained af_unix mediation"
mctp: Fix incorrect tx flow invalidation condition in mctp-i2c
net: usb: asix: ax88772: Increase phy_name size
net: phy: Introduce PHY_ID_SIZE — minimum size for PHY ID string
net: libwx: fix Tx L4 checksum
net: libwx: fix Tx descriptor content for some tunnel packets
atm: Fix NULL pointer dereference
net: tn40xx: add pci-id of the aqr105-based Tehuti TN4010 cards
net: tn40xx: prepare tn40xx driver to find phy of the TN9510 card
net: tn40xx: create swnode for mdio and aqr105 phy and add to mdiobus
net: phy: aquantia: add essential functions to aqr105 driver
net: phy: aquantia: search for firmware-name in fwnode
net: phy: aquantia: add probe function to aqr105 for firmware loading
net: phy: Add swnode support to mdiobus_scan
gve: add XDP DROP and PASS support for DQ
gve: update XDP allocation path support RX buffer posting
gve: merge packet buffer size fields
gve: update GQ RX to use buf_size
gve: introduce config-based allocation for XDP
gve: remove xdp_xsk_done and xdp_xsk_wakeup statistics
...
319 lines
5.9 KiB
C
319 lines
5.9 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Support for dynamic clock devices
|
|
*
|
|
* Copyright (C) 2010 OMICRON electronics GmbH
|
|
*/
|
|
#include <linux/device.h>
|
|
#include <linux/export.h>
|
|
#include <linux/file.h>
|
|
#include <linux/posix-clock.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/syscalls.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
#include "posix-timers.h"
|
|
|
|
/*
|
|
* Returns NULL if the posix_clock instance attached to 'fp' is old and stale.
|
|
*/
|
|
static struct posix_clock *get_posix_clock(struct file *fp)
|
|
{
|
|
struct posix_clock_context *pccontext = fp->private_data;
|
|
struct posix_clock *clk = pccontext->clk;
|
|
|
|
down_read(&clk->rwsem);
|
|
|
|
if (!clk->zombie)
|
|
return clk;
|
|
|
|
up_read(&clk->rwsem);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static void put_posix_clock(struct posix_clock *clk)
|
|
{
|
|
up_read(&clk->rwsem);
|
|
}
|
|
|
|
static ssize_t posix_clock_read(struct file *fp, char __user *buf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
struct posix_clock_context *pccontext = fp->private_data;
|
|
struct posix_clock *clk = get_posix_clock(fp);
|
|
int err = -EINVAL;
|
|
|
|
if (!clk)
|
|
return -ENODEV;
|
|
|
|
if (clk->ops.read)
|
|
err = clk->ops.read(pccontext, fp->f_flags, buf, count);
|
|
|
|
put_posix_clock(clk);
|
|
|
|
return err;
|
|
}
|
|
|
|
static __poll_t posix_clock_poll(struct file *fp, poll_table *wait)
|
|
{
|
|
struct posix_clock_context *pccontext = fp->private_data;
|
|
struct posix_clock *clk = get_posix_clock(fp);
|
|
__poll_t result = 0;
|
|
|
|
if (!clk)
|
|
return EPOLLERR;
|
|
|
|
if (clk->ops.poll)
|
|
result = clk->ops.poll(pccontext, fp, wait);
|
|
|
|
put_posix_clock(clk);
|
|
|
|
return result;
|
|
}
|
|
|
|
static long posix_clock_ioctl(struct file *fp,
|
|
unsigned int cmd, unsigned long arg)
|
|
{
|
|
struct posix_clock_context *pccontext = fp->private_data;
|
|
struct posix_clock *clk = get_posix_clock(fp);
|
|
int err = -ENOTTY;
|
|
|
|
if (!clk)
|
|
return -ENODEV;
|
|
|
|
if (clk->ops.ioctl)
|
|
err = clk->ops.ioctl(pccontext, cmd, arg);
|
|
|
|
put_posix_clock(clk);
|
|
|
|
return err;
|
|
}
|
|
|
|
static int posix_clock_open(struct inode *inode, struct file *fp)
|
|
{
|
|
int err;
|
|
struct posix_clock *clk =
|
|
container_of(inode->i_cdev, struct posix_clock, cdev);
|
|
struct posix_clock_context *pccontext;
|
|
|
|
down_read(&clk->rwsem);
|
|
|
|
if (clk->zombie) {
|
|
err = -ENODEV;
|
|
goto out;
|
|
}
|
|
pccontext = kzalloc(sizeof(*pccontext), GFP_KERNEL);
|
|
if (!pccontext) {
|
|
err = -ENOMEM;
|
|
goto out;
|
|
}
|
|
pccontext->clk = clk;
|
|
pccontext->fp = fp;
|
|
if (clk->ops.open) {
|
|
err = clk->ops.open(pccontext, fp->f_mode);
|
|
if (err) {
|
|
kfree(pccontext);
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
fp->private_data = pccontext;
|
|
get_device(clk->dev);
|
|
err = 0;
|
|
out:
|
|
up_read(&clk->rwsem);
|
|
return err;
|
|
}
|
|
|
|
static int posix_clock_release(struct inode *inode, struct file *fp)
|
|
{
|
|
struct posix_clock_context *pccontext = fp->private_data;
|
|
struct posix_clock *clk;
|
|
int err = 0;
|
|
|
|
if (!pccontext)
|
|
return -ENODEV;
|
|
clk = pccontext->clk;
|
|
|
|
if (clk->ops.release)
|
|
err = clk->ops.release(pccontext);
|
|
|
|
put_device(clk->dev);
|
|
|
|
kfree(pccontext);
|
|
fp->private_data = NULL;
|
|
|
|
return err;
|
|
}
|
|
|
|
static const struct file_operations posix_clock_file_operations = {
|
|
.owner = THIS_MODULE,
|
|
.read = posix_clock_read,
|
|
.poll = posix_clock_poll,
|
|
.unlocked_ioctl = posix_clock_ioctl,
|
|
.compat_ioctl = posix_clock_ioctl,
|
|
.open = posix_clock_open,
|
|
.release = posix_clock_release,
|
|
};
|
|
|
|
int posix_clock_register(struct posix_clock *clk, struct device *dev)
|
|
{
|
|
int err;
|
|
|
|
init_rwsem(&clk->rwsem);
|
|
|
|
cdev_init(&clk->cdev, &posix_clock_file_operations);
|
|
err = cdev_device_add(&clk->cdev, dev);
|
|
if (err) {
|
|
pr_err("%s unable to add device %d:%d\n",
|
|
dev_name(dev), MAJOR(dev->devt), MINOR(dev->devt));
|
|
return err;
|
|
}
|
|
clk->cdev.owner = clk->ops.owner;
|
|
clk->dev = dev;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(posix_clock_register);
|
|
|
|
void posix_clock_unregister(struct posix_clock *clk)
|
|
{
|
|
cdev_device_del(&clk->cdev, clk->dev);
|
|
|
|
down_write(&clk->rwsem);
|
|
clk->zombie = true;
|
|
up_write(&clk->rwsem);
|
|
|
|
put_device(clk->dev);
|
|
}
|
|
EXPORT_SYMBOL_GPL(posix_clock_unregister);
|
|
|
|
struct posix_clock_desc {
|
|
struct file *fp;
|
|
struct posix_clock *clk;
|
|
};
|
|
|
|
static int get_clock_desc(const clockid_t id, struct posix_clock_desc *cd)
|
|
{
|
|
struct file *fp = fget(clockid_to_fd(id));
|
|
int err = -EINVAL;
|
|
|
|
if (!fp)
|
|
return err;
|
|
|
|
if (fp->f_op->open != posix_clock_open || !fp->private_data)
|
|
goto out;
|
|
|
|
cd->fp = fp;
|
|
cd->clk = get_posix_clock(fp);
|
|
|
|
err = cd->clk ? 0 : -ENODEV;
|
|
out:
|
|
if (err)
|
|
fput(fp);
|
|
return err;
|
|
}
|
|
|
|
static void put_clock_desc(struct posix_clock_desc *cd)
|
|
{
|
|
put_posix_clock(cd->clk);
|
|
fput(cd->fp);
|
|
}
|
|
|
|
static int pc_clock_adjtime(clockid_t id, struct __kernel_timex *tx)
|
|
{
|
|
struct posix_clock_desc cd;
|
|
int err;
|
|
|
|
err = get_clock_desc(id, &cd);
|
|
if (err)
|
|
return err;
|
|
|
|
if (tx->modes && (cd.fp->f_mode & FMODE_WRITE) == 0) {
|
|
err = -EACCES;
|
|
goto out;
|
|
}
|
|
|
|
if (cd.clk->ops.clock_adjtime)
|
|
err = cd.clk->ops.clock_adjtime(cd.clk, tx);
|
|
else
|
|
err = -EOPNOTSUPP;
|
|
out:
|
|
put_clock_desc(&cd);
|
|
|
|
return err;
|
|
}
|
|
|
|
static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
|
|
{
|
|
struct posix_clock_desc cd;
|
|
int err;
|
|
|
|
err = get_clock_desc(id, &cd);
|
|
if (err)
|
|
return err;
|
|
|
|
if (cd.clk->ops.clock_gettime)
|
|
err = cd.clk->ops.clock_gettime(cd.clk, ts);
|
|
else
|
|
err = -EOPNOTSUPP;
|
|
|
|
put_clock_desc(&cd);
|
|
|
|
return err;
|
|
}
|
|
|
|
static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
|
|
{
|
|
struct posix_clock_desc cd;
|
|
int err;
|
|
|
|
err = get_clock_desc(id, &cd);
|
|
if (err)
|
|
return err;
|
|
|
|
if (cd.clk->ops.clock_getres)
|
|
err = cd.clk->ops.clock_getres(cd.clk, ts);
|
|
else
|
|
err = -EOPNOTSUPP;
|
|
|
|
put_clock_desc(&cd);
|
|
|
|
return err;
|
|
}
|
|
|
|
static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
|
|
{
|
|
struct posix_clock_desc cd;
|
|
int err;
|
|
|
|
if (!timespec64_valid_strict(ts))
|
|
return -EINVAL;
|
|
|
|
err = get_clock_desc(id, &cd);
|
|
if (err)
|
|
return err;
|
|
|
|
if ((cd.fp->f_mode & FMODE_WRITE) == 0) {
|
|
err = -EACCES;
|
|
goto out;
|
|
}
|
|
|
|
if (cd.clk->ops.clock_settime)
|
|
err = cd.clk->ops.clock_settime(cd.clk, ts);
|
|
else
|
|
err = -EOPNOTSUPP;
|
|
out:
|
|
put_clock_desc(&cd);
|
|
|
|
return err;
|
|
}
|
|
|
|
const struct k_clock clock_posix_dynamic = {
|
|
.clock_getres = pc_clock_getres,
|
|
.clock_set = pc_clock_settime,
|
|
.clock_get_timespec = pc_clock_gettime,
|
|
.clock_adj = pc_clock_adjtime,
|
|
};
|