在 2021/8/11 22:45, Jian Shen 写道:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/wireless/ath/ath10k/mac.c | 7 +++++-- drivers/net/wireless/ath/ath11k/mac.c | 4 +++- drivers/net/wireless/ath/ath6kl/main.c | 15 ++++++++++----- drivers/net/wireless/ath/ath6kl/txrx.c | 6 ++++-- drivers/net/wireless/ath/wil6210/netdev.c | 11 +++++++---- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 4 ++-- drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c | 7 +++++-- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 17 +++++++++++------ drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 3 ++- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 8 ++++++-- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 3 ++- net/wireless/core.c | 15 ++++++++++----- 15 files changed, 72 insertions(+), 36 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index c272b29..493d15f 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -10119,8 +10119,11 @@ int ath10k_mac_register(struct ath10k *ar) if (ar->hw_params.dynamic_sar_support) ar->hw->wiphy->sar_capa = &ath10k_sar_capa;
- if (!test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags))
ar->hw->netdev_features = NETIF_F_HW_CSUM;
if (!test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
netdev_feature_zero(&ar->hw->netdev_features);
netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT,
&ar->hw->netdev_features);
}
if (IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED)) { /* Init ath dfs pattern detector */
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index e9b3689..ba892c4 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -6570,7 +6570,9 @@ static int __ath11k_mac_register(struct ath11k *ar) ath11k_reg_init(ar);
if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) {
ar->hw->netdev_features = NETIF_F_HW_CSUM;
netdev_feature_zero(&ar->hw->netdev_features);
netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT,
ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL); ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT); }&ar->hw->netdev_features);
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index d3aa9e7..2b15df2 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1126,24 +1126,28 @@ static int ath6kl_set_features(struct net_device *dev, struct ath6kl *ar = vif->ar; int err = 0;
- if ((features & NETIF_F_RXCSUM) &&
- if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, features) && (ar->rx_meta_ver != WMI_META_VERSION_2)) { ar->rx_meta_ver = WMI_META_VERSION_2; err = ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, vif->fw_vif_idx, ar->rx_meta_ver, 0, 0); if (err) {
dev->features = features & ~NETIF_F_RXCSUM;
netdev_feature_copy(&dev->features, features);
netdev_feature_clear_bit(NETIF_F_RXCSUM_BIT,
}&dev->features); return err;
- } else if (!(features & NETIF_F_RXCSUM) &&
- } else if (!netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, features) && (ar->rx_meta_ver == WMI_META_VERSION_2)) { ar->rx_meta_ver = 0; err = ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, vif->fw_vif_idx, ar->rx_meta_ver, 0, 0); if (err) {
dev->features = features | NETIF_F_RXCSUM;
netdev_feature_copy(&dev->features, features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT,
} }&dev->features); return err;
@@ -1305,7 +1309,8 @@ void init_netdev(struct net_device *dev)
if (!test_bit(ATH6KL_FW_CAPABILITY_NO_IP_CHECKSUM, ar->fw_capabilities))
dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
netdev_feature_set_bit(NETIF_F_IP_CSUM | NETIF_F_RXCSUM,
&dev->hw_features);
it should be "netdev_feature_set_bits", not "netdev_feature_set_bit", will fix it next version
return; } diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index b22ed49..6c7569c 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -391,7 +391,8 @@ netdev_tx_t ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) }
if (test_bit(WMI_ENABLED, &ar->flag)) {
if ((dev->features & NETIF_F_IP_CSUM) &&
if (netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT,
(csum == CHECKSUM_PARTIAL)) { csum_start = skb->csum_start - (skb_network_header(skb) - skb->head) +dev->features) &&
@@ -410,7 +411,8 @@ netdev_tx_t ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) goto fail_tx; }
if ((dev->features & NETIF_F_IP_CSUM) &&
if (netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT,
(csum == CHECKSUM_PARTIAL)) { meta_v2.csum_start = csum_start; meta_v2.csum_dest = csum_dest;dev->features) &&
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c index 0913f0b..b29a4d6 100644 --- a/drivers/net/wireless/ath/wil6210/netdev.c +++ b/drivers/net/wireless/ath/wil6210/netdev.c @@ -335,11 +335,14 @@ wil_vif_alloc(struct wil6210_priv *wil, const char *name, ndev->netdev_ops = &wil_netdev_ops; wil_set_ethtoolops(ndev); ndev->ieee80211_ptr = wdev;
- ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
NETIF_F_SG | NETIF_F_GRO |
NETIF_F_TSO | NETIF_F_TSO6;
- netdev_feature_zero(&ndev->hw_features);
- netdev_feature_set_bits(NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
NETIF_F_SG | NETIF_F_GRO |
NETIF_F_TSO | NETIF_F_TSO6,
&ndev->hw_features);
- netdev_feature_or(&ndev->features, ndev->features, ndev->hw_features);
- ndev->features |= ndev->hw_features; SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); wdev->netdev = ndev; return vif;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index db5f853..d04bff1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -616,9 +616,9 @@ static int brcmf_netdev_open(struct net_device *ndev) /* Get current TOE mode from dongle */ if (brcmf_fil_iovar_int_get(ifp, "toe_ol", &toe_ol) >= 0 && (toe_ol & TOE_TX_CSUM_OL) != 0)
ndev->features |= NETIF_F_IP_CSUM;
elsenetdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, &ndev->features);
ndev->features &= ~NETIF_F_IP_CSUM;
netdev_feature_clear_bit(NETIF_F_IP_CSUM_BIT, &ndev->features);
if (brcmf_cfg80211_up(ndev)) { bphy_err(drvr, "failed to bring up cfg80211\n");
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c index 75e7665..81df856 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c @@ -101,8 +101,11 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, ieee80211_hw_set(hw, SUPPORT_FAST_XMIT); ieee80211_hw_set(hw, WANT_MONITOR_VIF);
- if (priv->trans->max_skb_frags)
hw->netdev_features = NETIF_F_HIGHDMA | NETIF_F_SG;
if (priv->trans->max_skb_frags) {
netdev_feature_zero(&hw->netdev_features);
netdev_feature_set_bits(NETIF_F_HIGHDMA | NETIF_F_SG,
&hw->netdev_features);
}
hw->offchannel_tx_hw_queue = IWL_AUX_QUEUE; hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FMT;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index 70ebecb..65d0125 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -387,8 +387,11 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) if (mvm->trans->num_rx_queues > 1) ieee80211_hw_set(hw, USES_RSS);
- if (mvm->trans->max_skb_frags)
hw->netdev_features = NETIF_F_HIGHDMA | NETIF_F_SG;
if (mvm->trans->max_skb_frags) {
netdev_feature_zero(&hw->netdev_features);
netdev_feature_set_bits(NETIF_F_HIGHDMA | NETIF_F_SG,
&hw->netdev_features);
}
hw->queues = IEEE80211_MAX_QUEUES; hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE;
@@ -703,10 +706,11 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) hw->wiphy->features |= NL80211_FEATURE_TDLS_CHANNEL_SWITCH; }
- hw->netdev_features |= mvm->cfg->features;
- netdev_feature_copy(&hw->netdev_features, mvm->cfg->features); if (!iwl_mvm_is_csum_supported(mvm))
hw->netdev_features &= ~(IWL_TX_CSUM_NETIF_FLAGS |
NETIF_F_RXCSUM);
netdev_feature_clear_bits(IWL_TX_CSUM_NETIF_FLAGS |
NETIF_F_RXCSUM,
&hw->netdev_features);
if (mvm->cfg->vht_mu_mimo_supported) wiphy_ext_feature_set(hw->wiphy,
@@ -1451,7 +1455,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, goto out_unlock; }
- mvmvif->features |= hw->netdev_features;
netdev_feature_or(&mvmvif->features, mvmvif->features,
hw->netdev_features);
ret = iwl_mvm_mac_ctxt_add(mvm, vif); if (ret)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c index 8ef5399..21d97eb 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c @@ -276,7 +276,7 @@ static void iwl_mvm_rx_csum(struct ieee80211_sta *sta, struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
- if (mvmvif->features & NETIF_F_RXCSUM &&
- if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, mvmvif->features) && status & RX_MPDU_RES_STATUS_CSUM_DONE && status & RX_MPDU_RES_STATUS_CSUM_OK) skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c index c0babb8..91d9355 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c @@ -459,7 +459,8 @@ static void iwl_mvm_rx_csum(struct iwl_mvm *mvm,
mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
if (mvmvif->features & NETIF_F_RXCSUM &&
if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
flags & IWL_RX_L3L4_TCP_UDP_CSUM_OK && (flags & IWL_RX_L3L4_IP_HDR_CSUM_OK || l3_prot == IWL_RX_L3_TYPE_IPV6 ||mvmvif->features) &&
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index 0a13c2b..c254ab4 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c @@ -53,7 +53,8 @@ static u16 iwl_mvm_tx_csum(struct iwl_mvm *mvm, struct sk_buff *skb, goto out;
/* We do not expect to be requested to csum stuff we do not support */
- if (WARN_ONCE(!(mvm->hw->netdev_features & IWL_TX_CSUM_NETIF_FLAGS) ||
- if (WARN_ONCE(!netdev_feature_test_bits(IWL_TX_CSUM_NETIF_FLAGS,
mvm->hw->netdev_features) || (skb->protocol != htons(ETH_P_IP) && skb->protocol != htons(ETH_P_IPV6)), "No support for requested checksum\n")) {
@@ -836,9 +837,12 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb, unsigned int mss = skb_shinfo(skb)->gso_size; unsigned int num_subframes, tcp_payload_len, subf_len, max_amsdu_len; u16 snap_ip_tcp, pad;
- netdev_features_t netdev_flags = NETIF_F_CSUM_MASK | NETIF_F_SG;
netdev_features_t netdev_flags; u8 tid;
netdev_feature_zero(&netdev_flags);
netdev_feature_set_bits(NETIF_F_CSUM_MASK | NETIF_F_SG, &netdev_flags);
snap_ip_tcp = 8 + skb_transport_header(skb) - skb_network_header(skb) + tcp_hdrlen(skb);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c index 2f1ac64..e690e09 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c @@ -363,7 +363,8 @@ mt7615_init_wiphy(struct ieee80211_hw *hw) hw->max_rates = 3; hw->max_report_rates = 7; hw->max_rate_tries = 11;
- hw->netdev_features = NETIF_F_RXCSUM;
netdev_feature_zero(&hw->netdev_features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &hw->netdev_features);
hw->radiotap_timestamp.units_pos = IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 4798d63..a3ab1a5f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -217,7 +217,8 @@ mt7915_init_wiphy(struct ieee80211_hw *hw) hw->queues = 4; hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
- hw->netdev_features = NETIF_F_RXCSUM;
netdev_feature_zero(&hw->netdev_features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &hw->netdev_features);
hw->radiotap_timestamp.units_pos = IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index a9ce10b..368d6cf 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -51,7 +51,8 @@ mt7921_init_wiphy(struct ieee80211_hw *hw) hw->queues = 4; hw->max_rx_aggregation_subframes = 64; hw->max_tx_aggregation_subframes = 128;
- hw->netdev_features = NETIF_F_RXCSUM;
netdev_feature_zero(&hw->netdev_features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &hw->netdev_features);
hw->radiotap_timestamp.units_pos = IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
diff --git a/net/wireless/core.c b/net/wireless/core.c index 0332312..5849ebf 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -164,11 +164,13 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { if (!wdev->netdev) continue;
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
netdev_feature_clear_bit(NETIF_F_NETNS_LOCAL_BIT,
err = dev_change_net_namespace(wdev->netdev, net, "wlan%d"); if (err) break;&wdev->netdev->features);
wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT,
&wdev->netdev->features);
}
if (err) {
@@ -180,11 +182,13 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, list) { if (!wdev->netdev) continue;
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
netdev_feature_clear_bit(NETIF_F_NETNS_LOCAL_BIT,
&wdev->netdev->features); err = dev_change_net_namespace(wdev->netdev, net, "wlan%d"); WARN_ON(err);
wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT,
&wdev->netdev->features);
}
return err;
@@ -1384,7 +1388,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, SET_NETDEV_DEVTYPE(dev, &wiphy_type); wdev->netdev = dev; /* can only change netns with wiphy */
dev->features |= NETIF_F_NETNS_LOCAL;
netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT,
&dev->features);
cfg80211_init_wdev(wdev); break;