[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210929155334.12454-151-shenjian15@huawei.com>
Date: Wed, 29 Sep 2021 23:53:17 +0800
From: Jian Shen <shenjian15@...wei.com>
To: <davem@...emloft.net>, <kuba@...nel.org>, <andrew@...n.ch>,
<hkallweit1@...il.com>
CC: <netdev@...r.kernel.org>, <linuxarm@...neuler.org>
Subject: [RFCv2 net-next 150/167] RDMA: ipoib: use netdev feature helpers
Use netdev_feature_xxx helpers to replace the logical operation
for netdev features.
Signed-off-by: Jian Shen <shenjian15@...wei.com>
---
drivers/infiniband/hw/hfi1/vnic_main.c | 7 ++++---
drivers/infiniband/ulp/ipoib/ipoib_cm.c | 2 +-
drivers/infiniband/ulp/ipoib/ipoib_ib.c | 2 +-
drivers/infiniband/ulp/ipoib/ipoib_main.c | 16 ++++++++++------
drivers/infiniband/ulp/ipoib/ipoib_verbs.c | 2 +-
5 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/infiniband/hw/hfi1/vnic_main.c b/drivers/infiniband/hw/hfi1/vnic_main.c
index 3650fababf25..c02cf9467c62 100644
--- a/drivers/infiniband/hw/hfi1/vnic_main.c
+++ b/drivers/infiniband/hw/hfi1/vnic_main.c
@@ -588,9 +588,10 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
rn->free_rdma_netdev = hfi1_vnic_free_rn;
rn->set_id = hfi1_vnic_set_vesw_id;
- netdev->features = NETIF_F_HIGHDMA | NETIF_F_SG;
- netdev->hw_features = netdev->features;
- netdev->vlan_features = netdev->features;
+ netdev_feature_zero(&netdev->features);
+ netdev_feature_set_bits(NETIF_F_HIGHDMA | NETIF_F_SG, &netdev->features);
+ netdev_feature_copy(&netdev->hw_features, netdev->features)
+ netdev_feature_copy(&netdev->vlan_features, netdev->features)
netdev->watchdog_timeo = msecs_to_jiffies(HFI_TX_TIMEOUT_MS);
netdev->netdev_ops = &hfi1_netdev_ops;
mutex_init(&vinfo->lock);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 684c2ddb16f5..6b22253813ac 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1070,7 +1070,7 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_
};
struct ib_qp *tx_qp;
- if (dev->features & NETIF_F_SG)
+ if (netdev_feature_test_bit(NETIF_F_SG_BIT, dev->features))
attr.cap.max_send_sge = min_t(u32, priv->ca->attrs.max_send_sge,
MAX_SKB_FRAGS + 1);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index ceabfb0b0a83..a9fc7e58c689 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -260,7 +260,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
dev->stats.multicast++;
skb->dev = dev;
- if ((dev->features & NETIF_F_RXCSUM) &&
+ if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, dev->features) &&
likely(wc->wc_flags & IB_WC_IP_CSUM_OK))
skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 488d50a82a87..5fd0b7a1bcb9 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -220,7 +220,8 @@ static void ipoib_fix_features(struct net_device *dev,
struct ipoib_dev_priv *priv = ipoib_priv(dev);
if (test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags))
- *features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO);
+ netdev_feature_clear_bits(NETIF_F_IP_CSUM | NETIF_F_TSO,
+ features);
}
static int ipoib_change_mtu(struct net_device *dev, int new_mtu)
@@ -1849,12 +1850,15 @@ static void ipoib_set_dev_features(struct ipoib_dev_priv *priv)
priv->hca_caps = priv->ca->attrs.device_cap_flags;
if (priv->hca_caps & IB_DEVICE_UD_IP_CSUM) {
- priv->dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
+ netdev_feature_set_bits(NETIF_F_IP_CSUM | NETIF_F_RXCSUM,
+ &priv->dev->hw_features);
if (priv->hca_caps & IB_DEVICE_UD_TSO)
- priv->dev->hw_features |= NETIF_F_TSO;
+ netdev_feature_set_bit(NETIF_F_TSO_BIT,
+ &priv->dev->hw_features);
- priv->dev->features |= priv->dev->hw_features;
+ netdev_feature_or(&priv->dev->features, priv->dev->features,
+ priv->dev->hw_features);
}
}
@@ -2117,8 +2121,8 @@ void ipoib_setup_common(struct net_device *dev)
dev->addr_len = INFINIBAND_ALEN;
dev->type = ARPHRD_INFINIBAND;
dev->tx_queue_len = ipoib_sendq_size * 2;
- dev->features = (NETIF_F_VLAN_CHALLENGED |
- NETIF_F_HIGHDMA);
+ netdev_feature_set_bits(NETIF_F_VLAN_CHALLENGED |
+ NETIF_F_HIGHDMA, &dev->features);
netif_keep_dst(dev);
memcpy(dev->broadcast, ipv4_bcast_addr, INFINIBAND_ALEN);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 5a150a080ac2..d0437c302ef4 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -234,7 +234,7 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
priv->rx_wr.sg_list = priv->rx_sge;
if (init_attr.cap.max_send_sge > 1)
- dev->features |= NETIF_F_SG;
+ netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->features);
priv->max_send_sge = init_attr.cap.max_send_sge;
--
2.33.0
Powered by blists - more mailing lists