mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-17 18:20:28 -05:00
ionic: convert to ndo_hwtstamp API
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. ionic_eth_ioctl() becomes empty, remove it. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Brett Creeley <brett.creeley@amd.com> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/20251023220457.3201122-4-vadim.fedorenko@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
7a07dc723f
commit
38efb0ba3c
@@ -2335,20 +2335,6 @@ static int ionic_stop(struct net_device *netdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ionic_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
|
||||
{
|
||||
struct ionic_lif *lif = netdev_priv(netdev);
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSHWTSTAMP:
|
||||
return ionic_lif_hwstamp_set(lif, ifr);
|
||||
case SIOCGHWTSTAMP:
|
||||
return ionic_lif_hwstamp_get(lif, ifr);
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
static int ionic_get_vf_config(struct net_device *netdev,
|
||||
int vf, struct ifla_vf_info *ivf)
|
||||
{
|
||||
@@ -2812,7 +2798,6 @@ static int ionic_xdp(struct net_device *netdev, struct netdev_bpf *bpf)
|
||||
static const struct net_device_ops ionic_netdev_ops = {
|
||||
.ndo_open = ionic_open,
|
||||
.ndo_stop = ionic_stop,
|
||||
.ndo_eth_ioctl = ionic_eth_ioctl,
|
||||
.ndo_start_xmit = ionic_start_xmit,
|
||||
.ndo_bpf = ionic_xdp,
|
||||
.ndo_xdp_xmit = ionic_xdp_xmit,
|
||||
@@ -2833,6 +2818,8 @@ static const struct net_device_ops ionic_netdev_ops = {
|
||||
.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,
|
||||
.ndo_hwtstamp_get = ionic_hwstamp_get,
|
||||
.ndo_hwtstamp_set = ionic_hwstamp_set,
|
||||
};
|
||||
|
||||
static int ionic_cmb_reconfig(struct ionic_lif *lif,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <linux/ptp_clock_kernel.h>
|
||||
#include <linux/timecounter.h>
|
||||
#include <uapi/linux/net_tstamp.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
#include <linux/dim.h>
|
||||
#include <linux/pci.h>
|
||||
#include "ionic_rx_filter.h"
|
||||
@@ -254,7 +254,7 @@ struct ionic_phc {
|
||||
struct timecounter tc;
|
||||
|
||||
struct mutex config_lock; /* lock for ts_config */
|
||||
struct hwtstamp_config ts_config;
|
||||
struct kernel_hwtstamp_config ts_config;
|
||||
u64 ts_config_rx_filt;
|
||||
u32 ts_config_tx_mode;
|
||||
|
||||
@@ -362,8 +362,11 @@ int ionic_lif_size(struct ionic *ionic);
|
||||
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
|
||||
void ionic_lif_hwstamp_replay(struct ionic_lif *lif);
|
||||
void ionic_lif_hwstamp_recreate_queues(struct ionic_lif *lif);
|
||||
int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr);
|
||||
int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr);
|
||||
int ionic_hwstamp_set(struct net_device *netdev,
|
||||
struct kernel_hwtstamp_config *config,
|
||||
struct netlink_ext_ack *extack);
|
||||
int ionic_hwstamp_get(struct net_device *netdev,
|
||||
struct kernel_hwtstamp_config *config);
|
||||
ktime_t ionic_lif_phc_ktime(struct ionic_lif *lif, u64 counter);
|
||||
void ionic_lif_register_phc(struct ionic_lif *lif);
|
||||
void ionic_lif_unregister_phc(struct ionic_lif *lif);
|
||||
@@ -373,12 +376,15 @@ void ionic_lif_free_phc(struct ionic_lif *lif);
|
||||
static inline void ionic_lif_hwstamp_replay(struct ionic_lif *lif) {}
|
||||
static inline void ionic_lif_hwstamp_recreate_queues(struct ionic_lif *lif) {}
|
||||
|
||||
static inline int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr)
|
||||
static inline int ionic_hwstamp_set(struct net_device *netdev,
|
||||
struct kernel_hwtstamp_config *config,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr)
|
||||
static inline int ionic_hwstamp_get(struct net_device *netdev,
|
||||
struct kernel_hwtstamp_config *config)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
@@ -65,11 +65,12 @@ static u64 ionic_hwstamp_rx_filt(int config_rx_filter)
|
||||
}
|
||||
|
||||
static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
|
||||
struct hwtstamp_config *new_ts)
|
||||
struct kernel_hwtstamp_config *new_ts,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct kernel_hwtstamp_config *config;
|
||||
struct kernel_hwtstamp_config ts = {};
|
||||
struct ionic *ionic = lif->ionic;
|
||||
struct hwtstamp_config *config;
|
||||
struct hwtstamp_config ts;
|
||||
int tx_mode = 0;
|
||||
u64 rx_filt = 0;
|
||||
int err, err2;
|
||||
@@ -99,12 +100,16 @@ static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
|
||||
|
||||
tx_mode = ionic_hwstamp_tx_mode(config->tx_type);
|
||||
if (tx_mode < 0) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"TX time stamping mode isn't supported");
|
||||
err = tx_mode;
|
||||
goto err_queues;
|
||||
}
|
||||
|
||||
mask = cpu_to_le64(BIT_ULL(tx_mode));
|
||||
if ((ionic->ident.lif.eth.hwstamp_tx_modes & mask) != mask) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"TX time stamping mode isn't supported");
|
||||
err = -ERANGE;
|
||||
goto err_queues;
|
||||
}
|
||||
@@ -124,32 +129,47 @@ static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
|
||||
|
||||
if (tx_mode) {
|
||||
err = ionic_lif_create_hwstamp_txq(lif);
|
||||
if (err)
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Error creating TX timestamp queue");
|
||||
goto err_queues;
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_filt) {
|
||||
err = ionic_lif_create_hwstamp_rxq(lif);
|
||||
if (err)
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Error creating RX timestamp queue");
|
||||
goto err_queues;
|
||||
}
|
||||
}
|
||||
|
||||
if (tx_mode != lif->phc->ts_config_tx_mode) {
|
||||
err = ionic_lif_set_hwstamp_txmode(lif, tx_mode);
|
||||
if (err)
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Error enabling TX timestamp mode");
|
||||
goto err_txmode;
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_filt != lif->phc->ts_config_rx_filt) {
|
||||
err = ionic_lif_set_hwstamp_rxfilt(lif, rx_filt);
|
||||
if (err)
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Error enabling RX timestamp mode");
|
||||
goto err_rxfilt;
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_all != (lif->phc->ts_config.rx_filter == HWTSTAMP_FILTER_ALL)) {
|
||||
err = ionic_lif_config_hwstamp_rxq_all(lif, rx_all);
|
||||
if (err)
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Error enabling RX timestamp mode");
|
||||
goto err_rxall;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&lif->phc->ts_config, config, sizeof(*config));
|
||||
@@ -183,28 +203,24 @@ static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
|
||||
return err;
|
||||
}
|
||||
|
||||
int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr)
|
||||
int ionic_hwstamp_set(struct net_device *netdev,
|
||||
struct kernel_hwtstamp_config *config,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct hwtstamp_config config;
|
||||
struct ionic_lif *lif = netdev_priv(netdev);
|
||||
int err;
|
||||
|
||||
if (!lif->phc || !lif->phc->ptp)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
|
||||
return -EFAULT;
|
||||
|
||||
mutex_lock(&lif->queue_lock);
|
||||
err = ionic_lif_hwstamp_set_ts_config(lif, &config);
|
||||
err = ionic_lif_hwstamp_set_ts_config(lif, config, extack);
|
||||
mutex_unlock(&lif->queue_lock);
|
||||
if (err) {
|
||||
netdev_info(lif->netdev, "hwstamp set failed: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (copy_to_user(ifr->ifr_data, &config, sizeof(config)))
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -216,7 +232,7 @@ void ionic_lif_hwstamp_replay(struct ionic_lif *lif)
|
||||
return;
|
||||
|
||||
mutex_lock(&lif->queue_lock);
|
||||
err = ionic_lif_hwstamp_set_ts_config(lif, NULL);
|
||||
err = ionic_lif_hwstamp_set_ts_config(lif, NULL, NULL);
|
||||
mutex_unlock(&lif->queue_lock);
|
||||
if (err)
|
||||
netdev_info(lif->netdev, "hwstamp replay failed: %d\n", err);
|
||||
@@ -246,19 +262,18 @@ void ionic_lif_hwstamp_recreate_queues(struct ionic_lif *lif)
|
||||
mutex_unlock(&lif->phc->config_lock);
|
||||
}
|
||||
|
||||
int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr)
|
||||
int ionic_hwstamp_get(struct net_device *netdev,
|
||||
struct kernel_hwtstamp_config *config)
|
||||
{
|
||||
struct hwtstamp_config config;
|
||||
struct ionic_lif *lif = netdev_priv(netdev);
|
||||
|
||||
if (!lif->phc || !lif->phc->ptp)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
mutex_lock(&lif->phc->config_lock);
|
||||
memcpy(&config, &lif->phc->ts_config, sizeof(config));
|
||||
memcpy(config, &lif->phc->ts_config, sizeof(*config));
|
||||
mutex_unlock(&lif->phc->config_lock);
|
||||
|
||||
if (copy_to_user(ifr->ifr_data, &config, sizeof(config)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user