netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Igor Russkikh <Igor.Russkikh@aquantia.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Igor Russkikh <Igor.Russkikh@aquantia.com>
Subject: [PATCH net-next v3 8/8] net: aquantia: implement vlan offload configuration
Date: Wed, 26 Jun 2019 12:35:49 +0000	[thread overview]
Message-ID: <310dd524af035a8b3359aee19affc29420b67feb.1561552290.git.igor.russkikh@aquantia.com> (raw)
In-Reply-To: <cover.1561552290.git.igor.russkikh@aquantia.com>

set_features should update flags and reinit hardware if
vlan offload settings were changed.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Tested-by: Nikita Danilov <ndanilov@aquantia.com>
---
 .../net/ethernet/aquantia/atlantic/aq_main.c  | 34 +++++++++++++++----
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
index 5315df5ff6f8..100722ad5c2d 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
@@ -108,11 +108,16 @@ static int aq_ndev_change_mtu(struct net_device *ndev, int new_mtu)
 static int aq_ndev_set_features(struct net_device *ndev,
 				netdev_features_t features)
 {
+	bool is_vlan_rx_strip = !!(features & NETIF_F_HW_VLAN_CTAG_RX);
+	bool is_vlan_tx_insert = !!(features & NETIF_F_HW_VLAN_CTAG_TX);
 	struct aq_nic_s *aq_nic = netdev_priv(ndev);
-	struct aq_nic_cfg_s *aq_cfg = aq_nic_get_cfg(aq_nic);
+	bool need_ndev_restart = false;
+	struct aq_nic_cfg_s *aq_cfg;
 	bool is_lro = false;
 	int err = 0;
 
+	aq_cfg = aq_nic_get_cfg(aq_nic);
+
 	if (!(features & NETIF_F_NTUPLE)) {
 		if (aq_nic->ndev->features & NETIF_F_NTUPLE) {
 			err = aq_clear_rxnfc_all_rules(aq_nic);
@@ -135,17 +140,32 @@ static int aq_ndev_set_features(struct net_device *ndev,
 
 		if (aq_cfg->is_lro != is_lro) {
 			aq_cfg->is_lro = is_lro;
-
-			if (netif_running(ndev)) {
-				aq_ndev_close(ndev);
-				aq_ndev_open(ndev);
-			}
+			need_ndev_restart = true;
 		}
 	}
-	if ((aq_nic->ndev->features ^ features) & NETIF_F_RXCSUM)
+
+	if ((aq_nic->ndev->features ^ features) & NETIF_F_RXCSUM) {
 		err = aq_nic->aq_hw_ops->hw_set_offload(aq_nic->aq_hw,
 							aq_cfg);
 
+		if (unlikely(err))
+			goto err_exit;
+	}
+
+	if (aq_cfg->is_vlan_rx_strip != is_vlan_rx_strip) {
+		aq_cfg->is_vlan_rx_strip = is_vlan_rx_strip;
+		need_ndev_restart = true;
+	}
+	if (aq_cfg->is_vlan_tx_insert != is_vlan_tx_insert) {
+		aq_cfg->is_vlan_tx_insert = is_vlan_tx_insert;
+		need_ndev_restart = true;
+	}
+
+	if (need_ndev_restart && netif_running(ndev)) {
+		aq_ndev_close(ndev);
+		aq_ndev_open(ndev);
+	}
+
 err_exit:
 	return err;
 }
-- 
2.17.1


  parent reply	other threads:[~2019-06-26 12:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-26 12:35 [PATCH net-next v3 0/8] net: aquantia: implement vlan offloads Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 1/8] net: aquantia: replace internal driver version code with uts Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 2/8] net: aquantia: add documentation for the atlantic driver Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 3/8] maintainers: declare aquantia atlantic driver maintenance Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 4/8] net: aquantia: make all files GPL-2.0-only Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 5/8] net: aquantia: added vlan offload related macros and functions Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 6/8] net: aquantia: adding fields and device features for vlan offload Igor Russkikh
2019-06-26 12:35 ` [PATCH net-next v3 7/8] net: aquantia: vlan offloads logic in datapath Igor Russkikh
2019-06-26 12:35 ` Igor Russkikh [this message]
2019-06-26 16:26 ` [PATCH net-next v3 0/8] net: aquantia: implement vlan offloads David Miller
2019-06-27 17:58 ` David Miller

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=310dd524af035a8b3359aee19affc29420b67feb.1561552290.git.igor.russkikh@aquantia.com \
    --to=igor.russkikh@aquantia.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).