Commit 0ea7fae4 authored by Jacob Keller's avatar Jacob Keller Committed by Jeff Kirsher
Browse files

fm10k: use ethtool_rxfh_indir_default for default redirection table



The fm10k driver used its own code for generating a default indirection
table on device load, which was not the same as the default generated by
ethtool when indir_size of 0 is passed to SRXFH. Take advantage of
ethtool_rxfh_indir_default() and simplify code to write the redirection
table to reduce some code duplication.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarKrishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent d8ec92f2
......@@ -510,6 +510,8 @@ int fm10k_close(struct net_device *netdev);
/* Ethtool */
void fm10k_set_ethtool_ops(struct net_device *dev);
u32 fm10k_get_reta_size(struct net_device *netdev);
void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir);
/* IOV */
s32 fm10k_iov_event(struct fm10k_intfc *interface);
......
......@@ -1027,11 +1027,31 @@ static int fm10k_set_priv_flags(struct net_device *netdev, u32 priv_flags)
return 0;
}
static u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
{
return FM10K_RETA_SIZE * FM10K_RETA_ENTRIES_PER_REG;
}
void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir)
{
struct fm10k_hw *hw = &interface->hw;
int i;
/* record entries to reta table */
for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
u32 reta = indir[0] |
(indir[1] << 8) |
(indir[2] << 16) |
(indir[3] << 24);
if (interface->reta[i] == reta)
continue;
interface->reta[i] = reta;
fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
}
}
static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
{
struct fm10k_intfc *interface = netdev_priv(netdev);
......@@ -1055,7 +1075,6 @@ static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
{
struct fm10k_intfc *interface = netdev_priv(netdev);
struct fm10k_hw *hw = &interface->hw;
int i;
u16 rss_i;
......@@ -1070,19 +1089,7 @@ static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
return -EINVAL;
}
/* record entries to reta table */
for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
u32 reta = indir[0] |
(indir[1] << 8) |
(indir[2] << 16) |
(indir[3] << 24);
if (interface->reta[i] == reta)
continue;
interface->reta[i] = reta;
fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
}
fm10k_write_reta(interface, indir);
return 0;
}
......
......@@ -1943,7 +1943,8 @@ static void fm10k_assign_rings(struct fm10k_intfc *interface)
static void fm10k_init_reta(struct fm10k_intfc *interface)
{
u16 i, rss_i = interface->ring_feature[RING_F_RSS].indices;
u32 reta, base;
struct net_device *netdev = interface->netdev;
u32 reta, *indir;
/* If the Rx flow indirection table has been configured manually, we
* need to maintain it when possible.
......@@ -1968,21 +1969,16 @@ static void fm10k_init_reta(struct fm10k_intfc *interface)
}
repopulate_reta:
/* Populate the redirection table 4 entries at a time. To do this
* we are generating the results for n and n+2 and then interleaving
* those with the results with n+1 and n+3.
*/
for (i = FM10K_RETA_SIZE; i--;) {
/* first pass generates n and n+2 */
base = ((i * 0x00040004) + 0x00020000) * rss_i;
reta = (base & 0x3F803F80) >> 7;
indir = kcalloc(fm10k_get_reta_size(netdev),
sizeof(indir[0]), GFP_KERNEL);
/* second pass generates n+1 and n+3 */
base += 0x00010001 * rss_i;
reta |= (base & 0x3F803F80) << 1;
/* generate redirection table using the default kernel policy */
for (i = 0; i < fm10k_get_reta_size(netdev); i++)
indir[i] = ethtool_rxfh_indir_default(i, rss_i);
interface->reta[i] = reta;
}
fm10k_write_reta(interface, indir);
kfree(indir);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment