mirror of https://github.com/torvalds/linux.git
Merge branch 'convert-drivers-to-use-ndo_hwtstamp-callbacks-part-4'
Vadim Fedorenko says: ==================== convert drivers to use ndo_hwtstamp callbacks part 4 This patchset is a subset of part 3 patchset to convert bnx2x and qede drviers to use ndo callbacks instead ioctl to configure and report time stamping. These drivers implemented only SIOCSHWTSTAMP command, but converted to also provide configuration back to users. Some logic is changed to avoid reporting configuration which is not in sync with the HW in case of error happened. ==================== Link: https://patch.msgid.link/20251116094610.3932005-1-vadim.fedorenko@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
95236dfce3
|
|
@ -308,8 +308,11 @@ static int bnx2x_set_storm_rx_mode(struct bnx2x *bp);
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* General service functions
|
* General service functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
static int bnx2x_hwtstamp_set(struct net_device *dev,
|
||||||
static int bnx2x_hwtstamp_ioctl(struct bnx2x *bp, struct ifreq *ifr);
|
struct kernel_hwtstamp_config *config,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
|
static int bnx2x_hwtstamp_get(struct net_device *dev,
|
||||||
|
struct kernel_hwtstamp_config *config);
|
||||||
|
|
||||||
static void __storm_memset_dma_mapping(struct bnx2x *bp,
|
static void __storm_memset_dma_mapping(struct bnx2x *bp,
|
||||||
u32 addr, dma_addr_t mapping)
|
u32 addr, dma_addr_t mapping)
|
||||||
|
|
@ -12813,14 +12816,9 @@ static int bnx2x_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||||
if (!netif_running(dev))
|
if (!netif_running(dev))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
switch (cmd) {
|
|
||||||
case SIOCSHWTSTAMP:
|
|
||||||
return bnx2x_hwtstamp_ioctl(bp, ifr);
|
|
||||||
default:
|
|
||||||
DP(NETIF_MSG_LINK, "ioctl: phy id 0x%x, reg 0x%x, val_in 0x%x\n",
|
DP(NETIF_MSG_LINK, "ioctl: phy id 0x%x, reg 0x%x, val_in 0x%x\n",
|
||||||
mdio->phy_id, mdio->reg_num, mdio->val_in);
|
mdio->phy_id, mdio->reg_num, mdio->val_in);
|
||||||
return mdio_mii_ioctl(&bp->mdio, mdio, cmd);
|
return mdio_mii_ioctl(&bp->mdio, mdio, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bnx2x_validate_addr(struct net_device *dev)
|
static int bnx2x_validate_addr(struct net_device *dev)
|
||||||
|
|
@ -13036,6 +13034,8 @@ static const struct net_device_ops bnx2x_netdev_ops = {
|
||||||
.ndo_get_phys_port_id = bnx2x_get_phys_port_id,
|
.ndo_get_phys_port_id = bnx2x_get_phys_port_id,
|
||||||
.ndo_set_vf_link_state = bnx2x_set_vf_link_state,
|
.ndo_set_vf_link_state = bnx2x_set_vf_link_state,
|
||||||
.ndo_features_check = bnx2x_features_check,
|
.ndo_features_check = bnx2x_features_check,
|
||||||
|
.ndo_hwtstamp_get = bnx2x_hwtstamp_get,
|
||||||
|
.ndo_hwtstamp_set = bnx2x_hwtstamp_set,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
|
static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
|
||||||
|
|
@ -15350,31 +15350,57 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bnx2x_hwtstamp_ioctl(struct bnx2x *bp, struct ifreq *ifr)
|
static int bnx2x_hwtstamp_set(struct net_device *dev,
|
||||||
|
struct kernel_hwtstamp_config *config,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct hwtstamp_config config;
|
struct bnx2x *bp = netdev_priv(dev);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
DP(BNX2X_MSG_PTP, "HWTSTAMP IOCTL called\n");
|
DP(BNX2X_MSG_PTP, "HWTSTAMP SET called\n");
|
||||||
|
|
||||||
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
|
if (!netif_running(dev)) {
|
||||||
return -EFAULT;
|
NL_SET_ERR_MSG_MOD(extack, "Device is down");
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
DP(BNX2X_MSG_PTP, "Requested tx_type: %d, requested rx_filters = %d\n",
|
DP(BNX2X_MSG_PTP, "Requested tx_type: %d, requested rx_filters = %d\n",
|
||||||
config.tx_type, config.rx_filter);
|
config->tx_type, config->rx_filter);
|
||||||
|
|
||||||
|
switch (config->tx_type) {
|
||||||
|
case HWTSTAMP_TX_ON:
|
||||||
|
case HWTSTAMP_TX_OFF:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
|
"One-step timestamping is not supported");
|
||||||
|
return -ERANGE;
|
||||||
|
}
|
||||||
|
|
||||||
bp->hwtstamp_ioctl_called = true;
|
bp->hwtstamp_ioctl_called = true;
|
||||||
bp->tx_type = config.tx_type;
|
bp->tx_type = config->tx_type;
|
||||||
bp->rx_filter = config.rx_filter;
|
bp->rx_filter = config->rx_filter;
|
||||||
|
|
||||||
rc = bnx2x_configure_ptp_filters(bp);
|
rc = bnx2x_configure_ptp_filters(bp);
|
||||||
if (rc)
|
if (rc) {
|
||||||
|
NL_SET_ERR_MSG_MOD(extack, "HW configuration failure");
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
config.rx_filter = bp->rx_filter;
|
config->rx_filter = bp->rx_filter;
|
||||||
|
|
||||||
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
|
return 0;
|
||||||
-EFAULT : 0;
|
}
|
||||||
|
|
||||||
|
static int bnx2x_hwtstamp_get(struct net_device *dev,
|
||||||
|
struct kernel_hwtstamp_config *config)
|
||||||
|
{
|
||||||
|
struct bnx2x *bp = netdev_priv(dev);
|
||||||
|
|
||||||
|
config->rx_filter = bp->rx_filter;
|
||||||
|
config->tx_type = bp->tx_type;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configures HW for PTP */
|
/* Configures HW for PTP */
|
||||||
|
|
|
||||||
|
|
@ -506,25 +506,6 @@ static int qede_set_vf_trust(struct net_device *dev, int vfidx, bool setting)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int qede_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
||||||
{
|
|
||||||
struct qede_dev *edev = netdev_priv(dev);
|
|
||||||
|
|
||||||
if (!netif_running(dev))
|
|
||||||
return -EAGAIN;
|
|
||||||
|
|
||||||
switch (cmd) {
|
|
||||||
case SIOCSHWTSTAMP:
|
|
||||||
return qede_ptp_hw_ts(edev, ifr);
|
|
||||||
default:
|
|
||||||
DP_VERBOSE(edev, QED_MSG_DEBUG,
|
|
||||||
"default IOCTL cmd 0x%x\n", cmd);
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void qede_fp_sb_dump(struct qede_dev *edev, struct qede_fastpath *fp)
|
static void qede_fp_sb_dump(struct qede_dev *edev, struct qede_fastpath *fp)
|
||||||
{
|
{
|
||||||
char *p_sb = (char *)fp->sb_info->sb_virt;
|
char *p_sb = (char *)fp->sb_info->sb_virt;
|
||||||
|
|
@ -717,7 +698,6 @@ static const struct net_device_ops qede_netdev_ops = {
|
||||||
.ndo_set_mac_address = qede_set_mac_addr,
|
.ndo_set_mac_address = qede_set_mac_addr,
|
||||||
.ndo_validate_addr = eth_validate_addr,
|
.ndo_validate_addr = eth_validate_addr,
|
||||||
.ndo_change_mtu = qede_change_mtu,
|
.ndo_change_mtu = qede_change_mtu,
|
||||||
.ndo_eth_ioctl = qede_ioctl,
|
|
||||||
.ndo_tx_timeout = qede_tx_timeout,
|
.ndo_tx_timeout = qede_tx_timeout,
|
||||||
#ifdef CONFIG_QED_SRIOV
|
#ifdef CONFIG_QED_SRIOV
|
||||||
.ndo_set_vf_mac = qede_set_vf_mac,
|
.ndo_set_vf_mac = qede_set_vf_mac,
|
||||||
|
|
@ -742,6 +722,8 @@ static const struct net_device_ops qede_netdev_ops = {
|
||||||
#endif
|
#endif
|
||||||
.ndo_xdp_xmit = qede_xdp_transmit,
|
.ndo_xdp_xmit = qede_xdp_transmit,
|
||||||
.ndo_setup_tc = qede_setup_tc_offload,
|
.ndo_setup_tc = qede_setup_tc_offload,
|
||||||
|
.ndo_hwtstamp_get = qede_hwtstamp_get,
|
||||||
|
.ndo_hwtstamp_set = qede_hwtstamp_set,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct net_device_ops qede_netdev_vf_ops = {
|
static const struct net_device_ops qede_netdev_vf_ops = {
|
||||||
|
|
|
||||||
|
|
@ -199,18 +199,15 @@ static u64 qede_ptp_read_cc(struct cyclecounter *cc)
|
||||||
return phc_cycles;
|
return phc_cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qede_ptp_cfg_filters(struct qede_dev *edev)
|
static void qede_ptp_cfg_filters(struct qede_dev *edev)
|
||||||
{
|
{
|
||||||
enum qed_ptp_hwtstamp_tx_type tx_type = QED_PTP_HWTSTAMP_TX_ON;
|
enum qed_ptp_hwtstamp_tx_type tx_type = QED_PTP_HWTSTAMP_TX_ON;
|
||||||
enum qed_ptp_filter_type rx_filter = QED_PTP_FILTER_NONE;
|
enum qed_ptp_filter_type rx_filter = QED_PTP_FILTER_NONE;
|
||||||
struct qede_ptp *ptp = edev->ptp;
|
struct qede_ptp *ptp = edev->ptp;
|
||||||
|
|
||||||
if (!ptp)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
if (!ptp->hw_ts_ioctl_called) {
|
if (!ptp->hw_ts_ioctl_called) {
|
||||||
DP_INFO(edev, "TS IOCTL not called\n");
|
DP_INFO(edev, "TS IOCTL not called\n");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ptp->tx_type) {
|
switch (ptp->tx_type) {
|
||||||
|
|
@ -223,11 +220,6 @@ static int qede_ptp_cfg_filters(struct qede_dev *edev)
|
||||||
clear_bit(QEDE_FLAGS_TX_TIMESTAMPING_EN, &edev->flags);
|
clear_bit(QEDE_FLAGS_TX_TIMESTAMPING_EN, &edev->flags);
|
||||||
tx_type = QED_PTP_HWTSTAMP_TX_OFF;
|
tx_type = QED_PTP_HWTSTAMP_TX_OFF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HWTSTAMP_TX_ONESTEP_SYNC:
|
|
||||||
case HWTSTAMP_TX_ONESTEP_P2P:
|
|
||||||
DP_ERR(edev, "One-step timestamping is not supported\n");
|
|
||||||
return -ERANGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_bh(&ptp->lock);
|
spin_lock_bh(&ptp->lock);
|
||||||
|
|
@ -286,39 +278,65 @@ static int qede_ptp_cfg_filters(struct qede_dev *edev)
|
||||||
ptp->ops->cfg_filters(edev->cdev, rx_filter, tx_type);
|
ptp->ops->cfg_filters(edev->cdev, rx_filter, tx_type);
|
||||||
|
|
||||||
spin_unlock_bh(&ptp->lock);
|
spin_unlock_bh(&ptp->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int qede_hwtstamp_set(struct net_device *netdev,
|
||||||
|
struct kernel_hwtstamp_config *config,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
|
{
|
||||||
|
struct qede_dev *edev = netdev_priv(netdev);
|
||||||
|
struct qede_ptp *ptp;
|
||||||
|
|
||||||
|
if (!netif_running(netdev)) {
|
||||||
|
NL_SET_ERR_MSG_MOD(extack, "Device is down");
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptp = edev->ptp;
|
||||||
|
if (!ptp) {
|
||||||
|
NL_SET_ERR_MSG_MOD(extack, "HW timestamping is not supported");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
DP_VERBOSE(edev, QED_MSG_DEBUG,
|
||||||
|
"HWTSTAMP SET: Requested tx_type = %d, requested rx_filters = %d\n",
|
||||||
|
config->tx_type, config->rx_filter);
|
||||||
|
|
||||||
|
switch (config->tx_type) {
|
||||||
|
case HWTSTAMP_TX_ON:
|
||||||
|
case HWTSTAMP_TX_OFF:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
|
"One-step timestamping is not supported");
|
||||||
|
return -ERANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptp->hw_ts_ioctl_called = 1;
|
||||||
|
ptp->tx_type = config->tx_type;
|
||||||
|
ptp->rx_filter = config->rx_filter;
|
||||||
|
|
||||||
|
qede_ptp_cfg_filters(edev);
|
||||||
|
|
||||||
|
config->rx_filter = ptp->rx_filter;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qede_ptp_hw_ts(struct qede_dev *edev, struct ifreq *ifr)
|
int qede_hwtstamp_get(struct net_device *netdev,
|
||||||
|
struct kernel_hwtstamp_config *config)
|
||||||
{
|
{
|
||||||
struct hwtstamp_config config;
|
struct qede_dev *edev = netdev_priv(netdev);
|
||||||
struct qede_ptp *ptp;
|
struct qede_ptp *ptp;
|
||||||
int rc;
|
|
||||||
|
|
||||||
ptp = edev->ptp;
|
ptp = edev->ptp;
|
||||||
if (!ptp)
|
if (!ptp)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
|
config->tx_type = ptp->tx_type;
|
||||||
return -EFAULT;
|
config->rx_filter = ptp->rx_filter;
|
||||||
|
|
||||||
DP_VERBOSE(edev, QED_MSG_DEBUG,
|
return 0;
|
||||||
"HWTSTAMP IOCTL: Requested tx_type = %d, requested rx_filters = %d\n",
|
|
||||||
config.tx_type, config.rx_filter);
|
|
||||||
|
|
||||||
ptp->hw_ts_ioctl_called = 1;
|
|
||||||
ptp->tx_type = config.tx_type;
|
|
||||||
ptp->rx_filter = config.rx_filter;
|
|
||||||
|
|
||||||
rc = qede_ptp_cfg_filters(edev);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
config.rx_filter = ptp->rx_filter;
|
|
||||||
|
|
||||||
return copy_to_user(ifr->ifr_data, &config,
|
|
||||||
sizeof(config)) ? -EFAULT : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int qede_ptp_get_ts_info(struct qede_dev *edev, struct kernel_ethtool_ts_info *info)
|
int qede_ptp_get_ts_info(struct qede_dev *edev, struct kernel_ethtool_ts_info *info)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,11 @@
|
||||||
|
|
||||||
void qede_ptp_rx_ts(struct qede_dev *edev, struct sk_buff *skb);
|
void qede_ptp_rx_ts(struct qede_dev *edev, struct sk_buff *skb);
|
||||||
void qede_ptp_tx_ts(struct qede_dev *edev, struct sk_buff *skb);
|
void qede_ptp_tx_ts(struct qede_dev *edev, struct sk_buff *skb);
|
||||||
int qede_ptp_hw_ts(struct qede_dev *edev, struct ifreq *req);
|
int qede_hwtstamp_get(struct net_device *netdev,
|
||||||
|
struct kernel_hwtstamp_config *config);
|
||||||
|
int qede_hwtstamp_set(struct net_device *netdev,
|
||||||
|
struct kernel_hwtstamp_config *config,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
void qede_ptp_disable(struct qede_dev *edev);
|
void qede_ptp_disable(struct qede_dev *edev);
|
||||||
int qede_ptp_enable(struct qede_dev *edev);
|
int qede_ptp_enable(struct qede_dev *edev);
|
||||||
int qede_ptp_get_ts_info(struct qede_dev *edev, struct kernel_ethtool_ts_info *ts);
|
int qede_ptp_get_ts_info(struct qede_dev *edev, struct kernel_ethtool_ts_info *ts);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue