diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 2e157828..a48078dd 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ +#include #include "ether_linux.h" /** @@ -3576,7 +3577,15 @@ rst_clk_fail: static int ether_parse_phy_dt(struct ether_priv_data *pdata, struct device_node *node) { +#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE pdata->interface = of_get_phy_mode(node); +#else + int err; + + err = of_get_phy_mode(node, &pdata->interface); + if (err < 0) + pr_debug("%s(): phy interface not found\n", __func__); +#endif pdata->phy_node = of_parse_phandle(node, "phy-handle", 0); if (pdata->phy_node == NULL) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h index aaca3590..d8abe2d7 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h @@ -281,7 +281,7 @@ struct ether_priv_data { struct phy_device *phydev; /** Interface type assciated with MAC (SGMII/RGMII/...) * this information will be provided with phy-mode DT entry */ - int interface; + phy_interface_t interface; /** Previous detected link */ unsigned int oldlink; /** PHY link speed */ diff --git a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c index b2c7cc89..75f8426e 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ +#include #include "ether_linux.h" /** @@ -42,9 +43,15 @@ struct ether_stats { * @brief Name of pkt_err statistics, with length of name not more than * ETH_GSTRING_LEN */ +#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE #define ETHER_PKT_ERR_STAT(y) \ { (#y), FIELD_SIZEOF(struct osi_pkt_err_stats, y), \ offsetof(struct osi_dma_priv_data, pkt_err_stats.y)} +#else +#define ETHER_PKT_ERR_STAT(y) \ +{ (#y), sizeof_field(struct osi_pkt_err_stats, y), \ + offsetof(struct osi_dma_priv_data, pkt_err_stats.y)} +#endif /** * @brief ETHER clear pkt_err statistics */ @@ -62,9 +69,15 @@ static const struct ether_stats ether_cstrings_stats[] = { /** * @brief Name of extra DMA stat, with length of name not more than ETH_GSTRING_LEN */ +#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE #define ETHER_DMA_EXTRA_STAT(a) \ { (#a), FIELD_SIZEOF(struct osi_xtra_dma_stat_counters, a), \ offsetof(struct osi_dma_priv_data, dstats.a)} +#else +#define ETHER_DMA_EXTRA_STAT(a) \ +{ (#a), sizeof_field(struct osi_xtra_dma_stat_counters, a), \ + offsetof(struct osi_dma_priv_data, dstats.a)} +#endif /** * @brief Ethernet DMA extra statistics */ @@ -101,9 +114,15 @@ static const struct ether_stats ether_dstrings_stats[] = { * @brief Name of extra Ethernet stats, with length of name not more than * ETH_GSTRING_LEN MAC */ +#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE #define ETHER_EXTRA_STAT(b) \ { #b, FIELD_SIZEOF(struct osi_xtra_stat_counters, b), \ offsetof(struct osi_core_priv_data, xstats.b)} +#else +#define ETHER_EXTRA_STAT(b) \ +{ #b, sizeof_field(struct osi_xtra_stat_counters, b), \ + offsetof(struct osi_core_priv_data, xstats.b)} +#endif /** * @brief Ethernet extra statistics */ @@ -159,9 +178,15 @@ static const struct ether_stats ether_gstrings_stats[] = { * @brief HW MAC Management counters * Structure variable name MUST up to MAX length of ETH_GSTRING_LEN */ +#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE #define ETHER_MMC_STAT(c) \ { #c, FIELD_SIZEOF(struct osi_mmc_counters, c), \ offsetof(struct osi_core_priv_data, mmc.c)} +#else +#define ETHER_MMC_STAT(c) \ +{ #c, sizeof_field(struct osi_mmc_counters, c), \ + offsetof(struct osi_core_priv_data, mmc.c)} +#endif /** * @brief MMC statistics diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h index c5bcf6d9..4b761060 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h +++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h @@ -105,7 +105,7 @@ struct ifr_data_timestamp_struct { /** Store kernel time */ struct timespec64 kernel_ts; /** Store HW time */ - struct timespec hw_ptp_ts; + struct timespec64 hw_ptp_ts; }; /** diff --git a/drivers/net/ethernet/nvidia/nvethernet/ptp.c b/drivers/net/ethernet/nvidia/nvethernet/ptp.c index 9624c056..e8b1edcc 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ptp.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ptp.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ +#include #include "ether_linux.h" /** @@ -297,7 +298,11 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, struct osi_core_priv_data *osi_core = pdata->osi_core; struct hwtstamp_config config; unsigned int hwts_rx_en = 1; +#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE struct timespec now; +#else + struct timespec64 now; +#endif if (pdata->hw_feat.tsstssel == OSI_DISABLE) { dev_info(pdata->dev, "HW timestamping not available\n"); @@ -436,7 +441,11 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata, * can make use of it for coarse correction */ osi_core->ptp_config.ptp_clock = pdata->ptp_ref_clock_speed; /* initialize system time */ +#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE getnstimeofday(&now); +#else + ktime_get_ts64(&now); +#endif /* Store sec and nsec */ osi_core->ptp_config.sec = now.tv_sec; osi_core->ptp_config.nsec = now.tv_nsec; @@ -518,7 +527,11 @@ int ether_handle_priv_ts_ioctl(struct ether_priv_data *pdata, raw_spin_unlock_irqrestore(ðer_ts_lock, flags); +#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE dev_dbg(pdata->dev, "tv_sec = %ld, tv_nsec = %ld\n", +#else + dev_dbg(pdata->dev, "tv_sec = %lld, tv_nsec = %ld\n", +#endif req.hw_ptp_ts.tv_sec, req.hw_ptp_ts.tv_nsec); if (copy_to_user(ifr->ifr_data, &req, sizeof(req))) {