Skip to content

Commit

Permalink
Fix i40e compilation on latest RH9 kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Nov 28, 2024
1 parent 9dd3bfc commit 74c42be
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
64 changes: 61 additions & 3 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 @@ -7196,7 +7196,36 @@ static int i40e_get_module_eeprom(struct net_device *netdev,
#endif /* ETHTOOL_GMODULEINFO */

#ifdef ETHTOOL_GEEE
static int i40e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)

#ifdef HAVE_ETHTOOL_KEEE
static void i40e_eee_capability_to_kedata_supported(__le16 eee_capability_,
unsigned long *supported)
{
const int eee_capability = le16_to_cpu(eee_capability_);
static const int lut[] = {
ETHTOOL_LINK_MODE_100baseT_Full_BIT,
ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT,
ETHTOOL_LINK_MODE_10000baseKR_Full_BIT,
ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT,
};

linkmode_zero(supported);
for (unsigned int i = ARRAY_SIZE(lut); i--; )
if (eee_capability & BIT(i + 1))
linkmode_set_bit(lut[i], supported);
}
#endif

static int i40e_get_eee(struct net_device *netdev,
#ifdef HAVE_ETHTOOL_KEEE
struct ethtool_keee *edata
#else
struct ethtool_eee *edata
#endif
)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_aq_get_phy_abilities_resp phy_cfg;
Expand All @@ -7216,17 +7245,31 @@ static int i40e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
if (phy_cfg.eee_capability == 0)
return -EOPNOTSUPP;

#ifdef HAVE_ETHTOOL_KEEE
i40e_eee_capability_to_kedata_supported(phy_cfg.eee_capability,
edata->supported);
linkmode_copy(edata->lp_advertised, edata->supported);
#else
edata->supported = SUPPORTED_Autoneg;
edata->lp_advertised = edata->supported;
#endif

/* Get current configuration */
status = i40e_aq_get_phy_capabilities(hw, false, false, &phy_cfg, NULL);
if (status)
return -EAGAIN;

#ifdef HAVE_ETHTOOL_KEEE
linkmode_zero(edata->advertised);
if (phy_cfg.eee_capability)
linkmode_copy(edata->advertised, edata->supported);
edata->eee_enabled = !!phy_cfg.eee_capability;
edata->tx_lpi_enabled = pf->stats.tx_lpi_status;
#else
edata->advertised = phy_cfg.eee_capability ? SUPPORTED_Autoneg : 0U;
edata->eee_enabled = !!edata->advertised;
edata->tx_lpi_enabled = pf->stats.tx_lpi_status;
#endif

edata->eee_active = pf->stats.tx_lpi_status && pf->stats.rx_lpi_status;

Expand All @@ -7236,7 +7279,12 @@ static int i40e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)

#ifdef ETHTOOL_SEEE
static int i40e_is_eee_param_supported(struct net_device *netdev,
struct ethtool_eee *edata)
#ifdef HAVE_ETHTOOL_KEEE
struct ethtool_keee *edata
#else
struct ethtool_eee *edata
#endif
)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi;
Expand All @@ -7245,7 +7293,11 @@ static int i40e_is_eee_param_supported(struct net_device *netdev,
u32 value;
const char *name;
} param[] = {
#ifdef HAVE_ETHTOOL_KEEE
{!!(edata->advertised[0] & ~edata->supported[0]), "advertise"},
#else
{edata->advertised & ~SUPPORTED_Autoneg, "advertise"},
#endif
{edata->tx_lpi_timer, "tx-timer"},
{edata->tx_lpi_enabled != pf->stats.tx_lpi_status, "tx-lpi"}
};
Expand All @@ -7263,7 +7315,13 @@ static int i40e_is_eee_param_supported(struct net_device *netdev,
return 0;
}

static int i40e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
static int i40e_set_eee(struct net_device *netdev,
#ifdef HAVE_ETHTOOL_KEEE
struct ethtool_keee *edata
#else
struct ethtool_eee *edata
#endif
)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_aq_get_phy_abilities_resp abilities;
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 @@ -8098,10 +8098,16 @@ void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
"NIC Link is Up, %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s, Autoneg: %s, Flow Control: %s\n",
speed, req_fec, fec, an, fc);
} else {
#ifdef HAVE_ETHTOOL_KEEE
struct ethtool_keee edata;

memzero_explicit(&edata, sizeof(edata));
#else
struct ethtool_eee edata;

edata.supported = 0;
edata.eee_enabled = false;
#endif
if (vsi->netdev->ethtool_ops->get_eee)
vsi->netdev->ethtool_ops->get_eee(vsi->netdev, &edata);

Expand Down
5 changes: 5 additions & 0 deletions drivers/intel/i40e/i40e-2.24.6-zc/src/i40e_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2637,9 +2637,14 @@ static struct sk_buff *i40e_construct_skb(struct i40e_ring *rx_ring,
#endif

/* allocate a skb to store the frags */
#if 1
skb = napi_alloc_skb(&rx_ring->q_vector->napi,
I40E_RX_HDR_SIZE);
#else
skb = __napi_alloc_skb(&rx_ring->q_vector->napi,
I40E_RX_HDR_SIZE,
GFP_ATOMIC | __GFP_NOWARN);
#endif
if (unlikely(!skb))
return NULL;

Expand Down

0 comments on commit 74c42be

Please sign in to comment.