nvethernet: add support for RSS

Changes takes care generation Hash key and population
of hash table with necessary information.

It also adds support ethtool to get/set hash key/table.

Bug 200565647

Change-Id: I5d5364bc88f4dea9456919b886dd8ede7f638ae3
Signed-off-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2263899
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
This commit is contained in:
Bhadram Varka
2019-12-17 14:00:29 +05:30
committed by Revanth Kumar Uppala
parent 7f172a52f5
commit a6520f2194
3 changed files with 184 additions and 0 deletions

View File

@@ -4212,6 +4212,11 @@ static void ether_set_ndev_features(struct net_device *ndev,
features |= NETIF_F_HW_VLAN_CTAG_RX;
features |= NETIF_F_HW_VLAN_CTAG_FILTER;
/* Receive Hashing offload */
if (pdata->hw_feat.rss_en) {
features |= NETIF_F_RXHASH;
}
/* Features available in HW */
ndev->hw_features = features;
/* Features that can be changed by user */
@@ -4270,6 +4275,36 @@ static inline void tegra_pre_si_platform(struct osi_core_priv_data *osi_core,
osi_dma->pre_si = 0;
}
/**
* @brief ether_init_rss - Init OSI RSS structure
*
* Algorithm: Populates RSS hash key and table in OSI core structure.
*
* @param[in] pdata: Ethernet private data
* @param[in] features: Netdev features
*/
static void ether_init_rss(struct ether_priv_data *pdata,
netdev_features_t features)
{
struct osi_core_priv_data *osi_core = pdata->osi_core;
unsigned int num_q = osi_core->num_mtl_queues;
unsigned int i = 0;
if ((features & NETIF_F_RXHASH) == NETIF_F_RXHASH) {
osi_core->rss.enable = 1;
} else {
osi_core->rss.enable = 0;
return;
}
/* generate random key */
netdev_rss_key_fill(osi_core->rss.key, sizeof(osi_core->rss.key));
/* initialize hash table */
for (i = 0; i < OSI_RSS_MAX_TABLE_SIZE; i++)
osi_core->rss.table[i] = ethtool_rxfh_indir_default(i, num_q);
}
/**
* @brief Ethernet platform driver probe.
*
@@ -4388,6 +4423,9 @@ static int ether_probe(struct platform_device *pdev)
/* Set netdev features based on hw features */
ether_set_ndev_features(ndev, pdata);
/* RSS init */
ether_init_rss(pdata, ndev->features);
ret = ether_get_irqs(pdev, pdata, num_dma_chans);
if (ret < 0) {
dev_err(&pdev->dev, "failed to get IRQ's\n");