nvethernet: Fix build for Linux v5.14 and v5.17+

The nvethernet driver fails to build for Linux v5.14 and Linux v5.17+
kernels. In Linux v5.15 the return type of the get/set_coalesce
callbacks were updated. In Linux v5.17 the parameters for the
get/set_ringparam callbacks were updated. In Linux v6.1 the
weight parameter for the netif_napi_add() function was removed and the
function netif_napi_add_weight() was added for passing the weight
parameter. Add the necessary kernel version checks to ensure that the
drivers build with the different versions of the Linux kernel.

Bug 3793131

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Change-Id: I56738eddd27eb4ebf7db5a2d0d031a64379482e8
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2820712
Reviewed-by: Revanth Kumar Uppala <ruppala@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2022-12-02 13:18:38 +00:00
committed by mobile promotions
parent dc420b6a6d
commit 1e04890051
2 changed files with 22 additions and 2 deletions

View File

@@ -4256,8 +4256,13 @@ static int ether_alloc_napi(struct ether_priv_data *pdata)
pdata->tx_napi[chan]->pdata = pdata;
pdata->tx_napi[chan]->chan = chan;
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
netif_napi_add_weight(ndev, &pdata->tx_napi[chan]->napi,
ether_napi_poll_tx, 64);
#else
netif_napi_add(ndev, &pdata->tx_napi[chan]->napi,
ether_napi_poll_tx, 64);
#endif
pdata->rx_napi[chan] = devm_kzalloc(dev,
sizeof(struct ether_rx_napi),
@@ -4269,8 +4274,13 @@ static int ether_alloc_napi(struct ether_priv_data *pdata)
pdata->rx_napi[chan]->pdata = pdata;
pdata->rx_napi[chan]->chan = chan;
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
netif_napi_add_weight(ndev, &pdata->rx_napi[chan]->napi,
ether_napi_poll_rx, 64);
#else
netif_napi_add(ndev, &pdata->rx_napi[chan]->napi,
ether_napi_poll_rx, 64);
#endif
}
return 0;

View File

@@ -894,10 +894,15 @@ static int ether_get_ts_info(struct net_device *ndev,
* @retval 0 on Sucess
* @retval "negative value" on failure.
*/
#if (KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE)
static int ether_set_coalesce(struct net_device *dev,
struct ethtool_coalesce *ec,
struct kernel_ethtool_coalesce *kernel_coal,
struct netlink_ext_ack *extack)
#else
static int ether_set_coalesce(struct net_device *dev,
struct ethtool_coalesce *ec)
#endif
{
struct ether_priv_data *pdata = netdev_priv(dev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
@@ -1030,10 +1035,15 @@ static int ether_set_coalesce(struct net_device *dev,
*
* @retval 0 on Success.
*/
#if (KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE)
static int ether_get_coalesce(struct net_device *dev,
struct ethtool_coalesce *ec,
struct kernel_ethtool_coalesce *kernel_coal,
struct netlink_ext_ack *extack)
#else
static int ether_get_coalesce(struct net_device *dev,
struct ethtool_coalesce *ec)
#endif
{
struct ether_priv_data *pdata = netdev_priv(dev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
@@ -1485,7 +1495,7 @@ static int ether_set_rxfh(struct net_device *ndev, const u32 *indir,
}
#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
#if (KERNEL_VERSION(5, 17, 0) <= LINUX_VERSION_CODE)
static void ether_get_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
@@ -1505,7 +1515,7 @@ 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)
#if (KERNEL_VERSION(5, 17, 0) <= LINUX_VERSION_CODE)
static int ether_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,