Skip to content

Commit

Permalink
Fix i40e zc compilation on ubuntu 24
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed May 24, 2024
1 parent 936ce35 commit ccbb31a
Show file tree
Hide file tree
Showing 8 changed files with 491 additions and 97 deletions.
4 changes: 4 additions & 0 deletions drivers/intel/i40e/i40e-2.24.6-zc/src/i40e.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include <linux/if_vlan.h>
#include <linux/if_bridge.h>

#ifdef HAVE_PF_RING
#include <net/xdp.h>
#endif

/* AF_XDP is currently only supported in kernel versions 4.20 to 5.1,
* and only on redhat */
#include <linux/version.h>
Expand Down
99 changes: 78 additions & 21 deletions drivers/intel/i40e/i40e-2.24.6-zc/src/i40e_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -6558,22 +6558,25 @@ static u32 i40e_get_rxfh_indir_size(struct net_device *netdev)
return I40E_HLUT_ARRAY_SIZE;
}

#ifdef HAVE_RXFH_HASHFUNC
#ifdef HAVE_ETHTOOL_RXFH_PARAM
/**
* i40e_get_rxfh - get the rx flow hash indirection table
* i40e_get_rxfh - Get the Rx flow hash indirection table.
* @netdev: network interface device structure
* @indir: indirection table
* @key: hash key
* @hfunc: hash function
* @rxfh: pointer to param struct (indir, key, hfunc)
*
* Reads the indirection table directly from the hardware. Returns 0 on
* success.
**/
#ifdef HAVE_RXFH_HASHFUNC
static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
u8 *hfunc)
*/
static int
i40e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
#else
static int
i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc)
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
#else
static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
#endif
#endif /* HAVE_RXFH_HASHFUNC */
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi;
Expand All @@ -6582,49 +6585,71 @@ static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
u16 i;

#ifdef HAVE_RXFH_HASHFUNC
#ifdef HAVE_ETHTOOL_RXFH_PARAM
rxfh->hfunc = ETH_RSS_HASH_TOP;
#else
if (hfunc)
*hfunc = ETH_RSS_HASH_TOP;
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
#endif /* HAVE_RXFH_HASHFUNC */

#endif
#ifdef HAVE_ETHTOOL_RXFH_PARAM
if (!rxfh->indir)
#else
if (!indir)
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
return 0;

#ifdef HAVE_ETHTOOL_RXFH_PARAM
seed = rxfh->key;
#else
seed = key;
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
lut = (u8 *)kzalloc(I40E_HLUT_ARRAY_SIZE, GFP_KERNEL);
if (!lut)
return -ENOMEM;

ret = i40e_get_rss(vsi, seed, lut, I40E_HLUT_ARRAY_SIZE);
if (ret)
goto out;

for (i = 0; i < I40E_HLUT_ARRAY_SIZE; i++)
#ifdef HAVE_ETHTOOL_RXFH_PARAM
rxfh->indir[i] = (u32)(lut[i]);
#else
indir[i] = (u32)(lut[i]);
#endif /* HAVE_ETHTOOL_RXFH_PARAM */

out:
kfree(lut);

return ret;
}

#ifdef HAVE_RXFH_HASHFUNC
#ifdef HAVE_ETHTOOL_RXFH_PARAM
/**
* i40e_set_rxfh - set the rx flow hash indirection table
* i40e_set_rxfh - Set the Rx flow hash indirection table.
* @netdev: network interface device structure
* @indir: indirection table
* @key: hash key
* @hfunc: hash function to use
* @rxfh: pointer to param struct (indir, key, hfunc)
* @extack: extended ACK from the Netlink message
*
* Returns -EINVAL if the table specifies an invalid queue id, otherwise
* Returns -EINVAL if the table specifies an invalid queue ID, otherwise
* returns 0 after programming the table.
**/
#ifdef HAVE_RXFH_HASHFUNC
*/
static int
i40e_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
struct netlink_ext_ack *extack)
#else
static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
const u8 *key, const u8 hfunc)
#else
#ifdef HAVE_RXFH_NONCONST
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
#elif defined(HAVE_RXFH_NONCONST)
static int i40e_set_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
#else
static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
const u8 *key)
#endif /* HAVE_RXFH_NONCONST */
#endif /* HAVE_RXFH_HASHFUNC */
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
Expand All @@ -6634,26 +6659,49 @@ static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
u16 i;

#ifdef HAVE_RXFH_HASHFUNC
#ifdef HAVE_ETHTOOL_RXFH_PARAM
if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
rxfh->hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;
#else
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;
#endif
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
#endif /* HAVE_RXFH_HASHFUNC */

/* Verify user input. */
if (indir) {
#ifdef HAVE_ETHTOOL_RXFH_PARAM
if (rxfh->indir)
#else
if (indir)
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
{
for (i = 0; i < I40E_HLUT_ARRAY_SIZE; i++) {
#ifdef HAVE_ETHTOOL_RXFH_PARAM
if (rxfh->indir[i] >= vsi->rss_size)
#else
if (indir[i] >= vsi->rss_size)
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
return -EINVAL;
}
}

#ifdef HAVE_ETHTOOL_RXFH_PARAM
if (rxfh->key) {
#else
if (key) {
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
if (!vsi->rss_hkey_user) {
vsi->rss_hkey_user = (u8 *)
kzalloc(I40E_HKEY_ARRAY_SIZE, GFP_KERNEL);
if (!vsi->rss_hkey_user)
return -ENOMEM;
}
#ifdef HAVE_ETHTOOL_RXFH_PARAM
memcpy(vsi->rss_hkey_user, rxfh->key, I40E_HKEY_ARRAY_SIZE);
#else
memcpy(vsi->rss_hkey_user, key, I40E_HKEY_ARRAY_SIZE);
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
seed = vsi->rss_hkey_user;
}
if (!vsi->rss_lut_user) {
Expand All @@ -6664,9 +6712,18 @@ static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
}

/* Each 32 bits pointed by 'indir' is stored with a lut entry */

#ifdef HAVE_ETHTOOL_RXFH_PARAM
if (rxfh->indir)
#else
if (indir)
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
for (i = 0; i < I40E_HLUT_ARRAY_SIZE; i++)
#ifdef HAVE_ETHTOOL_RXFH_PARAM
vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]);
#else
vsi->rss_lut_user[i] = (u8)(indir[i]);
#endif /* HAVE_ETHTOOL_RXFH_PARAM */
else
i40e_fill_rss_lut(pf, vsi->rss_lut_user, I40E_HLUT_ARRAY_SIZE,
vsi->rss_size);
Expand Down
6 changes: 6 additions & 0 deletions drivers/intel/i40e/i40e-2.24.6-zc/src/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18095,7 +18095,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
"pci_request_mem_regions failed %d\n", err);
goto err_pci_reg;
}
#ifdef HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING
pci_enable_pcie_error_reporting(pdev);
#endif /* HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING */
pci_set_master(pdev);

/* Now that we have a PCI connection, we need to do the
Expand Down Expand Up @@ -18717,7 +18719,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_ioremap:
kfree(pf);
err_pf_alloc:
#ifdef HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING
pci_disable_pcie_error_reporting(pdev);
#endif /* HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING */
pci_release_mem_regions(pdev);
err_pci_reg:
err_dma:
Expand Down Expand Up @@ -18893,7 +18897,9 @@ static void i40e_remove(struct pci_dev *pdev)
kfree(pf);
pci_release_mem_regions(pdev);

#ifdef HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING
pci_disable_pcie_error_reporting(pdev);
#endif /* HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING */
pci_disable_device(pdev);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/intel/i40e/i40e-2.24.6-zc/src/i40e_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2938,7 +2938,7 @@ void i40e_finalize_xdp_rx(struct i40e_ring *rx_ring,
unsigned int xdp_res)
{
if (xdp_res & I40E_XDP_REDIR)
xdp_do_flush_map();
xdp_do_flush(); //xdp_do_flush_map();

if (xdp_res & I40E_XDP_TX) {
struct i40e_ring *xdp_ring =
Expand Down
Loading

0 comments on commit ccbb31a

Please sign in to comment.