Skip to content

Commit 4f675eb

Browse files
Govindarajulu Varadarajandavem330
authored andcommitted
enic: add support for set/get rss hash key
This patch adds support for setting/getting rss hash key using ethtool. v2: respin patch to support RSS hash function changes. Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7dbea3e commit 4f675eb

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

drivers/net/ethernet/cisco/enic/enic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ struct enic {
187187
unsigned int cq_count;
188188
struct enic_rfs_flw_tbl rfs_h;
189189
u32 rx_copybreak;
190+
u8 rss_key[ENIC_RSS_LEN];
190191
};
191192

192193
static inline struct device *enic_get_dev(struct enic *enic)
@@ -246,5 +247,6 @@ int enic_sriov_enabled(struct enic *enic);
246247
int enic_is_valid_vf(struct enic *enic, int vf);
247248
int enic_is_dynamic(struct enic *enic);
248249
void enic_set_ethtool_ops(struct net_device *netdev);
250+
int __enic_set_rsskey(struct enic *enic);
249251

250252
#endif /* _ENIC_H_ */

drivers/net/ethernet/cisco/enic/enic_ethtool.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "enic.h"
2424
#include "enic_dev.h"
2525
#include "enic_clsf.h"
26+
#include "vnic_rss.h"
2627

2728
struct enic_stat {
2829
char name[ETH_GSTRING_LEN];
@@ -416,6 +417,40 @@ static int enic_set_tunable(struct net_device *dev,
416417
return ret;
417418
}
418419

420+
static u32 enic_get_rxfh_key_size(struct net_device *netdev)
421+
{
422+
return ENIC_RSS_LEN;
423+
}
424+
425+
static int enic_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey,
426+
u8 *hfunc)
427+
{
428+
struct enic *enic = netdev_priv(netdev);
429+
430+
if (hkey)
431+
memcpy(hkey, enic->rss_key, ENIC_RSS_LEN);
432+
433+
if (hfunc)
434+
*hfunc = ETH_RSS_HASH_TOP;
435+
436+
return 0;
437+
}
438+
439+
static int enic_set_rxfh(struct net_device *netdev, const u32 *indir,
440+
const u8 *hkey, const u8 hfunc)
441+
{
442+
struct enic *enic = netdev_priv(netdev);
443+
444+
if ((hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) ||
445+
indir)
446+
return -EINVAL;
447+
448+
if (hkey)
449+
memcpy(enic->rss_key, hkey, ENIC_RSS_LEN);
450+
451+
return __enic_set_rsskey(enic);
452+
}
453+
419454
static const struct ethtool_ops enic_ethtool_ops = {
420455
.get_settings = enic_get_settings,
421456
.get_drvinfo = enic_get_drvinfo,
@@ -430,6 +465,9 @@ static const struct ethtool_ops enic_ethtool_ops = {
430465
.get_rxnfc = enic_get_rxnfc,
431466
.get_tunable = enic_get_tunable,
432467
.set_tunable = enic_set_tunable,
468+
.get_rxfh_key_size = enic_get_rxfh_key_size,
469+
.get_rxfh = enic_get_rxfh,
470+
.set_rxfh = enic_set_rxfh,
433471
};
434472

435473
void enic_set_ethtool_ops(struct net_device *netdev)

drivers/net/ethernet/cisco/enic/enic_main.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,11 +1888,10 @@ static int enic_dev_hang_reset(struct enic *enic)
18881888
return err;
18891889
}
18901890

1891-
static int enic_set_rsskey(struct enic *enic)
1891+
int __enic_set_rsskey(struct enic *enic)
18921892
{
18931893
union vnic_rss_key *rss_key_buf_va;
18941894
dma_addr_t rss_key_buf_pa;
1895-
u8 rss_key[ENIC_RSS_LEN];
18961895
int i, kidx, bidx, err;
18971896

18981897
rss_key_buf_va = pci_zalloc_consistent(enic->pdev,
@@ -1901,11 +1900,10 @@ static int enic_set_rsskey(struct enic *enic)
19011900
if (!rss_key_buf_va)
19021901
return -ENOMEM;
19031902

1904-
netdev_rss_key_fill(rss_key, ENIC_RSS_LEN);
19051903
for (i = 0; i < ENIC_RSS_LEN; i++) {
19061904
kidx = i / ENIC_RSS_BYTES_PER_KEY;
19071905
bidx = i % ENIC_RSS_BYTES_PER_KEY;
1908-
rss_key_buf_va->key[kidx].b[bidx] = rss_key[i];
1906+
rss_key_buf_va->key[kidx].b[bidx] = enic->rss_key[i];
19091907
}
19101908
spin_lock_bh(&enic->devcmd_lock);
19111909
err = enic_set_rss_key(enic,
@@ -1919,6 +1917,13 @@ static int enic_set_rsskey(struct enic *enic)
19191917
return err;
19201918
}
19211919

1920+
static int enic_set_rsskey(struct enic *enic)
1921+
{
1922+
netdev_rss_key_fill(enic->rss_key, ENIC_RSS_LEN);
1923+
1924+
return __enic_set_rsskey(enic);
1925+
}
1926+
19221927
static int enic_set_rsscpu(struct enic *enic, u8 rss_hash_bits)
19231928
{
19241929
dma_addr_t rss_cpu_buf_pa;

0 commit comments

Comments
 (0)