diff --git a/drivers/net/ethernet/nvidia/Makefile b/drivers/net/ethernet/nvidia/Makefile
index 8abef68f..a3cda4d8 100644
--- a/drivers/net/ethernet/nvidia/Makefile
+++ b/drivers/net/ethernet/nvidia/Makefile
@@ -1,4 +1,5 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
+#SPDX-License-Identifier: GPL-2.0-only
+#Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
obj-m += pcie/
+obj-m += nvethernet/
diff --git a/drivers/net/ethernet/nvidia/nvethernet/.gitignore b/drivers/net/ethernet/nvidia/nvethernet/.gitignore
deleted file mode 100644
index eb7f4672..00000000
--- a/drivers/net/ethernet/nvidia/nvethernet/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-nvethernetrm
diff --git a/drivers/net/ethernet/nvidia/nvethernet/Makefile b/drivers/net/ethernet/nvidia/nvethernet/Makefile
index 38074bfd..97d7f63b 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/Makefile
+++ b/drivers/net/ethernet/nvidia/nvethernet/Makefile
@@ -1,28 +1,17 @@
-# Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms and conditions of the GNU General Public License,
-# version 2, as published by the Free Software Foundation.
-#
-# This program is distributed in the hope it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
+#SPDX-License-Identifier: GPL-2.0-only
+#Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
OSI_COMMON := nvethernetrm/osi/common
OSI_CORE := nvethernetrm/osi/core
OSI_DMA := nvethernetrm/osi/dma
-obj-$(CONFIG_NVETHERNET) += nvethernet.o
+obj-m += nvethernet.o
ccflags-y += -DLINUX_IVC -DUPDATED_PAD_CAL \
-I$(srctree.nvidia)/drivers/net/ethernet/nvidia/nvethernet/nvethernetrm/include \
-I$(srctree.nvidia)/drivers/net/ethernet/nvidia/nvethernet/nvethernetrm/osi/common/include
-ccflags-y += -DMACSEC_SUPPORT -DNET30 -DDEBUG_MACSEC -DOSI_DEBUG -DHSI_SUPPORT -DLINUX_OS -DNVPKCS_MACSEC
+ccflags-y += -DMACSEC_SUPPORT -DNET30 -DDEBUG_MACSEC -DOSI_DEBUG $(if $(CONFIG_TEGRA_EPL),-DHSI_SUPPORT,) -DLINUX_OS -DNVPKCS_MACSEC
nvethernet-objs:= ether_linux.o \
osd.o \
@@ -32,6 +21,7 @@ nvethernet-objs:= ether_linux.o \
ioctl.o \
ptp.o \
macsec.o \
+ selftests.o \
$(OSI_CORE)/osi_core.o \
$(OSI_CORE)/osi_hal.o \
$(OSI_CORE)/macsec.o \
@@ -55,5 +45,3 @@ nvethernet-objs:= ether_linux.o \
$(OSI_CORE)/frp.o \
$(OSI_CORE)/vlan_filter.o \
$(OSI_CORE)/debug.o
-
-nvethernet-$(CONFIG_NVETHERNET_SELFTESTS) += selftests.o
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_export.h b/drivers/net/ethernet/nvidia/nvethernet/ether_export.h
index ac581d48..f692c273 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ether_export.h
+++ b/drivers/net/ethernet/nvidia/nvethernet/ether_export.h
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#ifndef ETHER_EXPORT_H
#define ETHER_EXPORT_H
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c
index f1053711..3f3d8bb0 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include
#include
@@ -20,6 +7,9 @@
#include
#endif
#include "ether_linux.h"
+#include
+#include
+#include
int ether_get_tx_ts(struct ether_priv_data *pdata)
{
@@ -2988,12 +2978,8 @@ static int ether_handle_tso(struct osi_tx_pkt_cx *tx_pkt_cx,
}
}
-#if (KERNEL_VERSION(5, 9, 0) < LINUX_VERSION_CODE)
/* Start filling packet details in Tx_pkt_cx */
if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_L4)) {
-#else
- if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP)) {
-#endif
tx_pkt_cx->tcp_udp_hdrlen = sizeof(struct udphdr);
tx_pkt_cx->mss = skb_shinfo(skb)->gso_size -
sizeof(struct udphdr);
@@ -3080,11 +3066,7 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
struct device *dev = pdata->dev;
unsigned int len = 0, offset = 0, size = 0;
int cnt = 0, ret = 0, i, num_frags;
-#if (KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE)
skb_frag_t *frag;
-#else
- struct skb_frag_struct *frag;
-#endif
unsigned int page_idx, page_offset;
unsigned int max_data_len_per_txd = (unsigned int)
ETHER_TX_MAX_BUFF_SIZE;
@@ -3221,19 +3203,10 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
}
size = min(len, max_data_len_per_txd);
-#if (KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE)
page_idx = (frag->bv_offset + offset) >> PAGE_SHIFT;
page_offset = (frag->bv_offset + offset) & ~PAGE_MASK;
-#else
- page_idx = (frag->page_offset + offset) >> PAGE_SHIFT;
- page_offset = (frag->page_offset + offset) & ~PAGE_MASK;
-#endif
tx_swcx->buf_phy_addr = dma_map_page(dev,
-#if (KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE)
(frag->bv_page + page_idx),
-#else
- (frag->page.p + page_idx),
-#endif
page_offset, size,
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(dev,
@@ -3283,12 +3256,7 @@ dma_map_failed:
*/
static unsigned short ether_select_queue(struct net_device *dev,
struct sk_buff *skb,
-#if (KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE)
- void *accel_priv,
- select_queue_fallback_t fallback)
-#else
struct net_device *sb_dev)
-#endif
{
struct ether_priv_data *pdata = netdev_priv(dev);
struct osi_core_priv_data *osi_core = pdata->osi_core;
@@ -3702,7 +3670,6 @@ void ether_set_rx_mode(struct net_device *dev)
static int ether_handle_priv_rmdio_ioctl(struct ether_priv_data *pdata,
struct ifreq *ifr)
{
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 9, 0))
struct mii_ioctl_data *mii_data = if_mii(ifr);
unsigned int prtad, devad;
int ret = 0;
@@ -3728,10 +3695,6 @@ static int ether_handle_priv_rmdio_ioctl(struct ether_priv_data *pdata,
mii_data->val_out = ret;
return 0;
-#else
- dev_err(pdata->dev, "Not supported for kernel versions less than 5.10");
- return -ENOTSUPP;
-#endif
}
/**
@@ -3749,7 +3712,6 @@ static int ether_handle_priv_rmdio_ioctl(struct ether_priv_data *pdata,
static int ether_handle_priv_wmdio_ioctl(struct ether_priv_data *pdata,
struct ifreq *ifr)
{
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 9, 0))
struct mii_ioctl_data *mii_data = if_mii(ifr);
unsigned int prtad, devad;
@@ -3767,10 +3729,6 @@ static int ether_handle_priv_wmdio_ioctl(struct ether_priv_data *pdata,
return osi_write_phy_reg(pdata->osi_core, prtad, devad,
mii_data->val_in);
-#else
- dev_err(pdata->dev, "Not supported for kernel versions less than 5.10");
- return -ENOTSUPP;
-#endif
}
/**
@@ -4106,7 +4064,6 @@ static int ether_vlan_rx_kill_vid(struct net_device *ndev, __be16 vlan_proto,
return ret;
}
-#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE)
/**
* @brief ether_setup_tc - TC HW offload support
*
@@ -4142,7 +4099,6 @@ static int ether_setup_tc(struct net_device *ndev, enum tc_setup_type type,
return -EOPNOTSUPP;
}
}
-#endif
/**
* @brief Ethernet network device operations
@@ -4159,9 +4115,7 @@ static const struct net_device_ops ether_netdev_ops = {
.ndo_set_rx_mode = ether_set_rx_mode,
.ndo_vlan_rx_add_vid = ether_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = ether_vlan_rx_kill_vid,
-#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE)
.ndo_setup_tc = ether_setup_tc,
-#endif
};
/**
@@ -4596,6 +4550,7 @@ static int ether_get_mac_address(struct ether_priv_data *pdata)
struct net_device *ndev = pdata->ndev;
struct device_node *np = dev->of_node;
const char *eth_mac_addr = NULL;
+ u8 *addr = NULL;
unsigned char mac_addr[ETH_ALEN] = {0};
/* Default choesn node property name for MAC address */
char str_mac_address[ETH_MAC_STR_LEN] = "nvidia,ether-mac";
@@ -4642,7 +4597,10 @@ static int ether_get_mac_address(struct ether_priv_data *pdata)
* upstream driver should have only this call to get
* MAC address
*/
- eth_mac_addr = of_get_mac_address(np);
+ ret = of_get_mac_address(np, addr);
+ if (!ret)
+ return ret;
+ eth_mac_addr = addr;
if (IS_ERR_OR_NULL(eth_mac_addr)) {
dev_err(dev, "No MAC address in local DT!\n");
@@ -5309,13 +5267,9 @@ static int ether_parse_phy_dt(struct ether_priv_data *pdata,
{
int err;
-#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE
- pdata->interface = of_get_phy_mode(node);
-#else
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)
@@ -6151,10 +6105,8 @@ static void ether_set_ndev_features(struct net_device *ndev,
features |= NETIF_F_SG;
}
-#if (KERNEL_VERSION(5, 9, 0) < LINUX_VERSION_CODE)
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE)
features |= NETIF_F_GSO_UDP_L4;
-#endif
if (pdata->hw_feat.tx_coe_sel) {
features |= NETIF_F_IP_CSUM;
@@ -6855,13 +6807,8 @@ static int ether_resume_noirq(struct device *dev)
}
static const struct dev_pm_ops ether_pm_ops = {
-#if (KERNEL_VERSION(5, 9, 0) < LINUX_VERSION_CODE)
.suspend = ether_suspend_noirq,
.resume = ether_resume_noirq,
-#else
- .suspend_noirq = ether_suspend_noirq,
- .resume_noirq = ether_resume_noirq,
-#endif
};
#endif
@@ -6891,21 +6838,8 @@ static struct platform_driver ether_driver = {
},
};
-static int __init nvethernet_driver_init(void)
-{
- return platform_driver_register(ðer_driver);
-}
-
-#if IS_MODULE(CONFIG_NVETHERNET)
-static void __exit nvethernet_driver_deinit(void)
-{
- platform_driver_unregister(ðer_driver);
-}
-
-module_init(nvethernet_driver_init);
-module_exit(nvethernet_driver_deinit);
-#else
-late_initcall(nvethernet_driver_init);
-#endif
+module_platform_driver(ether_driver);
+MODULE_DESCRIPTION("NVIDIA ETHERNET DRIVER");
+MODULE_AUTHOR("Revanth Kumar Uppala ");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h
index a4a9f3f0..5e06513d 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h
+++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.h
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#ifndef ETHER_LINUX_H
#define ETHER_LINUX_H
@@ -47,18 +34,13 @@
#include
#include
#include
-#include
-#if (KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE)
-#include
-#else
+#include
+#include
#include
-#endif
#if IS_ENABLED(CONFIG_PAGE_POOL)
-#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE)
#include
#define ETHER_PAGE_POOL
#endif
-#endif
#include
#include
#include
@@ -73,6 +55,11 @@
#include
#endif /* ETHER_NVGRO */
+/**
+ * @brief Define for default DMA bit mask
+ */
+#define DMA_MASK_NONE 0x0ULL
+
/**
* @brief Constant for CBS value calculate
*/
@@ -717,25 +704,10 @@ int ether_conf_eee(struct ether_priv_data *pdata, unsigned int tx_lpi_enable);
*/
int ether_padctrl_mii_rx_pins(void *priv, unsigned int enable);
-#if IS_ENABLED(CONFIG_NVETHERNET_SELFTESTS)
void ether_selftest_run(struct net_device *dev,
struct ethtool_test *etest, u64 *buf);
void ether_selftest_get_strings(struct ether_priv_data *pdata, u8 *data);
int ether_selftest_get_count(struct ether_priv_data *pdata);
-#else
-static inline void ether_selftest_run(struct net_device *dev,
- struct ethtool_test *etest, u64 *buf)
-{
-}
-static inline void ether_selftest_get_strings(struct ether_priv_data *pdata,
- u8 *data)
-{
-}
-static inline int ether_selftest_get_count(struct ether_priv_data *pdata)
-{
- return -EOPNOTSUPP;
-}
-#endif /* CONFIG_NVETHERNET_SELFTESTS */
/**
* @brief ether_assign_osd_ops - Assigns OSD ops for OSI
@@ -769,7 +741,6 @@ int osd_ivc_send_cmd(void *priv, ivc_msg_common_t *ivc_buf,
void ether_set_rx_mode(struct net_device *dev);
-#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE)
/**
* @brief Function to configure traffic class
*
@@ -804,7 +775,6 @@ int ether_tc_setup_taprio(struct ether_priv_data *pdata,
int ether_tc_setup_cbs(struct ether_priv_data *pdata,
struct tc_cbs_qopt_offload *qopt);
-#endif
/**
* @brief Get Tx done timestamp from OSI and update in skb
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_tc.c b/drivers/net/ethernet/nvidia/nvethernet/ether_tc.c
index 381c7c33..f180fb65 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ether_tc.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/ether_tc.c
@@ -1,22 +1,8 @@
-/*
- * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include "ether_linux.h"
-#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE)
int ether_tc_setup_taprio(struct ether_priv_data *pdata,
struct tc_taprio_qopt_offload *qopt)
{
@@ -253,4 +239,3 @@ int ether_tc_setup_cbs(struct ether_priv_data *pdata,
return osi_handle_ioctl(osi_core, &ioctl_data);
}
-#endif
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c
index d28be284..82e51c55 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include
#include "ether_linux.h"
@@ -43,15 +30,9 @@ struct ether_stats {
* @brief Name of FRP statistics, with length of name not more than
* ETH_GSTRING_LEN
*/
-#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE
-#define ETHER_PKT_FRP_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_FRP_STAT(y) \
{ (#y), sizeof_field(struct osi_pkt_err_stats, y), \
offsetof(struct osi_dma_priv_data, pkt_err_stats.y)}
-#endif
/**
* @brief FRP statistics
@@ -72,15 +53,9 @@ static const struct ether_stats ether_frpstrings_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 pkt_err statistics
@@ -110,15 +85,9 @@ 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
*/
@@ -173,15 +142,9 @@ 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 ether_xtra_stat_counters, b), \
- offsetof(struct ether_priv_data, xstats.b)}
-#else
#define ETHER_EXTRA_STAT(b) \
{ #b, sizeof_field(struct ether_xtra_stat_counters, b), \
offsetof(struct ether_priv_data, xstats.b)}
-#endif
/**
* @brief Ethernet extra statistics
*/
@@ -242,15 +205,9 @@ 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
@@ -440,15 +397,9 @@ static const struct ether_stats ether_mmc[] = {
* @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_CORE_STATS(r) \
-{ (#r), FIELD_SIZEOF(struct osi_stats, r), \
- offsetof(struct osi_core_priv_data, stats.r)}
-#else
#define ETHER_CORE_STATS(r) \
{ (#r), sizeof_field(struct osi_stats, r), \
offsetof(struct osi_core_priv_data, stats.r)}
-#endif
/**
* @brief Ethernet extra statistics
@@ -791,13 +742,8 @@ static void ether_get_pauseparam(struct net_device *ndev,
/* return if pause frame is not supported */
if ((pdata->osi_core->pause_frames == OSI_PAUSE_FRAMES_DISABLE) ||
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
(!linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported) ||
!linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported))) {
-#else
- (!(phydev->supported & SUPPORTED_Pause) ||
- !(phydev->supported & SUPPORTED_Asym_Pause))) {
-#endif
dev_err(pdata->dev, "FLOW control not supported\n");
return;
}
@@ -847,13 +793,8 @@ static int ether_set_pauseparam(struct net_device *ndev,
/* return if pause frame is not supported */
if ((pdata->osi_core->pause_frames == OSI_PAUSE_FRAMES_DISABLE) ||
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
(!linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported) ||
!linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported))) {
-#else
- (!(phydev->supported & SUPPORTED_Pause) ||
- !(phydev->supported & SUPPORTED_Asym_Pause))) {
-#endif
dev_err(pdata->dev, "FLOW control not supported\n");
return -EOPNOTSUPP;
}
@@ -954,7 +895,9 @@ static int ether_get_ts_info(struct net_device *ndev,
* @retval "negative value" on failure.
*/
static int ether_set_coalesce(struct net_device *dev,
- struct ethtool_coalesce *ec)
+ struct ethtool_coalesce *ec,
+ struct kernel_ethtool_coalesce *kernel_coal,
+ struct netlink_ext_ack *extack)
{
struct ether_priv_data *pdata = netdev_priv(dev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
@@ -1088,7 +1031,9 @@ static int ether_set_coalesce(struct net_device *dev,
* @retval 0 on Success.
*/
static int ether_get_coalesce(struct net_device *dev,
- struct ethtool_coalesce *ec)
+ struct ethtool_coalesce *ec,
+ struct kernel_ethtool_coalesce *kernel_coal,
+ struct netlink_ext_ack *extack)
{
struct ether_priv_data *pdata = netdev_priv(dev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
@@ -1540,8 +1485,15 @@ static int ether_set_rxfh(struct net_device *ndev, const u32 *indir,
}
+#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
+static void ether_get_ringparam(struct net_device *ndev,
+ struct ethtool_ringparam *ring,
+ struct kernel_ethtool_ringparam *kernel_ring,
+ struct netlink_ext_ack *extack)
+#else
static void ether_get_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring)
+#endif
{
struct ether_priv_data *pdata = netdev_priv(ndev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
@@ -1553,8 +1505,15 @@ static void ether_get_ringparam(struct net_device *ndev,
ring->tx_pending = osi_dma->tx_ring_sz;
}
+#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
+static int ether_set_ringparam(struct net_device *ndev,
+ struct ethtool_ringparam *ring,
+ struct kernel_ethtool_ringparam *kernel_ring,
+ struct netlink_ext_ack *extack)
+#else
static int ether_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring)
+#endif
{
struct ether_priv_data *pdata = netdev_priv(ndev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
@@ -1618,10 +1577,8 @@ static const struct ethtool_ops ether_ethtool_ops = {
.get_ethtool_stats = ether_get_ethtool_stats,
.get_sset_count = ether_get_sset_count,
.get_coalesce = ether_get_coalesce,
-#if KERNEL_VERSION(5, 5, 0) <= LINUX_VERSION_CODE
.supported_coalesce_params = (ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES),
-#endif
.set_coalesce = ether_set_coalesce,
.get_wol = ether_get_wol,
.set_wol = ether_set_wol,
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.c b/drivers/net/ethernet/nvidia/nvethernet/ioctl.c
index 94fa62f3..68004d53 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include "ether_linux.h"
@@ -322,11 +309,7 @@ static int ether_config_ptp_offload(struct ether_priv_data *pdata,
unsigned int snap_type = 0x0;
unsigned int master = 0x0;
struct osi_ioctl ioctl_data = {};
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
struct timespec64 now;
-#else
- struct timespec now;
-#endif
if (!ifrd_p->ptr) {
dev_err(pdata->dev, "%s: Invalid data for priv ioctl %d\n",
@@ -342,11 +325,7 @@ static int ether_config_ptp_offload(struct ether_priv_data *pdata,
pdata->osi_core->ptp_config.ptp_clock = pdata->ptp_ref_clock_speed;
/* initialize system time */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
ktime_get_real_ts64(&now);
-#else
- getnstimeofday(&now);
-#endif
/* Store sec and nsec */
pdata->osi_core->ptp_config.sec = now.tv_sec;
pdata->osi_core->ptp_config.nsec = now.tv_nsec;
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h
index 1ab64ea3..3f343cec 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ioctl.h
+++ b/drivers/net/ethernet/nvidia/nvethernet/ioctl.h
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#ifndef IOCTL_H
#define IOCTL_H
diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.c b/drivers/net/ethernet/nvidia/nvethernet/macsec.c
index 4953cf7f..c9293623 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/macsec.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#ifdef MACSEC_SUPPORT
#include "ether_linux.h"
@@ -450,7 +437,7 @@ static struct macsec_priv_data *genl_to_macsec_pdata(struct genl_info *info)
PRINT_ENTRY();
- nla_strlcpy(ifname, attrs[NV_MACSEC_ATTR_IFNAME], sizeof(ifname));
+ nla_strscpy(ifname, attrs[NV_MACSEC_ATTR_IFNAME], sizeof(ifname));
ndev = dev_get_by_name(genl_info_net(info),
ifname);
if (!ndev) {
diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.h b/drivers/net/ethernet/nvidia/nvethernet/macsec.h
index d972151d..459d2fe3 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/macsec.h
+++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.h
@@ -1,24 +1,5 @@
-/*
- * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#ifndef INCLUDED_MACSEC_H
#define INCLUDED_MACSEC_H
diff --git a/drivers/net/ethernet/nvidia/nvethernet/osd.c b/drivers/net/ethernet/nvidia/nvethernet/osd.c
index 0354cec2..598ac757 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/osd.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/osd.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include "ether_linux.h"
diff --git a/drivers/net/ethernet/nvidia/nvethernet/ptp.c b/drivers/net/ethernet/nvidia/nvethernet/ptp.c
index 5aa334c9..e981ad9b 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/ptp.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/ptp.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include
#include "ether_linux.h"
@@ -272,11 +259,7 @@ static int ether_early_ptp_init(struct ether_priv_data *pdata)
struct osi_core_priv_data *osi_core = pdata->osi_core;
struct osi_ioctl ioctl_data = {};
int ret = 0;
-#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
- struct timespec now;
-#else
struct timespec64 now;
-#endif
osi_core->ptp_config.ptp_filter =
OSI_MAC_TCR_TSENA | OSI_MAC_TCR_TSCFUPDT |
@@ -288,11 +271,7 @@ static int ether_early_ptp_init(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_real_ts64(&now);
-#endif
/* Store sec and nsec */
osi_core->ptp_config.sec = now.tv_sec;
osi_core->ptp_config.nsec = now.tv_nsec;
@@ -410,11 +389,7 @@ int ether_handle_hwtstamp_ioctl(struct ether_priv_data *pdata,
struct hwtstamp_config config;
unsigned int hwts_rx_en = 1;
int ret;
-#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");
@@ -574,11 +549,7 @@ 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_real_ts64(&now);
-#endif
/* Store sec and nsec */
osi_core->ptp_config.sec = now.tv_sec;
osi_core->ptp_config.nsec = now.tv_nsec;
@@ -666,11 +637,7 @@ 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))) {
diff --git a/drivers/net/ethernet/nvidia/nvethernet/selftests.c b/drivers/net/ethernet/nvidia/nvethernet/selftests.c
index d9d88ab8..a5ec0cad 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/selftests.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/selftests.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include "ether_linux.h"
#include
diff --git a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c
index a3ea1c9e..f049834e 100644
--- a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c
+++ b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c
@@ -1,18 +1,5 @@
-/*
- * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
#include "ether_linux.h"
#include "macsec.h"