nvidia: drivers: fix linux-5.7-rc5 build

Fix build linux-5.7-rc5 errors including following:
	- change timespec to timespec64. replace getnstimeofday
	  with ktime_get_ts64
	- replace usage of macro FIELD_SIZEOF with sizeof_field in ethtool.c
	  nvethernet and eqos files.
	- support 2 arguments for of_get_phy_mode call

bug 200617764

Change-Id: I46067d7d36d08ee9556b2722e9ccec707b8853d4
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2347244
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Bitan Biswas
2020-05-19 13:47:28 -07:00
committed by Revanth Kumar Uppala
parent c6b2d05d26
commit 0e7b230bab
5 changed files with 49 additions and 2 deletions

View File

@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/version.h>
#include "ether_linux.h" #include "ether_linux.h"
/** /**
@@ -3576,7 +3577,15 @@ rst_clk_fail:
static int ether_parse_phy_dt(struct ether_priv_data *pdata, static int ether_parse_phy_dt(struct ether_priv_data *pdata,
struct device_node *node) struct device_node *node)
{ {
#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE
pdata->interface = of_get_phy_mode(node); 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); pdata->phy_node = of_parse_phandle(node, "phy-handle", 0);
if (pdata->phy_node == NULL) if (pdata->phy_node == NULL)

View File

@@ -281,7 +281,7 @@ struct ether_priv_data {
struct phy_device *phydev; struct phy_device *phydev;
/** Interface type assciated with MAC (SGMII/RGMII/...) /** Interface type assciated with MAC (SGMII/RGMII/...)
* this information will be provided with phy-mode DT entry */ * this information will be provided with phy-mode DT entry */
int interface; phy_interface_t interface;
/** Previous detected link */ /** Previous detected link */
unsigned int oldlink; unsigned int oldlink;
/** PHY link speed */ /** PHY link speed */

View File

@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/version.h>
#include "ether_linux.h" #include "ether_linux.h"
/** /**
@@ -42,9 +43,15 @@ struct ether_stats {
* @brief Name of pkt_err statistics, with length of name not more than * @brief Name of pkt_err statistics, with length of name not more than
* ETH_GSTRING_LEN * ETH_GSTRING_LEN
*/ */
#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE
#define ETHER_PKT_ERR_STAT(y) \ #define ETHER_PKT_ERR_STAT(y) \
{ (#y), FIELD_SIZEOF(struct osi_pkt_err_stats, y), \ { (#y), FIELD_SIZEOF(struct osi_pkt_err_stats, y), \
offsetof(struct osi_dma_priv_data, 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 * @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 * @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) \ #define ETHER_DMA_EXTRA_STAT(a) \
{ (#a), FIELD_SIZEOF(struct osi_xtra_dma_stat_counters, a), \ { (#a), FIELD_SIZEOF(struct osi_xtra_dma_stat_counters, a), \
offsetof(struct osi_dma_priv_data, dstats.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 * @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 * @brief Name of extra Ethernet stats, with length of name not more than
* ETH_GSTRING_LEN MAC * ETH_GSTRING_LEN MAC
*/ */
#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE
#define ETHER_EXTRA_STAT(b) \ #define ETHER_EXTRA_STAT(b) \
{ #b, FIELD_SIZEOF(struct osi_xtra_stat_counters, b), \ { #b, FIELD_SIZEOF(struct osi_xtra_stat_counters, b), \
offsetof(struct osi_core_priv_data, xstats.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 * @brief Ethernet extra statistics
*/ */
@@ -159,9 +178,15 @@ static const struct ether_stats ether_gstrings_stats[] = {
* @brief HW MAC Management counters * @brief HW MAC Management counters
* Structure variable name MUST up to MAX length of ETH_GSTRING_LEN * 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) \ #define ETHER_MMC_STAT(c) \
{ #c, FIELD_SIZEOF(struct osi_mmc_counters, c), \ { #c, FIELD_SIZEOF(struct osi_mmc_counters, c), \
offsetof(struct osi_core_priv_data, mmc.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 * @brief MMC statistics

View File

@@ -105,7 +105,7 @@ struct ifr_data_timestamp_struct {
/** Store kernel time */ /** Store kernel time */
struct timespec64 kernel_ts; struct timespec64 kernel_ts;
/** Store HW time */ /** Store HW time */
struct timespec hw_ptp_ts; struct timespec64 hw_ptp_ts;
}; };
/** /**

View File

@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/version.h>
#include "ether_linux.h" #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 osi_core_priv_data *osi_core = pdata->osi_core;
struct hwtstamp_config config; struct hwtstamp_config config;
unsigned int hwts_rx_en = 1; unsigned int hwts_rx_en = 1;
#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
struct timespec now; struct timespec now;
#else
struct timespec64 now;
#endif
if (pdata->hw_feat.tsstssel == OSI_DISABLE) { if (pdata->hw_feat.tsstssel == OSI_DISABLE) {
dev_info(pdata->dev, "HW timestamping not available\n"); 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 */ * can make use of it for coarse correction */
osi_core->ptp_config.ptp_clock = pdata->ptp_ref_clock_speed; osi_core->ptp_config.ptp_clock = pdata->ptp_ref_clock_speed;
/* initialize system time */ /* initialize system time */
#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
getnstimeofday(&now); getnstimeofday(&now);
#else
ktime_get_ts64(&now);
#endif
/* Store sec and nsec */ /* Store sec and nsec */
osi_core->ptp_config.sec = now.tv_sec; osi_core->ptp_config.sec = now.tv_sec;
osi_core->ptp_config.nsec = now.tv_nsec; 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(&ether_ts_lock, flags); raw_spin_unlock_irqrestore(&ether_ts_lock, flags);
#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
dev_dbg(pdata->dev, "tv_sec = %ld, tv_nsec = %ld\n", 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); req.hw_ptp_ts.tv_sec, req.hw_ptp_ts.tv_nsec);
if (copy_to_user(ifr->ifr_data, &req, sizeof(req))) { if (copy_to_user(ifr->ifr_data, &req, sizeof(req))) {