162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/* Copyright (c) 2015 - 2023 Beijing WangXun Technology Co., Ltd. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#include <linux/pci.h>
562306a36Sopenharmony_ci#include <linux/phylink.h>
662306a36Sopenharmony_ci#include <linux/netdevice.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "../libwx/wx_ethtool.h"
962306a36Sopenharmony_ci#include "../libwx/wx_type.h"
1062306a36Sopenharmony_ci#include "txgbe_type.h"
1162306a36Sopenharmony_ci#include "txgbe_ethtool.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistatic int txgbe_nway_reset(struct net_device *netdev)
1462306a36Sopenharmony_ci{
1562306a36Sopenharmony_ci	struct txgbe *txgbe = netdev_to_txgbe(netdev);
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci	return phylink_ethtool_nway_reset(txgbe->phylink);
1862306a36Sopenharmony_ci}
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cistatic int txgbe_get_link_ksettings(struct net_device *netdev,
2162306a36Sopenharmony_ci				    struct ethtool_link_ksettings *cmd)
2262306a36Sopenharmony_ci{
2362306a36Sopenharmony_ci	struct txgbe *txgbe = netdev_to_txgbe(netdev);
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci	return phylink_ethtool_ksettings_get(txgbe->phylink, cmd);
2662306a36Sopenharmony_ci}
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistatic int txgbe_set_link_ksettings(struct net_device *netdev,
2962306a36Sopenharmony_ci				    const struct ethtool_link_ksettings *cmd)
3062306a36Sopenharmony_ci{
3162306a36Sopenharmony_ci	struct txgbe *txgbe = netdev_to_txgbe(netdev);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci	return phylink_ethtool_ksettings_set(txgbe->phylink, cmd);
3462306a36Sopenharmony_ci}
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistatic const struct ethtool_ops txgbe_ethtool_ops = {
3762306a36Sopenharmony_ci	.get_drvinfo		= wx_get_drvinfo,
3862306a36Sopenharmony_ci	.nway_reset		= txgbe_nway_reset,
3962306a36Sopenharmony_ci	.get_link		= ethtool_op_get_link,
4062306a36Sopenharmony_ci	.get_link_ksettings	= txgbe_get_link_ksettings,
4162306a36Sopenharmony_ci	.set_link_ksettings	= txgbe_set_link_ksettings,
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_civoid txgbe_set_ethtool_ops(struct net_device *netdev)
4562306a36Sopenharmony_ci{
4662306a36Sopenharmony_ci	netdev->ethtool_ops = &txgbe_ethtool_ops;
4762306a36Sopenharmony_ci}
48