
On 2021/9/22 22:57, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen <shenjian15@huawei.com> --- .../net/ethernet/pensando/ionic/ionic_lif.c | 123 +++++++++++------- .../net/ethernet/pensando/ionic/ionic_txrx.c | 9 +- 2 files changed, 79 insertions(+), 53 deletions(-)
[...]
if (lif->nxqs > 1) - features |= NETIF_F_RXHASH; + netdev_feature_set_bits(NETIF_F_RXHASH_BIT, &features);
netdev_feature_set_bits -> netdev_feature_set_bit
err = ionic_set_nic_features(lif, features); if (err) return err;
/* tell the netdev what we actually can support */ - netdev->features |= NETIF_F_HIGHDMA; + netdev_feature_set_bit(NETIF_F_HIGHDMA_BIT, &netdev->features);
if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) - netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX; + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, + &netdev->hw_features); if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) - netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX; + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_RX_BIT, + &netdev->hw_features); if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) - netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &netdev->hw_features); if (lif->hw_features & IONIC_ETH_HW_RX_HASH) - netdev->hw_features |= NETIF_F_RXHASH; + netdev_feature_set_bit(NETIF_F_RXHASH_BIT, + &netdev->hw_features); if (lif->hw_features & IONIC_ETH_HW_TX_SG) - netdev->hw_features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &netdev->hw_features);
if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) - netdev->hw_enc_features |= NETIF_F_HW_CSUM; + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) - netdev->hw_enc_features |= NETIF_F_RXCSUM; + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO) - netdev->hw_enc_features |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) - netdev->hw_enc_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) - netdev->hw_enc_features |= NETIF_F_TSO_ECN; + netdev_feature_set_bit(NETIF_F_TSO_ECN_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) - netdev->hw_enc_features |= NETIF_F_GSO_GRE; + netdev_feature_set_bit(NETIF_F_GSO_GRE_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) - netdev->hw_enc_features |= NETIF_F_GSO_GRE_CSUM; + netdev_feature_set_bit(NETIF_F_GSO_GRE_CSUM_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) - netdev->hw_enc_features |= NETIF_F_GSO_IPXIP4; + netdev_feature_set_bit(NETIF_F_GSO_IPXIP4_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) - netdev->hw_enc_features |= NETIF_F_GSO_IPXIP6; + netdev_feature_set_bit(NETIF_F_GSO_IPXIP6_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) - netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL; + netdev_feature_set_bit(NETIF_F_GSO_UDP_TUNNEL_BIT, + &netdev->hw_enc_features); if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) - netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM; - - netdev->hw_features |= netdev->hw_enc_features; - netdev->features |= netdev->hw_features; - netdev->vlan_features |= netdev->features & ~NETIF_F_VLAN_FEATURES; + netdev_feature_set_bit(NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT, + &netdev->hw_enc_features); + + netdev_feature_or(&netdev->hw_features, netdev->hw_features, + netdev->hw_enc_features); + netdev_feature_or(&netdev->features, netdev->features, + netdev->hw_features); + netdev_feature_or(&netdev->vlan_features, netdev->vlan_features, + netdev->features); + netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES, + &netdev->vlan_features);
if netdev->vlan_features already has NETIF_F_VLAN_FEATURES, after - netdev->vlan_features |= netdev->features & ~NETIF_F_VLAN_FEATURES; netdev->vlan_features still has NETIF_F_VLAN_FEATURES, but after + netdev_feature_or(&netdev->vlan_features, netdev->vlan_features, + netdev->features); + netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES, + &netdev->vlan_features); netdev->vlan_features will lose NETIF_F_VLAN_FEATURES
netdev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE; @@ -2124,7 +2146,7 @@ static int ionic_txrx_init(struct ionic_lif *lif) } }
- if (lif->netdev->features & NETIF_F_RXHASH) + if (netdev_feature_test_bit(NETIF_F_RXHASH_BIT, lif->netdev->features)) ionic_lif_rss_init(lif);
ionic_lif_rx_mode(lif); @@ -3092,7 +3114,8 @@ void ionic_lif_deinit(struct ionic_lif *lif) cancel_work_sync(&lif->deferred.work); cancel_work_sync(&lif->tx_timeout_work); ionic_rx_filters_deinit(lif); - if (lif->netdev->features & NETIF_F_RXHASH) + if (netdev_feature_test_bit(NETIF_F_RXHASH_BIT, + lif->netdev->features)) ionic_lif_rss_deinit(lif); }
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 37c39581b659..8c0cf924a194 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -252,7 +252,8 @@ static void ionic_rx_clean(struct ionic_queue *q,
skb_record_rx_queue(skb, q->index);
- if (likely(netdev->features & NETIF_F_RXHASH)) { + if (likely(netdev_feature_test_bit(NETIF_F_RXHASH_BIT, + netdev->features))) { switch (comp->pkt_type_color & IONIC_RXQ_COMP_PKT_TYPE_MASK) { case IONIC_PKT_TYPE_IPV4: case IONIC_PKT_TYPE_IPV6: @@ -269,7 +270,8 @@ static void ionic_rx_clean(struct ionic_queue *q, } }
- if (likely(netdev->features & NETIF_F_RXCSUM) && + if (likely(netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, + netdev->features)) && (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_CALC)) { skb->ip_summed = CHECKSUM_COMPLETE; skb->csum = (__force __wsum)le16_to_cpu(comp->csum); @@ -283,7 +285,8 @@ static void ionic_rx_clean(struct ionic_queue *q, (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_IP_BAD))) stats->csum_error++;
- if (likely(netdev->features & NETIF_F_HW_VLAN_CTAG_RX) && + if (likely(netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_RX_BIT, + netdev->features)) && (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_VLAN)) { __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), le16_to_cpu(comp->vlan_tci));