From: Aleksey Makarov <aleksey.makarov@auriga.com>
To: <netdev@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
David Daney <david.daney@cavium.com>,
Robert Richter <robert.richter@caviumnetworks.com>,
Aleksey Makarov <aleksey.makarov@auriga.com>,
Sunil Goutham <Sunil.Goutham@caviumnetworks.com>,
Sunil Goutham <sgoutham@cavium.com>,
Robert Richter <rrichter@cavium.com>,
Aleksey Makarov <aleksey.makarov@caviumnetworks.com>,
Robert Richter <rric@kernel.org>
Subject: [PATCH net-next 4/8] net: thunderx: Receive hashing HW offload support
Date: Fri, 28 Aug 2015 17:59:56 +0300 [thread overview]
Message-ID: <1440774004-27923-4-git-send-email-aleksey.makarov@auriga.com> (raw)
In-Reply-To: <1440774004-27923-1-git-send-email-aleksey.makarov@auriga.com>
From: Sunil Goutham <sgoutham@cavium.com>
Adding support for receive hashing HW offload by using RSS_ALG
and RSS_TAG fields of CQE_RX descriptor. Also removed dependency
on minimum receive queue count to configure RSS so that hash is
always generated.
This hash is used by RPS logic to distribute flows across multiple
CPUs. Offload can be disabled via ethtool.
Signed-off-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
Signed-off-by: Aleksey Makarov <aleksey.makarov@caviumnetworks.com>
---
.../net/ethernet/cavium/thunder/nicvf_ethtool.c | 14 ++++-----
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 35 ++++++++++++++++++++--
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
index a961aa3..1eec2cd 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
@@ -525,17 +525,15 @@ static int nicvf_set_rxfh(struct net_device *dev, const u32 *indir,
struct nicvf_rss_info *rss = &nic->rss_info;
int idx;
- if ((nic->qs->rq_cnt <= 1) || (nic->cpi_alg != CPI_ALG_NONE)) {
- rss->enable = false;
- rss->hash_bits = 0;
- return -EIO;
- }
-
- /* We do not allow change in unsupported parameters */
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;
- rss->enable = true;
+ if (!rss->enable) {
+ netdev_err(nic->netdev,
+ "RSS is disabled, cannot change settings\n");
+ return -EIO;
+ }
+
if (indir) {
for (idx = 0; idx < rss->rss_size; idx++)
rss->ind_tbl[idx] = indir[idx];
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index d4ad36e..afd8ad4 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -313,7 +313,7 @@ static int nicvf_rss_init(struct nicvf *nic)
nicvf_get_rss_size(nic);
- if ((nic->qs->rq_cnt <= 1) || (cpi_alg != CPI_ALG_NONE)) {
+ if (cpi_alg != CPI_ALG_NONE) {
rss->enable = false;
rss->hash_bits = 0;
return 0;
@@ -416,6 +416,34 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev,
}
}
+static inline void nicvf_set_rxhash(struct net_device *netdev,
+ struct cqe_rx_t *cqe_rx,
+ struct sk_buff *skb)
+{
+ u8 hash_type;
+ u32 hash;
+
+ if (!(netdev->features & NETIF_F_RXHASH))
+ return;
+
+ switch (cqe_rx->rss_alg) {
+ case RSS_ALG_TCP_IP:
+ case RSS_ALG_UDP_IP:
+ hash_type = PKT_HASH_TYPE_L4;
+ hash = cqe_rx->rss_tag;
+ break;
+ case RSS_ALG_IP:
+ hash_type = PKT_HASH_TYPE_L3;
+ hash = cqe_rx->rss_tag;
+ break;
+ default:
+ hash_type = PKT_HASH_TYPE_NONE;
+ hash = 0;
+ }
+
+ skb_set_hash(skb, hash, hash_type);
+}
+
static void nicvf_rcv_pkt_handler(struct net_device *netdev,
struct napi_struct *napi,
struct cmp_queue *cq,
@@ -451,6 +479,8 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev,
nicvf_set_rx_frame_cnt(nic, skb);
+ nicvf_set_rxhash(netdev, cqe_rx, skb);
+
skb_record_rx_queue(skb, cqe_rx->rq_idx);
if (netdev->hw_features & NETIF_F_RXCSUM) {
/* HW by default verifies TCP/UDP/SCTP checksums */
@@ -1272,7 +1302,8 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_free_netdev;
netdev->features |= (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
- NETIF_F_TSO | NETIF_F_GRO);
+ NETIF_F_TSO | NETIF_F_GRO | NETIF_F_RXHASH);
+
netdev->hw_features = netdev->features;
netdev->netdev_ops = &nicvf_netdev_ops;
--
2.5.0
next prev parent reply other threads:[~2015-08-28 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 14:59 [PATCH net-next 1/8] net: thunderx: fix MAINTAINERS Aleksey Makarov
2015-08-28 14:59 ` [PATCH net-next 2/8] net: thunderx: Add receive error stats reporting via ethtool Aleksey Makarov
2015-08-28 14:59 ` [PATCH net-next 3/8] net: thunderx: mailboxes: remove code duplication Aleksey Makarov
2015-08-28 14:59 ` Aleksey Makarov [this message]
2015-08-28 14:59 ` [PATCH net-next 5/8] net: thunderx: Support for HW VLAN stripping Aleksey Makarov
2015-08-28 14:59 ` [PATCH net-next 6/8] net: thunderx: Rework interrupt handler Aleksey Makarov
2015-08-28 21:26 ` David Miller
2015-08-28 14:59 ` [PATCH net-next 7/8] net: thunderx: Support for upto 96 queues for a VF Aleksey Makarov
2015-08-29 1:45 ` Alexey Klimov
2015-08-29 5:10 ` David Miller
2015-08-28 15:00 ` [PATCH net-next 8/8] net: thunderx: Support for internal loopback mode Aleksey Makarov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440774004-27923-4-git-send-email-aleksey.makarov@auriga.com \
--to=aleksey.makarov@auriga.com \
--cc=Sunil.Goutham@caviumnetworks.com \
--cc=aleksey.makarov@caviumnetworks.com \
--cc=david.daney@cavium.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=robert.richter@caviumnetworks.com \
--cc=rric@kernel.org \
--cc=rrichter@cavium.com \
--cc=sgoutham@cavium.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®