* [PATCH intel-next 0/2] ice: add NETIF_F_LOOPBACK support
@ 2022-07-07 10:16 ` Maciej Fijalkowski
0 siblings, 0 replies; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-07-07 10:16 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, anthony.l.nguyen, kuba, davem, magnus.karlsson,
anatolii.gerasymenko, alexandr.lobakin, john.fastabend,
Maciej Fijalkowski
Hi,
these two patches are pulled out of the set
https://lore.kernel.org/bpf/20220616180609.905015-1-maciej.fijalkowski@intel.com/
they are about adding support for loopback toggle and they were written
for AF_XDP ZC testing purposes but they are good on their own and since
I need to rework ice ZC support a bit, let us route them via IWL
instead.
By the time I am done with refactor I believe there is a high chance
that these will land in net-next.
Thanks!
Maciej
Maciej Fijalkowski (2):
ice: compress branches in ice_set_features()
ice: allow toggling loopback mode via ndo_set_features callback
drivers/net/ethernet/intel/ice/ice_main.c | 73 ++++++++++++++++-------
1 file changed, 51 insertions(+), 22 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH intel-next 0/2] ice: add NETIF_F_LOOPBACK support
@ 2022-07-07 10:16 ` Maciej Fijalkowski
0 siblings, 0 replies; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-07-07 10:16 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, john.fastabend, anatolii.gerasymenko, kuba, davem,
magnus.karlsson
Hi,
these two patches are pulled out of the set
https://lore.kernel.org/bpf/20220616180609.905015-1-maciej.fijalkowski@intel.com/
they are about adding support for loopback toggle and they were written
for AF_XDP ZC testing purposes but they are good on their own and since
I need to rework ice ZC support a bit, let us route them via IWL
instead.
By the time I am done with refactor I believe there is a high chance
that these will land in net-next.
Thanks!
Maciej
Maciej Fijalkowski (2):
ice: compress branches in ice_set_features()
ice: allow toggling loopback mode via ndo_set_features callback
drivers/net/ethernet/intel/ice/ice_main.c | 73 ++++++++++++++++-------
1 file changed, 51 insertions(+), 22 deletions(-)
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH intel-next 1/2] ice: compress branches in ice_set_features()
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
@ 2022-07-07 10:16 ` Maciej Fijalkowski
-1 siblings, 0 replies; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-07-07 10:16 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, anthony.l.nguyen, kuba, davem, magnus.karlsson,
anatolii.gerasymenko, alexandr.lobakin, john.fastabend,
Maciej Fijalkowski
Instead of rather verbose comparison of current netdev->features bits vs
the incoming ones from user, let us compress them by a helper features
set that will be the result of netdev->features XOR features. This way,
current, extensive branches:
if (features & NETIF_F_BIT && !(netdev->features & NETIF_F_BIT))
set_feature(true);
else if (!(features & NETIF_F_BIT) && netdev->features & NETIF_F_BIT)
set_feature(false);
can become:
netdev_features_t changed = netdev->features ^ features;
if (changed & NETIF_F_BIT)
set_feature(!!(features & NETIF_F_BIT));
This is nothing new as currently several other drivers use this
approach, which I find much more convenient.
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 40 +++++++++++------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index c1ac2f746714..084f0e17187c 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -5923,44 +5923,41 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
static int
ice_set_features(struct net_device *netdev, netdev_features_t features)
{
+ netdev_features_t changed = netdev->features ^ features;
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi;
struct ice_pf *pf = vsi->back;
int ret = 0;
/* Don't set any netdev advanced features with device in Safe Mode */
- if (ice_is_safe_mode(vsi->back)) {
- dev_err(ice_pf_to_dev(vsi->back), "Device is in Safe Mode - not enabling advanced netdev features\n");
+ if (ice_is_safe_mode(pf)) {
+ dev_err(ice_pf_to_dev(pf),
+ "Device is in Safe Mode - not enabling advanced netdev features\n");
return ret;
}
/* Do not change setting during reset */
if (ice_is_reset_in_progress(pf->state)) {
- dev_err(ice_pf_to_dev(vsi->back), "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
+ dev_err(ice_pf_to_dev(pf),
+ "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
return -EBUSY;
}
/* Multiple features can be changed in one call so keep features in
* separate if/else statements to guarantee each feature is checked
*/
- if (features & NETIF_F_RXHASH && !(netdev->features & NETIF_F_RXHASH))
- ice_vsi_manage_rss_lut(vsi, true);
- else if (!(features & NETIF_F_RXHASH) &&
- netdev->features & NETIF_F_RXHASH)
- ice_vsi_manage_rss_lut(vsi, false);
+ if (changed & NETIF_F_RXHASH)
+ ice_vsi_manage_rss_lut(vsi, !!(features & NETIF_F_RXHASH));
ret = ice_set_vlan_features(netdev, features);
if (ret)
return ret;
- if ((features & NETIF_F_NTUPLE) &&
- !(netdev->features & NETIF_F_NTUPLE)) {
- ice_vsi_manage_fdir(vsi, true);
- ice_init_arfs(vsi);
- } else if (!(features & NETIF_F_NTUPLE) &&
- (netdev->features & NETIF_F_NTUPLE)) {
- ice_vsi_manage_fdir(vsi, false);
- ice_clear_arfs(vsi);
+ if (changed & NETIF_F_NTUPLE) {
+ bool ena = !!(features & NETIF_F_NTUPLE);
+
+ ice_vsi_manage_fdir(vsi, ena);
+ ena ? ice_init_arfs(vsi) : ice_clear_arfs(vsi);
}
/* don't turn off hw_tc_offload when ADQ is already enabled */
@@ -5969,11 +5966,12 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
return -EACCES;
}
- if ((features & NETIF_F_HW_TC) &&
- !(netdev->features & NETIF_F_HW_TC))
- set_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
- else
- clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
+ if (changed & NETIF_F_HW_TC) {
+ bool ena = !!(features & NETIF_F_HW_TC);
+
+ ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) :
+ clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
+ }
return 0;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH intel-next 1/2] ice: compress branches in ice_set_features()
@ 2022-07-07 10:16 ` Maciej Fijalkowski
0 siblings, 0 replies; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-07-07 10:16 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, john.fastabend, anatolii.gerasymenko, kuba, davem,
magnus.karlsson
Instead of rather verbose comparison of current netdev->features bits vs
the incoming ones from user, let us compress them by a helper features
set that will be the result of netdev->features XOR features. This way,
current, extensive branches:
if (features & NETIF_F_BIT && !(netdev->features & NETIF_F_BIT))
set_feature(true);
else if (!(features & NETIF_F_BIT) && netdev->features & NETIF_F_BIT)
set_feature(false);
can become:
netdev_features_t changed = netdev->features ^ features;
if (changed & NETIF_F_BIT)
set_feature(!!(features & NETIF_F_BIT));
This is nothing new as currently several other drivers use this
approach, which I find much more convenient.
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 40 +++++++++++------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index c1ac2f746714..084f0e17187c 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -5923,44 +5923,41 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
static int
ice_set_features(struct net_device *netdev, netdev_features_t features)
{
+ netdev_features_t changed = netdev->features ^ features;
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi;
struct ice_pf *pf = vsi->back;
int ret = 0;
/* Don't set any netdev advanced features with device in Safe Mode */
- if (ice_is_safe_mode(vsi->back)) {
- dev_err(ice_pf_to_dev(vsi->back), "Device is in Safe Mode - not enabling advanced netdev features\n");
+ if (ice_is_safe_mode(pf)) {
+ dev_err(ice_pf_to_dev(pf),
+ "Device is in Safe Mode - not enabling advanced netdev features\n");
return ret;
}
/* Do not change setting during reset */
if (ice_is_reset_in_progress(pf->state)) {
- dev_err(ice_pf_to_dev(vsi->back), "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
+ dev_err(ice_pf_to_dev(pf),
+ "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
return -EBUSY;
}
/* Multiple features can be changed in one call so keep features in
* separate if/else statements to guarantee each feature is checked
*/
- if (features & NETIF_F_RXHASH && !(netdev->features & NETIF_F_RXHASH))
- ice_vsi_manage_rss_lut(vsi, true);
- else if (!(features & NETIF_F_RXHASH) &&
- netdev->features & NETIF_F_RXHASH)
- ice_vsi_manage_rss_lut(vsi, false);
+ if (changed & NETIF_F_RXHASH)
+ ice_vsi_manage_rss_lut(vsi, !!(features & NETIF_F_RXHASH));
ret = ice_set_vlan_features(netdev, features);
if (ret)
return ret;
- if ((features & NETIF_F_NTUPLE) &&
- !(netdev->features & NETIF_F_NTUPLE)) {
- ice_vsi_manage_fdir(vsi, true);
- ice_init_arfs(vsi);
- } else if (!(features & NETIF_F_NTUPLE) &&
- (netdev->features & NETIF_F_NTUPLE)) {
- ice_vsi_manage_fdir(vsi, false);
- ice_clear_arfs(vsi);
+ if (changed & NETIF_F_NTUPLE) {
+ bool ena = !!(features & NETIF_F_NTUPLE);
+
+ ice_vsi_manage_fdir(vsi, ena);
+ ena ? ice_init_arfs(vsi) : ice_clear_arfs(vsi);
}
/* don't turn off hw_tc_offload when ADQ is already enabled */
@@ -5969,11 +5966,12 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
return -EACCES;
}
- if ((features & NETIF_F_HW_TC) &&
- !(netdev->features & NETIF_F_HW_TC))
- set_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
- else
- clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
+ if (changed & NETIF_F_HW_TC) {
+ bool ena = !!(features & NETIF_F_HW_TC);
+
+ ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) :
+ clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
+ }
return 0;
}
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH intel-next 2/2] ice: allow toggling loopback mode via ndo_set_features callback
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
@ 2022-07-07 10:16 ` Maciej Fijalkowski
-1 siblings, 0 replies; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-07-07 10:16 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, anthony.l.nguyen, kuba, davem, magnus.karlsson,
anatolii.gerasymenko, alexandr.lobakin, john.fastabend,
Maciej Fijalkowski
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.
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 33 ++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 084f0e17187c..4b08990590ef 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 |
@@ -5915,6 +5916,33 @@ 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
+ * @vsi: ptr to VSI
+ * @ena: flag to indicate the on/off setting
+ */
+static int
+ice_set_loopback(struct ice_vsi *vsi, bool ena)
+{
+ bool if_running = netif_running(vsi->netdev);
+ int ret;
+
+ if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
+ ret = ice_down(vsi);
+ if (ret) {
+ netdev_err(vsi->netdev, "Preparing device to toggle loopback failed\n");
+ return ret;
+ }
+ }
+ ret = ice_aq_set_mac_loopback(&vsi->back->hw, ena, NULL);
+ if (ret)
+ netdev_err(vsi->netdev, "Failed to toggle loopback state\n");
+ if (if_running)
+ ret = ice_up(vsi);
+
+ return ret;
+}
+
/**
* ice_set_features - set the netdev feature flags
* @netdev: ptr to the netdev being adjusted
@@ -5973,7 +6001,10 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
}
- return 0;
+ if (changed & NETIF_F_LOOPBACK)
+ ret = ice_set_loopback(vsi, !!(features & NETIF_F_LOOPBACK));
+
+ return ret;
}
/**
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Intel-wired-lan] [PATCH intel-next 2/2] ice: allow toggling loopback mode via ndo_set_features callback
@ 2022-07-07 10:16 ` Maciej Fijalkowski
0 siblings, 0 replies; 10+ messages in thread
From: Maciej Fijalkowski @ 2022-07-07 10:16 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, john.fastabend, anatolii.gerasymenko, kuba, davem,
magnus.karlsson
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.
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 33 ++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 084f0e17187c..4b08990590ef 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 |
@@ -5915,6 +5916,33 @@ 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
+ * @vsi: ptr to VSI
+ * @ena: flag to indicate the on/off setting
+ */
+static int
+ice_set_loopback(struct ice_vsi *vsi, bool ena)
+{
+ bool if_running = netif_running(vsi->netdev);
+ int ret;
+
+ if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
+ ret = ice_down(vsi);
+ if (ret) {
+ netdev_err(vsi->netdev, "Preparing device to toggle loopback failed\n");
+ return ret;
+ }
+ }
+ ret = ice_aq_set_mac_loopback(&vsi->back->hw, ena, NULL);
+ if (ret)
+ netdev_err(vsi->netdev, "Failed to toggle loopback state\n");
+ if (if_running)
+ ret = ice_up(vsi);
+
+ return ret;
+}
+
/**
* ice_set_features - set the netdev feature flags
* @netdev: ptr to the netdev being adjusted
@@ -5973,7 +6001,10 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
}
- return 0;
+ if (changed & NETIF_F_LOOPBACK)
+ ret = ice_set_loopback(vsi, !!(features & NETIF_F_LOOPBACK));
+
+ return ret;
}
/**
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH intel-next 2/2] ice: allow toggling loopback mode via ndo_set_features callback
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
@ 2022-07-27 18:07 ` Kuruvinakunnel, George
-1 siblings, 0 replies; 10+ messages in thread
From: Kuruvinakunnel, George @ 2022-07-27 18:07 UTC (permalink / raw)
To: Fijalkowski, Maciej, intel-wired-lan
Cc: netdev, john.fastabend, Gerasymenko, Anatolii, kuba, davem,
Karlsson, Magnus
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Maciej
> Fijalkowski
> Sent: Thursday, July 7, 2022 3:47 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; john.fastabend@gmail.com; Gerasymenko, Anatolii
> <anatolii.gerasymenko@intel.com>; kuba@kernel.org; davem@davemloft.net;
> Karlsson, Magnus <magnus.karlsson@intel.com>
> Subject: [Intel-wired-lan] [PATCH intel-next 2/2] 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.
>
> Acked-by: Jakub Kicinski <kuba@kernel.org>
> Acked-by: John Fastabend <john.fastabend@gmail.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 33 ++++++++++++++++++++++-
> 1 file changed, 32 insertions(+), 1 deletion(-)
>
Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [Intel-wired-lan] [PATCH intel-next 2/2] ice: allow toggling loopback mode via ndo_set_features callback
@ 2022-07-27 18:07 ` Kuruvinakunnel, George
0 siblings, 0 replies; 10+ messages in thread
From: Kuruvinakunnel, George @ 2022-07-27 18:07 UTC (permalink / raw)
To: Fijalkowski, Maciej, intel-wired-lan
Cc: netdev, john.fastabend, Gerasymenko, Anatolii, kuba, davem,
Karlsson, Magnus
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Maciej
> Fijalkowski
> Sent: Thursday, July 7, 2022 3:47 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; john.fastabend@gmail.com; Gerasymenko, Anatolii
> <anatolii.gerasymenko@intel.com>; kuba@kernel.org; davem@davemloft.net;
> Karlsson, Magnus <magnus.karlsson@intel.com>
> Subject: [Intel-wired-lan] [PATCH intel-next 2/2] 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.
>
> Acked-by: Jakub Kicinski <kuba@kernel.org>
> Acked-by: John Fastabend <john.fastabend@gmail.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 33 ++++++++++++++++++++++-
> 1 file changed, 32 insertions(+), 1 deletion(-)
>
Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH intel-next 1/2] ice: compress branches in ice_set_features()
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
@ 2022-07-27 18:09 ` Kuruvinakunnel, George
-1 siblings, 0 replies; 10+ messages in thread
From: Kuruvinakunnel, George @ 2022-07-27 18:09 UTC (permalink / raw)
To: Fijalkowski, Maciej, intel-wired-lan
Cc: netdev, john.fastabend, Gerasymenko, Anatolii, kuba, davem,
Karlsson, Magnus
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Maciej
> Fijalkowski
> Sent: Thursday, July 7, 2022 3:47 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; john.fastabend@gmail.com; Gerasymenko, Anatolii
> <anatolii.gerasymenko@intel.com>; kuba@kernel.org; davem@davemloft.net;
> Karlsson, Magnus <magnus.karlsson@intel.com>
> Subject: [Intel-wired-lan] [PATCH intel-next 1/2] ice: compress branches in
> ice_set_features()
>
> Instead of rather verbose comparison of current netdev->features bits vs the
> incoming ones from user, let us compress them by a helper features set that will be
> the result of netdev->features XOR features. This way, current, extensive branches:
>
> if (features & NETIF_F_BIT && !(netdev->features & NETIF_F_BIT))
> set_feature(true);
> else if (!(features & NETIF_F_BIT) && netdev->features & NETIF_F_BIT)
> set_feature(false);
>
> can become:
>
> netdev_features_t changed = netdev->features ^ features;
>
> if (changed & NETIF_F_BIT)
> set_feature(!!(features & NETIF_F_BIT));
>
> This is nothing new as currently several other drivers use this approach, which I find
> much more convenient.
>
> Acked-by: John Fastabend <john.fastabend@gmail.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 40 +++++++++++------------
> 1 file changed, 19 insertions(+), 21 deletions(-)
>
Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [Intel-wired-lan] [PATCH intel-next 1/2] ice: compress branches in ice_set_features()
@ 2022-07-27 18:09 ` Kuruvinakunnel, George
0 siblings, 0 replies; 10+ messages in thread
From: Kuruvinakunnel, George @ 2022-07-27 18:09 UTC (permalink / raw)
To: Fijalkowski, Maciej, intel-wired-lan
Cc: netdev, john.fastabend, Gerasymenko, Anatolii, kuba, davem,
Karlsson, Magnus
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Maciej
> Fijalkowski
> Sent: Thursday, July 7, 2022 3:47 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; john.fastabend@gmail.com; Gerasymenko, Anatolii
> <anatolii.gerasymenko@intel.com>; kuba@kernel.org; davem@davemloft.net;
> Karlsson, Magnus <magnus.karlsson@intel.com>
> Subject: [Intel-wired-lan] [PATCH intel-next 1/2] ice: compress branches in
> ice_set_features()
>
> Instead of rather verbose comparison of current netdev->features bits vs the
> incoming ones from user, let us compress them by a helper features set that will be
> the result of netdev->features XOR features. This way, current, extensive branches:
>
> if (features & NETIF_F_BIT && !(netdev->features & NETIF_F_BIT))
> set_feature(true);
> else if (!(features & NETIF_F_BIT) && netdev->features & NETIF_F_BIT)
> set_feature(false);
>
> can become:
>
> netdev_features_t changed = netdev->features ^ features;
>
> if (changed & NETIF_F_BIT)
> set_feature(!!(features & NETIF_F_BIT));
>
> This is nothing new as currently several other drivers use this approach, which I find
> much more convenient.
>
> Acked-by: John Fastabend <john.fastabend@gmail.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 40 +++++++++++------------
> 1 file changed, 19 insertions(+), 21 deletions(-)
>
Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-07-27 18:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 10:16 [PATCH intel-next 0/2] ice: add NETIF_F_LOOPBACK support Maciej Fijalkowski
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
2022-07-07 10:16 ` [PATCH intel-next 1/2] ice: compress branches in ice_set_features() Maciej Fijalkowski
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
2022-07-27 18:09 ` Kuruvinakunnel, George
2022-07-27 18:09 ` Kuruvinakunnel, George
2022-07-07 10:16 ` [PATCH intel-next 2/2] ice: allow toggling loopback mode via ndo_set_features callback Maciej Fijalkowski
2022-07-07 10:16 ` [Intel-wired-lan] " Maciej Fijalkowski
2022-07-27 18:07 ` Kuruvinakunnel, George
2022-07-27 18:07 ` Kuruvinakunnel, George
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.