[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220615161041.902916-3-maciej.fijalkowski@intel.com>
Date: Wed, 15 Jun 2022 18:10:32 +0200
From: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
To: bpf@...r.kernel.org, ast@...nel.org, daniel@...earbox.net
Cc: netdev@...r.kernel.org, magnus.karlsson@...el.com,
bjorn@...nel.org,
Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
Alexandr Lobakin <alexandr.lobakin@...el.com>
Subject: [PATCH v3 bpf-next 02/11] ice: allow toggling loopback mode via ndo_set_features callback
Add support for NETIF_F_LOOPBACK. This feature can be set via:
$ ethtool -K eth0 loopback <on|off>
Feature can be useful for local data path tests.
CC: Alexandr Lobakin <alexandr.lobakin@...el.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 24 +++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 23d1b1fc39fb..85d956517b2e 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3358,6 +3358,7 @@ static void ice_set_netdev_features(struct net_device *netdev)
netdev->features |= netdev->hw_features;
netdev->hw_features |= NETIF_F_HW_TC;
+ netdev->hw_features |= NETIF_F_LOOPBACK;
/* encap and VLAN devices inherit default, csumo and tso features */
netdev->hw_enc_features |= dflt_features | csumo_features |
@@ -5902,6 +5903,25 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
return 0;
}
+/**
+ * ice_set_loopback - turn on/off loopback mode on underlying PF
+ * @hw: ptr to ice_hw struct needed for AQ command
+ * @netdev: ptr to the netdev being adjusted
+ * @ena: flag to indicate the on/off setting
+ */
+static void
+ice_set_loopback(struct ice_hw *hw, struct net_device *netdev, bool ena)
+{
+ bool if_running = netif_running(netdev);
+
+ if (if_running)
+ ice_stop(netdev);
+ if (ice_aq_set_mac_loopback(hw, ena, NULL))
+ netdev_err(netdev, "Failed to toggle loopback state\n");
+ if (if_running)
+ ice_open(netdev);
+}
+
/**
* ice_set_features - set the netdev feature flags
* @netdev: ptr to the netdev being adjusted
@@ -5960,6 +5980,10 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
}
+ if (changed & NETIF_F_LOOPBACK)
+ ice_set_loopback(&pf->hw, netdev,
+ !!(features & NETIF_F_LOOPBACK));
+
return 0;
}
--
2.27.0
Powered by blists - more mailing lists