Thread (181 messages) 181 messages, 6 authors, 2022-01-27

[RFCv2 net-next 037/167] net: tls: use netdev feature helpers

From: Jian Shen <shenjian15@huawei.com>
Date: 2021-09-29 15:58:54
Subsystem: networking [general], networking [tls], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, John Fastabend, Sabrina Dubroca, Linus Torvalds

Use netdev_feature_xxx helpers to replace the logical operation
for netdev features.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 net/tls/tls_device.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index b932469ee69c..94189107995f 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -1125,7 +1125,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
 		goto disable_cad;
 	}
 
-	if (!(netdev->features & NETIF_F_HW_TLS_TX)) {
+	if (!netdev_feature_test_bit(NETIF_F_HW_TLS_TX_BIT, netdev->features)) {
 		rc = -EOPNOTSUPP;
 		goto release_netdev;
 	}
@@ -1200,7 +1200,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
 		return -EINVAL;
 	}
 
-	if (!(netdev->features & NETIF_F_HW_TLS_RX)) {
+	if (!netdev_feature_test_bit(NETIF_F_HW_TLS_RX_BIT, netdev->features)) {
 		rc = -EOPNOTSUPP;
 		goto release_netdev;
 	}
@@ -1361,7 +1361,8 @@ static int tls_dev_event(struct notifier_block *this, unsigned long event,
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 
 	if (!dev->tlsdev_ops &&
-	    !(dev->features & (NETIF_F_HW_TLS_RX | NETIF_F_HW_TLS_TX)))
+	    !netdev_feature_test_bits(NETIF_F_HW_TLS_RX | NETIF_F_HW_TLS_TX,
+				      dev->features))
 		return NOTIFY_DONE;
 
 	switch (event) {
@@ -1369,7 +1370,8 @@ static int tls_dev_event(struct notifier_block *this, unsigned long event,
 	case NETDEV_FEAT_CHANGE:
 		if (netif_is_bond_master(dev))
 			return NOTIFY_DONE;
-		if ((dev->features & NETIF_F_HW_TLS_RX) &&
+		if (netdev_feature_test_bit(NETIF_F_HW_TLS_RX_BIT,
+					    dev->features) &&
 		    !dev->tlsdev_ops->tls_dev_resync)
 			return NOTIFY_BAD;
 
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help