Thread (72 messages) 72 messages, 4 authors, 2023-10-03

Re: [RFCv8 PATCH net-next 01/55] net: introduce operation helpers for netdev features

From: "shenjian (K)" <shenjian15@huawei.com>
Date: 2022-09-21 03:04:48


在 2022/9/21 4:10, Jakub Kicinski 写道:
On Sun, 18 Sep 2022 09:42:42 +0000 Jian Shen wrote:
quoted
Introduce a set of bitmap operation helpers for netdev features,
then we can use them to replace the logical operation with them.

The implementation of these helpers are based on the old prototype
of netdev_features_t is still u64. These helpers will be rewritten
on the last patch, follow the prototype changes. For the new type
netdev_features_t maybe large than 8 bytes, use netdev_features_t
pointer as parameter.

To avoid interdependencies between netdev_features_helper.h and
netdevice.h, put the helpers for testing feature in the netdevice.h,
and move advandced helpers like netdev_get_wanted_features() and
netdev_intersect_features() to netdev_features_helper.h.
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
index 8b77582bdfa0..8023a3f0d43b 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
@@ -4,6 +4,7 @@
  #include <linux/etherdevice.h>
  #include <linux/io-64-nonatomic-hi-lo.h>
  #include <linux/lockdep.h>
+#include <linux/netdev_feature_helpers.h>
  #include <net/dst_metadata.h>
  
  #include "nfpcore/nfp_cpp.h"
We need to start breaking upstreamable chunks out of this mega-series
otherwise we won't make any progress..

Please make a patch which will move netdev_intersect_features() and
netdev_get_wanted_features() to the new linux/netdev_feature_helpers.h
header, and add the missing includes. Post it separately as soon as
possible.
ok, will split it.
quoted
diff --git a/include/linux/netdev_feature_helpers.h b/include/linux/netdev_feature_helpers.h
new file mode 100644
index 000000000000..4bb5de61e4e9
--- /dev/null
+++ b/include/linux/netdev_feature_helpers.h
@@ -0,0 +1,607 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Network device features helpers.
+ */
+#ifndef _LINUX_NETDEV_FEATURES_HELPER_H
+#define _LINUX_NETDEV_FEATURES_HELPER_H
+
+#include <linux/netdevice.h>
+
+static inline void __netdev_features_zero(netdev_features_t *dst)
+{
+	*dst = 0;
+}
+
+#define netdev_features_zero(features) __netdev_features_zero(&(features))
+
+/* active_feature prefer to netdev->features */
+#define netdev_active_features_zero(ndev) \
+		netdev_features_zero((ndev)->features)
+
No need for empty lines between the defines of the same category, IMHO.
ok,  will remove the unnecessary empty lines.
quoted
+#define netdev_hw_features_zero(ndev) \
+		netdev_features_zero((ndev)->hw_features)
.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help