For the prototype of netdev_features_t is u64, and the number of netdevice feature bits is 64 now. So there is no space to introduce new feature bit.
This patchset try to solve it by change the prototype of netdev_features_t from u64 to bitmap. With this change, it's necessary to introduce a set of bitmap operation helpers for netdev features. Meanwhile, the functions which use netdev_features_t as return value are also need to be changed, return the result as an output parameter.
With above changes, it will affect hundreds of files, and all the nic drivers. To make it easy to be reviewed, split the changes to 167 patches to 5 parts.
patch 1~22: convert the prototype which use netdev_features_t as return value patch 24: introduce fake helpers for bitmap operation patch 25~165: use netdev_feature_xxx helpers patch 166: use macro __DECLARE_NETDEV_FEATURE_MASK to replace netdev_feature_t declaration. patch 167: change the type of netdev_features_t to bitmap, and rewrite the bitmap helpers.
Jian Shen (167): net: convert the prototype of netdev_intersect_features net: convert the prototype of netdev_get_wanted_features net: convert the prototype of net_mpls_features net: convert the prototype of harmonize_features net: convert the prototype of gso_features_check net: convert the prototype of vlan_features_check net: convert the prototype of vxlan_features_check net: convert the prototype of dflt_features_check net: convert the prototype of ndo_features_check net: convert the prototype of netif_skb_features net: convert the prototype of ndo_fix_features net: convert the prototype of netdev_fix_features net: convert the prototype of netdev_sync_upper_features net: convert the prototype of br_features_recompute net: convert the prototype of netdev_add_tso_features net: convert the prototype of netdev_increment_features net: convert the prototype of hsr_features_recompute net: mlx5: convert prototype of mlx5e_ipsec_feature_check, mlx5e_tunnel_features_check and mlx5e_fix_uplink_rep_features net: sfc: convert the prototype of xxx_supported_features net: qlogic: convert the prototype of qlcnic_process_flags net: realtek: convert the prototype of rtl8168evl_fix_tso ethtool: convert the prototype of ethtool_get_feature_mask net: add netdev feature helpers net: core: use netdev feature helpers skbuff: use netdev feature helpers net: vlan: use netdev feature helpers bridge: use netdev feature helpers ipvlan: use netdev feature helpers veth: use netdev feature helpers bonding: use netdev feature helpers net: tun: use netdev feature helpers net: tap: use netdev feature helpers net: geneve: use netdev feature helpers hv_netvsc: use netdev feature helpers macvlan: use netdev feature helpers macsec: use netdev feature helpers net: tls: use netdev feature helpers s390: qeth: use netdev feature helpers dsa: use netdev feature helpers macvtap: use netdev feature helpers team: use netdev feature helpers vmxnet3: use netdev feature helpers net_failover: use netdev feature helpers pktgen: use netdev feature helpers net: sched: use netdev feature helpers netdevsim: use netdev feature helpers virtio_net: use netdev feature helpers net: ipv4: use netdev feature helpers net: ipv6: use netdev feature helpers net: hsr: use netdev feature helpers net: mpls: use netdev feature helpers net: nsh: use netdev feature helpers net: decnet: use netdev feature helpers net: dccp: use netdev feature helpers net: l2tp: use netdev feature helpers net: ntb_netdev: use netdev feature helpers net: thunderbolt: use netdev feature helpers net: phonet: use netdev feature helpers net: vrf: use netdev feature helpers net: sctp: use netdev feature helpers vxlan: use netdev feature helpers xen-netback: use netdev feature helpers xen-netfront: use netdev feature helpers sock: use netdev feature helpers sunrpc: use netdev feature helpers net: caif: use netdev feature helpers net: loopback: use netdev feature helpers net: dummy: use netdev_feature helpers net: mac80211: use netdev feature helpers net: ifb: use netdev feature helpers net: bareudp: use netdev feature helpers net: rionet: use netdev feature helpers net: gtp: use netdev feature helpers net: vsockmon: use netdev feature helpers net: nlmon: use netdev feature helpers net: wireguard: use netdev feature helpers net: can: use netdev feature helpers net: ppp: use netdev feature helpers net: ipa: use netdev feature helpers net: fjes: use netdev feature helpers net: usb: use netdev feature helpers net: wireless: use netdev feature helpers net: realtek: use netdev feature helpers net: broadcom: use netdev feature helpers net: intel: use netdev feature helpers net: hisilicon: use netdev feature helpers net: mellanox: use netdev feature helpers net: atlantic: use netdev feature helpers net: atheros: use netdev feature helpers net: chelsio: use netdev feature helpers net: davicom: use netdev feature helpers net: freescale: use netdev feature helpers net: synopsys: use netdev feature helpers net: sfc: use netdev feature helpers net: qualcomm: use netdev feature helpers net: nvidia: use netdev feature helpers net: faraday: use netdev feature helpers net: google: use netdev feature helpers net: hinic: use netdev feature helpers net: ibm: use netdev feature helpers net: ionic: use netdev feature helpers net: jme: use netdev feature helpers net: micrel: use netdev feature helpers net: cavium: use netdev feature helpers net: cadence: use netdev feature helpers net: mediatek: use netdev feature helpers net: marvell: use netdev feature helpers net: socionext: use netdev feature helpers net: qlogic: use netdev feature helpers net: nfp: use netdev feature helpers net: mscc: use netdev feature helpers net: oki-semi: use netdev feature helpers net: renesas: use netdev feature helpers net: neterion: use netdev feature helpers net: cortina: use netdev feature helpers net: stmmac: use netdev feature helpers net: sxgbe: use netdev feature helpers net: xgmac: use netdev feature helpers net: altera: use netdev feature helpers net: ti: use netdev feature helpers net: benet: use netdev feature helpers net: amd: use netdev feature helpers net: bna: use netdev feature helpers net: enic: use netdev feature helpers net: 3com: use netdev feature helpers net: aeroflex: use netdev feature helpers net: sun: use netdev feature helpers net: mana: use netdev feature helpers net: myricom: use netdev feature helpers net: alacritech: use netdev feature helpers net: toshiba: use netdev feature helpers net: tehuti: use netdev feature helpers net: alteon: use netdev feature helpers net: ena: use netdev feature helpers net: sgi: use netdev feature helpers net: microchip: use netdev feature helpers net: ni: use netdev feature helpers net: apm: use netdev feature helpers net: natsemi: use netdev feature helpers net: xilinx: use netdev feature helpers net: pasemi: use netdev feature helpers net: rocker: use netdev feature helpers net: silan: use netdev feature helpers net: adaptec: use netdev feature helpers net: tundra: use netdev feature helpers net: via: use netdev feature helpers net: wiznet: use netdev feature helpers net: dnet: use netdev feature helpers net: ethoc: use netdev feature helpers RDMA: ipoib: use netdev feature helpers um: use netdev feature helpers scsi: fcoe: use netdev feature helpers net: ipvs: use netdev feature helpers net: xfrm: use netdev feature helpers net: cirrus: use netdev feature helpers net: ec_bhf: use netdev feature helpers net: hamradio: use netdev feature helpers net: batman: use netdev feature helpers net: ieee802154: use netdev feature helpers test_bpf: change the prototype of features net: openvswitch: use netdev feature helpers firewire: use netdev feature helpers staging: qlge: use netdev feature helpers staging: octeon: use netdev feature helpers net: sock: add helper sk_nocaps_add_gso() treewide: introduce macro __DECLARE_NETDEV_FEATURE_MASK net: extend the type of netdev_features_t to bitmap
arch/um/drivers/vector_kern.c | 15 +- drivers/firewire/net.c | 3 +- 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 | 21 +- drivers/infiniband/ulp/ipoib/ipoib_verbs.c | 2 +- drivers/net/bareudp.c | 16 +- drivers/net/bonding/bond_main.c | 136 +++--- drivers/net/bonding/bond_options.c | 12 +- drivers/net/caif/caif_serial.c | 2 +- drivers/net/can/dev/dev.c | 3 +- drivers/net/can/slcan.c | 3 +- drivers/net/dsa/xrs700x/xrs700x.c | 6 +- drivers/net/dummy.c | 14 +- drivers/net/ethernet/3com/3c59x.c | 9 +- drivers/net/ethernet/3com/typhoon.c | 10 +- drivers/net/ethernet/adaptec/starfire.c | 9 +- drivers/net/ethernet/aeroflex/greth.c | 12 +- drivers/net/ethernet/alacritech/slicoss.c | 5 +- drivers/net/ethernet/alteon/acenic.c | 7 +- drivers/net/ethernet/altera/altera_tse_main.c | 11 +- .../net/ethernet/amazon/ena/ena_admin_defs.h | 2 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 50 ++- drivers/net/ethernet/amd/amd8111e.c | 8 +- drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 20 +- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 93 ++-- drivers/net/ethernet/amd/xgbe/xgbe-main.c | 68 +-- drivers/net/ethernet/amd/xgbe/xgbe.h | 2 +- drivers/net/ethernet/apm/xgene-v2/main.c | 5 +- .../net/ethernet/apm/xgene/xgene_enet_main.c | 21 +- .../ethernet/aquantia/atlantic/aq_filters.c | 12 +- .../ethernet/aquantia/atlantic/aq_macsec.c | 2 +- .../net/ethernet/aquantia/atlantic/aq_main.c | 27 +- .../net/ethernet/aquantia/atlantic/aq_nic.c | 28 +- .../net/ethernet/aquantia/atlantic/aq_nic.h | 2 +- .../net/ethernet/aquantia/atlantic/aq_ring.c | 3 +- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 3 +- drivers/net/ethernet/atheros/alx/main.c | 23 +- .../net/ethernet/atheros/atl1c/atl1c_main.c | 33 +- .../net/ethernet/atheros/atl1e/atl1e_main.c | 44 +- drivers/net/ethernet/atheros/atlx/atl1.c | 15 +- drivers/net/ethernet/atheros/atlx/atl2.c | 27 +- drivers/net/ethernet/atheros/atlx/atlx.c | 20 +- drivers/net/ethernet/broadcom/b44.c | 2 +- drivers/net/ethernet/broadcom/bcmsysport.c | 24 +- drivers/net/ethernet/broadcom/bgmac.c | 8 +- drivers/net/ethernet/broadcom/bnx2.c | 48 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 67 +-- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 3 +- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 93 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 171 ++++--- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 11 +- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 3 +- .../net/ethernet/broadcom/genet/bcmgenet.c | 12 +- drivers/net/ethernet/broadcom/tg3.c | 62 +-- drivers/net/ethernet/brocade/bna/bnad.c | 48 +- drivers/net/ethernet/cadence/macb_main.c | 81 ++-- drivers/net/ethernet/calxeda/xgmac.c | 20 +- .../net/ethernet/cavium/liquidio/lio_core.c | 6 +- .../net/ethernet/cavium/liquidio/lio_main.c | 95 ++-- .../ethernet/cavium/liquidio/lio_vf_main.c | 79 ++-- .../net/ethernet/cavium/thunder/nicvf_main.c | 50 ++- .../ethernet/cavium/thunder/nicvf_queues.c | 2 +- drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 50 ++- drivers/net/ethernet/chelsio/cxgb/sge.c | 12 +- .../net/ethernet/chelsio/cxgb3/cxgb3_main.c | 60 ++- drivers/net/ethernet/chelsio/cxgb3/sge.c | 10 +- .../net/ethernet/chelsio/cxgb4/cxgb4_fcoe.c | 16 +- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 88 ++-- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.h | 3 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 14 +- .../ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 39 +- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 8 +- .../chelsio/inline_crypto/chtls/chtls_main.c | 3 +- drivers/net/ethernet/cirrus/ep93xx_eth.c | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 74 ++-- drivers/net/ethernet/cortina/gemini.c | 18 +- drivers/net/ethernet/davicom/dm9000.c | 24 +- drivers/net/ethernet/dnet.c | 2 +- drivers/net/ethernet/ec_bhf.c | 2 +- drivers/net/ethernet/emulex/benet/be_main.c | 68 +-- drivers/net/ethernet/ethoc.c | 2 +- drivers/net/ethernet/faraday/ftgmac100.c | 38 +- .../net/ethernet/freescale/dpaa/dpaa_eth.c | 23 +- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 44 +- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 5 +- drivers/net/ethernet/freescale/enetc/enetc.c | 34 +- .../net/ethernet/freescale/enetc/enetc_pf.c | 38 +- .../net/ethernet/freescale/enetc/enetc_qos.c | 2 +- .../net/ethernet/freescale/enetc/enetc_vf.c | 16 +- drivers/net/ethernet/freescale/fec_main.c | 29 +- .../ethernet/freescale/fs_enet/fs_enet-main.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 39 +- .../net/ethernet/freescale/gianfar_ethtool.c | 11 +- drivers/net/ethernet/google/gve/gve_adminq.c | 6 +- drivers/net/ethernet/google/gve/gve_main.c | 31 +- drivers/net/ethernet/google/gve/gve_rx.c | 8 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 8 +- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 8 +- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 52 ++- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 109 +++-- .../net/ethernet/huawei/hinic/hinic_main.c | 80 ++-- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 5 +- drivers/net/ethernet/ibm/ehea/ehea_main.c | 22 +- drivers/net/ethernet/ibm/emac/core.c | 7 +- drivers/net/ethernet/ibm/ibmveth.c | 76 ++-- drivers/net/ethernet/ibm/ibmvnic.c | 69 +-- drivers/net/ethernet/intel/e100.c | 26 +- drivers/net/ethernet/intel/e1000/e1000_main.c | 82 ++-- drivers/net/ethernet/intel/e1000e/netdev.c | 129 +++--- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 9 +- .../net/ethernet/intel/fm10k/fm10k_netdev.c | 65 +-- drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 11 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 122 ++--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 9 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 153 ++++--- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 12 +- drivers/net/ethernet/intel/ice/ice_main.c | 177 +++++--- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 9 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 +- drivers/net/ethernet/intel/igb/igb_main.c | 150 ++++--- drivers/net/ethernet/intel/igbvf/netdev.c | 86 ++-- drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +- drivers/net/ethernet/intel/igc/igc_main.c | 130 +++--- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 49 +- .../net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 3 +- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 7 +- drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 3 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 215 +++++---- .../net/ethernet/intel/ixgbe/ixgbe_sriov.c | 6 +- drivers/net/ethernet/intel/ixgbevf/ipsec.c | 9 +- .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 105 +++-- drivers/net/ethernet/jme.c | 49 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 14 +- drivers/net/ethernet/marvell/mvneta.c | 22 +- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 73 +-- .../marvell/octeontx2/nic/otx2_common.c | 3 +- .../marvell/octeontx2/nic/otx2_ethtool.c | 4 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 85 ++-- .../marvell/octeontx2/nic/otx2_txrx.c | 8 +- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 35 +- .../ethernet/marvell/prestera/prestera_main.c | 3 +- drivers/net/ethernet/marvell/skge.c | 11 +- drivers/net/ethernet/marvell/sky2.c | 75 ++-- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 68 +-- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- .../net/ethernet/mellanox/mlx4/en_ethtool.c | 4 +- drivers/net/ethernet/mellanox/mlx4/en_main.c | 8 +- .../net/ethernet/mellanox/mlx4/en_netdev.c | 198 +++++---- .../net/ethernet/mellanox/mlx4/en_resources.c | 4 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 19 +- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 5 +- drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 +- .../mellanox/mlx5/core/en_accel/ipsec.c | 18 +- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h | 15 +- .../mellanox/mlx5/core/en_accel/ktls.c | 14 +- .../mellanox/mlx5/core/en_accel/tls.c | 16 +- .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 6 +- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 3 +- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 250 ++++++----- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 25 +- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 19 +- .../net/ethernet/mellanox/mlxsw/spectrum.c | 36 +- drivers/net/ethernet/micrel/ksz884x.c | 10 +- drivers/net/ethernet/microchip/lan743x_main.c | 7 +- .../ethernet/microchip/sparx5/sparx5_fdma.c | 2 +- drivers/net/ethernet/microsoft/mana/mana_en.c | 20 +- drivers/net/ethernet/mscc/ocelot.c | 3 +- drivers/net/ethernet/mscc/ocelot_net.c | 18 +- .../net/ethernet/myricom/myri10ge/myri10ge.c | 31 +- drivers/net/ethernet/natsemi/ns83820.c | 13 +- drivers/net/ethernet/neterion/s2io.c | 32 +- .../net/ethernet/neterion/vxge/vxge-main.c | 49 +- .../net/ethernet/netronome/nfp/crypto/tls.c | 12 +- .../ethernet/netronome/nfp/nfp_net_common.c | 117 +++-- .../net/ethernet/netronome/nfp/nfp_net_repr.c | 76 ++-- drivers/net/ethernet/netronome/nfp/nfp_port.c | 3 +- drivers/net/ethernet/ni/nixge.c | 3 +- drivers/net/ethernet/nvidia/forcedeth.c | 66 +-- .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 13 +- .../ethernet/oki-semi/pch_gbe/pch_gbe_param.c | 6 +- drivers/net/ethernet/pasemi/pasemi_mac.c | 6 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 125 +++--- .../net/ethernet/pensando/ionic/ionic_txrx.c | 9 +- .../ethernet/qlogic/netxen/netxen_nic_init.c | 3 +- .../ethernet/qlogic/netxen/netxen_nic_main.c | 50 ++- drivers/net/ethernet/qlogic/qede/qede.h | 10 +- .../net/ethernet/qlogic/qede/qede_ethtool.c | 2 +- .../net/ethernet/qlogic/qede/qede_filter.c | 19 +- drivers/net/ethernet/qlogic/qede/qede_fp.c | 23 +- drivers/net/ethernet/qlogic/qede/qede_main.c | 67 +-- drivers/net/ethernet/qlogic/qla3xxx.c | 5 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 3 +- .../net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 72 +-- .../net/ethernet/qlogic/qlcnic/qlcnic_io.c | 3 +- .../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 57 +-- drivers/net/ethernet/qualcomm/emac/emac-mac.c | 6 +- drivers/net/ethernet/qualcomm/emac/emac.c | 25 +- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 11 +- .../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 10 +- drivers/net/ethernet/realtek/8139cp.c | 36 +- drivers/net/ethernet/realtek/8139too.c | 28 +- drivers/net/ethernet/realtek/r8169_main.c | 85 ++-- drivers/net/ethernet/renesas/ravb.h | 4 +- drivers/net/ethernet/renesas/ravb_main.c | 24 +- drivers/net/ethernet/renesas/sh_eth.c | 28 +- drivers/net/ethernet/rocker/rocker_main.c | 3 +- .../net/ethernet/samsung/sxgbe/sxgbe_main.c | 19 +- drivers/net/ethernet/sfc/ef10.c | 41 +- drivers/net/ethernet/sfc/ef100_nic.c | 43 +- drivers/net/ethernet/sfc/ef100_rx.c | 6 +- drivers/net/ethernet/sfc/ef100_tx.c | 11 +- drivers/net/ethernet/sfc/ef10_sriov.c | 6 +- drivers/net/ethernet/sfc/efx.c | 32 +- drivers/net/ethernet/sfc/efx_common.c | 41 +- drivers/net/ethernet/sfc/efx_common.h | 4 +- drivers/net/ethernet/sfc/falcon/efx.c | 44 +- drivers/net/ethernet/sfc/falcon/falcon.c | 4 +- drivers/net/ethernet/sfc/falcon/net_driver.h | 9 +- drivers/net/ethernet/sfc/falcon/rx.c | 6 +- drivers/net/ethernet/sfc/farch.c | 2 +- drivers/net/ethernet/sfc/mcdi_filters.c | 21 +- drivers/net/ethernet/sfc/mcdi_port_common.c | 3 +- drivers/net/ethernet/sfc/net_driver.h | 9 +- drivers/net/ethernet/sfc/rx.c | 3 +- drivers/net/ethernet/sfc/rx_common.c | 5 +- drivers/net/ethernet/sfc/siena.c | 4 +- drivers/net/ethernet/sgi/ioc3-eth.c | 11 +- drivers/net/ethernet/silan/sc92031.c | 6 +- drivers/net/ethernet/socionext/netsec.c | 10 +- drivers/net/ethernet/socionext/sni_ave.c | 6 +- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 62 +-- .../stmicro/stmmac/stmmac_selftests.c | 6 +- drivers/net/ethernet/sun/cassini.c | 5 +- drivers/net/ethernet/sun/ldmvsw.c | 5 +- drivers/net/ethernet/sun/niu.c | 11 +- drivers/net/ethernet/sun/sungem.c | 11 +- drivers/net/ethernet/sun/sunhme.c | 14 +- drivers/net/ethernet/sun/sunvnet.c | 8 +- drivers/net/ethernet/sun/sunvnet_common.c | 5 +- .../net/ethernet/synopsys/dwc-xlgmac-common.c | 45 +- drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c | 20 +- .../net/ethernet/synopsys/dwc-xlgmac-net.c | 41 +- drivers/net/ethernet/synopsys/dwc-xlgmac.h | 2 +- drivers/net/ethernet/tehuti/tehuti.c | 22 +- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 23 +- drivers/net/ethernet/ti/cpsw.c | 6 +- drivers/net/ethernet/ti/cpsw_new.c | 7 +- drivers/net/ethernet/ti/netcp_core.c | 9 +- drivers/net/ethernet/toshiba/ps3_gelic_net.c | 14 +- drivers/net/ethernet/toshiba/spider_net.c | 12 +- drivers/net/ethernet/tundra/tsi108_eth.c | 3 +- drivers/net/ethernet/via/via-rhine.c | 10 +- drivers/net/ethernet/via/via-velocity.c | 14 +- drivers/net/ethernet/wiznet/w5100.c | 2 +- drivers/net/ethernet/wiznet/w5300.c | 2 +- drivers/net/ethernet/xilinx/ll_temac_main.c | 5 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 9 +- drivers/net/fjes/fjes_main.c | 3 +- drivers/net/geneve.c | 18 +- drivers/net/gtp.c | 2 +- drivers/net/hamradio/bpqether.c | 3 +- drivers/net/hyperv/netvsc_bpf.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 46 +- drivers/net/hyperv/rndis_filter.c | 30 +- drivers/net/ifb.c | 12 +- drivers/net/ipa/ipa_modem.c | 3 +- drivers/net/ipvlan/ipvlan.h | 2 +- drivers/net/ipvlan/ipvlan_main.c | 40 +- drivers/net/ipvlan/ipvtap.c | 5 +- drivers/net/loopback.c | 20 +- drivers/net/macsec.c | 49 +- drivers/net/macvlan.c | 58 ++- drivers/net/macvtap.c | 5 +- drivers/net/net_failover.c | 77 ++-- drivers/net/netdevsim/ipsec.c | 4 +- drivers/net/netdevsim/netdev.c | 15 +- drivers/net/nlmon.c | 5 +- drivers/net/ntb_netdev.c | 5 +- drivers/net/ppp/ppp_generic.c | 2 +- drivers/net/rionet.c | 3 +- drivers/net/tap.c | 38 +- drivers/net/team/team.c | 90 ++-- drivers/net/thunderbolt.c | 10 +- drivers/net/tun.c | 53 ++- drivers/net/usb/aqc111.c | 42 +- drivers/net/usb/ax88179_178a.c | 26 +- drivers/net/usb/cdc-phonet.c | 2 +- drivers/net/usb/cdc_mbim.c | 4 +- drivers/net/usb/lan78xx.c | 46 +- drivers/net/usb/r8152.c | 71 +-- drivers/net/usb/smsc75xx.c | 14 +- drivers/net/usb/smsc95xx.c | 18 +- drivers/net/veth.c | 67 +-- drivers/net/virtio_net.c | 50 ++- drivers/net/vmxnet3/vmxnet3_drv.c | 75 ++-- drivers/net/vmxnet3/vmxnet3_ethtool.c | 88 ++-- drivers/net/vmxnet3/vmxnet3_int.h | 4 +- drivers/net/vrf.c | 20 +- drivers/net/vsockmon.c | 6 +- drivers/net/vxlan.c | 21 +- drivers/net/wireguard/device.c | 8 +- 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 +- .../broadcom/brcm80211/brcmfmac/core.c | 4 +- .../net/wireless/intel/iwlwifi/cfg/22000.c | 4 +- drivers/net/wireless/intel/iwlwifi/cfg/8000.c | 2 +- drivers/net/wireless/intel/iwlwifi/cfg/9000.c | 2 +- .../net/wireless/intel/iwlwifi/dvm/mac80211.c | 7 +- .../net/wireless/intel/iwlwifi/iwl-config.h | 2 +- .../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 | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 10 +- .../net/wireless/mediatek/mt76/mt7615/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7915/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7921/init.c | 3 +- drivers/net/xen-netback/interface.c | 27 +- drivers/net/xen-netfront.c | 53 ++- drivers/s390/net/qeth_core.h | 7 +- drivers/s390/net/qeth_core_main.c | 139 +++--- drivers/s390/net/qeth_l2_main.c | 44 +- drivers/s390/net/qeth_l3_main.c | 49 +- drivers/scsi/fcoe/fcoe.c | 14 +- drivers/staging/octeon/ethernet.c | 5 +- drivers/staging/qlge/qlge_main.c | 59 +-- drivers/usb/gadget/function/f_phonet.c | 2 +- include/linux/if_macvlan.h | 2 +- include/linux/if_tap.h | 2 +- include/linux/if_vlan.h | 22 +- include/linux/netdev_features.h | 181 +++++++- include/linux/netdevice.h | 122 ++--- include/linux/skbuff.h | 6 +- include/net/mac80211.h | 2 +- include/net/pkt_cls.h | 2 +- include/net/sock.h | 22 +- include/net/udp.h | 8 +- include/net/udp_tunnel.h | 12 +- include/net/vxlan.h | 13 +- lib/test_bpf.c | 21 +- lib/vsprintf.c | 4 +- net/8021q/vlan.c | 11 +- net/8021q/vlan.h | 24 +- net/8021q/vlan_core.c | 6 +- net/8021q/vlan_dev.c | 57 +-- net/batman-adv/soft-interface.c | 5 +- net/bridge/br_device.c | 21 +- net/bridge/br_if.c | 19 +- net/bridge/br_private.h | 3 +- net/core/dev.c | 418 ++++++++++-------- net/core/netpoll.c | 4 +- net/core/pktgen.c | 6 +- net/core/skbuff.c | 10 +- net/core/skmsg.c | 3 +- net/core/sock.c | 17 +- net/dccp/ipv4.c | 2 +- net/dccp/ipv6.c | 7 +- net/decnet/af_decnet.c | 2 +- net/decnet/dn_nsp_out.c | 2 +- net/dsa/slave.c | 24 +- net/ethtool/features.c | 94 ++-- net/ethtool/ioctl.c | 154 ++++--- net/hsr/hsr_device.c | 40 +- net/hsr/hsr_forward.c | 11 +- net/hsr/hsr_framereg.c | 3 +- net/hsr/hsr_slave.c | 3 +- net/ieee802154/6lowpan/core.c | 2 +- net/ieee802154/core.c | 14 +- net/ipv4/af_inet.c | 5 +- net/ipv4/esp4_offload.c | 28 +- net/ipv4/gre_offload.c | 8 +- net/ipv4/ip_gre.c | 36 +- net/ipv4/ip_output.c | 27 +- net/ipv4/ip_tunnel.c | 4 +- net/ipv4/ip_vti.c | 2 +- net/ipv4/ipip.c | 6 +- net/ipv4/ipmr.c | 2 +- net/ipv4/tcp.c | 10 +- net/ipv4/tcp_ipv4.c | 6 +- net/ipv4/tcp_offload.c | 5 +- net/ipv4/tcp_output.c | 2 +- net/ipv4/udp_offload.c | 28 +- net/ipv6/af_inet6.c | 2 +- net/ipv6/esp6_offload.c | 19 +- net/ipv6/inet6_connection_sock.c | 2 +- net/ipv6/ip6_gre.c | 17 +- net/ipv6/ip6_offload.c | 3 +- net/ipv6/ip6_output.c | 24 +- net/ipv6/ip6_tunnel.c | 9 +- net/ipv6/ip6mr.c | 2 +- net/ipv6/sit.c | 9 +- net/ipv6/tcp_ipv6.c | 2 +- net/ipv6/udp_offload.c | 2 +- net/l2tp/l2tp_eth.c | 3 +- net/mac80211/iface.c | 10 +- net/mac80211/main.c | 5 +- net/mpls/mpls_gso.c | 4 +- net/netfilter/ipvs/ip_vs_proto_sctp.c | 3 +- net/nsh/nsh.c | 2 +- net/openvswitch/datapath.c | 5 +- net/openvswitch/vport-internal_dev.c | 23 +- net/phonet/pep-gprs.c | 3 +- net/sched/sch_cake.c | 6 +- net/sched/sch_netem.c | 6 +- net/sched/sch_taprio.c | 6 +- net/sched/sch_tbf.c | 6 +- net/sctp/offload.c | 12 +- net/sctp/output.c | 2 +- net/sunrpc/sunrpc.h | 2 +- net/tls/tls_device.c | 10 +- net/wireless/core.c | 14 +- net/xfrm/xfrm_device.c | 31 +- net/xfrm/xfrm_interface.c | 6 +- net/xfrm/xfrm_output.c | 4 +- 424 files changed, 6578 insertions(+), 4454 deletions(-)
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_intersect_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | 2 +- include/linux/netdevice.h | 7 ++++--- net/8021q/vlan_dev.c | 8 ++++---- net/core/dev.c | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 369f6ae700c7..f04b79f04a9d 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -246,7 +246,7 @@ nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) if (lower_features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- features = netdev_intersect_features(features, lower_features); + netdev_intersect_features(&features, features, lower_features); features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC); features |= NETIF_F_LLTX;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d79163208dfd..5d5129d4791f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5017,8 +5017,9 @@ const char *netdev_drivername(const struct net_device *dev);
void linkwatch_run_queue(void);
-static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, - netdev_features_t f2) +static inline void netdev_intersect_features(netdev_features_t *ret, + netdev_features_t f1, + netdev_features_t f2) { if ((f1 ^ f2) & NETIF_F_HW_CSUM) { if (f1 & NETIF_F_HW_CSUM) @@ -5027,7 +5028,7 @@ static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, f2 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); }
- return f1 & f2; + *ret = f1 & f2; }
static inline netdev_features_t netdev_get_wanted_features( diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 0c21d1fec852..2987201ec93d 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -640,16 +640,16 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev, netdev_features_t old_features = features; netdev_features_t lower_features;
- lower_features = netdev_intersect_features((real_dev->vlan_features | - NETIF_F_RXCSUM), - real_dev->features); + netdev_intersect_features(&lower_features, + (real_dev->vlan_features | NETIF_F_RXCSUM), + real_dev->features);
/* Add HW_CSUM setting to preserve user ability to control * checksum offload on the vlan device. */ if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM; - features = netdev_intersect_features(features, lower_features); + netdev_intersect_features(&features, features, lower_features); features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); features |= NETIF_F_LLTX;
diff --git a/net/core/dev.c b/net/core/dev.c index f930329f0dc2..f1d2224ace75 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3548,10 +3548,10 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb)) - features = netdev_intersect_features(features, - dev->vlan_features | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX); + netdev_intersect_features(&features, features, + dev->vlan_features | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check) features &= dev->netdev_ops->ndo_features_check(skb, dev,
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_intersect_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | 2 +- include/linux/netdevice.h | 7 ++++--- net/8021q/vlan_dev.c | 8 ++++---- net/core/dev.c | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 369f6ae700c7..f04b79f04a9d 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -246,7 +246,7 @@ nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) if (lower_features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- features = netdev_intersect_features(features, lower_features);
- netdev_intersect_features(&features, features, lower_features); features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC); features |= NETIF_F_LLTX;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d79163208dfd..5d5129d4791f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5017,8 +5017,9 @@ const char *netdev_drivername(const struct net_device *dev);
void linkwatch_run_queue(void);
-static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
netdev_features_t f2)
+static inline void netdev_intersect_features(netdev_features_t *ret,
netdev_features_t f1,
netdev_features_t f2)
{ if ((f1 ^ f2) & NETIF_F_HW_CSUM) { if (f1 & NETIF_F_HW_CSUM) @@ -5027,7 +5028,7 @@ static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, f2 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); }
- return f1 & f2;
- *ret = f1 & f2;
}
static inline netdev_features_t netdev_get_wanted_features( diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 0c21d1fec852..2987201ec93d 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -640,16 +640,16 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev, netdev_features_t old_features = features; netdev_features_t lower_features;
- lower_features = netdev_intersect_features((real_dev->vlan_features |
NETIF_F_RXCSUM),
real_dev->features);
- netdev_intersect_features(&lower_features,
(real_dev->vlan_features | NETIF_F_RXCSUM),
Is the "()" here necessary? Will it get some warning in static check tools or checkpatch.pl? Below change in netif_skb_features() doesn't get this.
@@ -3548,10 +3548,10 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb)) - features = netdev_intersect_features(features, - dev->vlan_features | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX); + netdev_intersect_features(&features, features, + dev->vlan_features | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX);
real_dev->features);
/* Add HW_CSUM setting to preserve user ability to control
- checksum offload on the vlan device.
*/ if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- features = netdev_intersect_features(features, lower_features);
- netdev_intersect_features(&features, features, lower_features); features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); features |= NETIF_F_LLTX;
diff --git a/net/core/dev.c b/net/core/dev.c index f930329f0dc2..f1d2224ace75 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3548,10 +3548,10 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb))
features = netdev_intersect_features(features,
dev->vlan_features |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
netdev_intersect_features(&features, features,
dev->vlan_features |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check) features &= dev->netdev_ops->ndo_features_check(skb, dev,
在 2021/9/23 11:00, moyufeng 写道:
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_intersect_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | 2 +- include/linux/netdevice.h | 7 ++++--- net/8021q/vlan_dev.c | 8 ++++---- net/core/dev.c | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 369f6ae700c7..f04b79f04a9d 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -246,7 +246,7 @@ nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) if (lower_features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- features = netdev_intersect_features(features, lower_features);
- netdev_intersect_features(&features, features, lower_features); features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC); features |= NETIF_F_LLTX;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d79163208dfd..5d5129d4791f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5017,8 +5017,9 @@ const char *netdev_drivername(const struct net_device *dev);
void linkwatch_run_queue(void);
-static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
netdev_features_t f2)
+static inline void netdev_intersect_features(netdev_features_t *ret,
netdev_features_t f1,
{ if ((f1 ^ f2) & NETIF_F_HW_CSUM) { if (f1 & NETIF_F_HW_CSUM)netdev_features_t f2)
@@ -5027,7 +5028,7 @@ static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, f2 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); }
- return f1 & f2;
*ret = f1 & f2; }
static inline netdev_features_t netdev_get_wanted_features(
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 0c21d1fec852..2987201ec93d 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -640,16 +640,16 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev, netdev_features_t old_features = features; netdev_features_t lower_features;
- lower_features = netdev_intersect_features((real_dev->vlan_features |
NETIF_F_RXCSUM),
real_dev->features);
- netdev_intersect_features(&lower_features,
(real_dev->vlan_features | NETIF_F_RXCSUM),
Is the "()" here necessary? Will it get some warning in static check tools or checkpatch.pl? Below change in netif_skb_features() doesn't get this.
No warning reported, for it's unrelated for the interface change, so I think should keep it .
@@ -3548,10 +3548,10 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb))
features = netdev_intersect_features(features,
dev->vlan_features |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
netdev_intersect_features(&features, features,
dev->vlan_features |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
real_dev->features);
/* Add HW_CSUM setting to preserve user ability to control
- checksum offload on the vlan device.
*/ if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- features = netdev_intersect_features(features, lower_features);
- netdev_intersect_features(&features, features, lower_features); features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); features |= NETIF_F_LLTX;
diff --git a/net/core/dev.c b/net/core/dev.c index f930329f0dc2..f1d2224ace75 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3548,10 +3548,10 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb))
features = netdev_intersect_features(features,
dev->vlan_features |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
netdev_intersect_features(&features, features,
dev->vlan_features |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check) features &= dev->netdev_ops->ndo_features_check(skb, dev,
.
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_get_wanted_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- include/linux/netdevice.h | 6 +++--- net/core/dev.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5d5129d4791f..a5598d617789 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5031,10 +5031,10 @@ static inline void netdev_intersect_features(netdev_features_t *ret, *ret = f1 & f2; }
-static inline netdev_features_t netdev_get_wanted_features( - struct net_device *dev) +static inline void netdev_get_wanted_features(struct net_device *dev, + netdev_features_t *wanted) { - return (dev->features & ~dev->hw_features) | dev->wanted_features; + *wanted = (dev->features & ~dev->hw_features) | dev->wanted_features; } netdev_features_t netdev_increment_features(netdev_features_t all, netdev_features_t one, netdev_features_t mask); diff --git a/net/core/dev.c b/net/core/dev.c index f1d2224ace75..486e75a4f1e1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9929,7 +9929,7 @@ int __netdev_update_features(struct net_device *dev)
ASSERT_RTNL();
- features = netdev_get_wanted_features(dev); + netdev_get_wanted_features(dev, &features);
if (dev->netdev_ops->ndo_fix_features) features = dev->netdev_ops->ndo_fix_features(dev, features);
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_get_wanted_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
include/linux/netdevice.h | 6 +++--- net/core/dev.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5d5129d4791f..a5598d617789 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5031,10 +5031,10 @@ static inline void netdev_intersect_features(netdev_features_t *ret, *ret = f1 & f2; }
-static inline netdev_features_t netdev_get_wanted_features(
- struct net_device *dev)
+static inline void netdev_get_wanted_features(struct net_device *dev,
netdev_features_t *wanted)
{
- return (dev->features & ~dev->hw_features) | dev->wanted_features;
- *wanted = (dev->features & ~dev->hw_features) | dev->wanted_features;
} netdev_features_t netdev_increment_features(netdev_features_t all, netdev_features_t one, netdev_features_t mask); diff --git a/net/core/dev.c b/net/core/dev.c index f1d2224ace75..486e75a4f1e1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9929,7 +9929,7 @@ int __netdev_update_features(struct net_device *dev)
ASSERT_RTNL();
- features = netdev_get_wanted_features(dev);
netdev_get_wanted_features(dev, &features);
if (dev->netdev_ops->ndo_fix_features) features = dev->netdev_ops->ndo_fix_features(dev, features);
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of net_mpls_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/core/dev.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 486e75a4f1e1..866ade9b8a41 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3444,21 +3444,16 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) * instead of standard features for the netdev. */ #if IS_ENABLED(CONFIG_NET_MPLS_GSO) -static netdev_features_t net_mpls_features(struct sk_buff *skb, - netdev_features_t features, - __be16 type) +static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features, + __be16 type) { if (eth_p_mpls(type)) - features &= skb->dev->mpls_features; - - return features; + *features &= skb->dev->mpls_features; } #else -static netdev_features_t net_mpls_features(struct sk_buff *skb, - netdev_features_t features, - __be16 type) +static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features, + __be16 type) { - return features; } #endif
@@ -3468,7 +3463,7 @@ static netdev_features_t harmonize_features(struct sk_buff *skb, __be16 type;
type = skb_network_protocol(skb, NULL); - features = net_mpls_features(skb, features, type); + net_mpls_features(skb, &features, type);
if (skb->ip_summed != CHECKSUM_NONE && !can_checksum_protocol(features, type)) {
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of net_mpls_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
net/core/dev.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 486e75a4f1e1..866ade9b8a41 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3444,21 +3444,16 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
- instead of standard features for the netdev.
*/ #if IS_ENABLED(CONFIG_NET_MPLS_GSO) -static netdev_features_t net_mpls_features(struct sk_buff *skb,
netdev_features_t features,
__be16 type)
+static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features,
__be16 type)
{ if (eth_p_mpls(type))
features &= skb->dev->mpls_features;
- return features;
*features &= skb->dev->mpls_features;
} #else -static netdev_features_t net_mpls_features(struct sk_buff *skb,
netdev_features_t features,
__be16 type)
+static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features,
__be16 type)
{
- return features;
} #endif
@@ -3468,7 +3463,7 @@ static netdev_features_t harmonize_features(struct sk_buff *skb, __be16 type;
type = skb_network_protocol(skb, NULL);
- features = net_mpls_features(skb, features, type);
net_mpls_features(skb, &features, type);
if (skb->ip_summed != CHECKSUM_NONE && !can_checksum_protocol(features, type)) {
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of harmonize_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/core/dev.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 866ade9b8a41..7b4c4cd8338c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3457,22 +3457,19 @@ static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features, } #endif
-static netdev_features_t harmonize_features(struct sk_buff *skb, - netdev_features_t features) +static void harmonize_features(struct sk_buff *skb, netdev_features_t *features) { __be16 type;
type = skb_network_protocol(skb, NULL); - net_mpls_features(skb, &features, type); + net_mpls_features(skb, features, type);
if (skb->ip_summed != CHECKSUM_NONE && - !can_checksum_protocol(features, type)) { - features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + !can_checksum_protocol(*features, type)) { + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); } if (illegal_highdma(skb->dev, skb)) - features &= ~NETIF_F_SG; - - return features; + *features &= ~NETIF_F_SG; }
netdev_features_t passthru_features_check(struct sk_buff *skb, @@ -3554,7 +3551,8 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) else features &= dflt_features_check(skb, dev, features);
- return harmonize_features(skb, features); + harmonize_features(skb, &features); + return features; } EXPORT_SYMBOL(netif_skb_features);
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of harmonize_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
net/core/dev.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 866ade9b8a41..7b4c4cd8338c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3457,22 +3457,19 @@ static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features, } #endif
-static netdev_features_t harmonize_features(struct sk_buff *skb,
- netdev_features_t features)
+static void harmonize_features(struct sk_buff *skb, netdev_features_t *features) { __be16 type;
type = skb_network_protocol(skb, NULL);
- net_mpls_features(skb, &features, type);
net_mpls_features(skb, features, type);
if (skb->ip_summed != CHECKSUM_NONE &&
!can_checksum_protocol(features, type)) {
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
!can_checksum_protocol(*features, type)) {
} if (illegal_highdma(skb->dev, skb))*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
features &= ~NETIF_F_SG;
- return features;
*features &= ~NETIF_F_SG;
}
netdev_features_t passthru_features_check(struct sk_buff *skb, @@ -3554,7 +3551,8 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) else features &= dflt_features_check(skb, dev, features);
- return harmonize_features(skb, features);
- harmonize_features(skb, &features);
- return features;
} EXPORT_SYMBOL(netif_skb_features);
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of gso_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/core/dev.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 7b4c4cd8338c..3e13bd2022c2 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3487,18 +3487,21 @@ static netdev_features_t dflt_features_check(struct sk_buff *skb, return vlan_features_check(skb, features); }
-static netdev_features_t gso_features_check(const struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void gso_features_check(const struct sk_buff *skb, + struct net_device *dev, + netdev_features_t *features) { u16 gso_segs = skb_shinfo(skb)->gso_segs;
- if (gso_segs > dev->gso_max_segs) - return features & ~NETIF_F_GSO_MASK; + if (gso_segs > dev->gso_max_segs) { + *features &= ~NETIF_F_GSO_MASK; + return; + }
if (!skb_shinfo(skb)->gso_type) { skb_warn_bad_offload(skb); - return features & ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK; + return; }
/* Support for GSO partial features requires software @@ -3508,7 +3511,7 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb, * segmented the frame. */ if (!(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL)) - features &= ~dev->gso_partial_features; + *features &= ~dev->gso_partial_features;
/* Make sure to clear the IPv4 ID mangling feature if the * IPv4 header has the potential to be fragmented. @@ -3518,10 +3521,8 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb, inner_ip_hdr(skb) : ip_hdr(skb);
if (!(iph->frag_off & htons(IP_DF))) - features &= ~NETIF_F_TSO_MANGLEID; + *features &= ~NETIF_F_TSO_MANGLEID; } - - return features; }
netdev_features_t netif_skb_features(struct sk_buff *skb) @@ -3530,7 +3531,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) netdev_features_t features = dev->features;
if (skb_is_gso(skb)) - features = gso_features_check(skb, dev, features); + gso_features_check(skb, dev, &features);
/* If encapsulation offload request, verify we are testing * hardware encapsulation features instead of standard
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of gso_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
net/core/dev.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 7b4c4cd8338c..3e13bd2022c2 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3487,18 +3487,21 @@ static netdev_features_t dflt_features_check(struct sk_buff *skb, return vlan_features_check(skb, features); }
-static netdev_features_t gso_features_check(const struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void gso_features_check(const struct sk_buff *skb,
struct net_device *dev,
netdev_features_t *features)
{ u16 gso_segs = skb_shinfo(skb)->gso_segs;
- if (gso_segs > dev->gso_max_segs)
return features & ~NETIF_F_GSO_MASK;
if (gso_segs > dev->gso_max_segs) {
*features &= ~NETIF_F_GSO_MASK;
return;
}
if (!skb_shinfo(skb)->gso_type) { skb_warn_bad_offload(skb);
return features & ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
return;
}
/* Support for GSO partial features requires software
@@ -3508,7 +3511,7 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb, * segmented the frame. */ if (!(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL))
features &= ~dev->gso_partial_features;
*features &= ~dev->gso_partial_features;
/* Make sure to clear the IPv4 ID mangling feature if the
- IPv4 header has the potential to be fragmented.
@@ -3518,10 +3521,8 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb, inner_ip_hdr(skb) : ip_hdr(skb);
if (!(iph->frag_off & htons(IP_DF)))
features &= ~NETIF_F_TSO_MANGLEID;
}*features &= ~NETIF_F_TSO_MANGLEID;
- return features;
}
netdev_features_t netif_skb_features(struct sk_buff *skb) @@ -3530,7 +3531,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) netdev_features_t features = dev->features;
if (skb_is_gso(skb))
features = gso_features_check(skb, dev, features);
gso_features_check(skb, dev, &features);
/* If encapsulation offload request, verify we are testing
- hardware encapsulation features instead of standard
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of vlan_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/emulex/benet/be_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- drivers/net/ethernet/realtek/8139cp.c | 3 ++- drivers/net/ethernet/realtek/r8169_main.c | 3 ++- drivers/net/usb/lan78xx.c | 2 +- drivers/s390/net/qeth_core_main.c | 3 ++- include/linux/if_vlan.h | 12 +++++------- net/core/dev.c | 3 ++- 14 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index 17a585adfb49..3fb15f675ddf 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2271,7 +2271,7 @@ static netdev_features_t xgbe_features_check(struct sk_buff *skb, struct net_device *netdev, netdev_features_t features) { - features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
return features; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index ae87296ae1ff..105aae3e21bf 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12856,7 +12856,7 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb, !skb_gso_validate_mac_len(skb, 9700))) features &= ~NETIF_F_GSO_MASK;
- features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); return vxlan_features_check(skb, features); }
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 037767b370d5..c8ee75ecf494 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11097,7 +11097,7 @@ static netdev_features_t bnxt_features_check(struct sk_buff *skb, struct bnxt *bp = netdev_priv(dev); u8 *l4_proto;
- features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!skb->encapsulation) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 361c1c87c183..556242d32d93 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -5092,7 +5092,7 @@ static netdev_features_t be_features_check(struct sk_buff *skb, * Q-in-Q packets. * Offload features for normal (non tunnel) packets are unchanged. */ - features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); if (!skb->encapsulation || !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)) return features; diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index a2f61a87cef8..c51bd5d14741 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2664,7 +2664,7 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) { - features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 3fd515e7bf30..b6aa5da06776 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3910,7 +3910,7 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb, { struct mlx5e_priv *priv = netdev_priv(netdev);
- features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
/* Validate if the tunneled packet is being offloaded by HW */ diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 5bfa22accf2c..58e7d98d0dd6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3605,7 +3605,7 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, u8 l4_hdr;
/* We can't do TSO over double tagged packets (802.1AD) */ - features &= vlan_features_check(skb, features); + vlan_features_check(skb, &features);
if (!skb->encapsulation) return features; diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 75960a29f80e..8f3a2a021082 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -496,7 +496,7 @@ static netdev_features_t qlcnic_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) { - features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); return vxlan_features_check(skb, features); }
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index 2b84b4565e64..d2135fe99cd7 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c @@ -1860,7 +1860,8 @@ static netdev_features_t cp_features_check(struct sk_buff *skb, if (skb_shinfo(skb)->gso_size > MSSMask) features &= ~NETIF_F_TSO;
- return vlan_features_check(skb, features); + vlan_features_check(skb, &features); + return features; } static const struct net_device_ops cp_netdev_ops = { .ndo_open = cp_open, diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 0199914440ab..98e7ffa6aa0a 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4374,7 +4374,8 @@ static netdev_features_t rtl8169_features_check(struct sk_buff *skb, features &= ~NETIF_F_CSUM_MASK; }
- return vlan_features_check(skb, features); + vlan_features_check(skb, &features); + return features; }
static void rtl8169_pcierr_interrupt(struct net_device *dev) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 793f8fbe0069..bf477ea4ac26 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3983,7 +3983,7 @@ static netdev_features_t lan78xx_features_check(struct sk_buff *skb, if (skb->len + TX_OVERHEAD > MAX_SINGLE_PACKET_SIZE) features &= ~NETIF_F_GSO_MASK;
- features = vlan_features_check(skb, features); + vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
return features; diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 41ca6273b750..bf72dd88297a 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -7002,7 +7002,8 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, features &= ~NETIF_F_SG; }
- return vlan_features_check(skb, features); + vlan_features_check(skb, &features); + return features; } EXPORT_SYMBOL_GPL(qeth_features_check);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 41a518336673..2337538ef015 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -727,8 +727,8 @@ static inline bool skb_vlan_tagged_multi(struct sk_buff *skb) * * Returns features without unsafe ones if the skb has multiple tags. */ -static inline netdev_features_t vlan_features_check(struct sk_buff *skb, - netdev_features_t features) +static inline void vlan_features_check(struct sk_buff *skb, + netdev_features_t *features) { if (skb_vlan_tagged_multi(skb)) { /* In the case of multi-tagged packets, use a direct mask @@ -736,12 +736,10 @@ static inline netdev_features_t vlan_features_check(struct sk_buff *skb, * sure that only devices supporting NETIF_F_HW_CSUM will * have checksum offloading support. */ - features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | - NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; + *features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | + NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX; } - - return features; }
/** diff --git a/net/core/dev.c b/net/core/dev.c index 3e13bd2022c2..bdeb0dfed608 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3484,7 +3484,8 @@ static netdev_features_t dflt_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) { - return vlan_features_check(skb, features); + vlan_features_check(skb, &features); + return features; }
static void gso_features_check(const struct sk_buff *skb,
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of vlan_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/emulex/benet/be_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- drivers/net/ethernet/realtek/8139cp.c | 3 ++- drivers/net/ethernet/realtek/r8169_main.c | 3 ++- drivers/net/usb/lan78xx.c | 2 +- drivers/s390/net/qeth_core_main.c | 3 ++- include/linux/if_vlan.h | 12 +++++------- net/core/dev.c | 3 ++- 14 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index 17a585adfb49..3fb15f675ddf 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2271,7 +2271,7 @@ static netdev_features_t xgbe_features_check(struct sk_buff *skb, struct net_device *netdev, netdev_features_t features) {
- features = vlan_features_check(skb, features);
vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
return features;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index ae87296ae1ff..105aae3e21bf 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12856,7 +12856,7 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb, !skb_gso_validate_mac_len(skb, 9700))) features &= ~NETIF_F_GSO_MASK;
- features = vlan_features_check(skb, features);
- vlan_features_check(skb, &features); return vxlan_features_check(skb, features);
}
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 037767b370d5..c8ee75ecf494 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11097,7 +11097,7 @@ static netdev_features_t bnxt_features_check(struct sk_buff *skb, struct bnxt *bp = netdev_priv(dev); u8 *l4_proto;
- features = vlan_features_check(skb, features);
- vlan_features_check(skb, &features); switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!skb->encapsulation)
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 361c1c87c183..556242d32d93 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -5092,7 +5092,7 @@ static netdev_features_t be_features_check(struct sk_buff *skb, * Q-in-Q packets. * Offload features for normal (non tunnel) packets are unchanged. */
- features = vlan_features_check(skb, features);
- vlan_features_check(skb, &features); if (!skb->encapsulation || !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)) return features;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index a2f61a87cef8..c51bd5d14741 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2664,7 +2664,7 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) {
- features = vlan_features_check(skb, features);
vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 3fd515e7bf30..b6aa5da06776 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3910,7 +3910,7 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb, { struct mlx5e_priv *priv = netdev_priv(netdev);
- features = vlan_features_check(skb, features);
vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
/* Validate if the tunneled packet is being offloaded by HW */
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 5bfa22accf2c..58e7d98d0dd6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3605,7 +3605,7 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, u8 l4_hdr;
/* We can't do TSO over double tagged packets (802.1AD) */
- features &= vlan_features_check(skb, features);
vlan_features_check(skb, &features);
if (!skb->encapsulation) return features;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 75960a29f80e..8f3a2a021082 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -496,7 +496,7 @@ static netdev_features_t qlcnic_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) {
- features = vlan_features_check(skb, features);
- vlan_features_check(skb, &features); return vxlan_features_check(skb, features);
}
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index 2b84b4565e64..d2135fe99cd7 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c @@ -1860,7 +1860,8 @@ static netdev_features_t cp_features_check(struct sk_buff *skb, if (skb_shinfo(skb)->gso_size > MSSMask) features &= ~NETIF_F_TSO;
- return vlan_features_check(skb, features);
- vlan_features_check(skb, &features);
- return features;
} static const struct net_device_ops cp_netdev_ops = { .ndo_open = cp_open, diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 0199914440ab..98e7ffa6aa0a 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4374,7 +4374,8 @@ static netdev_features_t rtl8169_features_check(struct sk_buff *skb, features &= ~NETIF_F_CSUM_MASK; }
- return vlan_features_check(skb, features);
- vlan_features_check(skb, &features);
- return features;
}
static void rtl8169_pcierr_interrupt(struct net_device *dev) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 793f8fbe0069..bf477ea4ac26 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3983,7 +3983,7 @@ static netdev_features_t lan78xx_features_check(struct sk_buff *skb, if (skb->len + TX_OVERHEAD > MAX_SINGLE_PACKET_SIZE) features &= ~NETIF_F_GSO_MASK;
- features = vlan_features_check(skb, features);
vlan_features_check(skb, &features); features = vxlan_features_check(skb, features);
return features;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 41ca6273b750..bf72dd88297a 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -7002,7 +7002,8 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, features &= ~NETIF_F_SG; }
- return vlan_features_check(skb, features);
- vlan_features_check(skb, &features);
- return features;
} EXPORT_SYMBOL_GPL(qeth_features_check);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 41a518336673..2337538ef015 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -727,8 +727,8 @@ static inline bool skb_vlan_tagged_multi(struct sk_buff *skb)
- Returns features without unsafe ones if the skb has multiple tags.
*/ -static inline netdev_features_t vlan_features_check(struct sk_buff *skb,
netdev_features_t features)
+static inline void vlan_features_check(struct sk_buff *skb,
netdev_features_t *features)
{ if (skb_vlan_tagged_multi(skb)) { /* In the case of multi-tagged packets, use a direct mask @@ -736,12 +736,10 @@ static inline netdev_features_t vlan_features_check(struct sk_buff *skb, * sure that only devices supporting NETIF_F_HW_CSUM will * have checksum offloading support. */
features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM |
NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
*features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM |
NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX |
}NETIF_F_HW_VLAN_STAG_TX;
- return features;
}
/** diff --git a/net/core/dev.c b/net/core/dev.c index 3e13bd2022c2..bdeb0dfed608 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3484,7 +3484,8 @@ static netdev_features_t dflt_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) {
- return vlan_features_check(skb, features);
- vlan_features_check(skb, &features);
- return features;
}
static void gso_features_check(const struct sk_buff *skb,
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of vxlan_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 ++- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 3 ++- drivers/net/usb/lan78xx.c | 2 +- include/net/vxlan.h | 13 ++++++------- 8 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index 3fb15f675ddf..29bca9fabcde 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2272,7 +2272,7 @@ static netdev_features_t xgbe_features_check(struct sk_buff *skb, netdev_features_t features) { vlan_features_check(skb, &features); - features = vxlan_features_check(skb, features); + vxlan_features_check(skb, &features);
return features; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 105aae3e21bf..f444515452a5 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12857,7 +12857,8 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb, features &= ~NETIF_F_GSO_MASK;
vlan_features_check(skb, &features); - return vxlan_features_check(skb, features); + vxlan_features_check(skb, &features); + return features; }
static int __bnx2x_vlan_configure_vid(struct bnx2x *bp, u16 vid, bool add) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index d0a8f7106958..033b9dee2bb7 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -253,7 +253,7 @@ static netdev_features_t enic_features_check(struct sk_buff *skb, if (!skb->encapsulation) return features;
- features = vxlan_features_check(skb, features); + vxlan_features_check(skb, &features);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IPV6): diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index c51bd5d14741..941d2d45cd23 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2665,7 +2665,7 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, netdev_features_t features) { vlan_features_check(skb, &features); - features = vxlan_features_check(skb, features); + vxlan_features_check(skb, &features);
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does * support inner IPv6 checksums and segmentation so we need to diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index b6aa5da06776..4518a490cdcd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3911,7 +3911,7 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb, struct mlx5e_priv *priv = netdev_priv(netdev);
vlan_features_check(skb, &features); - features = vxlan_features_check(skb, features); + vxlan_features_check(skb, &features);
/* Validate if the tunneled packet is being offloaded by HW */ if (skb->encapsulation && diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 8f3a2a021082..d823f2a22472 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -497,7 +497,8 @@ static netdev_features_t qlcnic_features_check(struct sk_buff *skb, netdev_features_t features) { vlan_features_check(skb, &features); - return vxlan_features_check(skb, features); + vxlan_features_check(skb, &features); + return features; }
static const struct net_device_ops qlcnic_netdev_ops = { diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index bf477ea4ac26..9bfee75cbaf1 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3984,7 +3984,7 @@ static netdev_features_t lan78xx_features_check(struct sk_buff *skb, features &= ~NETIF_F_GSO_MASK;
vlan_features_check(skb, &features); - features = vxlan_features_check(skb, features); + vxlan_features_check(skb, &features);
return features; } diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 08537aa14f7c..a801e59e2313 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -296,13 +296,13 @@ struct vxlan_dev { struct net_device *vxlan_dev_create(struct net *net, const char *name, u8 name_assign_type, struct vxlan_config *conf);
-static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, - netdev_features_t features) +static inline void vxlan_features_check(struct sk_buff *skb, + netdev_features_t *features) { u8 l4_hdr = 0;
if (!skb->encapsulation) - return features; + return;
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): @@ -312,7 +312,7 @@ static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, l4_hdr = ipv6_hdr(skb)->nexthdr; break; default: - return features; + return; }
if ((l4_hdr == IPPROTO_UDP) && @@ -321,10 +321,9 @@ static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, (skb_inner_mac_header(skb) - skb_transport_header(skb) != sizeof(struct udphdr) + sizeof(struct vxlanhdr)) || (skb->ip_summed != CHECKSUM_NONE && - !can_checksum_protocol(features, inner_eth_hdr(skb)->h_proto)))) - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + !can_checksum_protocol(*features, inner_eth_hdr(skb)->h_proto)))) + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- return features; }
/* IP header + UDP + VXLAN + Ethernet header */
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of vxlan_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 ++- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 3 ++- drivers/net/usb/lan78xx.c | 2 +- include/net/vxlan.h | 13 ++++++------- 8 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index 3fb15f675ddf..29bca9fabcde 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2272,7 +2272,7 @@ static netdev_features_t xgbe_features_check(struct sk_buff *skb, netdev_features_t features) { vlan_features_check(skb, &features);
- features = vxlan_features_check(skb, features);
vxlan_features_check(skb, &features);
return features;
} diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 105aae3e21bf..f444515452a5 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12857,7 +12857,8 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb, features &= ~NETIF_F_GSO_MASK;
vlan_features_check(skb, &features);
- return vxlan_features_check(skb, features);
- vxlan_features_check(skb, &features);
- return features;
}
static int __bnx2x_vlan_configure_vid(struct bnx2x *bp, u16 vid, bool add) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index d0a8f7106958..033b9dee2bb7 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -253,7 +253,7 @@ static netdev_features_t enic_features_check(struct sk_buff *skb, if (!skb->encapsulation) return features;
- features = vxlan_features_check(skb, features);
vxlan_features_check(skb, &features);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IPV6):
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index c51bd5d14741..941d2d45cd23 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2665,7 +2665,7 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, netdev_features_t features) { vlan_features_check(skb, &features);
- features = vxlan_features_check(skb, features);
vxlan_features_check(skb, &features);
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does
- support inner IPv6 checksums and segmentation so we need to
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index b6aa5da06776..4518a490cdcd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3911,7 +3911,7 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb, struct mlx5e_priv *priv = netdev_priv(netdev);
vlan_features_check(skb, &features);
- features = vxlan_features_check(skb, features);
vxlan_features_check(skb, &features);
/* Validate if the tunneled packet is being offloaded by HW */ if (skb->encapsulation &&
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 8f3a2a021082..d823f2a22472 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -497,7 +497,8 @@ static netdev_features_t qlcnic_features_check(struct sk_buff *skb, netdev_features_t features) { vlan_features_check(skb, &features);
- return vxlan_features_check(skb, features);
- vxlan_features_check(skb, &features);
- return features;
}
static const struct net_device_ops qlcnic_netdev_ops = { diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index bf477ea4ac26..9bfee75cbaf1 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3984,7 +3984,7 @@ static netdev_features_t lan78xx_features_check(struct sk_buff *skb, features &= ~NETIF_F_GSO_MASK;
vlan_features_check(skb, &features);
- features = vxlan_features_check(skb, features);
vxlan_features_check(skb, &features);
return features;
} diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 08537aa14f7c..a801e59e2313 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -296,13 +296,13 @@ struct vxlan_dev { struct net_device *vxlan_dev_create(struct net *net, const char *name, u8 name_assign_type, struct vxlan_config *conf);
-static inline netdev_features_t vxlan_features_check(struct sk_buff *skb,
netdev_features_t features)
+static inline void vxlan_features_check(struct sk_buff *skb,
netdev_features_t *features)
{ u8 l4_hdr = 0;
if (!skb->encapsulation)
return features;
return;
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP):
@@ -312,7 +312,7 @@ static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, l4_hdr = ipv6_hdr(skb)->nexthdr; break; default:
return features;
return;
}
if ((l4_hdr == IPPROTO_UDP) &&
@@ -321,10 +321,9 @@ static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, (skb_inner_mac_header(skb) - skb_transport_header(skb) != sizeof(struct udphdr) + sizeof(struct vxlanhdr)) || (skb->ip_summed != CHECKSUM_NONE &&
!can_checksum_protocol(features, inner_eth_hdr(skb)->h_proto))))
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
!can_checksum_protocol(*features, inner_eth_hdr(skb)->h_proto))))
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- return features;
}
/* IP header + UDP + VXLAN + Ethernet header */
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of dflt_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/core/dev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index bdeb0dfed608..4aab7b83fcb8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3480,12 +3480,11 @@ netdev_features_t passthru_features_check(struct sk_buff *skb, } EXPORT_SYMBOL(passthru_features_check);
-static netdev_features_t dflt_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void dflt_features_check(struct sk_buff *skb, + struct net_device *dev, + netdev_features_t *features) { - vlan_features_check(skb, &features); - return features; + vlan_features_check(skb, features); }
static void gso_features_check(const struct sk_buff *skb, @@ -3551,7 +3550,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->netdev_ops->ndo_features_check(skb, dev, features); else - features &= dflt_features_check(skb, dev, features); + dflt_features_check(skb, dev, &features);
harmonize_features(skb, &features); return features;
Review-by: Yufeng Mo moyufeng@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of dflt_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
net/core/dev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index bdeb0dfed608..4aab7b83fcb8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3480,12 +3480,11 @@ netdev_features_t passthru_features_check(struct sk_buff *skb, } EXPORT_SYMBOL(passthru_features_check);
-static netdev_features_t dflt_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void dflt_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t *features)
{
- vlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
}
static void gso_features_check(const struct sk_buff *skb, @@ -3551,7 +3550,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) features &= dev->netdev_ops->ndo_features_check(skb, dev, features); else
features &= dflt_features_check(skb, dev, features);
dflt_features_check(skb, dev, &features);
harmonize_features(skb, &features); return features;
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of ndo_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 11 ++--- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 12 +++--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++--- drivers/net/ethernet/cadence/macb_main.c | 20 +++++---- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 +++-- drivers/net/ethernet/cisco/enic/enic_main.c | 13 +++--- drivers/net/ethernet/emulex/benet/be_main.c | 23 +++++------ .../net/ethernet/hisilicon/hns3/hns3_enet.c | 11 ++--- drivers/net/ethernet/ibm/ibmvnic.c | 9 ++-- .../net/ethernet/intel/fm10k/fm10k_netdev.c | 9 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++--- drivers/net/ethernet/intel/iavf/iavf_main.c | 13 +++--- drivers/net/ethernet/intel/ice/ice_main.c | 15 ++++--- drivers/net/ethernet/intel/igb/igb_main.c | 41 ++++++++++--------- drivers/net/ethernet/intel/igbvf/netdev.c | 37 +++++++++-------- drivers/net/ethernet/intel/igc/igc_main.c | 37 +++++++++-------- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 41 ++++++++++--------- .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 37 +++++++++-------- .../net/ethernet/mellanox/mlx4/en_netdev.c | 13 +++--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 15 +++---- .../ethernet/netronome/nfp/nfp_net_common.c | 22 +++++----- drivers/net/ethernet/qlogic/qede/qede.h | 5 +-- drivers/net/ethernet/qlogic/qede/qede_fp.c | 20 ++++----- .../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 10 ++--- drivers/net/ethernet/realtek/8139cp.c | 10 ++--- drivers/net/ethernet/realtek/r8169_main.c | 18 ++++---- drivers/net/ethernet/sfc/efx_common.c | 13 +++--- drivers/net/ethernet/sfc/efx_common.h | 4 +- drivers/net/usb/lan78xx.c | 14 +++---- drivers/net/usb/r8152.c | 11 ++--- drivers/net/vmxnet3/vmxnet3_ethtool.c | 15 +++---- drivers/net/vmxnet3/vmxnet3_int.h | 4 +- drivers/s390/net/qeth_core.h | 5 +-- drivers/s390/net/qeth_core_main.c | 18 ++++---- drivers/s390/net/qeth_l3_main.c | 10 ++--- include/linux/netdevice.h | 9 ++-- net/core/dev.c | 9 ++-- 38 files changed, 280 insertions(+), 318 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index 29bca9fabcde..cc1f1a7a46ae 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2267,14 +2267,11 @@ static int xgbe_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t xgbe_features_check(struct sk_buff *skb, - struct net_device *netdev, - netdev_features_t features) +static void xgbe_features_check(struct sk_buff *skb, struct net_device *netdev, + netdev_features_t *features) { - vlan_features_check(skb, &features); - vxlan_features_check(skb, &features); - - return features; + vlan_features_check(skb, features); + vxlan_features_check(skb, features); }
static const struct net_device_ops xgbe_netdev_ops = { diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index f444515452a5..1f817dfa5b64 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12834,9 +12834,8 @@ static int bnx2x_get_phys_port_id(struct net_device *netdev, return 0; }
-static netdev_features_t bnx2x_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void bnx2x_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { /* * A skb with gso_size + header length > 9700 will cause a @@ -12854,11 +12853,10 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb, if (unlikely(skb_is_gso(skb) && (skb_shinfo(skb)->gso_size > 9000) && !skb_gso_validate_mac_len(skb, 9700))) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK;
- vlan_features_check(skb, &features); - vxlan_features_check(skb, &features); - return features; + vlan_features_check(skb, features); + vxlan_features_check(skb, features); }
static int __bnx2x_vlan_configure_vid(struct bnx2x *bp, u16 vid, bool add) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c8ee75ecf494..b43b96cfaebc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11090,31 +11090,30 @@ static bool bnxt_tunl_check(struct bnxt *bp, struct sk_buff *skb, u8 l4_proto) return false; }
-static netdev_features_t bnxt_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void bnxt_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { struct bnxt *bp = netdev_priv(dev); u8 *l4_proto;
- vlan_features_check(skb, &features); + vlan_features_check(skb, features); switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!skb->encapsulation) - return features; + return; l4_proto = &ip_hdr(skb)->protocol; if (bnxt_tunl_check(bp, skb, *l4_proto)) - return features; + return; break; case htons(ETH_P_IPV6): if (!bnxt_exthdr_check(bp, skb, skb_network_offset(skb), &l4_proto)) break; if (!l4_proto || bnxt_tunl_check(bp, skb, *l4_proto)) - return features; + return; break; } - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index e2730b3e1a57..e30ee19d9ba2 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2035,9 +2035,8 @@ static unsigned int macb_tx_map(struct macb *bp, return 0; }
-static netdev_features_t macb_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void macb_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { unsigned int nr_frags, f; unsigned int hdrlen; @@ -2046,7 +2045,7 @@ static netdev_features_t macb_features_check(struct sk_buff *skb,
/* there is only one buffer or protocol is not UDP */ if (!skb_is_nonlinear(skb) || (ip_hdr(skb)->protocol != IPPROTO_UDP)) - return features; + return;
/* length of header */ hdrlen = skb_transport_offset(skb); @@ -2055,8 +2054,10 @@ static netdev_features_t macb_features_check(struct sk_buff *skb, * When software supplies two or more payload buffers all payload buffers * apart from the last must be a multiple of 8 bytes in size. */ - if (!IS_ALIGNED(skb_headlen(skb) - hdrlen, MACB_TX_LEN_ALIGN)) - return features & ~MACB_NETIF_LSO; + if (!IS_ALIGNED(skb_headlen(skb) - hdrlen, MACB_TX_LEN_ALIGN)) { + *features &= ~MACB_NETIF_LSO; + return; + }
nr_frags = skb_shinfo(skb)->nr_frags; /* No need to check last fragment */ @@ -2064,10 +2065,11 @@ static netdev_features_t macb_features_check(struct sk_buff *skb, for (f = 0; f < nr_frags; f++) { const skb_frag_t *frag = &skb_shinfo(skb)->frags[f];
- if (!IS_ALIGNED(skb_frag_size(frag), MACB_TX_LEN_ALIGN)) - return features & ~MACB_NETIF_LSO; + if (!IS_ALIGNED(skb_frag_size(frag), MACB_TX_LEN_ALIGN)) { + *features &= ~MACB_NETIF_LSO; + return; + } } - return features; }
static inline int macb_clear_csum(struct sk_buff *skb) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 0d9cda4ab303..a654169b9dfc 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -3834,22 +3834,21 @@ static const struct udp_tunnel_nic_info cxgb_udp_tunnels = { }, };
-static netdev_features_t cxgb_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void cxgb_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { struct port_info *pi = netdev_priv(dev); struct adapter *adapter = pi->adapter;
if (CHELSIO_CHIP_VERSION(adapter->params.chip) < CHELSIO_T6) - return features; + return;
/* Check if hw supports offload for this packet */ if (!skb->encapsulation || cxgb_encap_offload_supported(skb)) - return features; + return;
/* Offload is not supported for this encapsulated packet */ - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
static netdev_features_t cxgb_fix_features(struct net_device *dev, diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 033b9dee2bb7..a2cc1d5d40cd 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -240,9 +240,8 @@ static const struct udp_tunnel_nic_info enic_udp_tunnels = { }, };
-static netdev_features_t enic_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void enic_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { const struct ethhdr *eth = (struct ethhdr *)skb_inner_mac_header(skb); struct enic *enic = netdev_priv(dev); @@ -251,9 +250,9 @@ static netdev_features_t enic_features_check(struct sk_buff *skb, u8 proto;
if (!skb->encapsulation) - return features; + return;
- vxlan_features_check(skb, &features); + vxlan_features_check(skb, features);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IPV6): @@ -291,10 +290,10 @@ static netdev_features_t enic_features_check(struct sk_buff *skb, if (port != enic->vxlan.vxlan_udp_port_number) goto out;
- return features; + return;
out: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
int enic_is_dynamic(struct enic *enic) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 556242d32d93..27e8a1d95a9a 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -5064,9 +5064,8 @@ static struct be_cmd_work *be_alloc_work(struct be_adapter *adapter, return work; }
-static netdev_features_t be_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void be_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { struct be_adapter *adapter = netdev_priv(dev); u8 l4_hdr = 0; @@ -5076,7 +5075,7 @@ static netdev_features_t be_features_check(struct sk_buff *skb, * to Lancer and BE3 HW. Disable TSO6 feature. */ if (!skyhawk_chip(adapter) && is_ipv6_ext_hdr(skb)) - features &= ~NETIF_F_TSO6; + *features &= ~NETIF_F_TSO6;
/* Lancer cannot handle the packet with MSS less than 256. * Also it can't handle a TSO packet with a single segment @@ -5085,17 +5084,17 @@ static netdev_features_t be_features_check(struct sk_buff *skb, if (lancer_chip(adapter) && (skb_shinfo(skb)->gso_size < 256 || skb_shinfo(skb)->gso_segs == 1)) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK; }
/* The code below restricts offload features for some tunneled and * Q-in-Q packets. * Offload features for normal (non tunnel) packets are unchanged. */ - vlan_features_check(skb, &features); + vlan_features_check(skb, features); if (!skb->encapsulation || !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)) - return features; + return;
/* It's an encapsulated packet and VxLAN offloads are enabled. We * should disable tunnel offload features if it's not a VxLAN packet, @@ -5111,7 +5110,7 @@ static netdev_features_t be_features_check(struct sk_buff *skb, l4_hdr = ipv6_hdr(skb)->nexthdr; break; default: - return features; + return; }
if (l4_hdr != IPPROTO_UDP || @@ -5120,10 +5119,10 @@ static netdev_features_t be_features_check(struct sk_buff *skb, skb_inner_mac_header(skb) - skb_transport_header(skb) != sizeof(struct udphdr) + sizeof(struct vxlanhdr) || !adapter->vxlan_port || - udp_hdr(skb)->dest != adapter->vxlan_port) - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); - - return features; + udp_hdr(skb)->dest != adapter->vxlan_port) { + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; + } }
static int be_get_phys_port_id(struct net_device *dev, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index adc54a726661..e8179ac6d4e3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2353,9 +2353,8 @@ static int hns3_nic_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t hns3_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void hns3_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { #define HNS3_MAX_HDR_LEN 480U #define HNS3_MAX_L4_HDR_LEN 60U @@ -2363,7 +2362,7 @@ static netdev_features_t hns3_features_check(struct sk_buff *skb, size_t len;
if (skb->ip_summed != CHECKSUM_PARTIAL) - return features; + return;
if (skb->encapsulation) len = skb_inner_transport_header(skb) - skb->data; @@ -2379,9 +2378,7 @@ static netdev_features_t hns3_features_check(struct sk_buff *skb, * len of 480 bytes. */ if (len > HNS3_MAX_HDR_LEN) - features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); - - return features; + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
static void hns3_nic_get_stats64(struct net_device *netdev, diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 8f17096e614d..b8ee2e3977b5 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -3003,9 +3003,8 @@ static int ibmvnic_change_mtu(struct net_device *netdev, int new_mtu) return wait_for_reset(adapter); }
-static netdev_features_t ibmvnic_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void ibmvnic_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { /* Some backing hardware adapters can not * handle packets with a MSS less than 224 @@ -3014,10 +3013,8 @@ static netdev_features_t ibmvnic_features_check(struct sk_buff *skb, if (skb_is_gso(skb)) { if (skb_shinfo(skb)->gso_size < 224 || skb_shinfo(skb)->gso_segs == 1) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK; } - - return features; }
static const struct net_device_ops ibmvnic_netdev_ops = { diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c index 2fb52bd6fc0e..a311bcdfbff2 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c @@ -1504,14 +1504,13 @@ static void fm10k_dfwd_del_station(struct net_device *dev, void *priv) } }
-static netdev_features_t fm10k_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void fm10k_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { if (!skb->encapsulation || fm10k_tx_encap_offload(skb)) - return features; + return;
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
static const struct net_device_ops fm10k_netdev_ops = { diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 2f20980dd9a5..5246c6abbd7d 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -12873,9 +12873,8 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, * @dev: This physical port's netdev * @features: Offload features that the stack believes apply **/ -static netdev_features_t i40e_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void i40e_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { size_t len;
@@ -12884,13 +12883,13 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb, * checking for CHECKSUM_PARTIAL */ if (skb->ip_summed != CHECKSUM_PARTIAL) - return features; + return;
/* We cannot support GSO if the MSS is going to be less than * 64 bytes. If it is then we need to drop support for GSO. */ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64)) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK;
/* MACLEN can support at most 63 words */ len = skb_network_header(skb) - skb->data; @@ -12920,9 +12919,9 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb, * by TCP, which is at most 15 dwords */
- return features; + return; out_err: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
/** diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index 23762a7ef740..b066f1864b3f 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -3379,9 +3379,8 @@ static int iavf_set_features(struct net_device *netdev, * @dev: This physical port's netdev * @features: Offload features that the stack believes apply **/ -static netdev_features_t iavf_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void iavf_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { size_t len;
@@ -3390,13 +3389,13 @@ static netdev_features_t iavf_features_check(struct sk_buff *skb, * checking for CHECKSUM_PARTIAL */ if (skb->ip_summed != CHECKSUM_PARTIAL) - return features; + return;
/* We cannot support GSO if the MSS is going to be less than * 64 bytes. If it is then we need to drop support for GSO. */ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64)) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK;
/* MACLEN can support at most 63 words */ len = skb_network_header(skb) - skb->data; @@ -3426,9 +3425,9 @@ static netdev_features_t iavf_features_check(struct sk_buff *skb, * by TCP, which is at most 15 dwords */
- return features; + return; out_err: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
/** diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 0d6c143f6653..edfd1e374681 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7179,10 +7179,9 @@ int ice_stop(struct net_device *netdev) * @netdev: This port's netdev * @features: Offload features that the stack believes apply */ -static netdev_features_t -ice_features_check(struct sk_buff *skb, - struct net_device __always_unused *netdev, - netdev_features_t features) +static void ice_features_check(struct sk_buff *skb, + struct net_device __always_unused *netdev, + netdev_features_t *features) { size_t len;
@@ -7191,13 +7190,13 @@ ice_features_check(struct sk_buff *skb, * checking for CHECKSUM_PARTIAL */ if (skb->ip_summed != CHECKSUM_PARTIAL) - return features; + return;
/* We cannot support GSO if the MSS is going to be less than * 64 bytes. If it is then we need to drop support for GSO. */ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64)) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK;
len = skb_network_header(skb) - skb->data; if (len > ICE_TXD_MACLEN_MAX || len & 0x1) @@ -7218,9 +7217,9 @@ ice_features_check(struct sk_buff *skb, goto out_rm_features; }
- return features; + return; out_rm_features: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
static const struct net_device_ops ice_netdev_safe_mode_ops = { diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 751de06019a0..82b59adf8034 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2505,37 +2505,38 @@ static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], #define IGB_MAX_MAC_HDR_LEN 127 #define IGB_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -igb_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void igb_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data; - if (unlikely(mac_hdr_len > IGB_MAX_MAC_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_GSO_UDP_L4 | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(mac_hdr_len > IGB_MAX_MAC_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_GSO_UDP_L4 | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); - if (unlikely(network_hdr_len > IGB_MAX_NETWORK_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_GSO_UDP_L4 | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(network_hdr_len > IGB_MAX_NETWORK_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_GSO_UDP_L4 | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
/* We can only support IPV4 TSO in tunnels if we can mangle the * inner IP ID field, so strip TSO if MANGLEID is not supported. */ - if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) - features &= ~NETIF_F_TSO; - - return features; + if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID)) + *features &= ~NETIF_F_TSO; }
static void igb_offload_apply(struct igb_adapter *adapter, s32 queue) diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index d32e72d953c8..92a46ac4ee1f 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c @@ -2619,35 +2619,36 @@ static int igbvf_set_features(struct net_device *netdev, #define IGBVF_MAX_MAC_HDR_LEN 127 #define IGBVF_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -igbvf_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void igbvf_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data; - if (unlikely(mac_hdr_len > IGBVF_MAX_MAC_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(mac_hdr_len > IGBVF_MAX_MAC_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); - if (unlikely(network_hdr_len > IGBVF_MAX_NETWORK_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(network_hdr_len > IGBVF_MAX_NETWORK_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
/* We can only support IPV4 TSO in tunnels if we can mangle the * inner IP ID field, so strip TSO if MANGLEID is not supported. */ - if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) - features &= ~NETIF_F_TSO; - - return features; + if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID)) + *features &= ~NETIF_F_TSO; }
static const struct net_device_ops igbvf_netdev_ops = { diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 0e19b4d02e62..fdb3ed051456 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4955,35 +4955,36 @@ static int igc_set_features(struct net_device *netdev, return 1; }
-static netdev_features_t -igc_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void igc_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data; - if (unlikely(mac_hdr_len > IGC_MAX_MAC_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(mac_hdr_len > IGC_MAX_MAC_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); - if (unlikely(network_hdr_len > IGC_MAX_NETWORK_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(network_hdr_len > IGC_MAX_NETWORK_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
/* We can only support IPv4 TSO in tunnels if we can mangle the * inner IP ID field, so strip TSO if MANGLEID is not supported. */ - if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) - features &= ~NETIF_F_TSO; - - return features; + if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID)) + *features &= ~NETIF_F_TSO; }
static void igc_tsync_interrupt(struct igc_adapter *adapter) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 24e06ba6f5e9..e39d3983a455 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -10067,43 +10067,44 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv) #define IXGBE_MAX_MAC_HDR_LEN 127 #define IXGBE_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -ixgbe_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void ixgbe_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data; - if (unlikely(mac_hdr_len > IXGBE_MAX_MAC_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_GSO_UDP_L4 | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(mac_hdr_len > IXGBE_MAX_MAC_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_GSO_UDP_L4 | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); - if (unlikely(network_hdr_len > IXGBE_MAX_NETWORK_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_GSO_UDP_L4 | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(network_hdr_len > IXGBE_MAX_NETWORK_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_GSO_UDP_L4 | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
/* We can only support IPV4 TSO in tunnels if we can mangle the * inner IP ID field, so strip TSO if MANGLEID is not supported. * IPsec offoad sets skb->encapsulation but still can handle * the TSO, so it's the exception. */ - if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) { + if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID)) { #ifdef CONFIG_IXGBE_IPSEC if (!secpath_exists(skb)) #endif - features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO; } - - return features; }
static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index c714e1ecd308..f2f6d00960c5 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -4381,35 +4381,36 @@ static void ixgbevf_get_stats(struct net_device *netdev, #define IXGBEVF_MAX_MAC_HDR_LEN 127 #define IXGBEVF_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -ixgbevf_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void ixgbevf_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data; - if (unlikely(mac_hdr_len > IXGBEVF_MAX_MAC_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(mac_hdr_len > IXGBEVF_MAX_MAC_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); - if (unlikely(network_hdr_len > IXGBEVF_MAX_NETWORK_HDR_LEN)) - return features & ~(NETIF_F_HW_CSUM | - NETIF_F_SCTP_CRC | - NETIF_F_TSO | - NETIF_F_TSO6); + if (unlikely(network_hdr_len > IXGBEVF_MAX_NETWORK_HDR_LEN)) { + *features &= ~(NETIF_F_HW_CSUM | + NETIF_F_SCTP_CRC | + NETIF_F_TSO | + NETIF_F_TSO6); + return; + }
/* We can only support IPV4 TSO in tunnels if we can mangle the * inner IP ID field, so strip TSO if MANGLEID is not supported. */ - if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) - features &= ~NETIF_F_TSO; - - return features; + if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID)) + *features &= ~NETIF_F_TSO; }
static int ixgbevf_xdp_setup(struct net_device *dev, struct bpf_prog *prog) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 941d2d45cd23..bc504dcb1c2b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2660,12 +2660,11 @@ static const struct udp_tunnel_nic_info mlx4_udp_tunnels = { }, };
-static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void mlx4_en_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { - vlan_features_check(skb, &features); - vxlan_features_check(skb, &features); + vlan_features_check(skb, features); + vxlan_features_check(skb, features);
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does * support inner IPv6 checksums and segmentation so we need to @@ -2678,10 +2677,8 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, if (!priv->vxlan_port || (ip_hdr(skb)->version != 4) || (udp_hdr(skb)->dest != priv->vxlan_port)) - features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); } - - return features; }
static int mlx4_en_set_tx_maxrate(struct net_device *dev, int queue_index, u32 maxrate) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 7b8c8187543a..9174b7b187fb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -1130,9 +1130,8 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16 void mlx5e_rx_dim_work(struct work_struct *work); void mlx5e_tx_dim_work(struct work_struct *work);
-netdev_features_t mlx5e_features_check(struct sk_buff *skb, - struct net_device *netdev, - netdev_features_t features); +void mlx5e_features_check(struct sk_buff *skb, struct net_device *netdev, + netdev_features_t *features); int mlx5e_set_features(struct net_device *netdev, netdev_features_t features); #ifdef CONFIG_MLX5_ESWITCH int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 4518a490cdcd..6fdc2a793c1f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3904,21 +3904,18 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
-netdev_features_t mlx5e_features_check(struct sk_buff *skb, - struct net_device *netdev, - netdev_features_t features) +void mlx5e_features_check(struct sk_buff *skb, struct net_device *netdev, + netdev_features_t *features) { struct mlx5e_priv *priv = netdev_priv(netdev);
- vlan_features_check(skb, &features); - vxlan_features_check(skb, &features); + vlan_features_check(skb, features); + vxlan_features_check(skb, features);
/* Validate if the tunneled packet is being offloaded by HW */ if (skb->encapsulation && - (features & NETIF_F_CSUM_MASK || features & NETIF_F_GSO_MASK)) - return mlx5e_tunnel_features_check(priv, skb, features); - - return features; + (*features & NETIF_F_CSUM_MASK || *features & NETIF_F_GSO_MASK)) + *features = mlx5e_tunnel_features_check(priv, skb, *features); }
static void mlx5e_tx_timeout_work(struct work_struct *work) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 58e7d98d0dd6..6261596cfda6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3598,17 +3598,16 @@ static int nfp_net_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t -nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { u8 l4_hdr;
/* We can't do TSO over double tagged packets (802.1AD) */ - vlan_features_check(skb, &features); + vlan_features_check(skb, features);
if (!skb->encapsulation) - return features; + return;
/* Ensure that inner L4 header offset fits into TX descriptor field */ if (skb_is_gso(skb)) { @@ -3621,7 +3620,7 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, * metadata prepend - 8B */ if (unlikely(hdrlen > NFP_NET_LSO_MAX_HDR_SZ - 8)) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK; }
/* VXLAN/GRE check */ @@ -3633,7 +3632,8 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, l4_hdr = ipv6_hdr(skb)->nexthdr; break; default: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; }
if (skb->inner_protocol_type != ENCAP_TYPE_ETHER || @@ -3641,10 +3641,10 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, (l4_hdr != IPPROTO_UDP && l4_hdr != IPPROTO_GRE) || (l4_hdr == IPPROTO_UDP && (skb_inner_mac_header(skb) - skb_transport_header(skb) != - sizeof(struct udphdr) + sizeof(struct vxlanhdr)))) - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); - - return features; + sizeof(struct udphdr) + sizeof(struct vxlanhdr)))) { + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; + } }
static int diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h index f90dcfe9ee68..c1f26a2e374d 100644 --- a/drivers/net/ethernet/qlogic/qede/qede.h +++ b/drivers/net/ethernet/qlogic/qede/qede.h @@ -527,9 +527,8 @@ int qede_xdp_transmit(struct net_device *dev, int n_frames, struct xdp_frame **frames, u32 flags); u16 qede_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev); -netdev_features_t qede_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features); +void qede_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features); int qede_alloc_rx_buffer(struct qede_rx_queue *rxq, bool allow_lazy); int qede_free_tx_pkt(struct qede_dev *edev, struct qede_tx_queue *txq, int *len); diff --git a/drivers/net/ethernet/qlogic/qede/qede_fp.c b/drivers/net/ethernet/qlogic/qede/qede_fp.c index 065e9004598e..8a459d2ca983 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_fp.c +++ b/drivers/net/ethernet/qlogic/qede/qede_fp.c @@ -1747,9 +1747,8 @@ u16 qede_select_queue(struct net_device *dev, struct sk_buff *skb, /* 8B udp header + 8B base tunnel header + 32B option length */ #define QEDE_MAX_TUN_HDR_LEN 48
-netdev_features_t qede_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +void qede_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { if (skb->encapsulation) { u8 l4_proto = 0; @@ -1762,7 +1761,7 @@ netdev_features_t qede_features_check(struct sk_buff *skb, l4_proto = ipv6_hdr(skb)->nexthdr; break; default: - return features; + return; }
/* Disable offloads for geneve tunnels, as HW can't parse @@ -1780,16 +1779,17 @@ netdev_features_t qede_features_check(struct sk_buff *skb, if ((skb_inner_mac_header(skb) - skb_transport_header(skb)) > hdrlen || (ntohs(udp_hdr(skb)->dest) != vxln_port && - ntohs(udp_hdr(skb)->dest) != gnv_port)) - return features & ~(NETIF_F_CSUM_MASK | - NETIF_F_GSO_MASK); + ntohs(udp_hdr(skb)->dest) != gnv_port)) { + *features &= ~(NETIF_F_CSUM_MASK | + NETIF_F_GSO_MASK); + return; + } } else if (l4_proto == IPPROTO_IPIP) { /* IPIP tunnels are unknown to the device or at least unsupported natively, * offloads for them can't be done trivially, so disable them for such skb. */ - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; } } - - return features; } diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index d823f2a22472..192d74665c20 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -492,13 +492,11 @@ static const struct udp_tunnel_nic_info qlcnic_udp_tunnels = { }, };
-static netdev_features_t qlcnic_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void qlcnic_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { - vlan_features_check(skb, &features); - vxlan_features_check(skb, &features); - return features; + vlan_features_check(skb, features); + vxlan_features_check(skb, features); }
static const struct net_device_ops qlcnic_netdev_ops = { diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index d2135fe99cd7..663a12598cad 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c @@ -1853,15 +1853,13 @@ static void cp_set_d3_state (struct cp_private *cp) pci_set_power_state (cp->pdev, PCI_D3hot); }
-static netdev_features_t cp_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void cp_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { if (skb_shinfo(skb)->gso_size > MSSMask) - features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO;
- vlan_features_check(skb, &features); - return features; + vlan_features_check(skb, features); } static const struct net_device_ops cp_netdev_ops = { .ndo_open = cp_open, diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 98e7ffa6aa0a..3d753ddd1a89 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4347,35 +4347,33 @@ static netdev_features_t rtl8168evl_fix_tso(struct sk_buff *skb, return features; }
-static netdev_features_t rtl8169_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void rtl8169_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { int transport_offset = skb_transport_offset(skb); struct rtl8169_private *tp = netdev_priv(dev);
if (skb_is_gso(skb)) { if (tp->mac_version == RTL_GIGA_MAC_VER_34) - features = rtl8168evl_fix_tso(skb, features); + *features = rtl8168evl_fix_tso(skb, *features);
if (transport_offset > GTTCPHO_MAX && rtl_chip_supports_csum_v2(tp)) - features &= ~NETIF_F_ALL_TSO; + *features &= ~NETIF_F_ALL_TSO; } else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* work around hw bug on some chip versions */ if (skb->len < ETH_ZLEN) - features &= ~NETIF_F_CSUM_MASK; + *features &= ~NETIF_F_CSUM_MASK;
if (rtl_quirk_packet_padto(tp, skb)) - features &= ~NETIF_F_CSUM_MASK; + *features &= ~NETIF_F_CSUM_MASK;
if (transport_offset > TCPHO_MAX && rtl_chip_supports_csum_v2(tp)) - features &= ~NETIF_F_CSUM_MASK; + *features &= ~NETIF_F_CSUM_MASK; }
- vlan_features_check(skb, &features); - return features; + vlan_features_check(skb, features); }
static void rtl8169_pcierr_interrupt(struct net_device *dev) diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index 896b59253197..a101fa50a5cc 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -1353,25 +1353,24 @@ static bool efx_can_encap_offloads(struct efx_nic *efx, struct sk_buff *skb) } }
-netdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +void efx_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { struct efx_nic *efx = netdev_priv(dev);
if (skb->encapsulation) { - if (features & NETIF_F_GSO_MASK) + if (*features & NETIF_F_GSO_MASK) /* Hardware can only do TSO with at most 208 bytes * of headers. */ if (skb_inner_transport_offset(skb) > EFX_TSO2_MAX_HDRLEN) - features &= ~(NETIF_F_GSO_MASK); - if (features & (NETIF_F_GSO_MASK | NETIF_F_CSUM_MASK)) + *features &= ~(NETIF_F_GSO_MASK); + if (*features & (NETIF_F_GSO_MASK | NETIF_F_CSUM_MASK)) if (!efx_can_encap_offloads(efx, skb)) - features &= ~(NETIF_F_GSO_MASK | + *features &= ~(NETIF_F_GSO_MASK | NETIF_F_CSUM_MASK); } - return features; }
int efx_get_phys_port_id(struct net_device *net_dev, diff --git a/drivers/net/ethernet/sfc/efx_common.h b/drivers/net/ethernet/sfc/efx_common.h index 65513fd0cf6c..c4fea3997704 100644 --- a/drivers/net/ethernet/sfc/efx_common.h +++ b/drivers/net/ethernet/sfc/efx_common.h @@ -105,8 +105,8 @@ int efx_change_mtu(struct net_device *net_dev, int new_mtu);
extern const struct pci_error_handlers efx_err_handlers;
-netdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features); +void efx_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features);
int efx_get_phys_port_id(struct net_device *net_dev, struct netdev_phys_item_id *ppid); diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 9bfee75cbaf1..7a60cc0f6aad 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3976,17 +3976,15 @@ static void lan78xx_tx_timeout(struct net_device *net, unsigned int txqueue) tasklet_schedule(&dev->bh); }
-static netdev_features_t lan78xx_features_check(struct sk_buff *skb, - struct net_device *netdev, - netdev_features_t features) +static void lan78xx_features_check(struct sk_buff *skb, + struct net_device *netdev, + netdev_features_t *features) { if (skb->len + TX_OVERHEAD > MAX_SINGLE_PACKET_SIZE) - features &= ~NETIF_F_GSO_MASK; + *features &= ~NETIF_F_GSO_MASK;
- vlan_features_check(skb, &features); - vxlan_features_check(skb, &features); - - return features; + vlan_features_check(skb, features); + vxlan_features_check(skb, features); }
static const struct net_device_ops lan78xx_netdev_ops = { diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 60ba9b734055..5bb327b8d8e0 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -2741,20 +2741,17 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev) netif_wake_queue(netdev); }
-static netdev_features_t -rtl8152_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) +static void rtl8152_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { u32 mss = skb_shinfo(skb)->gso_size; int max_offset = mss ? GTTCPHO_MAX : TCPHO_MAX; int offset = skb_transport_offset(skb);
if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) && offset > max_offset) - features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); else if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz) - features &= ~NETIF_F_GSO_MASK; - - return features; + *features &= ~NETIF_F_GSO_MASK; }
static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index 5dd8360b21a0..e840547cd19e 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -256,9 +256,8 @@ netdev_features_t vmxnet3_fix_features(struct net_device *netdev, return features; }
-netdev_features_t vmxnet3_features_check(struct sk_buff *skb, - struct net_device *netdev, - netdev_features_t features) +void vmxnet3_features_check(struct sk_buff *skb, struct net_device *netdev, + netdev_features_t *features) { struct vmxnet3_adapter *adapter = netdev_priv(netdev);
@@ -277,7 +276,8 @@ netdev_features_t vmxnet3_features_check(struct sk_buff *skb, l4_proto = ipv6_hdr(skb)->nexthdr; break; default: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; }
switch (l4_proto) { @@ -288,14 +288,15 @@ netdev_features_t vmxnet3_features_check(struct sk_buff *skb, if (port != GENEVE_UDP_PORT && port != IANA_VXLAN_UDP_PORT && port != VXLAN_UDP_PORT) { - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; } break; default: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + return; } } - return features; }
static void vmxnet3_enable_encap_offloads(struct net_device *netdev) diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 7027ff483fa5..a711759ebb00 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -478,9 +478,9 @@ vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); netdev_features_t vmxnet3_fix_features(struct net_device *netdev, netdev_features_t features);
-netdev_features_t +void vmxnet3_features_check(struct sk_buff *skb, - struct net_device *netdev, netdev_features_t features); + struct net_device *netdev, netdev_features_t *features);
int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features); diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 535a60b3946d..06d02e2e2b66 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -1095,9 +1095,8 @@ int qeth_setassparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long); int qeth_set_features(struct net_device *, netdev_features_t); void qeth_enable_hw_features(struct net_device *dev); netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t); -netdev_features_t qeth_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features); +void qeth_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features); void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); int qeth_set_real_num_tx_queues(struct qeth_card *card, unsigned int count); u16 qeth_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index bf72dd88297a..6811af22ee2b 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -6950,9 +6950,8 @@ netdev_features_t qeth_fix_features(struct net_device *dev, } EXPORT_SYMBOL_GPL(qeth_fix_features);
-netdev_features_t qeth_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +void qeth_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { struct qeth_card *card = dev->ml_priv;
@@ -6961,7 +6960,7 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, READ_ONCE(card->options.isolation) != ISOLATION_MODE_FWD) { netdev_features_t restricted = 0;
- if (skb_is_gso(skb) && !netif_needs_gso(skb, features)) + if (skb_is_gso(skb) && !netif_needs_gso(skb, *features)) restricted |= NETIF_F_ALL_TSO;
switch (vlan_get_protocol(skb)) { @@ -6970,14 +6969,14 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, restricted |= NETIF_F_IP_CSUM;
if (restricted && qeth_next_hop_is_local_v4(card, skb)) - features &= ~restricted; + *features &= ~restricted; break; case htons(ETH_P_IPV6): if (!card->info.has_lp2lp_cso_v6) restricted |= NETIF_F_IPV6_CSUM;
if (restricted && qeth_next_hop_is_local_v6(card, skb)) - features &= ~restricted; + *features &= ~restricted; break; default: break; @@ -6991,7 +6990,7 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, * additional buffer element. This reduces buffer utilization, and * hurts throughput. So compress small segments into one element. */ - if (netif_needs_gso(skb, features)) { + if (netif_needs_gso(skb, *features)) { /* match skb_segment(): */ unsigned int doffset = skb->data - skb_mac_header(skb); unsigned int hsize = skb_shinfo(skb)->gso_size; @@ -6999,11 +6998,10 @@ netdev_features_t qeth_features_check(struct sk_buff *skb,
/* linearize only if resulting skb allocations are order-0: */ if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0)) - features &= ~NETIF_F_SG; + *features &= ~NETIF_F_SG; }
- vlan_features_check(skb, &features); - return features; + vlan_features_check(skb, features); } EXPORT_SYMBOL_GPL(qeth_features_check);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 3a523e700a5a..76c37eedf614 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1804,13 +1804,13 @@ qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np) return 0; }
-static netdev_features_t qeth_l3_osa_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +static void qeth_l3_osa_features_check(struct sk_buff *skb, + struct net_device *dev, + netdev_features_t *features) { if (vlan_get_protocol(skb) != htons(ETH_P_IP)) - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - return qeth_features_check(skb, dev, features); + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; + qeth_features_check(skb, dev, features); }
static u16 qeth_l3_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a5598d617789..09233e7df8f1 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1352,9 +1352,9 @@ struct net_device_ops { int (*ndo_stop)(struct net_device *dev); netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb, struct net_device *dev); - netdev_features_t (*ndo_features_check)(struct sk_buff *skb, + void (*ndo_features_check)(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features); + netdev_features_t *features); u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev); @@ -5056,9 +5056,8 @@ void netdev_change_features(struct net_device *dev); void netif_stacked_transfer_operstate(const struct net_device *rootdev, struct net_device *dev);
-netdev_features_t passthru_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features); +void passthru_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features); netdev_features_t netif_skb_features(struct sk_buff *skb);
static inline bool net_gso_ok(netdev_features_t features, int gso_type) diff --git a/net/core/dev.c b/net/core/dev.c index 4aab7b83fcb8..993249e22e9f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3472,11 +3472,9 @@ static void harmonize_features(struct sk_buff *skb, netdev_features_t *features) *features &= ~NETIF_F_SG; }
-netdev_features_t passthru_features_check(struct sk_buff *skb, - struct net_device *dev, - netdev_features_t features) +void passthru_features_check(struct sk_buff *skb, struct net_device *dev, + netdev_features_t *features) { - return features; } EXPORT_SYMBOL(passthru_features_check);
@@ -3547,8 +3545,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check) - features &= dev->netdev_ops->ndo_features_check(skb, dev, - features); + dev->netdev_ops->ndo_features_check(skb, dev, &features); else dflt_features_check(skb, dev, &features);
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of ndo_features_check for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 11 ++--- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 12 +++--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++--- drivers/net/ethernet/cadence/macb_main.c | 20 +++++---- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 +++-- drivers/net/ethernet/cisco/enic/enic_main.c | 13 +++--- drivers/net/ethernet/emulex/benet/be_main.c | 23 +++++------ .../net/ethernet/hisilicon/hns3/hns3_enet.c | 11 ++--- drivers/net/ethernet/ibm/ibmvnic.c | 9 ++-- .../net/ethernet/intel/fm10k/fm10k_netdev.c | 9 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++--- drivers/net/ethernet/intel/iavf/iavf_main.c | 13 +++--- drivers/net/ethernet/intel/ice/ice_main.c | 15 ++++--- drivers/net/ethernet/intel/igb/igb_main.c | 41 ++++++++++--------- drivers/net/ethernet/intel/igbvf/netdev.c | 37 +++++++++-------- drivers/net/ethernet/intel/igc/igc_main.c | 37 +++++++++-------- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 41 ++++++++++--------- .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 37 +++++++++-------- .../net/ethernet/mellanox/mlx4/en_netdev.c | 13 +++--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 15 +++---- .../ethernet/netronome/nfp/nfp_net_common.c | 22 +++++----- drivers/net/ethernet/qlogic/qede/qede.h | 5 +-- drivers/net/ethernet/qlogic/qede/qede_fp.c | 20 ++++----- .../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 10 ++--- drivers/net/ethernet/realtek/8139cp.c | 10 ++--- drivers/net/ethernet/realtek/r8169_main.c | 18 ++++---- drivers/net/ethernet/sfc/efx_common.c | 13 +++--- drivers/net/ethernet/sfc/efx_common.h | 4 +- drivers/net/usb/lan78xx.c | 14 +++---- drivers/net/usb/r8152.c | 11 ++--- drivers/net/vmxnet3/vmxnet3_ethtool.c | 15 +++---- drivers/net/vmxnet3/vmxnet3_int.h | 4 +- drivers/s390/net/qeth_core.h | 5 +-- drivers/s390/net/qeth_core_main.c | 18 ++++---- drivers/s390/net/qeth_l3_main.c | 10 ++--- include/linux/netdevice.h | 9 ++-- net/core/dev.c | 9 ++-- 38 files changed, 280 insertions(+), 318 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index 29bca9fabcde..cc1f1a7a46ae 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2267,14 +2267,11 @@ static int xgbe_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t xgbe_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features)
+static void xgbe_features_check(struct sk_buff *skb, struct net_device *netdev,
netdev_features_t *features)
{
- vlan_features_check(skb, &features);
- vxlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
- vxlan_features_check(skb, features);
}
static const struct net_device_ops xgbe_netdev_ops = { diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index f444515452a5..1f817dfa5b64 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12834,9 +12834,8 @@ static int bnx2x_get_phys_port_id(struct net_device *netdev, return 0; }
-static netdev_features_t bnx2x_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void bnx2x_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ /* * A skb with gso_size + header length > 9700 will cause a @@ -12854,11 +12853,10 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb, if (unlikely(skb_is_gso(skb) && (skb_shinfo(skb)->gso_size > 9000) && !skb_gso_validate_mac_len(skb, 9700)))
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
- vlan_features_check(skb, &features);
- vxlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
- vxlan_features_check(skb, features);
}
static int __bnx2x_vlan_configure_vid(struct bnx2x *bp, u16 vid, bool add) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c8ee75ecf494..b43b96cfaebc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11090,31 +11090,30 @@ static bool bnxt_tunl_check(struct bnxt *bp, struct sk_buff *skb, u8 l4_proto) return false; }
-static netdev_features_t bnxt_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void bnxt_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ struct bnxt *bp = netdev_priv(dev); u8 *l4_proto;
- vlan_features_check(skb, &features);
- vlan_features_check(skb, features); switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!skb->encapsulation)
return features;
l4_proto = &ip_hdr(skb)->protocol; if (bnxt_tunl_check(bp, skb, *l4_proto))return;
return features;
break; case htons(ETH_P_IPV6): if (!bnxt_exthdr_check(bp, skb, skb_network_offset(skb), &l4_proto)) break; if (!l4_proto || bnxt_tunl_check(bp, skb, *l4_proto))return;
return features;
break; }return;
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index e2730b3e1a57..e30ee19d9ba2 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2035,9 +2035,8 @@ static unsigned int macb_tx_map(struct macb *bp, return 0; }
-static netdev_features_t macb_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void macb_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ unsigned int nr_frags, f; unsigned int hdrlen; @@ -2046,7 +2045,7 @@ static netdev_features_t macb_features_check(struct sk_buff *skb,
/* there is only one buffer or protocol is not UDP */ if (!skb_is_nonlinear(skb) || (ip_hdr(skb)->protocol != IPPROTO_UDP))
return features;
return;
/* length of header */ hdrlen = skb_transport_offset(skb);
@@ -2055,8 +2054,10 @@ static netdev_features_t macb_features_check(struct sk_buff *skb, * When software supplies two or more payload buffers all payload buffers * apart from the last must be a multiple of 8 bytes in size. */
- if (!IS_ALIGNED(skb_headlen(skb) - hdrlen, MACB_TX_LEN_ALIGN))
return features & ~MACB_NETIF_LSO;
if (!IS_ALIGNED(skb_headlen(skb) - hdrlen, MACB_TX_LEN_ALIGN)) {
*features &= ~MACB_NETIF_LSO;
return;
}
nr_frags = skb_shinfo(skb)->nr_frags; /* No need to check last fragment */
@@ -2064,10 +2065,11 @@ static netdev_features_t macb_features_check(struct sk_buff *skb, for (f = 0; f < nr_frags; f++) { const skb_frag_t *frag = &skb_shinfo(skb)->frags[f];
if (!IS_ALIGNED(skb_frag_size(frag), MACB_TX_LEN_ALIGN))
return features & ~MACB_NETIF_LSO;
if (!IS_ALIGNED(skb_frag_size(frag), MACB_TX_LEN_ALIGN)) {
*features &= ~MACB_NETIF_LSO;
return;
}}
- return features;
}
static inline int macb_clear_csum(struct sk_buff *skb) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 0d9cda4ab303..a654169b9dfc 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -3834,22 +3834,21 @@ static const struct udp_tunnel_nic_info cxgb_udp_tunnels = { }, };
-static netdev_features_t cxgb_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void cxgb_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ struct port_info *pi = netdev_priv(dev); struct adapter *adapter = pi->adapter;
if (CHELSIO_CHIP_VERSION(adapter->params.chip) < CHELSIO_T6)
return features;
return;
/* Check if hw supports offload for this packet */ if (!skb->encapsulation || cxgb_encap_offload_supported(skb))
return features;
return;
/* Offload is not supported for this encapsulated packet */
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
static netdev_features_t cxgb_fix_features(struct net_device *dev, diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 033b9dee2bb7..a2cc1d5d40cd 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -240,9 +240,8 @@ static const struct udp_tunnel_nic_info enic_udp_tunnels = { }, };
-static netdev_features_t enic_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void enic_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ const struct ethhdr *eth = (struct ethhdr *)skb_inner_mac_header(skb); struct enic *enic = netdev_priv(dev); @@ -251,9 +250,9 @@ static netdev_features_t enic_features_check(struct sk_buff *skb, u8 proto;
if (!skb->encapsulation)
return features;
return;
- vxlan_features_check(skb, &features);
vxlan_features_check(skb, features);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IPV6):
@@ -291,10 +290,10 @@ static netdev_features_t enic_features_check(struct sk_buff *skb, if (port != enic->vxlan.vxlan_udp_port_number) goto out;
- return features;
- return;
out:
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
int enic_is_dynamic(struct enic *enic) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 556242d32d93..27e8a1d95a9a 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -5064,9 +5064,8 @@ static struct be_cmd_work *be_alloc_work(struct be_adapter *adapter, return work; }
-static netdev_features_t be_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void be_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ struct be_adapter *adapter = netdev_priv(dev); u8 l4_hdr = 0; @@ -5076,7 +5075,7 @@ static netdev_features_t be_features_check(struct sk_buff *skb, * to Lancer and BE3 HW. Disable TSO6 feature. */ if (!skyhawk_chip(adapter) && is_ipv6_ext_hdr(skb))
features &= ~NETIF_F_TSO6;
*features &= ~NETIF_F_TSO6;
/* Lancer cannot handle the packet with MSS less than 256.
- Also it can't handle a TSO packet with a single segment
@@ -5085,17 +5084,17 @@ static netdev_features_t be_features_check(struct sk_buff *skb, if (lancer_chip(adapter) && (skb_shinfo(skb)->gso_size < 256 || skb_shinfo(skb)->gso_segs == 1))
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
}
/* The code below restricts offload features for some tunneled and
- Q-in-Q packets.
- Offload features for normal (non tunnel) packets are unchanged.
*/
- vlan_features_check(skb, &features);
- vlan_features_check(skb, features); if (!skb->encapsulation || !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS))
return features;
return;
/* It's an encapsulated packet and VxLAN offloads are enabled. We
- should disable tunnel offload features if it's not a VxLAN packet,
@@ -5111,7 +5110,7 @@ static netdev_features_t be_features_check(struct sk_buff *skb, l4_hdr = ipv6_hdr(skb)->nexthdr; break; default:
return features;
return;
}
if (l4_hdr != IPPROTO_UDP ||
@@ -5120,10 +5119,10 @@ static netdev_features_t be_features_check(struct sk_buff *skb, skb_inner_mac_header(skb) - skb_transport_header(skb) != sizeof(struct udphdr) + sizeof(struct vxlanhdr) || !adapter->vxlan_port ||
udp_hdr(skb)->dest != adapter->vxlan_port)
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- return features;
udp_hdr(skb)->dest != adapter->vxlan_port) {
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
return;
- }
}
static int be_get_phys_port_id(struct net_device *dev, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index adc54a726661..e8179ac6d4e3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2353,9 +2353,8 @@ static int hns3_nic_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t hns3_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void hns3_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ #define HNS3_MAX_HDR_LEN 480U #define HNS3_MAX_L4_HDR_LEN 60U @@ -2363,7 +2362,7 @@ static netdev_features_t hns3_features_check(struct sk_buff *skb, size_t len;
if (skb->ip_summed != CHECKSUM_PARTIAL)
return features;
return;
if (skb->encapsulation) len = skb_inner_transport_header(skb) - skb->data;
@@ -2379,9 +2378,7 @@ static netdev_features_t hns3_features_check(struct sk_buff *skb, * len of 480 bytes. */ if (len > HNS3_MAX_HDR_LEN)
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- return features;
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
static void hns3_nic_get_stats64(struct net_device *netdev, diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 8f17096e614d..b8ee2e3977b5 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -3003,9 +3003,8 @@ static int ibmvnic_change_mtu(struct net_device *netdev, int new_mtu) return wait_for_reset(adapter); }
-static netdev_features_t ibmvnic_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void ibmvnic_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ /* Some backing hardware adapters can not * handle packets with a MSS less than 224 @@ -3014,10 +3013,8 @@ static netdev_features_t ibmvnic_features_check(struct sk_buff *skb, if (skb_is_gso(skb)) { if (skb_shinfo(skb)->gso_size < 224 || skb_shinfo(skb)->gso_segs == 1)
features &= ~NETIF_F_GSO_MASK;
}*features &= ~NETIF_F_GSO_MASK;
- return features;
}
static const struct net_device_ops ibmvnic_netdev_ops = { diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c index 2fb52bd6fc0e..a311bcdfbff2 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c @@ -1504,14 +1504,13 @@ static void fm10k_dfwd_del_station(struct net_device *dev, void *priv) } }
-static netdev_features_t fm10k_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void fm10k_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ if (!skb->encapsulation || fm10k_tx_encap_offload(skb))
return features;
return;
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
static const struct net_device_ops fm10k_netdev_ops = { diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 2f20980dd9a5..5246c6abbd7d 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -12873,9 +12873,8 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
- @dev: This physical port's netdev
- @features: Offload features that the stack believes apply
**/ -static netdev_features_t i40e_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void i40e_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ size_t len;
@@ -12884,13 +12883,13 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb, * checking for CHECKSUM_PARTIAL */ if (skb->ip_summed != CHECKSUM_PARTIAL)
return features;
return;
/* We cannot support GSO if the MSS is going to be less than
- 64 bytes. If it is then we need to drop support for GSO.
*/ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64))
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
/* MACLEN can support at most 63 words */ len = skb_network_header(skb) - skb->data;
@@ -12920,9 +12919,9 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb, * by TCP, which is at most 15 dwords */
- return features;
- return;
out_err:
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
/** diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index 23762a7ef740..b066f1864b3f 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -3379,9 +3379,8 @@ static int iavf_set_features(struct net_device *netdev,
- @dev: This physical port's netdev
- @features: Offload features that the stack believes apply
**/ -static netdev_features_t iavf_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void iavf_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ size_t len;
@@ -3390,13 +3389,13 @@ static netdev_features_t iavf_features_check(struct sk_buff *skb, * checking for CHECKSUM_PARTIAL */ if (skb->ip_summed != CHECKSUM_PARTIAL)
return features;
return;
/* We cannot support GSO if the MSS is going to be less than
- 64 bytes. If it is then we need to drop support for GSO.
*/ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64))
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
/* MACLEN can support at most 63 words */ len = skb_network_header(skb) - skb->data;
@@ -3426,9 +3425,9 @@ static netdev_features_t iavf_features_check(struct sk_buff *skb, * by TCP, which is at most 15 dwords */
- return features;
- return;
out_err:
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
/** diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 0d6c143f6653..edfd1e374681 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7179,10 +7179,9 @@ int ice_stop(struct net_device *netdev)
- @netdev: This port's netdev
- @features: Offload features that the stack believes apply
*/ -static netdev_features_t -ice_features_check(struct sk_buff *skb,
struct net_device __always_unused *netdev,
netdev_features_t features)
+static void ice_features_check(struct sk_buff *skb,
struct net_device __always_unused *netdev,
netdev_features_t *features)
{ size_t len;
@@ -7191,13 +7190,13 @@ ice_features_check(struct sk_buff *skb, * checking for CHECKSUM_PARTIAL */ if (skb->ip_summed != CHECKSUM_PARTIAL)
return features;
return;
/* We cannot support GSO if the MSS is going to be less than
- 64 bytes. If it is then we need to drop support for GSO.
*/ if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_size < 64))
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
len = skb_network_header(skb) - skb->data; if (len > ICE_TXD_MACLEN_MAX || len & 0x1)
@@ -7218,9 +7217,9 @@ ice_features_check(struct sk_buff *skb, goto out_rm_features; }
- return features;
- return;
out_rm_features:
- return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}
static const struct net_device_ops ice_netdev_safe_mode_ops = { diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 751de06019a0..82b59adf8034 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2505,37 +2505,38 @@ static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], #define IGB_MAX_MAC_HDR_LEN 127 #define IGB_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -igb_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void igb_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data;
- if (unlikely(mac_hdr_len > IGB_MAX_MAC_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(mac_hdr_len > IGB_MAX_MAC_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb);
- if (unlikely(network_hdr_len > IGB_MAX_NETWORK_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(network_hdr_len > IGB_MAX_NETWORK_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
/* We can only support IPV4 TSO in tunnels if we can mangle the
- inner IP ID field, so strip TSO if MANGLEID is not supported.
*/
- if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID))
features &= ~NETIF_F_TSO;
- return features;
- if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID))
*features &= ~NETIF_F_TSO;
}
static void igb_offload_apply(struct igb_adapter *adapter, s32 queue) diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index d32e72d953c8..92a46ac4ee1f 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c @@ -2619,35 +2619,36 @@ static int igbvf_set_features(struct net_device *netdev, #define IGBVF_MAX_MAC_HDR_LEN 127 #define IGBVF_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -igbvf_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void igbvf_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data;
- if (unlikely(mac_hdr_len > IGBVF_MAX_MAC_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(mac_hdr_len > IGBVF_MAX_MAC_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb);
- if (unlikely(network_hdr_len > IGBVF_MAX_NETWORK_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(network_hdr_len > IGBVF_MAX_NETWORK_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
/* We can only support IPV4 TSO in tunnels if we can mangle the
- inner IP ID field, so strip TSO if MANGLEID is not supported.
*/
- if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID))
features &= ~NETIF_F_TSO;
- return features;
- if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID))
*features &= ~NETIF_F_TSO;
}
static const struct net_device_ops igbvf_netdev_ops = { diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 0e19b4d02e62..fdb3ed051456 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4955,35 +4955,36 @@ static int igc_set_features(struct net_device *netdev, return 1; }
-static netdev_features_t -igc_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void igc_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data;
- if (unlikely(mac_hdr_len > IGC_MAX_MAC_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(mac_hdr_len > IGC_MAX_MAC_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb);
- if (unlikely(network_hdr_len > IGC_MAX_NETWORK_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(network_hdr_len > IGC_MAX_NETWORK_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
/* We can only support IPv4 TSO in tunnels if we can mangle the
- inner IP ID field, so strip TSO if MANGLEID is not supported.
*/
- if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID))
features &= ~NETIF_F_TSO;
- return features;
- if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID))
*features &= ~NETIF_F_TSO;
}
static void igc_tsync_interrupt(struct igc_adapter *adapter) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 24e06ba6f5e9..e39d3983a455 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -10067,43 +10067,44 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv) #define IXGBE_MAX_MAC_HDR_LEN 127 #define IXGBE_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data;
- if (unlikely(mac_hdr_len > IXGBE_MAX_MAC_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(mac_hdr_len > IXGBE_MAX_MAC_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb);
- if (unlikely(network_hdr_len > IXGBE_MAX_NETWORK_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(network_hdr_len > IXGBE_MAX_NETWORK_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_GSO_UDP_L4 |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
/* We can only support IPV4 TSO in tunnels if we can mangle the
- inner IP ID field, so strip TSO if MANGLEID is not supported.
- IPsec offoad sets skb->encapsulation but still can handle
- the TSO, so it's the exception.
*/
- if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) {
- if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID)) {
#ifdef CONFIG_IXGBE_IPSEC if (!secpath_exists(skb)) #endif
features &= ~NETIF_F_TSO;
}*features &= ~NETIF_F_TSO;
- return features;
}
static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index c714e1ecd308..f2f6d00960c5 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -4381,35 +4381,36 @@ static void ixgbevf_get_stats(struct net_device *netdev, #define IXGBEVF_MAX_MAC_HDR_LEN 127 #define IXGBEVF_MAX_NETWORK_HDR_LEN 511
-static netdev_features_t -ixgbevf_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void ixgbevf_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ unsigned int network_hdr_len, mac_hdr_len;
/* Make certain the headers can be described by a context descriptor */ mac_hdr_len = skb_network_header(skb) - skb->data;
- if (unlikely(mac_hdr_len > IXGBEVF_MAX_MAC_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(mac_hdr_len > IXGBEVF_MAX_MAC_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb);
- if (unlikely(network_hdr_len > IXGBEVF_MAX_NETWORK_HDR_LEN))
return features & ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_TSO |
NETIF_F_TSO6);
if (unlikely(network_hdr_len > IXGBEVF_MAX_NETWORK_HDR_LEN)) {
*features &= ~(NETIF_F_HW_CSUM |
NETIF_F_SCTP_CRC |
NETIF_F_TSO |
NETIF_F_TSO6);
return;
}
/* We can only support IPV4 TSO in tunnels if we can mangle the
- inner IP ID field, so strip TSO if MANGLEID is not supported.
*/
- if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID))
features &= ~NETIF_F_TSO;
- return features;
- if (skb->encapsulation && !(*features & NETIF_F_TSO_MANGLEID))
*features &= ~NETIF_F_TSO;
}
static int ixgbevf_xdp_setup(struct net_device *dev, struct bpf_prog *prog) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 941d2d45cd23..bc504dcb1c2b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2660,12 +2660,11 @@ static const struct udp_tunnel_nic_info mlx4_udp_tunnels = { }, };
-static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void mlx4_en_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{
- vlan_features_check(skb, &features);
- vxlan_features_check(skb, &features);
vlan_features_check(skb, features);
vxlan_features_check(skb, features);
/* The ConnectX-3 doesn't support outer IPv6 checksums but it does
- support inner IPv6 checksums and segmentation so we need to
@@ -2678,10 +2677,8 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, if (!priv->vxlan_port || (ip_hdr(skb)->version != 4) || (udp_hdr(skb)->dest != priv->vxlan_port))
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
}*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- return features;
}
static int mlx4_en_set_tx_maxrate(struct net_device *dev, int queue_index, u32 maxrate) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 7b8c8187543a..9174b7b187fb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -1130,9 +1130,8 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16 void mlx5e_rx_dim_work(struct work_struct *work); void mlx5e_tx_dim_work(struct work_struct *work);
-netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features);
+void mlx5e_features_check(struct sk_buff *skb, struct net_device *netdev,
netdev_features_t *features);
int mlx5e_set_features(struct net_device *netdev, netdev_features_t features); #ifdef CONFIG_MLX5_ESWITCH int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 4518a490cdcd..6fdc2a793c1f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3904,21 +3904,18 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
-netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features)
+void mlx5e_features_check(struct sk_buff *skb, struct net_device *netdev,
netdev_features_t *features)
{ struct mlx5e_priv *priv = netdev_priv(netdev);
- vlan_features_check(skb, &features);
- vxlan_features_check(skb, &features);
vlan_features_check(skb, features);
vxlan_features_check(skb, features);
/* Validate if the tunneled packet is being offloaded by HW */ if (skb->encapsulation &&
(features & NETIF_F_CSUM_MASK || features & NETIF_F_GSO_MASK))
return mlx5e_tunnel_features_check(priv, skb, features);
- return features;
(*features & NETIF_F_CSUM_MASK || *features & NETIF_F_GSO_MASK))
*features = mlx5e_tunnel_features_check(priv, skb, *features);
}
static void mlx5e_tx_timeout_work(struct work_struct *work) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 58e7d98d0dd6..6261596cfda6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3598,17 +3598,16 @@ static int nfp_net_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t -nfp_net_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void nfp_net_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ u8 l4_hdr;
/* We can't do TSO over double tagged packets (802.1AD) */
- vlan_features_check(skb, &features);
vlan_features_check(skb, features);
if (!skb->encapsulation)
return features;
return;
/* Ensure that inner L4 header offset fits into TX descriptor field */ if (skb_is_gso(skb)) {
@@ -3621,7 +3620,7 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, * metadata prepend - 8B */ if (unlikely(hdrlen > NFP_NET_LSO_MAX_HDR_SZ - 8))
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
}
/* VXLAN/GRE check */
@@ -3633,7 +3632,8 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, l4_hdr = ipv6_hdr(skb)->nexthdr; break; default:
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
return;
}
if (skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
@@ -3641,10 +3641,10 @@ nfp_net_features_check(struct sk_buff *skb, struct net_device *dev, (l4_hdr != IPPROTO_UDP && l4_hdr != IPPROTO_GRE) || (l4_hdr == IPPROTO_UDP && (skb_inner_mac_header(skb) - skb_transport_header(skb) !=
sizeof(struct udphdr) + sizeof(struct vxlanhdr))))
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
- return features;
sizeof(struct udphdr) + sizeof(struct vxlanhdr)))) {
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
return;
- }
}
static int diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h index f90dcfe9ee68..c1f26a2e374d 100644 --- a/drivers/net/ethernet/qlogic/qede/qede.h +++ b/drivers/net/ethernet/qlogic/qede/qede.h @@ -527,9 +527,8 @@ int qede_xdp_transmit(struct net_device *dev, int n_frames, struct xdp_frame **frames, u32 flags); u16 qede_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev); -netdev_features_t qede_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features);
+void qede_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features);
int qede_alloc_rx_buffer(struct qede_rx_queue *rxq, bool allow_lazy); int qede_free_tx_pkt(struct qede_dev *edev, struct qede_tx_queue *txq, int *len); diff --git a/drivers/net/ethernet/qlogic/qede/qede_fp.c b/drivers/net/ethernet/qlogic/qede/qede_fp.c index 065e9004598e..8a459d2ca983 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_fp.c +++ b/drivers/net/ethernet/qlogic/qede/qede_fp.c @@ -1747,9 +1747,8 @@ u16 qede_select_queue(struct net_device *dev, struct sk_buff *skb, /* 8B udp header + 8B base tunnel header + 32B option length */ #define QEDE_MAX_TUN_HDR_LEN 48
-netdev_features_t qede_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+void qede_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ if (skb->encapsulation) { u8 l4_proto = 0; @@ -1762,7 +1761,7 @@ netdev_features_t qede_features_check(struct sk_buff *skb, l4_proto = ipv6_hdr(skb)->nexthdr; break; default:
return features;
return;
}
/* Disable offloads for geneve tunnels, as HW can't parse
@@ -1780,16 +1779,17 @@ netdev_features_t qede_features_check(struct sk_buff *skb, if ((skb_inner_mac_header(skb) - skb_transport_header(skb)) > hdrlen || (ntohs(udp_hdr(skb)->dest) != vxln_port &&
ntohs(udp_hdr(skb)->dest) != gnv_port))
return features & ~(NETIF_F_CSUM_MASK |
NETIF_F_GSO_MASK);
ntohs(udp_hdr(skb)->dest) != gnv_port)) {
*features &= ~(NETIF_F_CSUM_MASK |
NETIF_F_GSO_MASK);
return;
} else if (l4_proto == IPPROTO_IPIP) { /* IPIP tunnels are unknown to the device or at least unsupported natively, * offloads for them can't be done trivially, so disable them for such skb. */}
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
} }return;
- return features;
} diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index d823f2a22472..192d74665c20 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -492,13 +492,11 @@ static const struct udp_tunnel_nic_info qlcnic_udp_tunnels = { }, };
-static netdev_features_t qlcnic_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void qlcnic_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{
- vlan_features_check(skb, &features);
- vxlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
- vxlan_features_check(skb, features);
}
static const struct net_device_ops qlcnic_netdev_ops = { diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index d2135fe99cd7..663a12598cad 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c @@ -1853,15 +1853,13 @@ static void cp_set_d3_state (struct cp_private *cp) pci_set_power_state (cp->pdev, PCI_D3hot); }
-static netdev_features_t cp_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void cp_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ if (skb_shinfo(skb)->gso_size > MSSMask)
features &= ~NETIF_F_TSO;
*features &= ~NETIF_F_TSO;
- vlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
} static const struct net_device_ops cp_netdev_ops = { .ndo_open = cp_open, diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 98e7ffa6aa0a..3d753ddd1a89 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4347,35 +4347,33 @@ static netdev_features_t rtl8168evl_fix_tso(struct sk_buff *skb, return features; }
-static netdev_features_t rtl8169_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void rtl8169_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ int transport_offset = skb_transport_offset(skb); struct rtl8169_private *tp = netdev_priv(dev);
if (skb_is_gso(skb)) { if (tp->mac_version == RTL_GIGA_MAC_VER_34)
features = rtl8168evl_fix_tso(skb, features);
*features = rtl8168evl_fix_tso(skb, *features);
if (transport_offset > GTTCPHO_MAX && rtl_chip_supports_csum_v2(tp))
features &= ~NETIF_F_ALL_TSO;
} else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* work around hw bug on some chip versions */ if (skb->len < ETH_ZLEN)*features &= ~NETIF_F_ALL_TSO;
features &= ~NETIF_F_CSUM_MASK;
*features &= ~NETIF_F_CSUM_MASK;
if (rtl_quirk_packet_padto(tp, skb))
features &= ~NETIF_F_CSUM_MASK;
*features &= ~NETIF_F_CSUM_MASK;
if (transport_offset > TCPHO_MAX && rtl_chip_supports_csum_v2(tp))
features &= ~NETIF_F_CSUM_MASK;
}*features &= ~NETIF_F_CSUM_MASK;
- vlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
}
static void rtl8169_pcierr_interrupt(struct net_device *dev) diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index 896b59253197..a101fa50a5cc 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -1353,25 +1353,24 @@ static bool efx_can_encap_offloads(struct efx_nic *efx, struct sk_buff *skb) } }
-netdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+void efx_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ struct efx_nic *efx = netdev_priv(dev);
if (skb->encapsulation) {
if (features & NETIF_F_GSO_MASK)
if (*features & NETIF_F_GSO_MASK) /* Hardware can only do TSO with at most 208 bytes * of headers. */ if (skb_inner_transport_offset(skb) > EFX_TSO2_MAX_HDRLEN)
features &= ~(NETIF_F_GSO_MASK);
if (features & (NETIF_F_GSO_MASK | NETIF_F_CSUM_MASK))
*features &= ~(NETIF_F_GSO_MASK);
if (*features & (NETIF_F_GSO_MASK | NETIF_F_CSUM_MASK)) if (!efx_can_encap_offloads(efx, skb))
features &= ~(NETIF_F_GSO_MASK |
}*features &= ~(NETIF_F_GSO_MASK | NETIF_F_CSUM_MASK);
- return features;
}
int efx_get_phys_port_id(struct net_device *net_dev, diff --git a/drivers/net/ethernet/sfc/efx_common.h b/drivers/net/ethernet/sfc/efx_common.h index 65513fd0cf6c..c4fea3997704 100644 --- a/drivers/net/ethernet/sfc/efx_common.h +++ b/drivers/net/ethernet/sfc/efx_common.h @@ -105,8 +105,8 @@ int efx_change_mtu(struct net_device *net_dev, int new_mtu);
extern const struct pci_error_handlers efx_err_handlers;
-netdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features);
+void efx_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features);
int efx_get_phys_port_id(struct net_device *net_dev, struct netdev_phys_item_id *ppid); diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 9bfee75cbaf1..7a60cc0f6aad 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3976,17 +3976,15 @@ static void lan78xx_tx_timeout(struct net_device *net, unsigned int txqueue) tasklet_schedule(&dev->bh); }
-static netdev_features_t lan78xx_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features)
+static void lan78xx_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t *features)
{ if (skb->len + TX_OVERHEAD > MAX_SINGLE_PACKET_SIZE)
features &= ~NETIF_F_GSO_MASK;
*features &= ~NETIF_F_GSO_MASK;
- vlan_features_check(skb, &features);
- vxlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
- vxlan_features_check(skb, features);
}
static const struct net_device_ops lan78xx_netdev_ops = { diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 60ba9b734055..5bb327b8d8e0 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -2741,20 +2741,17 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev) netif_wake_queue(netdev); }
-static netdev_features_t -rtl8152_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features)
+static void rtl8152_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ u32 mss = skb_shinfo(skb)->gso_size; int max_offset = mss ? GTTCPHO_MAX : TCPHO_MAX; int offset = skb_transport_offset(skb);
if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) && offset > max_offset)
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
else if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz)*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
features &= ~NETIF_F_GSO_MASK;
- return features;
*features &= ~NETIF_F_GSO_MASK;
}
static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index 5dd8360b21a0..e840547cd19e 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -256,9 +256,8 @@ netdev_features_t vmxnet3_fix_features(struct net_device *netdev, return features; }
-netdev_features_t vmxnet3_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features)
+void vmxnet3_features_check(struct sk_buff *skb, struct net_device *netdev,
netdev_features_t *features)
{ struct vmxnet3_adapter *adapter = netdev_priv(netdev);
@@ -277,7 +276,8 @@ netdev_features_t vmxnet3_features_check(struct sk_buff *skb, l4_proto = ipv6_hdr(skb)->nexthdr; break; default:
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
return;
}
switch (l4_proto) {
@@ -288,14 +288,15 @@ netdev_features_t vmxnet3_features_check(struct sk_buff *skb, if (port != GENEVE_UDP_PORT && port != IANA_VXLAN_UDP_PORT && port != VXLAN_UDP_PORT) {
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
default:return; } break;
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
} }return;
- return features;
}
static void vmxnet3_enable_encap_offloads(struct net_device *netdev) diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 7027ff483fa5..a711759ebb00 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -478,9 +478,9 @@ vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); netdev_features_t vmxnet3_fix_features(struct net_device *netdev, netdev_features_t features);
-netdev_features_t +void vmxnet3_features_check(struct sk_buff *skb,
struct net_device *netdev, netdev_features_t features);
struct net_device *netdev, netdev_features_t *features);
int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features); diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 535a60b3946d..06d02e2e2b66 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -1095,9 +1095,8 @@ int qeth_setassparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long); int qeth_set_features(struct net_device *, netdev_features_t); void qeth_enable_hw_features(struct net_device *dev); netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t); -netdev_features_t qeth_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features);
+void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features);
void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); int qeth_set_real_num_tx_queues(struct qeth_card *card, unsigned int count); u16 qeth_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index bf72dd88297a..6811af22ee2b 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -6950,9 +6950,8 @@ netdev_features_t qeth_fix_features(struct net_device *dev, } EXPORT_SYMBOL_GPL(qeth_fix_features);
-netdev_features_t qeth_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{ struct qeth_card *card = dev->ml_priv;
@@ -6961,7 +6960,7 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, READ_ONCE(card->options.isolation) != ISOLATION_MODE_FWD) { netdev_features_t restricted = 0;
if (skb_is_gso(skb) && !netif_needs_gso(skb, features))
if (skb_is_gso(skb) && !netif_needs_gso(skb, *features)) restricted |= NETIF_F_ALL_TSO;
switch (vlan_get_protocol(skb)) {
@@ -6970,14 +6969,14 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, restricted |= NETIF_F_IP_CSUM;
if (restricted && qeth_next_hop_is_local_v4(card, skb))
features &= ~restricted;
*features &= ~restricted; break;
case htons(ETH_P_IPV6): if (!card->info.has_lp2lp_cso_v6) restricted |= NETIF_F_IPV6_CSUM;
if (restricted && qeth_next_hop_is_local_v6(card, skb))
features &= ~restricted;
default: break;*features &= ~restricted; break;
@@ -6991,7 +6990,7 @@ netdev_features_t qeth_features_check(struct sk_buff *skb, * additional buffer element. This reduces buffer utilization, and * hurts throughput. So compress small segments into one element. */
- if (netif_needs_gso(skb, features)) {
- if (netif_needs_gso(skb, *features)) { /* match skb_segment(): */ unsigned int doffset = skb->data - skb_mac_header(skb); unsigned int hsize = skb_shinfo(skb)->gso_size;
@@ -6999,11 +6998,10 @@ netdev_features_t qeth_features_check(struct sk_buff *skb,
/* linearize only if resulting skb allocations are order-0: */ if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0))
features &= ~NETIF_F_SG;
}*features &= ~NETIF_F_SG;
- vlan_features_check(skb, &features);
- return features;
- vlan_features_check(skb, features);
} EXPORT_SYMBOL_GPL(qeth_features_check);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 3a523e700a5a..76c37eedf614 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1804,13 +1804,13 @@ qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np) return 0; }
-static netdev_features_t qeth_l3_osa_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+static void qeth_l3_osa_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t *features)
{ if (vlan_get_protocol(skb) != htons(ETH_P_IP))
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return qeth_features_check(skb, dev, features);
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- qeth_features_check(skb, dev, features);
}
static u16 qeth_l3_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a5598d617789..09233e7df8f1 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1352,9 +1352,9 @@ struct net_device_ops { int (*ndo_stop)(struct net_device *dev); netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb, struct net_device *dev);
- netdev_features_t (*ndo_features_check)(struct sk_buff *skb,
- void (*ndo_features_check)(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features);
u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev);netdev_features_t *features);
@@ -5056,9 +5056,8 @@ void netdev_change_features(struct net_device *dev); void netif_stacked_transfer_operstate(const struct net_device *rootdev, struct net_device *dev);
-netdev_features_t passthru_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features);
+void passthru_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features);
netdev_features_t netif_skb_features(struct sk_buff *skb);
static inline bool net_gso_ok(netdev_features_t features, int gso_type) diff --git a/net/core/dev.c b/net/core/dev.c index 4aab7b83fcb8..993249e22e9f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3472,11 +3472,9 @@ static void harmonize_features(struct sk_buff *skb, netdev_features_t *features) *features &= ~NETIF_F_SG; }
-netdev_features_t passthru_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
+void passthru_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t *features)
{
- return features;
} EXPORT_SYMBOL(passthru_features_check);
@@ -3547,8 +3545,7 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check)
features &= dev->netdev_ops->ndo_features_check(skb, dev,
features);
else dflt_features_check(skb, dev, &features);dev->netdev_ops->ndo_features_check(skb, dev, &features);
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netif_skb_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/xen-netfront.c | 9 +++++++-- include/linux/netdevice.h | 2 +- net/core/dev.c | 20 ++++++++++---------- net/core/netpoll.c | 2 +- net/ipv4/ip_output.c | 2 +- net/ipv6/ip6_output.c | 2 +- net/sched/sch_cake.c | 3 ++- net/sched/sch_netem.c | 3 ++- net/sched/sch_taprio.c | 3 ++- net/sched/sch_tbf.c | 3 ++- 10 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index e31b98403f31..65c134ac2be5 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -679,6 +679,7 @@ static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev struct netfront_queue *queue = NULL; struct xennet_gnttab_make_txreq info = { }; unsigned int num_queues = dev->real_num_tx_queues; + netdev_features_t features; u16 queue_index; struct sk_buff *nskb;
@@ -730,8 +731,12 @@ static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev spin_lock_irqsave(&queue->tx_lock, flags);
if (unlikely(!netif_carrier_ok(dev) || - (slots > 1 && !xennet_can_sg(dev)) || - netif_needs_gso(skb, netif_skb_features(skb)))) { + (slots > 1 && !xennet_can_sg(dev)))) { + spin_unlock_irqrestore(&queue->tx_lock, flags); + goto drop; + } + netif_skb_features(skb, &features); + if (unlikely(netif_needs_gso(skb, features))) { spin_unlock_irqrestore(&queue->tx_lock, flags); goto drop; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 09233e7df8f1..d62edd4c99a9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5058,7 +5058,7 @@ void netif_stacked_transfer_operstate(const struct net_device *rootdev,
void passthru_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t *features); -netdev_features_t netif_skb_features(struct sk_buff *skb); +void netif_skb_features(struct sk_buff *skb, netdev_features_t *features);
static inline bool net_gso_ok(netdev_features_t features, int gso_type) { diff --git a/net/core/dev.c b/net/core/dev.c index 993249e22e9f..7b71d322c68e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3523,34 +3523,34 @@ static void gso_features_check(const struct sk_buff *skb, } }
-netdev_features_t netif_skb_features(struct sk_buff *skb) +void netif_skb_features(struct sk_buff *skb, netdev_features_t *features) { struct net_device *dev = skb->dev; - netdev_features_t features = dev->features; + + *features = dev->features;
if (skb_is_gso(skb)) - gso_features_check(skb, dev, &features); + gso_features_check(skb, dev, features);
/* If encapsulation offload request, verify we are testing * hardware encapsulation features instead of standard * features for the netdev */ if (skb->encapsulation) - features &= dev->hw_enc_features; + *features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb)) - netdev_intersect_features(&features, features, + netdev_intersect_features(features, *features, dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check) - dev->netdev_ops->ndo_features_check(skb, dev, &features); + dev->netdev_ops->ndo_features_check(skb, dev, features); else - dflt_features_check(skb, dev, &features); + dflt_features_check(skb, dev, features);
- harmonize_features(skb, &features); - return features; + harmonize_features(skb, features); } EXPORT_SYMBOL(netif_skb_features);
@@ -3635,7 +3635,7 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device { netdev_features_t features;
- features = netif_skb_features(skb); + netif_skb_features(skb, &features); skb = validate_xmit_vlan(skb, features); if (unlikely(!skb)) goto out_null; diff --git a/net/core/netpoll.c b/net/core/netpoll.c index edfc0f8011f8..d2fc92b89a5f 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -77,7 +77,7 @@ static netdev_tx_t netpoll_start_xmit(struct sk_buff *skb, netdev_tx_t status = NETDEV_TX_OK; netdev_features_t features;
- features = netif_skb_features(skb); + netif_skb_features(skb, &features);
if (skb_vlan_tag_present(skb) && !vlan_hw_offload_capable(features, skb->vlan_proto)) { diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 9bca57ef8b83..8d552f1b7f62 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -255,7 +255,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk, * bridged to a NETIF_F_TSO tunnel stacked over an interface with an * insufficient MTU. */ - features = netif_skb_features(skb); + netif_skb_features(skb, &features); BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_GSO_CB_OFFSET); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) { diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 12f985f43bcc..46a0867bcedf 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -146,7 +146,7 @@ ip6_finish_output_gso_slowpath_drop(struct net *net, struct sock *sk, * describing the cases where GSO segment length exceeds the * egress MTU. */ - features = netif_skb_features(skb); + netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) { kfree_skb(skb); diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 3c2300d14468..e650ec5dc791 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1740,9 +1740,10 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
if (skb_is_gso(skb) && q->rate_flags & CAKE_FLAG_SPLIT_GSO) { struct sk_buff *segs, *nskb; - netdev_features_t features = netif_skb_features(skb); + netdev_features_t features; unsigned int slen = 0, numsegs = 0;
+ netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) return qdisc_drop(skb, sch, to_free); diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 0c345e43a09a..414d57e017b9 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -413,8 +413,9 @@ static struct sk_buff *netem_segment(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) { struct sk_buff *segs; - netdev_features_t features = netif_skb_features(skb); + netdev_features_t features;
+ netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs)) { diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1ab2fc933a21..d7fe4a2cc14f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -453,10 +453,11 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, */ if (skb_is_gso(skb) && !FULL_OFFLOAD_IS_ENABLED(q->flags)) { unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb); - netdev_features_t features = netif_skb_features(skb); + netdev_features_t features; struct sk_buff *segs, *nskb; int ret;
+ netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) return qdisc_drop(skb, sch, to_free); diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 78e79029dc63..99e6d7265e7f 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -192,10 +192,11 @@ static int tbf_segment(struct sk_buff *skb, struct Qdisc *sch, { struct tbf_sched_data *q = qdisc_priv(sch); struct sk_buff *segs, *nskb; - netdev_features_t features = netif_skb_features(skb); + netdev_features_t features; unsigned int len = 0, prev_len = qdisc_pkt_len(skb); int ret, nb;
+ netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs))
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netif_skb_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/xen-netfront.c | 9 +++++++-- include/linux/netdevice.h | 2 +- net/core/dev.c | 20 ++++++++++---------- net/core/netpoll.c | 2 +- net/ipv4/ip_output.c | 2 +- net/ipv6/ip6_output.c | 2 +- net/sched/sch_cake.c | 3 ++- net/sched/sch_netem.c | 3 ++- net/sched/sch_taprio.c | 3 ++- net/sched/sch_tbf.c | 3 ++- 10 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index e31b98403f31..65c134ac2be5 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -679,6 +679,7 @@ static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev struct netfront_queue *queue = NULL; struct xennet_gnttab_make_txreq info = { }; unsigned int num_queues = dev->real_num_tx_queues;
- netdev_features_t features; u16 queue_index; struct sk_buff *nskb;
@@ -730,8 +731,12 @@ static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev spin_lock_irqsave(&queue->tx_lock, flags);
if (unlikely(!netif_carrier_ok(dev) ||
(slots > 1 && !xennet_can_sg(dev)) ||
netif_needs_gso(skb, netif_skb_features(skb)))) {
(slots > 1 && !xennet_can_sg(dev)))) {
spin_unlock_irqrestore(&queue->tx_lock, flags);
goto drop;
- }
- netif_skb_features(skb, &features);
- if (unlikely(netif_needs_gso(skb, features))) { spin_unlock_irqrestore(&queue->tx_lock, flags); goto drop; }
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 09233e7df8f1..d62edd4c99a9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5058,7 +5058,7 @@ void netif_stacked_transfer_operstate(const struct net_device *rootdev,
void passthru_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t *features); -netdev_features_t netif_skb_features(struct sk_buff *skb); +void netif_skb_features(struct sk_buff *skb, netdev_features_t *features);
static inline bool net_gso_ok(netdev_features_t features, int gso_type) { diff --git a/net/core/dev.c b/net/core/dev.c index 993249e22e9f..7b71d322c68e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3523,34 +3523,34 @@ static void gso_features_check(const struct sk_buff *skb, } }
-netdev_features_t netif_skb_features(struct sk_buff *skb) +void netif_skb_features(struct sk_buff *skb, netdev_features_t *features) { struct net_device *dev = skb->dev;
- netdev_features_t features = dev->features;
*features = dev->features;
if (skb_is_gso(skb))
gso_features_check(skb, dev, &features);
gso_features_check(skb, dev, features);
/* If encapsulation offload request, verify we are testing
- hardware encapsulation features instead of standard
- features for the netdev
*/ if (skb->encapsulation)
features &= dev->hw_enc_features;
*features &= dev->hw_enc_features;
if (skb_vlan_tagged(skb))
netdev_intersect_features(&features, features,
netdev_intersect_features(features, *features, dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX);
if (dev->netdev_ops->ndo_features_check)
dev->netdev_ops->ndo_features_check(skb, dev, &features);
elsedev->netdev_ops->ndo_features_check(skb, dev, features);
dflt_features_check(skb, dev, &features);
dflt_features_check(skb, dev, features);
- harmonize_features(skb, &features);
- return features;
- harmonize_features(skb, features);
} EXPORT_SYMBOL(netif_skb_features);
@@ -3635,7 +3635,7 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device { netdev_features_t features;
- features = netif_skb_features(skb);
- netif_skb_features(skb, &features); skb = validate_xmit_vlan(skb, features); if (unlikely(!skb)) goto out_null;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index edfc0f8011f8..d2fc92b89a5f 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -77,7 +77,7 @@ static netdev_tx_t netpoll_start_xmit(struct sk_buff *skb, netdev_tx_t status = NETDEV_TX_OK; netdev_features_t features;
- features = netif_skb_features(skb);
netif_skb_features(skb, &features);
if (skb_vlan_tag_present(skb) && !vlan_hw_offload_capable(features, skb->vlan_proto)) {
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 9bca57ef8b83..8d552f1b7f62 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -255,7 +255,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk, * bridged to a NETIF_F_TSO tunnel stacked over an interface with an * insufficient MTU. */
- features = netif_skb_features(skb);
- netif_skb_features(skb, &features); BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_GSO_CB_OFFSET); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) {
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 12f985f43bcc..46a0867bcedf 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -146,7 +146,7 @@ ip6_finish_output_gso_slowpath_drop(struct net *net, struct sock *sk, * describing the cases where GSO segment length exceeds the * egress MTU. */
- features = netif_skb_features(skb);
- netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) { kfree_skb(skb);
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 3c2300d14468..e650ec5dc791 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1740,9 +1740,10 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
if (skb_is_gso(skb) && q->rate_flags & CAKE_FLAG_SPLIT_GSO) { struct sk_buff *segs, *nskb;
netdev_features_t features = netif_skb_features(skb);
netdev_features_t features;
unsigned int slen = 0, numsegs = 0;
netif_skb_features(skb, &features);
segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) return qdisc_drop(skb, sch, to_free);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 0c345e43a09a..414d57e017b9 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -413,8 +413,9 @@ static struct sk_buff *netem_segment(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) { struct sk_buff *segs;
- netdev_features_t features = netif_skb_features(skb);
netdev_features_t features;
netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs)) {
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1ab2fc933a21..d7fe4a2cc14f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -453,10 +453,11 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, */ if (skb_is_gso(skb) && !FULL_OFFLOAD_IS_ENABLED(q->flags)) { unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb);
netdev_features_t features = netif_skb_features(skb);
netdev_features_t features;
struct sk_buff *segs, *nskb; int ret;
netif_skb_features(skb, &features);
segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) return qdisc_drop(skb, sch, to_free);
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 78e79029dc63..99e6d7265e7f 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -192,10 +192,11 @@ static int tbf_segment(struct sk_buff *skb, struct Qdisc *sch, { struct tbf_sched_data *q = qdisc_priv(sch); struct sk_buff *segs, *nskb;
- netdev_features_t features = netif_skb_features(skb);
netdev_features_t features; unsigned int len = 0, prev_len = qdisc_pkt_len(skb); int ret, nb;
netif_skb_features(skb, &features); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs))
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of ndo_fix_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- arch/um/drivers/vector_kern.c | 7 ++-- drivers/infiniband/ulp/ipoib/ipoib_main.c | 7 ++-- drivers/net/bonding/bond_main.c | 24 ++++++------- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 28 +++++++-------- drivers/net/ethernet/atheros/alx/main.c | 8 ++--- .../net/ethernet/atheros/atl1c/atl1c_main.c | 14 ++++---- .../net/ethernet/atheros/atl1e/atl1e_main.c | 12 +++---- drivers/net/ethernet/atheros/atlx/atl2.c | 12 +++---- drivers/net/ethernet/atheros/atlx/atlx.c | 12 +++---- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 29 +++++++--------- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 3 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 27 +++++++-------- drivers/net/ethernet/broadcom/tg3.c | 8 ++--- .../net/ethernet/cavium/liquidio/lio_main.c | 34 +++++++++---------- .../ethernet/cavium/liquidio/lio_vf_main.c | 30 ++++++++-------- .../net/ethernet/cavium/thunder/nicvf_main.c | 10 +++--- drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 11 +++--- .../net/ethernet/chelsio/cxgb3/cxgb3_main.c | 12 +++---- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 10 +++--- .../ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 12 +++---- drivers/net/ethernet/cortina/gemini.c | 8 ++--- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 7 ++-- .../net/ethernet/huawei/hinic/hinic_main.c | 10 +++--- drivers/net/ethernet/ibm/ibmveth.c | 10 +++--- drivers/net/ethernet/intel/e1000/e1000_main.c | 12 +++---- drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++---- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 ++--- drivers/net/ethernet/intel/igb/igb_main.c | 12 +++---- drivers/net/ethernet/intel/igc/igc_main.c | 12 +++---- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 10 +++--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++----- drivers/net/ethernet/jme.c | 7 ++-- drivers/net/ethernet/marvell/mvneta.c | 8 ++--- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 12 +++---- drivers/net/ethernet/marvell/sky2.c | 16 ++++----- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++--- .../net/ethernet/mellanox/mlx4/en_netdev.c | 12 +++---- .../net/ethernet/mellanox/mlx5/core/en_main.c | 14 ++++---- .../net/ethernet/neterion/vxge/vxge-main.c | 10 +++--- .../net/ethernet/netronome/nfp/nfp_net_repr.c | 14 ++++---- drivers/net/ethernet/nvidia/forcedeth.c | 10 +++--- .../ethernet/qlogic/netxen/netxen_nic_main.c | 10 +++--- drivers/net/ethernet/qlogic/qede/qede.h | 3 +- .../net/ethernet/qlogic/qede/qede_filter.c | 9 ++--- drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 3 +- .../net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 15 ++++---- drivers/net/ethernet/realtek/r8169_main.c | 10 +++--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++---- drivers/net/hyperv/netvsc_drv.c | 12 +++---- drivers/net/ipvlan/ipvlan_main.c | 18 +++++----- drivers/net/macsec.c | 16 ++++----- drivers/net/macvlan.c | 20 +++++------ drivers/net/team/team.c | 20 +++++------ drivers/net/tun.c | 7 ++-- drivers/net/veth.c | 10 +++--- drivers/net/vmxnet3/vmxnet3_ethtool.c | 10 +++--- drivers/net/vmxnet3/vmxnet3_int.h | 4 +-- drivers/net/xen-netback/interface.c | 16 ++++----- drivers/net/xen-netfront.c | 22 ++++++------ drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 16 ++++----- include/linux/netdevice.h | 4 +-- net/8021q/vlan_dev.c | 14 ++++---- net/bridge/br_device.c | 5 ++- net/core/dev.c | 2 +- net/hsr/hsr_device.c | 6 ++-- 66 files changed, 349 insertions(+), 461 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index cde6db184c26..88cc24a58742 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -1342,11 +1342,10 @@ static void vector_net_tx_timeout(struct net_device *dev, unsigned int txqueue) schedule_work(&vp->reset_tx); }
-static netdev_features_t vector_fix_features(struct net_device *dev, - netdev_features_t features) +static void vector_fix_features(struct net_device *dev, + netdev_features_t *features) { - features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); - return features; + *features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); }
static int vector_set_features(struct net_device *dev, diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 0aa8629fdf62..488d50a82a87 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -214,14 +214,13 @@ static int ipoib_stop(struct net_device *dev) return 0; }
-static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_features_t features) +static void ipoib_fix_features(struct net_device *dev, + netdev_features_t *features) { 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); - - return features; + *features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO); }
static int ipoib_change_mtu(struct net_device *dev, int new_mtu) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 77dc79a7f574..469509260a51 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1361,8 +1361,8 @@ static void bond_netpoll_cleanup(struct net_device *bond_dev)
/*---------------------------------- IOCTL ----------------------------------*/
-static netdev_features_t bond_fix_features(struct net_device *dev, - netdev_features_t features) +static void bond_fix_features(struct net_device *dev, + netdev_features_t *features) { struct bonding *bond = netdev_priv(dev); struct list_head *iter; @@ -1371,24 +1371,22 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
#if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond)) - features |= BOND_TLS_FEATURES; + *features |= BOND_TLS_FEATURES; else - features &= ~BOND_TLS_FEATURES; + *features &= ~BOND_TLS_FEATURES; #endif
- mask = features; + mask = *features;
- features &= ~NETIF_F_ONE_FOR_ALL; - features |= NETIF_F_ALL_FOR_ALL; + *features &= ~NETIF_F_ONE_FOR_ALL; + *features |= NETIF_F_ALL_FOR_ALL;
bond_for_each_slave(bond, slave, iter) { - features = netdev_increment_features(features, - slave->dev->features, - mask); + *features = netdev_increment_features(*features, + slave->dev->features, + mask); } - features = netdev_add_tso_features(features, mask); - - return features; + *features = netdev_add_tso_features(*features, mask); }
#define BOND_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index cc1f1a7a46ae..dff9eecac6e9 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2182,8 +2182,8 @@ static int xgbe_setup_tc(struct net_device *netdev, enum tc_setup_type type, return 0; }
-static netdev_features_t xgbe_fix_features(struct net_device *netdev, - netdev_features_t features) +static void xgbe_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct xgbe_prv_data *pdata = netdev_priv(netdev); netdev_features_t vxlan_base; @@ -2191,38 +2191,36 @@ static netdev_features_t xgbe_fix_features(struct net_device *netdev, vxlan_base = NETIF_F_GSO_UDP_TUNNEL | NETIF_F_RX_UDP_TUNNEL_PORT;
if (!pdata->hw_feat.vxn) - return features; + return;
/* VXLAN CSUM requires VXLAN base */ - if ((features & NETIF_F_GSO_UDP_TUNNEL_CSUM) && - !(features & NETIF_F_GSO_UDP_TUNNEL)) { + if ((*features & NETIF_F_GSO_UDP_TUNNEL_CSUM) && + !(*features & NETIF_F_GSO_UDP_TUNNEL)) { netdev_notice(netdev, "forcing tx udp tunnel support\n"); - features |= NETIF_F_GSO_UDP_TUNNEL; + *features |= NETIF_F_GSO_UDP_TUNNEL; }
/* Can't do one without doing the other */ - if ((features & vxlan_base) != vxlan_base) { + if ((*features & vxlan_base) != vxlan_base) { netdev_notice(netdev, "forcing both tx and rx udp tunnel support\n"); - features |= vxlan_base; + *features |= vxlan_base; }
- if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) { - if (!(features & NETIF_F_GSO_UDP_TUNNEL_CSUM)) { + if (*features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) { + if (!(*features & NETIF_F_GSO_UDP_TUNNEL_CSUM)) { netdev_notice(netdev, "forcing tx udp tunnel checksumming on\n"); - features |= NETIF_F_GSO_UDP_TUNNEL_CSUM; + *features |= NETIF_F_GSO_UDP_TUNNEL_CSUM; } } else { - if (features & NETIF_F_GSO_UDP_TUNNEL_CSUM) { + if (*features & NETIF_F_GSO_UDP_TUNNEL_CSUM) { netdev_notice(netdev, "forcing tx udp tunnel checksumming off\n"); - features &= ~NETIF_F_GSO_UDP_TUNNEL_CSUM; + *features &= ~NETIF_F_GSO_UDP_TUNNEL_CSUM; } } - - return features; }
static int xgbe_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c index 4ea157efca86..922c600fd292 100644 --- a/drivers/net/ethernet/atheros/alx/main.c +++ b/drivers/net/ethernet/atheros/alx/main.c @@ -1097,13 +1097,11 @@ static int alx_init_sw(struct alx_priv *alx) }
-static netdev_features_t alx_fix_features(struct net_device *netdev, - netdev_features_t features) +static void alx_fix_features(struct net_device *netdev, + netdev_features_t *features) { if (netdev->mtu > ALX_MAX_TSO_PKT_SIZE) - features &= ~(NETIF_F_TSO | NETIF_F_TSO6); - - return features; + *features &= ~(NETIF_F_TSO | NETIF_F_TSO6); }
static void alx_netif_stop(struct alx_priv *alx) diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index 20c032ab631b..aa86936bca97 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c @@ -504,8 +504,8 @@ static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter, adapter->rx_frag_size = roundup_pow_of_two(head_size); }
-static netdev_features_t atl1c_fix_features(struct net_device *netdev, - netdev_features_t features) +static void atl1c_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct atl1c_adapter *adapter = netdev_priv(netdev); struct atl1c_hw *hw = &adapter->hw; @@ -514,17 +514,15 @@ static netdev_features_t atl1c_fix_features(struct net_device *netdev, * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX;
if (hw->nic_type != athr_mt) { if (netdev->mtu > MAX_TSO_FRAME_SIZE) - features &= ~(NETIF_F_TSO | NETIF_F_TSO6); + *features &= ~(NETIF_F_TSO | NETIF_F_TSO6); } - - return features; }
static int atl1c_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 2e22483a9040..ea99949c91eb 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -382,19 +382,17 @@ static int atl1e_set_mac_addr(struct net_device *netdev, void *p) return 0; }
-static netdev_features_t atl1e_fix_features(struct net_device *netdev, - netdev_features_t features) +static void atl1e_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int atl1e_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index b69298ddb647..c4d303ce284c 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c @@ -371,19 +371,17 @@ static void atl2_restore_vlan(struct atl2_adapter *adapter) atl2_vlan_mode(adapter->netdev, adapter->netdev->features); }
-static netdev_features_t atl2_fix_features(struct net_device *netdev, - netdev_features_t features) +static void atl2_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int atl2_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c index 0941d07d0833..3b0dbc3a5896 100644 --- a/drivers/net/ethernet/atheros/atlx/atlx.c +++ b/drivers/net/ethernet/atheros/atlx/atlx.c @@ -237,19 +237,17 @@ static void atlx_restore_vlan(struct atlx_adapter *adapter) atlx_vlan_mode(adapter->netdev, adapter->netdev->features); }
-static netdev_features_t atlx_fix_features(struct net_device *netdev, - netdev_features_t features) +static void atlx_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int atlx_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index b5d954cb409a..d74510306068 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -4899,38 +4899,35 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) return bnx2x_reload_if_running(dev); }
-netdev_features_t bnx2x_fix_features(struct net_device *dev, - netdev_features_t features) +void bnx2x_fix_features(struct net_device *dev, netdev_features_t *features) { struct bnx2x *bp = netdev_priv(dev);
if (pci_num_vf(bp->pdev)) { - netdev_features_t changed = dev->features ^ features; + netdev_features_t changed = dev->features ^ *features;
/* Revert the requested changes in features if they * would require internal reload of PF in bnx2x_set_features(). */ - if (!(features & NETIF_F_RXCSUM) && !bp->disable_tpa) { - features &= ~NETIF_F_RXCSUM; - features |= dev->features & NETIF_F_RXCSUM; + if (!(*features & NETIF_F_RXCSUM) && !bp->disable_tpa) { + *features &= ~NETIF_F_RXCSUM; + *features |= dev->features & NETIF_F_RXCSUM; }
if (changed & NETIF_F_LOOPBACK) { - features &= ~NETIF_F_LOOPBACK; - features |= dev->features & NETIF_F_LOOPBACK; + *features &= ~NETIF_F_LOOPBACK; + *features |= dev->features & NETIF_F_LOOPBACK; } }
/* TPA requires Rx CSUM offloading */ - if (!(features & NETIF_F_RXCSUM)) - features &= ~NETIF_F_LRO; + if (!(*features & NETIF_F_RXCSUM)) + *features &= ~NETIF_F_LRO;
- if (!(features & NETIF_F_GRO) || !bnx2x_mtu_allows_gro(dev->mtu)) - features &= ~NETIF_F_GRO_HW; - if (features & NETIF_F_GRO_HW) - features &= ~NETIF_F_LRO; - - return features; + if (!(*features & NETIF_F_GRO) || !bnx2x_mtu_allows_gro(dev->mtu)) + *features &= ~NETIF_F_GRO_HW; + if (*features & NETIF_F_GRO_HW) + *features &= ~NETIF_F_LRO; }
int bnx2x_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index d8b1824c334d..4c66ef3e04bf 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -606,8 +606,7 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu); int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type); #endif
-netdev_features_t bnx2x_fix_features(struct net_device *dev, - netdev_features_t features); +void bnx2x_fix_features(struct net_device *dev, netdev_features_t *features); int bnx2x_set_features(struct net_device *dev, netdev_features_t features);
/** diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b43b96cfaebc..106a0378c3b4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10894,39 +10894,38 @@ static bool bnxt_rfs_capable(struct bnxt *bp) #endif }
-static netdev_features_t bnxt_fix_features(struct net_device *dev, - netdev_features_t features) +static void bnxt_fix_features(struct net_device *dev, + netdev_features_t *features) { struct bnxt *bp = netdev_priv(dev); netdev_features_t vlan_features;
- if ((features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp)) - features &= ~NETIF_F_NTUPLE; + if ((*features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp)) + *features &= ~NETIF_F_NTUPLE;
if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) - features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); + *features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
- if (!(features & NETIF_F_GRO)) - features &= ~NETIF_F_GRO_HW; + if (!(*features & NETIF_F_GRO)) + *features &= ~NETIF_F_GRO_HW;
- if (features & NETIF_F_GRO_HW) - features &= ~NETIF_F_LRO; + if (*features & NETIF_F_GRO_HW) + *features &= ~NETIF_F_LRO;
/* Both CTAG and STAG VLAN accelaration on the RX side have to be * turned on or off together. */ - vlan_features = features & BNXT_HW_FEATURE_VLAN_ALL_RX; + vlan_features = *features & BNXT_HW_FEATURE_VLAN_ALL_RX; if (vlan_features != BNXT_HW_FEATURE_VLAN_ALL_RX) { if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) - features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX; + *features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX; else if (vlan_features) - features |= BNXT_HW_FEATURE_VLAN_ALL_RX; + *features |= BNXT_HW_FEATURE_VLAN_ALL_RX; } #ifdef CONFIG_BNXT_SRIOV if (BNXT_VF(bp) && bp->vf.vlan) - features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX; + *features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX; #endif - return features; }
static int bnxt_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 5e0e0e70d801..df0d6a35f093 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -8302,15 +8302,13 @@ static void tg3_set_loopback(struct net_device *dev, netdev_features_t features) } }
-static netdev_features_t tg3_fix_features(struct net_device *dev, - netdev_features_t features) +static void tg3_fix_features(struct net_device *dev, + netdev_features_t *features) { struct tg3 *tp = netdev_priv(dev);
if (dev->mtu > ETH_DATA_LEN && tg3_flag(tp, 5780_CLASS)) - features &= ~NETIF_F_ALL_TSO; - - return features; + *features &= ~NETIF_F_ALL_TSO; }
static int tg3_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 2907e13b9df6..0230a63b86d5 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -2716,38 +2716,36 @@ static const struct udp_tunnel_nic_info liquidio_udp_tunnels = { * @request: features requested * Return: updated features list */ -static netdev_features_t liquidio_fix_features(struct net_device *netdev, - netdev_features_t request) +static void liquidio_fix_features(struct net_device *netdev, + netdev_features_t *request) { struct lio *lio = netdev_priv(netdev);
- if ((request & NETIF_F_RXCSUM) && + if ((*request & NETIF_F_RXCSUM) && !(lio->dev_capability & NETIF_F_RXCSUM)) - request &= ~NETIF_F_RXCSUM; + *request &= ~NETIF_F_RXCSUM;
- if ((request & NETIF_F_HW_CSUM) && + if ((*request & NETIF_F_HW_CSUM) && !(lio->dev_capability & NETIF_F_HW_CSUM)) - request &= ~NETIF_F_HW_CSUM; + *request &= ~NETIF_F_HW_CSUM;
- if ((request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO)) - request &= ~NETIF_F_TSO; + if ((*request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO)) + *request &= ~NETIF_F_TSO;
- if ((request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6)) - request &= ~NETIF_F_TSO6; + if ((*request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6)) + *request &= ~NETIF_F_TSO6;
- if ((request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO)) - request &= ~NETIF_F_LRO; + if ((*request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO)) + *request &= ~NETIF_F_LRO;
/*Disable LRO if RXCSUM is off */ - if (!(request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) && + if (!(*request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) && (lio->dev_capability & NETIF_F_LRO)) - request &= ~NETIF_F_LRO; + *request &= ~NETIF_F_LRO;
- if ((request & NETIF_F_HW_VLAN_CTAG_FILTER) && + if ((*request & NETIF_F_HW_VLAN_CTAG_FILTER) && !(lio->dev_capability & NETIF_F_HW_VLAN_CTAG_FILTER)) - request &= ~NETIF_F_HW_VLAN_CTAG_FILTER; - - return request; + *request &= ~NETIF_F_HW_VLAN_CTAG_FILTER; }
/** diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c index f6396ac64006..1c4c039dff9b 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c @@ -1815,34 +1815,32 @@ static const struct udp_tunnel_nic_info liquidio_udp_tunnels = { * @param request features requested * @returns updated features list */ -static netdev_features_t liquidio_fix_features(struct net_device *netdev, - netdev_features_t request) +static void liquidio_fix_features(struct net_device *netdev, + netdev_features_t *request) { struct lio *lio = netdev_priv(netdev);
- if ((request & NETIF_F_RXCSUM) && + if ((*request & NETIF_F_RXCSUM) && !(lio->dev_capability & NETIF_F_RXCSUM)) - request &= ~NETIF_F_RXCSUM; + *request &= ~NETIF_F_RXCSUM;
- if ((request & NETIF_F_HW_CSUM) && + if ((*request & NETIF_F_HW_CSUM) && !(lio->dev_capability & NETIF_F_HW_CSUM)) - request &= ~NETIF_F_HW_CSUM; + *request &= ~NETIF_F_HW_CSUM;
- if ((request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO)) - request &= ~NETIF_F_TSO; + if ((*request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO)) + *request &= ~NETIF_F_TSO;
- if ((request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6)) - request &= ~NETIF_F_TSO6; + if ((*request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6)) + *request &= ~NETIF_F_TSO6;
- if ((request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO)) - request &= ~NETIF_F_LRO; + if ((*request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO)) + *request &= ~NETIF_F_LRO;
/* Disable LRO if RXCSUM is off */ - if (!(request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) && + if (!(*request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) && (lio->dev_capability & NETIF_F_LRO)) - request &= ~NETIF_F_LRO; - - return request; + *request &= ~NETIF_F_LRO; }
/** \brief Net device set features diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 2b87565781a0..781138a71458 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -1773,16 +1773,14 @@ static int nicvf_config_loopback(struct nicvf *nic, return nicvf_send_msg_to_pf(nic, &mbx); }
-static netdev_features_t nicvf_fix_features(struct net_device *netdev, - netdev_features_t features) +static void nicvf_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct nicvf *nic = netdev_priv(netdev);
- if ((features & NETIF_F_LOOPBACK) && + if ((*features & NETIF_F_LOOPBACK) && netif_running(netdev) && !nic->loopback_supported) - features &= ~NETIF_F_LOOPBACK; - - return features; + *features &= ~NETIF_F_LOOPBACK; }
static int nicvf_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c index d246eee4b6d5..3fcd628fa449 100644 --- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c +++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c @@ -858,19 +858,16 @@ static int t1_set_mac_addr(struct net_device *dev, void *p) return 0; }
-static netdev_features_t t1_fix_features(struct net_device *dev, - netdev_features_t features) +static void t1_fix_features(struct net_device *dev, netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int t1_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c index 38e47703f9ab..140b40e5c54c 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c @@ -2593,19 +2593,17 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p) return 0; }
-static netdev_features_t cxgb_fix_features(struct net_device *dev, - netdev_features_t features) +static void cxgb_fix_features(struct net_device *dev, + netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int cxgb_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index a654169b9dfc..238416724a7c 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -3851,14 +3851,12 @@ static void cxgb_features_check(struct sk_buff *skb, struct net_device *dev, *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
-static netdev_features_t cxgb_fix_features(struct net_device *dev, - netdev_features_t features) +static void cxgb_fix_features(struct net_device *dev, + netdev_features_t *features) { /* Disable GRO, if RX_CSUM is disabled */ - if (!(features & NETIF_F_RXCSUM)) - features &= ~NETIF_F_GRO; - - return features; + if (!(*features & NETIF_F_RXCSUM)) + *features &= ~NETIF_F_GRO; }
static const struct net_device_ops cxgb4_netdev_ops = { diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index 4920a80a0460..6d46d460a0a1 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -1173,19 +1173,17 @@ static int cxgb4vf_change_mtu(struct net_device *dev, int new_mtu) return ret; }
-static netdev_features_t cxgb4vf_fix_features(struct net_device *dev, - netdev_features_t features) +static void cxgb4vf_fix_features(struct net_device *dev, + netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int cxgb4vf_set_features(struct net_device *dev, diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 6e745ca4c433..44397d1f44e4 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1976,13 +1976,11 @@ static int gmac_change_mtu(struct net_device *netdev, int new_mtu) return 0; }
-static netdev_features_t gmac_fix_features(struct net_device *netdev, - netdev_features_t features) +static void gmac_fix_features(struct net_device *netdev, + netdev_features_t *features) { if (netdev->mtu + ETH_HLEN + VLAN_HLEN > MTU_SIZE_BIT_MASK) - features &= ~GMAC_OFFLOAD_FEATURES; - - return features; + *features &= ~GMAC_OFFLOAD_FEATURES; }
static int gmac_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 343c605c4be8..1e08c18c813f 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -1793,20 +1793,19 @@ static int hns_nic_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t hns_nic_fix_features( - struct net_device *netdev, netdev_features_t features) +static void hns_nic_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct hns_nic_priv *priv = netdev_priv(netdev);
switch (priv->enet_ver) { case AE_VERSION_1: - features &= ~(NETIF_F_TSO | NETIF_F_TSO6 | + *features &= ~(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_FILTER); break; default: break; } - return features; }
static int hns_nic_uc_sync(struct net_device *netdev, const unsigned char *addr) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c index 9965e8d5d0a9..cce66faa477c 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c @@ -888,18 +888,16 @@ static int hinic_set_features(struct net_device *netdev, features, false); }
-static netdev_features_t hinic_fix_features(struct net_device *netdev, - netdev_features_t features) +static void hinic_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct hinic_dev *nic_dev = netdev_priv(netdev);
/* If Rx checksum is disabled, then LRO should also be disabled */ - if (!(features & NETIF_F_RXCSUM)) { + if (!(*features & NETIF_F_RXCSUM)) { netif_info(nic_dev, drv, netdev, "disabling LRO as RXCSUM is off\n"); - features &= ~NETIF_F_LRO; + *features &= ~NETIF_F_LRO; } - - return features; }
static const struct net_device_ops hinic_netdev_ops = { diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 3d9b4f99d357..1afffcea1c02 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -749,8 +749,8 @@ static void netdev_get_drvinfo(struct net_device *dev, strlcpy(info->version, ibmveth_driver_version, sizeof(info->version)); }
-static netdev_features_t ibmveth_fix_features(struct net_device *dev, - netdev_features_t features) +static void ibmveth_fix_features(struct net_device *dev, + netdev_features_t *features) { /* * Since the ibmveth firmware interface does not have the @@ -761,10 +761,8 @@ static netdev_features_t ibmveth_fix_features(struct net_device *dev, * checksummed. */
- if (!(features & NETIF_F_RXCSUM)) - features &= ~NETIF_F_CSUM_MASK; - - return features; + if (!(*features & NETIF_F_RXCSUM)) + *features &= ~NETIF_F_CSUM_MASK; }
static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index bed4f040face..e333ca1e7395 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -787,18 +787,16 @@ static int e1000_is_need_ioport(struct pci_dev *pdev) } }
-static netdev_features_t e1000_fix_features(struct net_device *netdev, - netdev_features_t features) +static void e1000_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int e1000_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 900b3ab998bd..5dd183e0cb0f 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -7287,25 +7287,23 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) } }
-static netdev_features_t e1000_fix_features(struct net_device *netdev, - netdev_features_t features) +static void e1000_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw;
/* Jumbo frame workaround on 82579 and newer requires CRC be stripped */ if ((hw->mac.type >= e1000_pch2lan) && (netdev->mtu > ETH_DATA_LEN)) - features &= ~NETIF_F_RXFCS; + *features &= ~NETIF_F_RXFCS;
/* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int e1000_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index b066f1864b3f..9a086211af4a 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -3437,17 +3437,15 @@ static void iavf_features_check(struct sk_buff *skb, struct net_device *dev, * * Returns fixed-up features bits **/ -static netdev_features_t iavf_fix_features(struct net_device *netdev, - netdev_features_t features) +static void iavf_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct iavf_adapter *adapter = netdev_priv(netdev);
if (!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)) - features &= ~(NETIF_F_HW_VLAN_CTAG_TX | + *features &= ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER); - - return features; }
static const struct net_device_ops iavf_netdev_ops = { diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 82b59adf8034..2e4a53c76c60 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2433,18 +2433,16 @@ void igb_reset(struct igb_adapter *adapter) igb_get_phy_info(hw); }
-static netdev_features_t igb_fix_features(struct net_device *netdev, - netdev_features_t features) +static void igb_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int igb_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index fdb3ed051456..13b89a742ebc 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4915,18 +4915,16 @@ static void igc_get_stats64(struct net_device *netdev, spin_unlock(&adapter->stats64_lock); }
-static netdev_features_t igc_fix_features(struct net_device *netdev, - netdev_features_t features) +static void igc_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_CTAG_TX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_CTAG_TX; else - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int igc_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index 1588376d4c67..34c1bfc75b7b 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c @@ -293,17 +293,15 @@ ixgb_reset(struct ixgb_adapter *adapter) } }
-static netdev_features_t -ixgb_fix_features(struct net_device *netdev, netdev_features_t features) +static void ixgb_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* * Tx VLAN insertion does not work per HW design when Rx stripping is * disabled. */ - if (!(features & NETIF_F_HW_VLAN_CTAG_RX)) - features &= ~NETIF_F_HW_VLAN_CTAG_TX; - - return features; + if (!(*features & NETIF_F_HW_VLAN_CTAG_RX)) + *features &= ~NETIF_F_HW_VLAN_CTAG_TX; }
static int diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index e39d3983a455..c43c99a44914 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -9682,25 +9682,23 @@ void ixgbe_do_reset(struct net_device *netdev) ixgbe_reset(adapter); }
-static netdev_features_t ixgbe_fix_features(struct net_device *netdev, - netdev_features_t features) +static void ixgbe_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct ixgbe_adapter *adapter = netdev_priv(netdev);
/* If Rx checksum is disabled, then RSC/LRO should also be disabled */ - if (!(features & NETIF_F_RXCSUM)) - features &= ~NETIF_F_LRO; + if (!(*features & NETIF_F_RXCSUM)) + *features &= ~NETIF_F_LRO;
/* Turn off LRO if not RSC capable */ if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) - features &= ~NETIF_F_LRO; + *features &= ~NETIF_F_LRO;
- if (adapter->xdp_prog && (features & NETIF_F_LRO)) { + if (adapter->xdp_prog && (*features & NETIF_F_LRO)) { e_dev_err("LRO is not supported with XDP\n"); - features &= ~NETIF_F_LRO; + *features &= ~NETIF_F_LRO; } - - return features; }
static void ixgbe_reset_l2fw_offload(struct ixgbe_adapter *adapter) diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 1bdc4f23e1e5..11749bd7276d 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c @@ -2659,12 +2659,11 @@ jme_set_msglevel(struct net_device *netdev, u32 value) jme->msg_enable = value; }
-static netdev_features_t -jme_fix_features(struct net_device *netdev, netdev_features_t features) +static void jme_fix_features(struct net_device *netdev, + netdev_features_t *features) { if (netdev->mtu > 1900) - features &= ~(NETIF_F_ALL_TSO | NETIF_F_CSUM_MASK); - return features; + *features &= ~(NETIF_F_ALL_TSO | NETIF_F_CSUM_MASK); }
static int diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 9d460a270601..a4093977cd2b 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -3770,19 +3770,17 @@ static int mvneta_change_mtu(struct net_device *dev, int mtu) return 0; }
-static netdev_features_t mvneta_fix_features(struct net_device *dev, - netdev_features_t features) +static void mvneta_fix_features(struct net_device *dev, + netdev_features_t *features) { struct mvneta_port *pp = netdev_priv(dev);
if (pp->tx_csum_limit && dev->mtu > pp->tx_csum_limit) { - features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO); + *features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO); netdev_info(dev, "Disable IP checksum for MTU greater than %dB\n", pp->tx_csum_limit); } - - return features; }
/* Get mac address */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 53df7fff92c4..35602e49d60d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1773,15 +1773,13 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev) return NETDEV_TX_OK; }
-static netdev_features_t otx2_fix_features(struct net_device *dev, - netdev_features_t features) +static void otx2_fix_features(struct net_device *dev, + netdev_features_t *features) { - if (features & NETIF_F_HW_VLAN_CTAG_RX) - features |= NETIF_F_HW_VLAN_STAG_RX; + if (*features & NETIF_F_HW_VLAN_CTAG_RX) + *features |= NETIF_F_HW_VLAN_STAG_RX; else - features &= ~NETIF_F_HW_VLAN_STAG_RX; - - return features; + *features &= ~NETIF_F_HW_VLAN_STAG_RX; }
static void otx2_set_rx_mode(struct net_device *netdev) diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 3cb9c1271328..8b1af582c250 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -4358,8 +4358,8 @@ static int sky2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom return sky2_vpd_write(sky2->hw, cap, data, eeprom->offset, eeprom->len); }
-static netdev_features_t sky2_fix_features(struct net_device *dev, - netdev_features_t features) +static void sky2_fix_features(struct net_device *dev, + netdev_features_t *features) { const struct sky2_port *sky2 = netdev_priv(dev); const struct sky2_hw *hw = sky2->hw; @@ -4369,18 +4369,16 @@ static netdev_features_t sky2_fix_features(struct net_device *dev, */ if (dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U) { netdev_info(dev, "checksum offload not possible with jumbo frames\n"); - features &= ~(NETIF_F_TSO | NETIF_F_SG | NETIF_F_CSUM_MASK); + *features &= ~(NETIF_F_TSO | NETIF_F_SG | NETIF_F_CSUM_MASK); }
/* Some hardware requires receive checksum for RSS to work. */ - if ( (features & NETIF_F_RXHASH) && - !(features & NETIF_F_RXCSUM) && - (sky2->hw->flags & SKY2_HW_RSS_CHKSUM)) { + if ((*features & NETIF_F_RXHASH) && + !(*features & NETIF_F_RXCSUM) && + (sky2->hw->flags & SKY2_HW_RSS_CHKSUM)) { netdev_info(dev, "receive hashing forces receive checksum\n"); - features |= NETIF_F_RXCSUM; + *features |= NETIF_F_RXCSUM; } - - return features; }
static int sky2_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 398c23cec815..6a6ef1c29657 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2021,21 +2021,19 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev, return 0; }
-static netdev_features_t mtk_fix_features(struct net_device *dev, - netdev_features_t features) +static void mtk_fix_features(struct net_device *dev, + netdev_features_t *features) { - if (!(features & NETIF_F_LRO)) { + if (!(*features & NETIF_F_LRO)) { struct mtk_mac *mac = netdev_priv(dev); int ip_cnt = mtk_hwlro_get_ip_cnt(mac);
if (ip_cnt) { netdev_info(dev, "RX flow is programmed, LRO should keep on\n");
- features |= NETIF_F_LRO; + *features |= NETIF_F_LRO; } } - - return features; }
static int mtk_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index bc504dcb1c2b..06bc81d874be 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2479,8 +2479,8 @@ static int mlx4_en_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } }
-static netdev_features_t mlx4_en_fix_features(struct net_device *netdev, - netdev_features_t features) +static void mlx4_en_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct mlx4_en_priv *en_priv = netdev_priv(netdev); struct mlx4_en_dev *mdev = en_priv->mdev; @@ -2489,13 +2489,11 @@ static netdev_features_t mlx4_en_fix_features(struct net_device *netdev, * enable/disable make sure S-TAG flag is always in same state as * C-TAG. */ - if (features & NETIF_F_HW_VLAN_CTAG_RX && + if (*features & NETIF_F_HW_VLAN_CTAG_RX && !(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN)) - features |= NETIF_F_HW_VLAN_STAG_RX; + *features |= NETIF_F_HW_VLAN_STAG_RX; else - features &= ~NETIF_F_HW_VLAN_STAG_RX; - - return features; + *features &= ~NETIF_F_HW_VLAN_STAG_RX; }
static int mlx4_en_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 6fdc2a793c1f..4092210fb079 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3397,8 +3397,8 @@ static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev return features; }
-static netdev_features_t mlx5e_fix_features(struct net_device *netdev, - netdev_features_t features) +static void mlx5e_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_params *params; @@ -3410,20 +3410,20 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, /* HW strips the outer C-tag header, this is a problem * for S-tag traffic. */ - features &= ~NETIF_F_HW_VLAN_CTAG_RX; + *features &= ~NETIF_F_HW_VLAN_CTAG_RX; if (!params->vlan_strip_disable) netdev_warn(netdev, "Dropping C-tag vlan stripping offload due to S-tag vlan\n"); }
if (!MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_STRIDING_RQ)) { - if (features & NETIF_F_LRO) { + if (*features & NETIF_F_LRO) { netdev_warn(netdev, "Disabling LRO, not supported in legacy RQ\n"); - features &= ~NETIF_F_LRO; + *features &= ~NETIF_F_LRO; } }
if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)) { - features &= ~NETIF_F_RXHASH; + *features &= ~NETIF_F_RXHASH; if (netdev->features & NETIF_F_RXHASH) netdev_warn(netdev, "Disabling rxhash, not supported when CQE compress is active\n"); } @@ -3432,8 +3432,6 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, features = mlx5e_fix_uplink_rep_features(netdev, features);
mutex_unlock(&priv->state_lock); - - return features; }
static bool mlx5e_xsk_validate_mtu(struct net_device *netdev, diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index df4a3f3da83a..5f720e97a558 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c @@ -2639,19 +2639,17 @@ static void vxge_poll_vp_lockup(struct timer_list *t) mod_timer(&vdev->vp_lockup_timer, jiffies + HZ / 1000); }
-static netdev_features_t vxge_fix_features(struct net_device *dev, - netdev_features_t features) +static void vxge_fix_features(struct net_device *dev, + netdev_features_t *features) { - netdev_features_t changed = dev->features ^ features; + netdev_features_t changed = dev->features ^ *features;
/* Enabling RTH requires some of the logic in vxge_device_register and a * vpath reset. Due to these restrictions, only allow modification * while the interface is down. */ if ((changed & NETIF_F_RXHASH) && netif_running(dev)) - features ^= NETIF_F_RXHASH; - - return features; + *features ^= NETIF_F_RXHASH; }
static int vxge_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index f04b79f04a9d..fcb2e30e8ac7 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -232,11 +232,11 @@ static int nfp_repr_open(struct net_device *netdev) return err; }
-static netdev_features_t -nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) +static void nfp_repr_fix_features(struct net_device *netdev, + netdev_features_t *features) { struct nfp_repr *repr = netdev_priv(netdev); - netdev_features_t old_features = features; + netdev_features_t old_features = *features; netdev_features_t lower_features; struct net_device *lower_dev;
@@ -246,11 +246,9 @@ nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) if (lower_features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- netdev_intersect_features(&features, features, lower_features); - features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC); - features |= NETIF_F_LLTX; - - return features; + netdev_intersect_features(features, *features, lower_features); + *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC); + *features |= NETIF_F_LLTX; }
const struct net_device_ops nfp_repr_netdev_ops = { diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index ef3fb4cc90af..e1f16988cb75 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -4920,14 +4920,12 @@ static int nv_set_loopback(struct net_device *dev, netdev_features_t features) return retval; }
-static netdev_features_t nv_fix_features(struct net_device *dev, - netdev_features_t features) +static void nv_fix_features(struct net_device *dev, + netdev_features_t *features) { /* vlan is dependent on rx checksum offload */ - if (features & (NETIF_F_HW_VLAN_CTAG_TX|NETIF_F_HW_VLAN_CTAG_RX)) - features |= NETIF_F_RXCSUM; - - return features; + if (*features & (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX)) + *features |= NETIF_F_RXCSUM; }
static void nv_vlan_mode(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 344ea1143454..251668839926 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -517,16 +517,14 @@ static void netxen_set_multicast_list(struct net_device *dev) adapter->set_multi(dev); }
-static netdev_features_t netxen_fix_features(struct net_device *dev, - netdev_features_t features) +static void netxen_fix_features(struct net_device *dev, + netdev_features_t *features) { - if (!(features & NETIF_F_RXCSUM)) { + if (!(*features & NETIF_F_RXCSUM)) { netdev_info(dev, "disabling LRO as RXCSUM is off\n");
- features &= ~NETIF_F_LRO; + *features &= ~NETIF_F_LRO; } - - return features; }
static int netxen_set_features(struct net_device *dev, diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h index c1f26a2e374d..ada71452d454 100644 --- a/drivers/net/ethernet/qlogic/qede/qede.h +++ b/drivers/net/ethernet/qlogic/qede/qede.h @@ -545,8 +545,7 @@ int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid); void qede_vlan_mark_nonconfigured(struct qede_dev *edev); int qede_configure_vlan_filters(struct qede_dev *edev);
-netdev_features_t qede_fix_features(struct net_device *dev, - netdev_features_t features); +void qede_fix_features(struct net_device *dev, netdev_features_t *features); int qede_set_features(struct net_device *dev, netdev_features_t features); void qede_set_rx_mode(struct net_device *ndev); void qede_config_rx_mode(struct net_device *ndev); diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index f99b085b56a5..ea89a3afa206 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c @@ -910,16 +910,13 @@ static void qede_set_features_reload(struct qede_dev *edev, edev->ndev->features = args->u.features; }
-netdev_features_t qede_fix_features(struct net_device *dev, - netdev_features_t features) +void qede_fix_features(struct net_device *dev, netdev_features_t *features) { struct qede_dev *edev = netdev_priv(dev);
if (edev->xdp_prog || edev->ndev->mtu > PAGE_SIZE || - !(features & NETIF_F_GRO)) - features &= ~NETIF_F_GRO_HW; - - return features; + !(*features & NETIF_F_GRO)) + *features &= ~NETIF_F_GRO_HW; }
int qede_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index be7abee160e7..7fbf895becdd 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h @@ -1622,8 +1622,7 @@ int qlcnic_82xx_read_phys_port_id(struct qlcnic_adapter *); int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *, u32); int qlcnic_change_mtu(struct net_device *netdev, int new_mtu); -netdev_features_t qlcnic_fix_features(struct net_device *netdev, - netdev_features_t features); +void qlcnic_fix_features(struct net_device *netdev, netdev_features_t *features); int qlcnic_set_features(struct net_device *netdev, netdev_features_t features); int qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); void qlcnic_update_cmd_producer(struct qlcnic_host_tx_ring *); diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c index 4b8bc46f55c2..e6ed7f8413b4 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c @@ -1053,8 +1053,7 @@ static netdev_features_t qlcnic_process_flags(struct qlcnic_adapter *adapter, return features; }
-netdev_features_t qlcnic_fix_features(struct net_device *netdev, - netdev_features_t features) +void qlcnic_fix_features(struct net_device *netdev, netdev_features_t *features) { struct qlcnic_adapter *adapter = netdev_priv(netdev); netdev_features_t changed; @@ -1062,10 +1061,10 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev, if (qlcnic_82xx_check(adapter) && (adapter->flags & QLCNIC_ESWITCH_ENABLED)) { if (adapter->flags & QLCNIC_APP_CHANGED_FLAGS) { - features = qlcnic_process_flags(adapter, features); + *features = qlcnic_process_flags(adapter, *features); } else { - changed = features ^ netdev->features; - features ^= changed & (NETIF_F_RXCSUM | + changed = *features ^ netdev->features; + *features ^= changed & (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_TSO | @@ -1073,10 +1072,8 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev, } }
- if (!(features & NETIF_F_RXCSUM)) - features &= ~NETIF_F_LRO; - - return features; + if (!(*features & NETIF_F_RXCSUM)) + *features &= ~NETIF_F_LRO; }
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 3d753ddd1a89..8affae2b55a6 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1431,19 +1431,17 @@ static int rtl8169_get_regs_len(struct net_device *dev) return R8169_REGS_SIZE; }
-static netdev_features_t rtl8169_fix_features(struct net_device *dev, - netdev_features_t features) +static void rtl8169_fix_features(struct net_device *dev, + netdev_features_t *features) { struct rtl8169_private *tp = netdev_priv(dev);
if (dev->mtu > TD_MSS_MAX) - features &= ~NETIF_F_ALL_TSO; + *features &= ~NETIF_F_ALL_TSO;
if (dev->mtu > ETH_DATA_LEN && tp->mac_version > RTL_GIGA_MAC_VER_06) - features &= ~(NETIF_F_CSUM_MASK | NETIF_F_ALL_TSO); - - return features; + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_ALL_TSO); }
static void rtl_set_rx_config_features(struct rtl8169_private *tp, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 553c4403258a..124b3b81001f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5457,16 +5457,16 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) return 0; }
-static netdev_features_t stmmac_fix_features(struct net_device *dev, - netdev_features_t features) +static void stmmac_fix_features(struct net_device *dev, + netdev_features_t *features) { struct stmmac_priv *priv = netdev_priv(dev);
if (priv->plat->rx_coe == STMMAC_RX_COE_NONE) - features &= ~NETIF_F_RXCSUM; + *features &= ~NETIF_F_RXCSUM;
if (!priv->plat->tx_coe) - features &= ~NETIF_F_CSUM_MASK; + *features &= ~NETIF_F_CSUM_MASK;
/* Some GMAC devices have a bugged Jumbo frame support that * needs to have the Tx COE disabled for oversized frames @@ -5474,17 +5474,15 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, * the TX csum insertion in the TDES and not use SF. */ if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN)) - features &= ~NETIF_F_CSUM_MASK; + *features &= ~NETIF_F_CSUM_MASK;
/* Disable tso if asked by ethtool */ if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) { - if (features & NETIF_F_TSO) + if (*features & NETIF_F_TSO) priv->tso = true; else priv->tso = false; } - - return features; }
static int stmmac_set_features(struct net_device *netdev, diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 382bebc2420d..5371328422ec 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1919,21 +1919,19 @@ static int netvsc_set_ringparam(struct net_device *ndev, return ret; }
-static netdev_features_t netvsc_fix_features(struct net_device *ndev, - netdev_features_t features) +static void netvsc_fix_features(struct net_device *ndev, + netdev_features_t *features) { struct net_device_context *ndevctx = netdev_priv(ndev); struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
if (!nvdev || nvdev->destroy) - return features; + return;
- if ((features & NETIF_F_LRO) && netvsc_xdp_get(nvdev)) { - features ^= NETIF_F_LRO; + if ((*features & NETIF_F_LRO) && netvsc_xdp_get(nvdev)) { + *features ^= NETIF_F_LRO; netdev_info(ndev, "Skip LRO - unsupported with XDP\n"); } - - return features; }
static int netvsc_set_features(struct net_device *ndev, diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index c0b21a5580d5..8fcc91c0b0f4 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -235,19 +235,17 @@ static netdev_tx_t ipvlan_start_xmit(struct sk_buff *skb, return ret; }
-static netdev_features_t ipvlan_fix_features(struct net_device *dev, - netdev_features_t features) +static void ipvlan_fix_features(struct net_device *dev, + netdev_features_t *features) { struct ipvl_dev *ipvlan = netdev_priv(dev);
- features |= NETIF_F_ALL_FOR_ALL; - features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES); - features = netdev_increment_features(ipvlan->phy_dev->features, - features, features); - features |= IPVLAN_ALWAYS_ON; - features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON); - - return features; + *features |= NETIF_F_ALL_FOR_ALL; + *features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES); + *features = netdev_increment_features(ipvlan->phy_dev->features, + *features, *features); + *features |= IPVLAN_ALWAYS_ON; + *features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON); }
static void ipvlan_change_rx_flags(struct net_device *dev, int change) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 93dc48b9b4f2..601b833a40bd 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3470,20 +3470,20 @@ static void macsec_dev_uninit(struct net_device *dev) free_percpu(dev->tstats); }
-static netdev_features_t macsec_fix_features(struct net_device *dev, - netdev_features_t features) +static void macsec_fix_features(struct net_device *dev, + netdev_features_t *features) { struct macsec_dev *macsec = macsec_priv(dev); struct net_device *real_dev = macsec->real_dev;
- if (macsec_is_offloaded(macsec)) - return REAL_DEV_FEATURES(real_dev); + if (macsec_is_offloaded(macsec)) { + *features = REAL_DEV_FEATURES(real_dev); + return; + }
- features &= (real_dev->features & SW_MACSEC_FEATURES) | + *features &= (real_dev->features & SW_MACSEC_FEATURES) | NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES; - features |= NETIF_F_LLTX; - - return features; + *features |= NETIF_F_LLTX; }
static int macsec_dev_open(struct net_device *dev) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 35f46ad040b0..27cd9c08bb1e 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1067,23 +1067,21 @@ static int macvlan_ethtool_get_ts_info(struct net_device *dev, return 0; }
-static netdev_features_t macvlan_fix_features(struct net_device *dev, - netdev_features_t features) +static void macvlan_fix_features(struct net_device *dev, + netdev_features_t *features) { struct macvlan_dev *vlan = netdev_priv(dev); netdev_features_t lowerdev_features = vlan->lowerdev->features; netdev_features_t mask;
- features |= NETIF_F_ALL_FOR_ALL; - features &= (vlan->set_features | ~MACVLAN_FEATURES); - mask = features; + *features |= NETIF_F_ALL_FOR_ALL; + *features &= (vlan->set_features | ~MACVLAN_FEATURES); + mask = *features;
- lowerdev_features &= (features | ~NETIF_F_LRO); - features = netdev_increment_features(lowerdev_features, features, mask); - features |= ALWAYS_ON_FEATURES; - features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES); - - return features; + lowerdev_features &= (*features | ~NETIF_F_LRO); + *features = netdev_increment_features(lowerdev_features, *features, mask); + *features |= ALWAYS_ON_FEATURES; + *features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES); }
#ifdef CONFIG_NET_POLL_CONTROLLER diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index dd7917cab2b1..340be925d4eb 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1995,28 +1995,26 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev) return err; }
-static netdev_features_t team_fix_features(struct net_device *dev, - netdev_features_t features) +static void team_fix_features(struct net_device *dev, + netdev_features_t *features) { struct team_port *port; struct team *team = netdev_priv(dev); netdev_features_t mask;
- mask = features; - features &= ~NETIF_F_ONE_FOR_ALL; - features |= NETIF_F_ALL_FOR_ALL; + mask = *features; + *features &= ~NETIF_F_ONE_FOR_ALL; + *features |= NETIF_F_ALL_FOR_ALL;
rcu_read_lock(); list_for_each_entry_rcu(port, &team->port_list, list) { - features = netdev_increment_features(features, - port->dev->features, - mask); + *features = netdev_increment_features(*features, + port->dev->features, + mask); } rcu_read_unlock();
- features = netdev_add_tso_features(features, mask); - - return features; + *features = netdev_add_tso_features(*features, mask); }
static int team_change_carrier(struct net_device *dev, bool new_carrier) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index fecc9a1d293a..d89a9874eb37 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1079,12 +1079,13 @@ static void tun_net_mclist(struct net_device *dev) */ }
-static netdev_features_t tun_net_fix_features(struct net_device *dev, - netdev_features_t features) +static void tun_net_fix_features(struct net_device *dev, + netdev_features_t *features) { struct tun_struct *tun = netdev_priv(dev);
- return (features & tun->set_features) | (features & ~TUN_USER_FEATURES); + *features = (*features & tun->set_features) | + (*features & ~TUN_USER_FEATURES); }
static void tun_set_headroom(struct net_device *dev, int new_hr) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 50eb43e5bf45..82c900d7ba7b 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1382,8 +1382,8 @@ static int veth_get_iflink(const struct net_device *dev) return iflink; }
-static netdev_features_t veth_fix_features(struct net_device *dev, - netdev_features_t features) +static void veth_fix_features(struct net_device *dev, + netdev_features_t *features) { struct veth_priv *priv = netdev_priv(dev); struct net_device *peer; @@ -1393,12 +1393,10 @@ static netdev_features_t veth_fix_features(struct net_device *dev, struct veth_priv *peer_priv = netdev_priv(peer);
if (peer_priv->_xdp_prog) - features &= ~NETIF_F_GSO_SOFTWARE; + *features &= ~NETIF_F_GSO_SOFTWARE; } if (priv->_xdp_prog) - features |= NETIF_F_GRO; - - return features; + *features |= NETIF_F_GRO; }
static int veth_set_features(struct net_device *dev, diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index e840547cd19e..6a5827c21c63 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -246,14 +246,12 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) ethtool_sprintf(&buf, vmxnet3_global_stats[i].desc); }
-netdev_features_t vmxnet3_fix_features(struct net_device *netdev, - netdev_features_t features) +void vmxnet3_fix_features(struct net_device *netdev, + netdev_features_t *features) { /* If Rx checksum is disabled, then LRO should also be disabled */ - if (!(features & NETIF_F_RXCSUM)) - features &= ~NETIF_F_LRO; - - return features; + if (!(*features & NETIF_F_RXCSUM)) + *features &= ~NETIF_F_LRO; }
void vmxnet3_features_check(struct sk_buff *skb, struct net_device *netdev, diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index a711759ebb00..aed4e1bf9298 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -475,8 +475,8 @@ vmxnet3_tq_destroy_all(struct vmxnet3_adapter *adapter); void vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter);
-netdev_features_t -vmxnet3_fix_features(struct net_device *netdev, netdev_features_t features); +void +vmxnet3_fix_features(struct net_device *netdev, netdev_features_t *features);
void vmxnet3_features_check(struct sk_buff *skb, diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index c58996c1e230..f964f0a402a6 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -374,23 +374,21 @@ static int xenvif_change_mtu(struct net_device *dev, int mtu) return 0; }
-static netdev_features_t xenvif_fix_features(struct net_device *dev, - netdev_features_t features) +static void xenvif_fix_features(struct net_device *dev, + netdev_features_t *features) { struct xenvif *vif = netdev_priv(dev);
if (!vif->can_sg) - features &= ~NETIF_F_SG; + *features &= ~NETIF_F_SG; if (~(vif->gso_mask) & GSO_BIT(TCPV4)) - features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO; if (~(vif->gso_mask) & GSO_BIT(TCPV6)) - features &= ~NETIF_F_TSO6; + *features &= ~NETIF_F_TSO6; if (!vif->ip_csum) - features &= ~NETIF_F_IP_CSUM; + *features &= ~NETIF_F_IP_CSUM; if (!vif->ipv6_csum) - features &= ~NETIF_F_IPV6_CSUM; - - return features; + *features &= ~NETIF_F_IPV6_CSUM; }
static const struct xenvif_stat { diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 65c134ac2be5..79752f16277a 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1386,29 +1386,27 @@ static void xennet_release_rx_bufs(struct netfront_queue *queue) spin_unlock_bh(&queue->rx_lock); }
-static netdev_features_t xennet_fix_features(struct net_device *dev, - netdev_features_t features) +static void xennet_fix_features(struct net_device *dev, + netdev_features_t *features) { struct netfront_info *np = netdev_priv(dev);
- if (features & NETIF_F_SG && + if (*features & NETIF_F_SG && !xenbus_read_unsigned(np->xbdev->otherend, "feature-sg", 0)) - features &= ~NETIF_F_SG; + *features &= ~NETIF_F_SG;
- if (features & NETIF_F_IPV6_CSUM && + if (*features & NETIF_F_IPV6_CSUM && !xenbus_read_unsigned(np->xbdev->otherend, "feature-ipv6-csum-offload", 0)) - features &= ~NETIF_F_IPV6_CSUM; + *features &= ~NETIF_F_IPV6_CSUM;
- if (features & NETIF_F_TSO && + if (*features & NETIF_F_TSO && !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv4", 0)) - features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO;
- if (features & NETIF_F_TSO6 && + if (*features & NETIF_F_TSO6 && !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv6", 0)) - features &= ~NETIF_F_TSO6; - - return features; + *features &= ~NETIF_F_TSO6; }
static int xennet_set_features(struct net_device *dev, diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 06d02e2e2b66..2b260754b38e 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -1094,7 +1094,7 @@ int qeth_hw_trap(struct qeth_card *, enum qeth_diags_trap_action); int qeth_setassparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long); int qeth_set_features(struct net_device *, netdev_features_t); void qeth_enable_hw_features(struct net_device *dev); -netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t); +void qeth_fix_features(struct net_device *dev, netdev_features_t *features); void qeth_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t *features); void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 6811af22ee2b..d8269f4f7a83 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -6927,26 +6927,24 @@ int qeth_set_features(struct net_device *dev, netdev_features_t features) } EXPORT_SYMBOL_GPL(qeth_set_features);
-netdev_features_t qeth_fix_features(struct net_device *dev, - netdev_features_t features) +void qeth_fix_features(struct net_device *dev, netdev_features_t *features) { struct qeth_card *card = dev->ml_priv;
QETH_CARD_TEXT(card, 2, "fixfeat"); if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) - features &= ~NETIF_F_IP_CSUM; + *features &= ~NETIF_F_IP_CSUM; if (!qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) - features &= ~NETIF_F_IPV6_CSUM; + *features &= ~NETIF_F_IPV6_CSUM; if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM) && !qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) - features &= ~NETIF_F_RXCSUM; + *features &= ~NETIF_F_RXCSUM; if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) - features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO; if (!qeth_is_supported6(card, IPA_OUTBOUND_TSO)) - features &= ~NETIF_F_TSO6; + *features &= ~NETIF_F_TSO6;
- QETH_CARD_HEX(card, 2, &features, sizeof(features)); - return features; + QETH_CARD_HEX(card, 2, features, sizeof(*features)); } EXPORT_SYMBOL_GPL(qeth_fix_features);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d62edd4c99a9..43eb57fa9434 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1481,8 +1481,8 @@ struct net_device_ops { bool all_slaves); struct net_device* (*ndo_sk_get_lower_dev)(struct net_device *dev, struct sock *sk); - netdev_features_t (*ndo_fix_features)(struct net_device *dev, - netdev_features_t features); + void (*ndo_fix_features)(struct net_device *dev, + netdev_features_t *features); int (*ndo_set_features)(struct net_device *dev, netdev_features_t features); int (*ndo_neigh_construct)(struct net_device *dev, diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 2987201ec93d..9f90a587d4e5 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -633,11 +633,11 @@ void vlan_dev_uninit(struct net_device *dev) } }
-static netdev_features_t vlan_dev_fix_features(struct net_device *dev, - netdev_features_t features) +static void vlan_dev_fix_features(struct net_device *dev, + netdev_features_t *features) { struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; - netdev_features_t old_features = features; + netdev_features_t old_features = *features; netdev_features_t lower_features;
netdev_intersect_features(&lower_features, @@ -649,11 +649,9 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev, */ if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM; - netdev_intersect_features(&features, features, lower_features); - features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); - features |= NETIF_F_LLTX; - - return features; + netdev_intersect_features(features, *features, lower_features); + *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); + *features |= NETIF_F_LLTX; }
static int vlan_ethtool_get_link_ksettings(struct net_device *dev, diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 8d6bab244c4a..622559aff2dd 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -288,12 +288,11 @@ static int br_get_link_ksettings(struct net_device *dev, return 0; }
-static netdev_features_t br_fix_features(struct net_device *dev, - netdev_features_t features) +static void br_fix_features(struct net_device *dev, netdev_features_t *features) { struct net_bridge *br = netdev_priv(dev);
- return br_features_recompute(br, features); + *features = br_features_recompute(br, *features); }
#ifdef CONFIG_NET_POLL_CONTROLLER diff --git a/net/core/dev.c b/net/core/dev.c index 7b71d322c68e..95d0c4f0da58 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9923,7 +9923,7 @@ int __netdev_update_features(struct net_device *dev) netdev_get_wanted_features(dev, &features);
if (dev->netdev_ops->ndo_fix_features) - features = dev->netdev_ops->ndo_fix_features(dev, features); + dev->netdev_ops->ndo_fix_features(dev, &features);
/* driver might be less strict about feature dependencies */ features = netdev_fix_features(dev, features); diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 26c32407f029..acaf48a1e136 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -201,12 +201,12 @@ static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr, return features; }
-static netdev_features_t hsr_fix_features(struct net_device *dev, - netdev_features_t features) +static void hsr_fix_features(struct net_device *dev, + netdev_features_t *features) { struct hsr_priv *hsr = netdev_priv(dev);
- return hsr_features_recompute(hsr, features); + *features = hsr_features_recompute(hsr, *features); }
static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of ndo_fix_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com
arch/um/drivers/vector_kern.c | 7 ++-- drivers/infiniband/ulp/ipoib/ipoib_main.c | 7 ++-- drivers/net/bonding/bond_main.c | 24 ++++++------- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 28 +++++++-------- drivers/net/ethernet/atheros/alx/main.c | 8 ++--- .../net/ethernet/atheros/atl1c/atl1c_main.c | 14 ++++---- .../net/ethernet/atheros/atl1e/atl1e_main.c | 12 +++---- drivers/net/ethernet/atheros/atlx/atl2.c | 12 +++---- drivers/net/ethernet/atheros/atlx/atlx.c | 12 +++---- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 29 +++++++--------- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 3 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 27 +++++++-------- drivers/net/ethernet/broadcom/tg3.c | 8 ++--- .../net/ethernet/cavium/liquidio/lio_main.c | 34 +++++++++---------- .../ethernet/cavium/liquidio/lio_vf_main.c | 30 ++++++++-------- .../net/ethernet/cavium/thunder/nicvf_main.c | 10 +++--- drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 11 +++--- .../net/ethernet/chelsio/cxgb3/cxgb3_main.c | 12 +++---- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 10 +++--- .../ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 12 +++---- drivers/net/ethernet/cortina/gemini.c | 8 ++--- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 7 ++-- .../net/ethernet/huawei/hinic/hinic_main.c | 10 +++--- drivers/net/ethernet/ibm/ibmveth.c | 10 +++--- drivers/net/ethernet/intel/e1000/e1000_main.c | 12 +++---- drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++---- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 ++--- drivers/net/ethernet/intel/igb/igb_main.c | 12 +++---- drivers/net/ethernet/intel/igc/igc_main.c | 12 +++---- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 10 +++--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++----- drivers/net/ethernet/jme.c | 7 ++-- drivers/net/ethernet/marvell/mvneta.c | 8 ++--- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 12 +++---- drivers/net/ethernet/marvell/sky2.c | 16 ++++----- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++--- .../net/ethernet/mellanox/mlx4/en_netdev.c | 12 +++---- .../net/ethernet/mellanox/mlx5/core/en_main.c | 14 ++++---- .../net/ethernet/neterion/vxge/vxge-main.c | 10 +++--- .../net/ethernet/netronome/nfp/nfp_net_repr.c | 14 ++++---- drivers/net/ethernet/nvidia/forcedeth.c | 10 +++--- .../ethernet/qlogic/netxen/netxen_nic_main.c | 10 +++--- drivers/net/ethernet/qlogic/qede/qede.h | 3 +- .../net/ethernet/qlogic/qede/qede_filter.c | 9 ++--- drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 3 +- .../net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 15 ++++---- drivers/net/ethernet/realtek/r8169_main.c | 10 +++--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++---- drivers/net/hyperv/netvsc_drv.c | 12 +++---- drivers/net/ipvlan/ipvlan_main.c | 18 +++++----- drivers/net/macsec.c | 16 ++++----- drivers/net/macvlan.c | 20 +++++------ drivers/net/team/team.c | 20 +++++------ drivers/net/tun.c | 7 ++-- drivers/net/veth.c | 10 +++--- drivers/net/vmxnet3/vmxnet3_ethtool.c | 10 +++--- drivers/net/vmxnet3/vmxnet3_int.h | 4 +-- drivers/net/xen-netback/interface.c | 16 ++++----- drivers/net/xen-netfront.c | 22 ++++++------ drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 16 ++++----- include/linux/netdevice.h | 4 +-- net/8021q/vlan_dev.c | 14 ++++---- net/bridge/br_device.c | 5 ++- net/core/dev.c | 2 +- net/hsr/hsr_device.c | 6 ++-- 66 files changed, 349 insertions(+), 461 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index cde6db184c26..88cc24a58742 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -1342,11 +1342,10 @@ static void vector_net_tx_timeout(struct net_device *dev, unsigned int txqueue) schedule_work(&vp->reset_tx); }
-static netdev_features_t vector_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void vector_fix_features(struct net_device *dev,
netdev_features_t *features)
{
- features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
- return features;
- *features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
}
static int vector_set_features(struct net_device *dev, diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 0aa8629fdf62..488d50a82a87 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -214,14 +214,13 @@ static int ipoib_stop(struct net_device *dev) return 0; }
-static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_features_t features) +static void ipoib_fix_features(struct net_device *dev,
netdev_features_t *features)
{ 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);
- return features;
*features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO);
}
static int ipoib_change_mtu(struct net_device *dev, int new_mtu) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 77dc79a7f574..469509260a51 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1361,8 +1361,8 @@ static void bond_netpoll_cleanup(struct net_device *bond_dev)
/*---------------------------------- IOCTL ----------------------------------*/
-static netdev_features_t bond_fix_features(struct net_device *dev,
netdev_features_t features)
+static void bond_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct bonding *bond = netdev_priv(dev); struct list_head *iter; @@ -1371,24 +1371,22 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
#if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond))
features |= BOND_TLS_FEATURES;
else*features |= BOND_TLS_FEATURES;
features &= ~BOND_TLS_FEATURES;
*features &= ~BOND_TLS_FEATURES;
#endif
- mask = features;
- mask = *features;
- features &= ~NETIF_F_ONE_FOR_ALL;
- features |= NETIF_F_ALL_FOR_ALL;
*features &= ~NETIF_F_ONE_FOR_ALL;
*features |= NETIF_F_ALL_FOR_ALL;
bond_for_each_slave(bond, slave, iter) {
features = netdev_increment_features(features,
slave->dev->features,
mask);
*features = netdev_increment_features(*features,
slave->dev->features,
}mask);
- features = netdev_add_tso_features(features, mask);
- return features;
- *features = netdev_add_tso_features(*features, mask);
}
#define BOND_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index cc1f1a7a46ae..dff9eecac6e9 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c @@ -2182,8 +2182,8 @@ static int xgbe_setup_tc(struct net_device *netdev, enum tc_setup_type type, return 0; }
-static netdev_features_t xgbe_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void xgbe_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct xgbe_prv_data *pdata = netdev_priv(netdev); netdev_features_t vxlan_base; @@ -2191,38 +2191,36 @@ static netdev_features_t xgbe_fix_features(struct net_device *netdev, vxlan_base = NETIF_F_GSO_UDP_TUNNEL | NETIF_F_RX_UDP_TUNNEL_PORT;
if (!pdata->hw_feat.vxn)
return features;
return;
/* VXLAN CSUM requires VXLAN base */
- if ((features & NETIF_F_GSO_UDP_TUNNEL_CSUM) &&
!(features & NETIF_F_GSO_UDP_TUNNEL)) {
- if ((*features & NETIF_F_GSO_UDP_TUNNEL_CSUM) &&
netdev_notice(netdev, "forcing tx udp tunnel support\n");!(*features & NETIF_F_GSO_UDP_TUNNEL)) {
features |= NETIF_F_GSO_UDP_TUNNEL;
*features |= NETIF_F_GSO_UDP_TUNNEL;
}
/* Can't do one without doing the other */
- if ((features & vxlan_base) != vxlan_base) {
- if ((*features & vxlan_base) != vxlan_base) { netdev_notice(netdev, "forcing both tx and rx udp tunnel support\n");
features |= vxlan_base;
}*features |= vxlan_base;
- if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) {
if (!(features & NETIF_F_GSO_UDP_TUNNEL_CSUM)) {
- if (*features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) {
if (!(*features & NETIF_F_GSO_UDP_TUNNEL_CSUM)) { netdev_notice(netdev, "forcing tx udp tunnel checksumming on\n");
features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
} } else {*features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
if (features & NETIF_F_GSO_UDP_TUNNEL_CSUM) {
if (*features & NETIF_F_GSO_UDP_TUNNEL_CSUM) { netdev_notice(netdev, "forcing tx udp tunnel checksumming off\n");
features &= ~NETIF_F_GSO_UDP_TUNNEL_CSUM;
} }*features &= ~NETIF_F_GSO_UDP_TUNNEL_CSUM;
- return features;
}
static int xgbe_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c index 4ea157efca86..922c600fd292 100644 --- a/drivers/net/ethernet/atheros/alx/main.c +++ b/drivers/net/ethernet/atheros/alx/main.c @@ -1097,13 +1097,11 @@ static int alx_init_sw(struct alx_priv *alx) }
-static netdev_features_t alx_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void alx_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ if (netdev->mtu > ALX_MAX_TSO_PKT_SIZE)
features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
- return features;
*features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
}
static void alx_netif_stop(struct alx_priv *alx) diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index 20c032ab631b..aa86936bca97 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c @@ -504,8 +504,8 @@ static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter, adapter->rx_frag_size = roundup_pow_of_two(head_size); }
-static netdev_features_t atl1c_fix_features(struct net_device *netdev,
- netdev_features_t features)
+static void atl1c_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct atl1c_adapter *adapter = netdev_priv(netdev); struct atl1c_hw *hw = &adapter->hw; @@ -514,17 +514,15 @@ static netdev_features_t atl1c_fix_features(struct net_device *netdev, * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
if (hw->nic_type != athr_mt) { if (netdev->mtu > MAX_TSO_FRAME_SIZE)
features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
}*features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
- return features;
}
static int atl1c_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 2e22483a9040..ea99949c91eb 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -382,19 +382,17 @@ static int atl1e_set_mac_addr(struct net_device *netdev, void *p) return 0; }
-static netdev_features_t atl1e_fix_features(struct net_device *netdev,
- netdev_features_t features)
+static void atl1e_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int atl1e_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index b69298ddb647..c4d303ce284c 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c @@ -371,19 +371,17 @@ static void atl2_restore_vlan(struct atl2_adapter *adapter) atl2_vlan_mode(adapter->netdev, adapter->netdev->features); }
-static netdev_features_t atl2_fix_features(struct net_device *netdev,
- netdev_features_t features)
+static void atl2_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int atl2_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c index 0941d07d0833..3b0dbc3a5896 100644 --- a/drivers/net/ethernet/atheros/atlx/atlx.c +++ b/drivers/net/ethernet/atheros/atlx/atlx.c @@ -237,19 +237,17 @@ static void atlx_restore_vlan(struct atlx_adapter *adapter) atlx_vlan_mode(adapter->netdev, adapter->netdev->features); }
-static netdev_features_t atlx_fix_features(struct net_device *netdev,
- netdev_features_t features)
+static void atlx_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int atlx_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index b5d954cb409a..d74510306068 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -4899,38 +4899,35 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) return bnx2x_reload_if_running(dev); }
-netdev_features_t bnx2x_fix_features(struct net_device *dev,
netdev_features_t features)
+void bnx2x_fix_features(struct net_device *dev, netdev_features_t *features) { struct bnx2x *bp = netdev_priv(dev);
if (pci_num_vf(bp->pdev)) {
netdev_features_t changed = dev->features ^ features;
netdev_features_t changed = dev->features ^ *features;
/* Revert the requested changes in features if they
- would require internal reload of PF in bnx2x_set_features().
*/
if (!(features & NETIF_F_RXCSUM) && !bp->disable_tpa) {
features &= ~NETIF_F_RXCSUM;
features |= dev->features & NETIF_F_RXCSUM;
if (!(*features & NETIF_F_RXCSUM) && !bp->disable_tpa) {
*features &= ~NETIF_F_RXCSUM;
*features |= dev->features & NETIF_F_RXCSUM;
}
if (changed & NETIF_F_LOOPBACK) {
features &= ~NETIF_F_LOOPBACK;
features |= dev->features & NETIF_F_LOOPBACK;
*features &= ~NETIF_F_LOOPBACK;
*features |= dev->features & NETIF_F_LOOPBACK;
} }
/* TPA requires Rx CSUM offloading */
- if (!(features & NETIF_F_RXCSUM))
features &= ~NETIF_F_LRO;
- if (!(*features & NETIF_F_RXCSUM))
*features &= ~NETIF_F_LRO;
- if (!(features & NETIF_F_GRO) || !bnx2x_mtu_allows_gro(dev->mtu))
features &= ~NETIF_F_GRO_HW;
- if (features & NETIF_F_GRO_HW)
features &= ~NETIF_F_LRO;
- return features;
- if (!(*features & NETIF_F_GRO) || !bnx2x_mtu_allows_gro(dev->mtu))
*features &= ~NETIF_F_GRO_HW;
- if (*features & NETIF_F_GRO_HW)
*features &= ~NETIF_F_LRO;
}
int bnx2x_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index d8b1824c334d..4c66ef3e04bf 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -606,8 +606,7 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu); int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type); #endif
-netdev_features_t bnx2x_fix_features(struct net_device *dev,
netdev_features_t features);
+void bnx2x_fix_features(struct net_device *dev, netdev_features_t *features); int bnx2x_set_features(struct net_device *dev, netdev_features_t features);
/** diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b43b96cfaebc..106a0378c3b4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10894,39 +10894,38 @@ static bool bnxt_rfs_capable(struct bnxt *bp) #endif }
-static netdev_features_t bnxt_fix_features(struct net_device *dev,
netdev_features_t features)
+static void bnxt_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct bnxt *bp = netdev_priv(dev); netdev_features_t vlan_features;
- if ((features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp))
features &= ~NETIF_F_NTUPLE;
if ((*features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp))
*features &= ~NETIF_F_NTUPLE;
if (bp->flags & BNXT_FLAG_NO_AGG_RINGS)
features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
*features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
- if (!(features & NETIF_F_GRO))
features &= ~NETIF_F_GRO_HW;
- if (!(*features & NETIF_F_GRO))
*features &= ~NETIF_F_GRO_HW;
- if (features & NETIF_F_GRO_HW)
features &= ~NETIF_F_LRO;
if (*features & NETIF_F_GRO_HW)
*features &= ~NETIF_F_LRO;
/* Both CTAG and STAG VLAN accelaration on the RX side have to be
- turned on or off together.
*/
- vlan_features = features & BNXT_HW_FEATURE_VLAN_ALL_RX;
- vlan_features = *features & BNXT_HW_FEATURE_VLAN_ALL_RX; if (vlan_features != BNXT_HW_FEATURE_VLAN_ALL_RX) { if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)
features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX;
else if (vlan_features)*features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX;
features |= BNXT_HW_FEATURE_VLAN_ALL_RX;
}*features |= BNXT_HW_FEATURE_VLAN_ALL_RX;
#ifdef CONFIG_BNXT_SRIOV if (BNXT_VF(bp) && bp->vf.vlan)
features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX;
*features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX;
#endif
- return features;
}
static int bnxt_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 5e0e0e70d801..df0d6a35f093 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -8302,15 +8302,13 @@ static void tg3_set_loopback(struct net_device *dev, netdev_features_t features) } }
-static netdev_features_t tg3_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void tg3_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct tg3 *tp = netdev_priv(dev);
if (dev->mtu > ETH_DATA_LEN && tg3_flag(tp, 5780_CLASS))
features &= ~NETIF_F_ALL_TSO;
- return features;
*features &= ~NETIF_F_ALL_TSO;
}
static int tg3_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 2907e13b9df6..0230a63b86d5 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -2716,38 +2716,36 @@ static const struct udp_tunnel_nic_info liquidio_udp_tunnels = {
- @request: features requested
- Return: updated features list
*/ -static netdev_features_t liquidio_fix_features(struct net_device *netdev,
netdev_features_t request)
+static void liquidio_fix_features(struct net_device *netdev,
netdev_features_t *request)
{ struct lio *lio = netdev_priv(netdev);
- if ((request & NETIF_F_RXCSUM) &&
- if ((*request & NETIF_F_RXCSUM) && !(lio->dev_capability & NETIF_F_RXCSUM))
request &= ~NETIF_F_RXCSUM;
*request &= ~NETIF_F_RXCSUM;
- if ((request & NETIF_F_HW_CSUM) &&
- if ((*request & NETIF_F_HW_CSUM) && !(lio->dev_capability & NETIF_F_HW_CSUM))
request &= ~NETIF_F_HW_CSUM;
*request &= ~NETIF_F_HW_CSUM;
- if ((request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO))
request &= ~NETIF_F_TSO;
- if ((*request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO))
*request &= ~NETIF_F_TSO;
- if ((request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6))
request &= ~NETIF_F_TSO6;
- if ((*request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6))
*request &= ~NETIF_F_TSO6;
- if ((request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO))
request &= ~NETIF_F_LRO;
if ((*request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO))
*request &= ~NETIF_F_LRO;
/*Disable LRO if RXCSUM is off */
- if (!(request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) &&
- if (!(*request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) && (lio->dev_capability & NETIF_F_LRO))
request &= ~NETIF_F_LRO;
*request &= ~NETIF_F_LRO;
- if ((request & NETIF_F_HW_VLAN_CTAG_FILTER) &&
- if ((*request & NETIF_F_HW_VLAN_CTAG_FILTER) && !(lio->dev_capability & NETIF_F_HW_VLAN_CTAG_FILTER))
request &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
- return request;
*request &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
}
/** diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c index f6396ac64006..1c4c039dff9b 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c @@ -1815,34 +1815,32 @@ static const struct udp_tunnel_nic_info liquidio_udp_tunnels = {
- @param request features requested
- @returns updated features list
*/ -static netdev_features_t liquidio_fix_features(struct net_device *netdev,
netdev_features_t request)
+static void liquidio_fix_features(struct net_device *netdev,
netdev_features_t *request)
{ struct lio *lio = netdev_priv(netdev);
- if ((request & NETIF_F_RXCSUM) &&
- if ((*request & NETIF_F_RXCSUM) && !(lio->dev_capability & NETIF_F_RXCSUM))
request &= ~NETIF_F_RXCSUM;
*request &= ~NETIF_F_RXCSUM;
- if ((request & NETIF_F_HW_CSUM) &&
- if ((*request & NETIF_F_HW_CSUM) && !(lio->dev_capability & NETIF_F_HW_CSUM))
request &= ~NETIF_F_HW_CSUM;
*request &= ~NETIF_F_HW_CSUM;
- if ((request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO))
request &= ~NETIF_F_TSO;
- if ((*request & NETIF_F_TSO) && !(lio->dev_capability & NETIF_F_TSO))
*request &= ~NETIF_F_TSO;
- if ((request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6))
request &= ~NETIF_F_TSO6;
- if ((*request & NETIF_F_TSO6) && !(lio->dev_capability & NETIF_F_TSO6))
*request &= ~NETIF_F_TSO6;
- if ((request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO))
request &= ~NETIF_F_LRO;
if ((*request & NETIF_F_LRO) && !(lio->dev_capability & NETIF_F_LRO))
*request &= ~NETIF_F_LRO;
/* Disable LRO if RXCSUM is off */
- if (!(request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) &&
- if (!(*request & NETIF_F_RXCSUM) && (netdev->features & NETIF_F_LRO) && (lio->dev_capability & NETIF_F_LRO))
request &= ~NETIF_F_LRO;
- return request;
*request &= ~NETIF_F_LRO;
}
/** \brief Net device set features diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 2b87565781a0..781138a71458 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -1773,16 +1773,14 @@ static int nicvf_config_loopback(struct nicvf *nic, return nicvf_send_msg_to_pf(nic, &mbx); }
-static netdev_features_t nicvf_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void nicvf_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct nicvf *nic = netdev_priv(netdev);
- if ((features & NETIF_F_LOOPBACK) &&
- if ((*features & NETIF_F_LOOPBACK) && netif_running(netdev) && !nic->loopback_supported)
features &= ~NETIF_F_LOOPBACK;
- return features;
*features &= ~NETIF_F_LOOPBACK;
}
static int nicvf_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c index d246eee4b6d5..3fcd628fa449 100644 --- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c +++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c @@ -858,19 +858,16 @@ static int t1_set_mac_addr(struct net_device *dev, void *p) return 0; }
-static netdev_features_t t1_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void t1_fix_features(struct net_device *dev, netdev_features_t *features) { /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int t1_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c index 38e47703f9ab..140b40e5c54c 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c @@ -2593,19 +2593,17 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p) return 0; }
-static netdev_features_t cxgb_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void cxgb_fix_features(struct net_device *dev,
netdev_features_t *features)
{ /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int cxgb_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index a654169b9dfc..238416724a7c 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -3851,14 +3851,12 @@ static void cxgb_features_check(struct sk_buff *skb, struct net_device *dev, *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
-static netdev_features_t cxgb_fix_features(struct net_device *dev,
netdev_features_t features)
+static void cxgb_fix_features(struct net_device *dev,
netdev_features_t *features)
{ /* Disable GRO, if RX_CSUM is disabled */
- if (!(features & NETIF_F_RXCSUM))
features &= ~NETIF_F_GRO;
- return features;
- if (!(*features & NETIF_F_RXCSUM))
*features &= ~NETIF_F_GRO;
}
static const struct net_device_ops cxgb4_netdev_ops = { diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index 4920a80a0460..6d46d460a0a1 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -1173,19 +1173,17 @@ static int cxgb4vf_change_mtu(struct net_device *dev, int new_mtu) return ret; }
-static netdev_features_t cxgb4vf_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void cxgb4vf_fix_features(struct net_device *dev,
netdev_features_t *features)
{ /* * Since there is no support for separate rx/tx vlan accel * enable/disable make sure tx flag is always in same state as rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int cxgb4vf_set_features(struct net_device *dev, diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 6e745ca4c433..44397d1f44e4 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1976,13 +1976,11 @@ static int gmac_change_mtu(struct net_device *netdev, int new_mtu) return 0; }
-static netdev_features_t gmac_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void gmac_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ if (netdev->mtu + ETH_HLEN + VLAN_HLEN > MTU_SIZE_BIT_MASK)
features &= ~GMAC_OFFLOAD_FEATURES;
- return features;
*features &= ~GMAC_OFFLOAD_FEATURES;
}
static int gmac_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 343c605c4be8..1e08c18c813f 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -1793,20 +1793,19 @@ static int hns_nic_set_features(struct net_device *netdev, return 0; }
-static netdev_features_t hns_nic_fix_features(
struct net_device *netdev, netdev_features_t features)
+static void hns_nic_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct hns_nic_priv *priv = netdev_priv(netdev);
switch (priv->enet_ver) { case AE_VERSION_1:
features &= ~(NETIF_F_TSO | NETIF_F_TSO6 |
break; default: break; }*features &= ~(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_FILTER);
- return features;
}
static int hns_nic_uc_sync(struct net_device *netdev, const unsigned char *addr) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c index 9965e8d5d0a9..cce66faa477c 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c @@ -888,18 +888,16 @@ static int hinic_set_features(struct net_device *netdev, features, false); }
-static netdev_features_t hinic_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void hinic_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct hinic_dev *nic_dev = netdev_priv(netdev);
/* If Rx checksum is disabled, then LRO should also be disabled */
- if (!(features & NETIF_F_RXCSUM)) {
- if (!(*features & NETIF_F_RXCSUM)) { netif_info(nic_dev, drv, netdev, "disabling LRO as RXCSUM is off\n");
features &= ~NETIF_F_LRO;
}*features &= ~NETIF_F_LRO;
- return features;
}
static const struct net_device_ops hinic_netdev_ops = { diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 3d9b4f99d357..1afffcea1c02 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -749,8 +749,8 @@ static void netdev_get_drvinfo(struct net_device *dev, strlcpy(info->version, ibmveth_driver_version, sizeof(info->version)); }
-static netdev_features_t ibmveth_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void ibmveth_fix_features(struct net_device *dev,
netdev_features_t *features)
{ /* * Since the ibmveth firmware interface does not have the @@ -761,10 +761,8 @@ static netdev_features_t ibmveth_fix_features(struct net_device *dev, * checksummed. */
- if (!(features & NETIF_F_RXCSUM))
features &= ~NETIF_F_CSUM_MASK;
- return features;
- if (!(*features & NETIF_F_RXCSUM))
*features &= ~NETIF_F_CSUM_MASK;
}
static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index bed4f040face..e333ca1e7395 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -787,18 +787,16 @@ static int e1000_is_need_ioport(struct pci_dev *pdev) } }
-static netdev_features_t e1000_fix_features(struct net_device *netdev,
- netdev_features_t features)
+static void e1000_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int e1000_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 900b3ab998bd..5dd183e0cb0f 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -7287,25 +7287,23 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) } }
-static netdev_features_t e1000_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void e1000_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw;
/* Jumbo frame workaround on 82579 and newer requires CRC be stripped */ if ((hw->mac.type >= e1000_pch2lan) && (netdev->mtu > ETH_DATA_LEN))
features &= ~NETIF_F_RXFCS;
*features &= ~NETIF_F_RXFCS;
/* Since there is no support for separate Rx/Tx vlan accel
- enable/disable make sure Tx flag is always in same state as Rx.
*/
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int e1000_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index b066f1864b3f..9a086211af4a 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -3437,17 +3437,15 @@ static void iavf_features_check(struct sk_buff *skb, struct net_device *dev,
- Returns fixed-up features bits
**/ -static netdev_features_t iavf_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void iavf_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct iavf_adapter *adapter = netdev_priv(netdev);
if (!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN))
features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
*features &= ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER);
- return features;
}
static const struct net_device_ops iavf_netdev_ops = { diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 82b59adf8034..2e4a53c76c60 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2433,18 +2433,16 @@ void igb_reset(struct igb_adapter *adapter) igb_get_phy_info(hw); }
-static netdev_features_t igb_fix_features(struct net_device *netdev,
- netdev_features_t features)
+static void igb_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int igb_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index fdb3ed051456..13b89a742ebc 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4915,18 +4915,16 @@ static void igc_get_stats64(struct net_device *netdev, spin_unlock(&adapter->stats64_lock); }
-static netdev_features_t igc_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void igc_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_CTAG_TX;
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int igc_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index 1588376d4c67..34c1bfc75b7b 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c @@ -293,17 +293,15 @@ ixgb_reset(struct ixgb_adapter *adapter) } }
-static netdev_features_t -ixgb_fix_features(struct net_device *netdev, netdev_features_t features) +static void ixgb_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* * Tx VLAN insertion does not work per HW design when Rx stripping is * disabled. */
- if (!(features & NETIF_F_HW_VLAN_CTAG_RX))
features &= ~NETIF_F_HW_VLAN_CTAG_TX;
- return features;
- if (!(*features & NETIF_F_HW_VLAN_CTAG_RX))
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
}
static int diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index e39d3983a455..c43c99a44914 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -9682,25 +9682,23 @@ void ixgbe_do_reset(struct net_device *netdev) ixgbe_reset(adapter); }
-static netdev_features_t ixgbe_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void ixgbe_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct ixgbe_adapter *adapter = netdev_priv(netdev);
/* If Rx checksum is disabled, then RSC/LRO should also be disabled */
- if (!(features & NETIF_F_RXCSUM))
features &= ~NETIF_F_LRO;
if (!(*features & NETIF_F_RXCSUM))
*features &= ~NETIF_F_LRO;
/* Turn off LRO if not RSC capable */ if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE))
features &= ~NETIF_F_LRO;
*features &= ~NETIF_F_LRO;
- if (adapter->xdp_prog && (features & NETIF_F_LRO)) {
- if (adapter->xdp_prog && (*features & NETIF_F_LRO)) { e_dev_err("LRO is not supported with XDP\n");
features &= ~NETIF_F_LRO;
}*features &= ~NETIF_F_LRO;
- return features;
}
static void ixgbe_reset_l2fw_offload(struct ixgbe_adapter *adapter) diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 1bdc4f23e1e5..11749bd7276d 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c @@ -2659,12 +2659,11 @@ jme_set_msglevel(struct net_device *netdev, u32 value) jme->msg_enable = value; }
-static netdev_features_t -jme_fix_features(struct net_device *netdev, netdev_features_t features) +static void jme_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ if (netdev->mtu > 1900)
features &= ~(NETIF_F_ALL_TSO | NETIF_F_CSUM_MASK);
- return features;
*features &= ~(NETIF_F_ALL_TSO | NETIF_F_CSUM_MASK);
}
static int diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 9d460a270601..a4093977cd2b 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -3770,19 +3770,17 @@ static int mvneta_change_mtu(struct net_device *dev, int mtu) return 0; }
-static netdev_features_t mvneta_fix_features(struct net_device *dev,
netdev_features_t features)
+static void mvneta_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct mvneta_port *pp = netdev_priv(dev);
if (pp->tx_csum_limit && dev->mtu > pp->tx_csum_limit) {
features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO);
netdev_info(dev, "Disable IP checksum for MTU greater than %dB\n", pp->tx_csum_limit); }*features &= ~(NETIF_F_IP_CSUM | NETIF_F_TSO);
- return features;
}
/* Get mac address */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 53df7fff92c4..35602e49d60d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1773,15 +1773,13 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev) return NETDEV_TX_OK; }
-static netdev_features_t otx2_fix_features(struct net_device *dev,
netdev_features_t features)
+static void otx2_fix_features(struct net_device *dev,
netdev_features_t *features)
{
- if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_STAG_RX;
- if (*features & NETIF_F_HW_VLAN_CTAG_RX)
else*features |= NETIF_F_HW_VLAN_STAG_RX;
features &= ~NETIF_F_HW_VLAN_STAG_RX;
- return features;
*features &= ~NETIF_F_HW_VLAN_STAG_RX;
}
static void otx2_set_rx_mode(struct net_device *netdev) diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 3cb9c1271328..8b1af582c250 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -4358,8 +4358,8 @@ static int sky2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom return sky2_vpd_write(sky2->hw, cap, data, eeprom->offset, eeprom->len); }
-static netdev_features_t sky2_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void sky2_fix_features(struct net_device *dev,
netdev_features_t *features)
{ const struct sky2_port *sky2 = netdev_priv(dev); const struct sky2_hw *hw = sky2->hw; @@ -4369,18 +4369,16 @@ static netdev_features_t sky2_fix_features(struct net_device *dev, */ if (dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U) { netdev_info(dev, "checksum offload not possible with jumbo frames\n");
features &= ~(NETIF_F_TSO | NETIF_F_SG | NETIF_F_CSUM_MASK);
*features &= ~(NETIF_F_TSO | NETIF_F_SG | NETIF_F_CSUM_MASK);
}
/* Some hardware requires receive checksum for RSS to work. */
- if ( (features & NETIF_F_RXHASH) &&
!(features & NETIF_F_RXCSUM) &&
(sky2->hw->flags & SKY2_HW_RSS_CHKSUM)) {
- if ((*features & NETIF_F_RXHASH) &&
!(*features & NETIF_F_RXCSUM) &&
netdev_info(dev, "receive hashing forces receive checksum\n");(sky2->hw->flags & SKY2_HW_RSS_CHKSUM)) {
features |= NETIF_F_RXCSUM;
}*features |= NETIF_F_RXCSUM;
- return features;
}
static int sky2_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 398c23cec815..6a6ef1c29657 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2021,21 +2021,19 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev, return 0; }
-static netdev_features_t mtk_fix_features(struct net_device *dev,
netdev_features_t features)
+static void mtk_fix_features(struct net_device *dev,
netdev_features_t *features)
{
- if (!(features & NETIF_F_LRO)) {
if (!(*features & NETIF_F_LRO)) { struct mtk_mac *mac = netdev_priv(dev); int ip_cnt = mtk_hwlro_get_ip_cnt(mac);
if (ip_cnt) { netdev_info(dev, "RX flow is programmed, LRO should keep on\n");
features |= NETIF_F_LRO;
} }*features |= NETIF_F_LRO;
- return features;
}
static int mtk_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index bc504dcb1c2b..06bc81d874be 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2479,8 +2479,8 @@ static int mlx4_en_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } }
-static netdev_features_t mlx4_en_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void mlx4_en_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct mlx4_en_priv *en_priv = netdev_priv(netdev); struct mlx4_en_dev *mdev = en_priv->mdev; @@ -2489,13 +2489,11 @@ static netdev_features_t mlx4_en_fix_features(struct net_device *netdev, * enable/disable make sure S-TAG flag is always in same state as * C-TAG. */
- if (features & NETIF_F_HW_VLAN_CTAG_RX &&
- if (*features & NETIF_F_HW_VLAN_CTAG_RX && !(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN))
features |= NETIF_F_HW_VLAN_STAG_RX;
else*features |= NETIF_F_HW_VLAN_STAG_RX;
features &= ~NETIF_F_HW_VLAN_STAG_RX;
- return features;
*features &= ~NETIF_F_HW_VLAN_STAG_RX;
}
static int mlx4_en_set_features(struct net_device *netdev, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 6fdc2a793c1f..4092210fb079 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3397,8 +3397,8 @@ static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev return features; }
-static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
netdev_features_t features)
+static void mlx5e_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_params *params; @@ -3410,20 +3410,20 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, /* HW strips the outer C-tag header, this is a problem * for S-tag traffic. */
features &= ~NETIF_F_HW_VLAN_CTAG_RX;
*features &= ~NETIF_F_HW_VLAN_CTAG_RX;
if (!params->vlan_strip_disable) netdev_warn(netdev, "Dropping C-tag vlan stripping offload due to S-tag vlan\n"); }
if (!MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_STRIDING_RQ)) {
if (features & NETIF_F_LRO) {
if (*features & NETIF_F_LRO) { netdev_warn(netdev, "Disabling LRO, not supported in legacy RQ\n");
features &= ~NETIF_F_LRO;
*features &= ~NETIF_F_LRO;
} }
if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)) {
features &= ~NETIF_F_RXHASH;
if (netdev->features & NETIF_F_RXHASH) netdev_warn(netdev, "Disabling rxhash, not supported when CQE compress is active\n"); }*features &= ~NETIF_F_RXHASH;
@@ -3432,8 +3432,6 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, features = mlx5e_fix_uplink_rep_features(netdev, features);
mutex_unlock(&priv->state_lock);
- return features;
}
static bool mlx5e_xsk_validate_mtu(struct net_device *netdev, diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index df4a3f3da83a..5f720e97a558 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c @@ -2639,19 +2639,17 @@ static void vxge_poll_vp_lockup(struct timer_list *t) mod_timer(&vdev->vp_lockup_timer, jiffies + HZ / 1000); }
-static netdev_features_t vxge_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void vxge_fix_features(struct net_device *dev,
netdev_features_t *features)
{
- netdev_features_t changed = dev->features ^ features;
netdev_features_t changed = dev->features ^ *features;
/* Enabling RTH requires some of the logic in vxge_device_register and a
- vpath reset. Due to these restrictions, only allow modification
- while the interface is down.
*/ if ((changed & NETIF_F_RXHASH) && netif_running(dev))
features ^= NETIF_F_RXHASH;
- return features;
*features ^= NETIF_F_RXHASH;
}
static int vxge_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index f04b79f04a9d..fcb2e30e8ac7 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -232,11 +232,11 @@ static int nfp_repr_open(struct net_device *netdev) return err; }
-static netdev_features_t -nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) +static void nfp_repr_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ struct nfp_repr *repr = netdev_priv(netdev);
- netdev_features_t old_features = features;
- netdev_features_t old_features = *features; netdev_features_t lower_features; struct net_device *lower_dev;
@@ -246,11 +246,9 @@ nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features) if (lower_features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- netdev_intersect_features(&features, features, lower_features);
- features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC);
- features |= NETIF_F_LLTX;
- return features;
- netdev_intersect_features(features, *features, lower_features);
- *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_HW_TC);
- *features |= NETIF_F_LLTX;
}
const struct net_device_ops nfp_repr_netdev_ops = { diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index ef3fb4cc90af..e1f16988cb75 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -4920,14 +4920,12 @@ static int nv_set_loopback(struct net_device *dev, netdev_features_t features) return retval; }
-static netdev_features_t nv_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void nv_fix_features(struct net_device *dev,
netdev_features_t *features)
{ /* vlan is dependent on rx checksum offload */
- if (features & (NETIF_F_HW_VLAN_CTAG_TX|NETIF_F_HW_VLAN_CTAG_RX))
features |= NETIF_F_RXCSUM;
- return features;
- if (*features & (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX))
*features |= NETIF_F_RXCSUM;
}
static void nv_vlan_mode(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 344ea1143454..251668839926 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -517,16 +517,14 @@ static void netxen_set_multicast_list(struct net_device *dev) adapter->set_multi(dev); }
-static netdev_features_t netxen_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void netxen_fix_features(struct net_device *dev,
netdev_features_t *features)
{
- if (!(features & NETIF_F_RXCSUM)) {
- if (!(*features & NETIF_F_RXCSUM)) { netdev_info(dev, "disabling LRO as RXCSUM is off\n");
features &= ~NETIF_F_LRO;
}*features &= ~NETIF_F_LRO;
- return features;
}
static int netxen_set_features(struct net_device *dev, diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h index c1f26a2e374d..ada71452d454 100644 --- a/drivers/net/ethernet/qlogic/qede/qede.h +++ b/drivers/net/ethernet/qlogic/qede/qede.h @@ -545,8 +545,7 @@ int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid); void qede_vlan_mark_nonconfigured(struct qede_dev *edev); int qede_configure_vlan_filters(struct qede_dev *edev);
-netdev_features_t qede_fix_features(struct net_device *dev,
netdev_features_t features);
+void qede_fix_features(struct net_device *dev, netdev_features_t *features); int qede_set_features(struct net_device *dev, netdev_features_t features); void qede_set_rx_mode(struct net_device *ndev); void qede_config_rx_mode(struct net_device *ndev); diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index f99b085b56a5..ea89a3afa206 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c @@ -910,16 +910,13 @@ static void qede_set_features_reload(struct qede_dev *edev, edev->ndev->features = args->u.features; }
-netdev_features_t qede_fix_features(struct net_device *dev,
netdev_features_t features)
+void qede_fix_features(struct net_device *dev, netdev_features_t *features) { struct qede_dev *edev = netdev_priv(dev);
if (edev->xdp_prog || edev->ndev->mtu > PAGE_SIZE ||
!(features & NETIF_F_GRO))
features &= ~NETIF_F_GRO_HW;
- return features;
!(*features & NETIF_F_GRO))
*features &= ~NETIF_F_GRO_HW;
}
int qede_set_features(struct net_device *dev, netdev_features_t features) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index be7abee160e7..7fbf895becdd 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h @@ -1622,8 +1622,7 @@ int qlcnic_82xx_read_phys_port_id(struct qlcnic_adapter *); int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *, u32); int qlcnic_change_mtu(struct net_device *netdev, int new_mtu); -netdev_features_t qlcnic_fix_features(struct net_device *netdev,
- netdev_features_t features);
+void qlcnic_fix_features(struct net_device *netdev, netdev_features_t *features); int qlcnic_set_features(struct net_device *netdev, netdev_features_t features); int qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); void qlcnic_update_cmd_producer(struct qlcnic_host_tx_ring *); diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c index 4b8bc46f55c2..e6ed7f8413b4 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c @@ -1053,8 +1053,7 @@ static netdev_features_t qlcnic_process_flags(struct qlcnic_adapter *adapter, return features; }
-netdev_features_t qlcnic_fix_features(struct net_device *netdev,
- netdev_features_t features)
+void qlcnic_fix_features(struct net_device *netdev, netdev_features_t *features) { struct qlcnic_adapter *adapter = netdev_priv(netdev); netdev_features_t changed; @@ -1062,10 +1061,10 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev, if (qlcnic_82xx_check(adapter) && (adapter->flags & QLCNIC_ESWITCH_ENABLED)) { if (adapter->flags & QLCNIC_APP_CHANGED_FLAGS) {
features = qlcnic_process_flags(adapter, features);
} else {*features = qlcnic_process_flags(adapter, *features);
changed = features ^ netdev->features;
features ^= changed & (NETIF_F_RXCSUM |
changed = *features ^ netdev->features;
*features ^= changed & (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_TSO |
@@ -1073,10 +1072,8 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev, } }
- if (!(features & NETIF_F_RXCSUM))
features &= ~NETIF_F_LRO;
- return features;
- if (!(*features & NETIF_F_RXCSUM))
*features &= ~NETIF_F_LRO;
}
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 3d753ddd1a89..8affae2b55a6 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1431,19 +1431,17 @@ static int rtl8169_get_regs_len(struct net_device *dev) return R8169_REGS_SIZE; }
-static netdev_features_t rtl8169_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void rtl8169_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct rtl8169_private *tp = netdev_priv(dev);
if (dev->mtu > TD_MSS_MAX)
features &= ~NETIF_F_ALL_TSO;
*features &= ~NETIF_F_ALL_TSO;
if (dev->mtu > ETH_DATA_LEN && tp->mac_version > RTL_GIGA_MAC_VER_06)
features &= ~(NETIF_F_CSUM_MASK | NETIF_F_ALL_TSO);
- return features;
*features &= ~(NETIF_F_CSUM_MASK | NETIF_F_ALL_TSO);
}
static void rtl_set_rx_config_features(struct rtl8169_private *tp, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 553c4403258a..124b3b81001f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5457,16 +5457,16 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) return 0; }
-static netdev_features_t stmmac_fix_features(struct net_device *dev,
netdev_features_t features)
+static void stmmac_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct stmmac_priv *priv = netdev_priv(dev);
if (priv->plat->rx_coe == STMMAC_RX_COE_NONE)
features &= ~NETIF_F_RXCSUM;
*features &= ~NETIF_F_RXCSUM;
if (!priv->plat->tx_coe)
features &= ~NETIF_F_CSUM_MASK;
*features &= ~NETIF_F_CSUM_MASK;
/* Some GMAC devices have a bugged Jumbo frame support that
- needs to have the Tx COE disabled for oversized frames
@@ -5474,17 +5474,15 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, * the TX csum insertion in the TDES and not use SF. */ if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN))
features &= ~NETIF_F_CSUM_MASK;
*features &= ~NETIF_F_CSUM_MASK;
/* Disable tso if asked by ethtool */ if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) {
if (features & NETIF_F_TSO)
else priv->tso = false; }if (*features & NETIF_F_TSO) priv->tso = true;
- return features;
}
static int stmmac_set_features(struct net_device *netdev, diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 382bebc2420d..5371328422ec 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1919,21 +1919,19 @@ static int netvsc_set_ringparam(struct net_device *ndev, return ret; }
-static netdev_features_t netvsc_fix_features(struct net_device *ndev,
netdev_features_t features)
+static void netvsc_fix_features(struct net_device *ndev,
netdev_features_t *features)
{ struct net_device_context *ndevctx = netdev_priv(ndev); struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
if (!nvdev || nvdev->destroy)
return features;
return;
- if ((features & NETIF_F_LRO) && netvsc_xdp_get(nvdev)) {
features ^= NETIF_F_LRO;
- if ((*features & NETIF_F_LRO) && netvsc_xdp_get(nvdev)) {
netdev_info(ndev, "Skip LRO - unsupported with XDP\n"); }*features ^= NETIF_F_LRO;
- return features;
}
static int netvsc_set_features(struct net_device *ndev, diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index c0b21a5580d5..8fcc91c0b0f4 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -235,19 +235,17 @@ static netdev_tx_t ipvlan_start_xmit(struct sk_buff *skb, return ret; }
-static netdev_features_t ipvlan_fix_features(struct net_device *dev,
netdev_features_t features)
+static void ipvlan_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct ipvl_dev *ipvlan = netdev_priv(dev);
- features |= NETIF_F_ALL_FOR_ALL;
- features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
- features = netdev_increment_features(ipvlan->phy_dev->features,
features, features);
- features |= IPVLAN_ALWAYS_ON;
- features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
- return features;
- *features |= NETIF_F_ALL_FOR_ALL;
- *features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
- *features = netdev_increment_features(ipvlan->phy_dev->features,
*features, *features);
- *features |= IPVLAN_ALWAYS_ON;
- *features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
}
static void ipvlan_change_rx_flags(struct net_device *dev, int change) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 93dc48b9b4f2..601b833a40bd 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3470,20 +3470,20 @@ static void macsec_dev_uninit(struct net_device *dev) free_percpu(dev->tstats); }
-static netdev_features_t macsec_fix_features(struct net_device *dev,
netdev_features_t features)
+static void macsec_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct macsec_dev *macsec = macsec_priv(dev); struct net_device *real_dev = macsec->real_dev;
- if (macsec_is_offloaded(macsec))
return REAL_DEV_FEATURES(real_dev);
- if (macsec_is_offloaded(macsec)) {
*features = REAL_DEV_FEATURES(real_dev);
return;
- }
- features &= (real_dev->features & SW_MACSEC_FEATURES) |
- *features &= (real_dev->features & SW_MACSEC_FEATURES) | NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES;
- features |= NETIF_F_LLTX;
- return features;
- *features |= NETIF_F_LLTX;
}
static int macsec_dev_open(struct net_device *dev) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 35f46ad040b0..27cd9c08bb1e 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1067,23 +1067,21 @@ static int macvlan_ethtool_get_ts_info(struct net_device *dev, return 0; }
-static netdev_features_t macvlan_fix_features(struct net_device *dev,
netdev_features_t features)
+static void macvlan_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct macvlan_dev *vlan = netdev_priv(dev); netdev_features_t lowerdev_features = vlan->lowerdev->features; netdev_features_t mask;
- features |= NETIF_F_ALL_FOR_ALL;
- features &= (vlan->set_features | ~MACVLAN_FEATURES);
- mask = features;
- *features |= NETIF_F_ALL_FOR_ALL;
- *features &= (vlan->set_features | ~MACVLAN_FEATURES);
- mask = *features;
- lowerdev_features &= (features | ~NETIF_F_LRO);
- features = netdev_increment_features(lowerdev_features, features, mask);
- features |= ALWAYS_ON_FEATURES;
- features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES);
- return features;
- lowerdev_features &= (*features | ~NETIF_F_LRO);
- *features = netdev_increment_features(lowerdev_features, *features, mask);
- *features |= ALWAYS_ON_FEATURES;
- *features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES);
}
#ifdef CONFIG_NET_POLL_CONTROLLER diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index dd7917cab2b1..340be925d4eb 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1995,28 +1995,26 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev) return err; }
-static netdev_features_t team_fix_features(struct net_device *dev,
netdev_features_t features)
+static void team_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct team_port *port; struct team *team = netdev_priv(dev); netdev_features_t mask;
- mask = features;
- features &= ~NETIF_F_ONE_FOR_ALL;
- features |= NETIF_F_ALL_FOR_ALL;
mask = *features;
*features &= ~NETIF_F_ONE_FOR_ALL;
*features |= NETIF_F_ALL_FOR_ALL;
rcu_read_lock(); list_for_each_entry_rcu(port, &team->port_list, list) {
features = netdev_increment_features(features,
port->dev->features,
mask);
*features = netdev_increment_features(*features,
port->dev->features,
} rcu_read_unlock();mask);
- features = netdev_add_tso_features(features, mask);
- return features;
- *features = netdev_add_tso_features(*features, mask);
}
static int team_change_carrier(struct net_device *dev, bool new_carrier) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index fecc9a1d293a..d89a9874eb37 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1079,12 +1079,13 @@ static void tun_net_mclist(struct net_device *dev) */ }
-static netdev_features_t tun_net_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void tun_net_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct tun_struct *tun = netdev_priv(dev);
- return (features & tun->set_features) | (features & ~TUN_USER_FEATURES);
- *features = (*features & tun->set_features) |
(*features & ~TUN_USER_FEATURES);
}
static void tun_set_headroom(struct net_device *dev, int new_hr) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 50eb43e5bf45..82c900d7ba7b 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1382,8 +1382,8 @@ static int veth_get_iflink(const struct net_device *dev) return iflink; }
-static netdev_features_t veth_fix_features(struct net_device *dev,
netdev_features_t features)
+static void veth_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct veth_priv *priv = netdev_priv(dev); struct net_device *peer; @@ -1393,12 +1393,10 @@ static netdev_features_t veth_fix_features(struct net_device *dev, struct veth_priv *peer_priv = netdev_priv(peer);
if (peer_priv->_xdp_prog)
features &= ~NETIF_F_GSO_SOFTWARE;
} if (priv->_xdp_prog)*features &= ~NETIF_F_GSO_SOFTWARE;
features |= NETIF_F_GRO;
- return features;
*features |= NETIF_F_GRO;
}
static int veth_set_features(struct net_device *dev, diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index e840547cd19e..6a5827c21c63 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -246,14 +246,12 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) ethtool_sprintf(&buf, vmxnet3_global_stats[i].desc); }
-netdev_features_t vmxnet3_fix_features(struct net_device *netdev,
netdev_features_t features)
+void vmxnet3_fix_features(struct net_device *netdev,
netdev_features_t *features)
{ /* If Rx checksum is disabled, then LRO should also be disabled */
- if (!(features & NETIF_F_RXCSUM))
features &= ~NETIF_F_LRO;
- return features;
- if (!(*features & NETIF_F_RXCSUM))
*features &= ~NETIF_F_LRO;
}
void vmxnet3_features_check(struct sk_buff *skb, struct net_device *netdev, diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index a711759ebb00..aed4e1bf9298 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -475,8 +475,8 @@ vmxnet3_tq_destroy_all(struct vmxnet3_adapter *adapter); void vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter);
-netdev_features_t -vmxnet3_fix_features(struct net_device *netdev, netdev_features_t features); +void +vmxnet3_fix_features(struct net_device *netdev, netdev_features_t *features);
void vmxnet3_features_check(struct sk_buff *skb, diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index c58996c1e230..f964f0a402a6 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -374,23 +374,21 @@ static int xenvif_change_mtu(struct net_device *dev, int mtu) return 0; }
-static netdev_features_t xenvif_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void xenvif_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct xenvif *vif = netdev_priv(dev);
if (!vif->can_sg)
features &= ~NETIF_F_SG;
if (~(vif->gso_mask) & GSO_BIT(TCPV4))*features &= ~NETIF_F_SG;
features &= ~NETIF_F_TSO;
if (~(vif->gso_mask) & GSO_BIT(TCPV6))*features &= ~NETIF_F_TSO;
features &= ~NETIF_F_TSO6;
if (!vif->ip_csum)*features &= ~NETIF_F_TSO6;
features &= ~NETIF_F_IP_CSUM;
if (!vif->ipv6_csum)*features &= ~NETIF_F_IP_CSUM;
features &= ~NETIF_F_IPV6_CSUM;
- return features;
*features &= ~NETIF_F_IPV6_CSUM;
}
static const struct xenvif_stat { diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 65c134ac2be5..79752f16277a 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1386,29 +1386,27 @@ static void xennet_release_rx_bufs(struct netfront_queue *queue) spin_unlock_bh(&queue->rx_lock); }
-static netdev_features_t xennet_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void xennet_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct netfront_info *np = netdev_priv(dev);
- if (features & NETIF_F_SG &&
- if (*features & NETIF_F_SG && !xenbus_read_unsigned(np->xbdev->otherend, "feature-sg", 0))
features &= ~NETIF_F_SG;
*features &= ~NETIF_F_SG;
- if (features & NETIF_F_IPV6_CSUM &&
- if (*features & NETIF_F_IPV6_CSUM && !xenbus_read_unsigned(np->xbdev->otherend, "feature-ipv6-csum-offload", 0))
features &= ~NETIF_F_IPV6_CSUM;
*features &= ~NETIF_F_IPV6_CSUM;
- if (features & NETIF_F_TSO &&
- if (*features & NETIF_F_TSO && !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv4", 0))
features &= ~NETIF_F_TSO;
*features &= ~NETIF_F_TSO;
- if (features & NETIF_F_TSO6 &&
- if (*features & NETIF_F_TSO6 && !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv6", 0))
features &= ~NETIF_F_TSO6;
- return features;
*features &= ~NETIF_F_TSO6;
}
static int xennet_set_features(struct net_device *dev, diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 06d02e2e2b66..2b260754b38e 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -1094,7 +1094,7 @@ int qeth_hw_trap(struct qeth_card *, enum qeth_diags_trap_action); int qeth_setassparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long); int qeth_set_features(struct net_device *, netdev_features_t); void qeth_enable_hw_features(struct net_device *dev); -netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t); +void qeth_fix_features(struct net_device *dev, netdev_features_t *features); void qeth_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t *features); void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 6811af22ee2b..d8269f4f7a83 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -6927,26 +6927,24 @@ int qeth_set_features(struct net_device *dev, netdev_features_t features) } EXPORT_SYMBOL_GPL(qeth_set_features);
-netdev_features_t qeth_fix_features(struct net_device *dev,
netdev_features_t features)
+void qeth_fix_features(struct net_device *dev, netdev_features_t *features) { struct qeth_card *card = dev->ml_priv;
QETH_CARD_TEXT(card, 2, "fixfeat"); if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM))
features &= ~NETIF_F_IP_CSUM;
if (!qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6))*features &= ~NETIF_F_IP_CSUM;
features &= ~NETIF_F_IPV6_CSUM;
if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM) && !qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6))*features &= ~NETIF_F_IPV6_CSUM;
features &= ~NETIF_F_RXCSUM;
if (!qeth_is_supported(card, IPA_OUTBOUND_TSO))*features &= ~NETIF_F_RXCSUM;
features &= ~NETIF_F_TSO;
if (!qeth_is_supported6(card, IPA_OUTBOUND_TSO))*features &= ~NETIF_F_TSO;
features &= ~NETIF_F_TSO6;
*features &= ~NETIF_F_TSO6;
- QETH_CARD_HEX(card, 2, &features, sizeof(features));
- return features;
- QETH_CARD_HEX(card, 2, features, sizeof(*features));
} EXPORT_SYMBOL_GPL(qeth_fix_features);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d62edd4c99a9..43eb57fa9434 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1481,8 +1481,8 @@ struct net_device_ops { bool all_slaves); struct net_device* (*ndo_sk_get_lower_dev)(struct net_device *dev, struct sock *sk);
- netdev_features_t (*ndo_fix_features)(struct net_device *dev,
netdev_features_t features);
- void (*ndo_fix_features)(struct net_device *dev,
int (*ndo_set_features)(struct net_device *dev, netdev_features_t features); int (*ndo_neigh_construct)(struct net_device *dev,netdev_features_t *features);
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 2987201ec93d..9f90a587d4e5 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -633,11 +633,11 @@ void vlan_dev_uninit(struct net_device *dev) } }
-static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void vlan_dev_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
- netdev_features_t old_features = features;
netdev_features_t old_features = *features; netdev_features_t lower_features;
netdev_intersect_features(&lower_features,
@@ -649,11 +649,9 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev, */ if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) lower_features |= NETIF_F_HW_CSUM;
- netdev_intersect_features(&features, features, lower_features);
- features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
- features |= NETIF_F_LLTX;
- return features;
- netdev_intersect_features(features, *features, lower_features);
- *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
- *features |= NETIF_F_LLTX;
}
static int vlan_ethtool_get_link_ksettings(struct net_device *dev, diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 8d6bab244c4a..622559aff2dd 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -288,12 +288,11 @@ static int br_get_link_ksettings(struct net_device *dev, return 0; }
-static netdev_features_t br_fix_features(struct net_device *dev,
- netdev_features_t features)
+static void br_fix_features(struct net_device *dev, netdev_features_t *features) { struct net_bridge *br = netdev_priv(dev);
- return br_features_recompute(br, features);
- *features = br_features_recompute(br, *features);
}
#ifdef CONFIG_NET_POLL_CONTROLLER diff --git a/net/core/dev.c b/net/core/dev.c index 7b71d322c68e..95d0c4f0da58 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9923,7 +9923,7 @@ int __netdev_update_features(struct net_device *dev) netdev_get_wanted_features(dev, &features);
if (dev->netdev_ops->ndo_fix_features)
features = dev->netdev_ops->ndo_fix_features(dev, features);
dev->netdev_ops->ndo_fix_features(dev, &features);
/* driver might be less strict about feature dependencies */ features = netdev_fix_features(dev, features);
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 26c32407f029..acaf48a1e136 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -201,12 +201,12 @@ static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr, return features; }
-static netdev_features_t hsr_fix_features(struct net_device *dev,
netdev_features_t features)
+static void hsr_fix_features(struct net_device *dev,
netdev_features_t *features)
{ struct hsr_priv *hsr = netdev_priv(dev);
- return hsr_features_recompute(hsr, features);
- *features = hsr_features_recompute(hsr, *features);
}
static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_fix_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/core/dev.c | 78 ++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 40 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index 95d0c4f0da58..ee5bf8620316 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9816,99 +9816,97 @@ static void netdev_sync_lower_features(struct net_device *upper, } }
-static netdev_features_t netdev_fix_features(struct net_device *dev, - netdev_features_t features) +static void netdev_fix_features(struct net_device *dev, + netdev_features_t *features) { /* Fix illegal checksum combinations */ - if ((features & NETIF_F_HW_CSUM) && - (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { + if ((*features & NETIF_F_HW_CSUM) && + (*features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))) { netdev_warn(dev, "mixed HW and IP checksum settings.\n"); - features &= ~(NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); + *features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); }
/* TSO requires that SG is present as well. */ - if ((features & NETIF_F_ALL_TSO) && !(features & NETIF_F_SG)) { + if ((*features & NETIF_F_ALL_TSO) && !(*features & NETIF_F_SG)) { netdev_dbg(dev, "Dropping TSO features since no SG feature.\n"); - features &= ~NETIF_F_ALL_TSO; + *features &= ~NETIF_F_ALL_TSO; }
- if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) && - !(features & NETIF_F_IP_CSUM)) { + if ((*features & NETIF_F_TSO) && !(*features & NETIF_F_HW_CSUM) && + !(*features & NETIF_F_IP_CSUM)) { netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n"); - features &= ~NETIF_F_TSO; - features &= ~NETIF_F_TSO_ECN; + *features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO_ECN; }
- if ((features & NETIF_F_TSO6) && !(features & NETIF_F_HW_CSUM) && - !(features & NETIF_F_IPV6_CSUM)) { + if ((*features & NETIF_F_TSO6) && !(*features & NETIF_F_HW_CSUM) && + !(*features & NETIF_F_IPV6_CSUM)) { netdev_dbg(dev, "Dropping TSO6 features since no CSUM feature.\n"); - features &= ~NETIF_F_TSO6; + *features &= ~NETIF_F_TSO6; }
/* TSO with IPv4 ID mangling requires IPv4 TSO be enabled */ - if ((features & NETIF_F_TSO_MANGLEID) && !(features & NETIF_F_TSO)) - features &= ~NETIF_F_TSO_MANGLEID; + if ((*features & NETIF_F_TSO_MANGLEID) && !(*features & NETIF_F_TSO)) + *features &= ~NETIF_F_TSO_MANGLEID;
/* TSO ECN requires that TSO is present as well. */ - if ((features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN) - features &= ~NETIF_F_TSO_ECN; + if ((*features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN) + *features &= ~NETIF_F_TSO_ECN;
/* Software GSO depends on SG. */ - if ((features & NETIF_F_GSO) && !(features & NETIF_F_SG)) { + if ((*features & NETIF_F_GSO) && !(*features & NETIF_F_SG)) { netdev_dbg(dev, "Dropping NETIF_F_GSO since no SG feature.\n"); - features &= ~NETIF_F_GSO; + *features &= ~NETIF_F_GSO; }
/* GSO partial features require GSO partial be set */ - if ((features & dev->gso_partial_features) && - !(features & NETIF_F_GSO_PARTIAL)) { + if ((*features & dev->gso_partial_features) && + !(*features & NETIF_F_GSO_PARTIAL)) { netdev_dbg(dev, "Dropping partially supported GSO features since no GSO partial.\n"); - features &= ~dev->gso_partial_features; + *features &= ~dev->gso_partial_features; }
- if (!(features & NETIF_F_RXCSUM)) { + if (!(*features & NETIF_F_RXCSUM)) { /* NETIF_F_GRO_HW implies doing RXCSUM since every packet * successfully merged by hardware must also have the * checksum verified by hardware. If the user does not * want to enable RXCSUM, logically, we should disable GRO_HW. */ - if (features & NETIF_F_GRO_HW) { + if (*features & NETIF_F_GRO_HW) { netdev_dbg(dev, "Dropping NETIF_F_GRO_HW since no RXCSUM feature.\n"); - features &= ~NETIF_F_GRO_HW; + *features &= ~NETIF_F_GRO_HW; } }
/* LRO/HW-GRO features cannot be combined with RX-FCS */ - if (features & NETIF_F_RXFCS) { - if (features & NETIF_F_LRO) { + if (*features & NETIF_F_RXFCS) { + if (*features & NETIF_F_LRO) { netdev_dbg(dev, "Dropping LRO feature since RX-FCS is requested.\n"); - features &= ~NETIF_F_LRO; + *features &= ~NETIF_F_LRO; }
- if (features & NETIF_F_GRO_HW) { + if (*features & NETIF_F_GRO_HW) { netdev_dbg(dev, "Dropping HW-GRO feature since RX-FCS is requested.\n"); - features &= ~NETIF_F_GRO_HW; + *features &= ~NETIF_F_GRO_HW; } }
- if (features & NETIF_F_HW_TLS_TX) { - bool ip_csum = (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == + if (*features & NETIF_F_HW_TLS_TX) { + bool ip_csum = (*features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); - bool hw_csum = features & NETIF_F_HW_CSUM; + bool hw_csum = *features & NETIF_F_HW_CSUM;
if (!ip_csum && !hw_csum) { netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); - features &= ~NETIF_F_HW_TLS_TX; + *features &= ~NETIF_F_HW_TLS_TX; } }
- if ((features & NETIF_F_HW_TLS_RX) && !(features & NETIF_F_RXCSUM)) { + if ((*features & NETIF_F_HW_TLS_RX) && !(*features & NETIF_F_RXCSUM)) { netdev_dbg(dev, "Dropping TLS RX HW offload feature since no RXCSUM feature.\n"); - features &= ~NETIF_F_HW_TLS_RX; + *features &= ~NETIF_F_HW_TLS_RX; } - - return features; }
int __netdev_update_features(struct net_device *dev) @@ -9926,7 +9924,7 @@ int __netdev_update_features(struct net_device *dev) dev->netdev_ops->ndo_fix_features(dev, &features);
/* driver might be less strict about feature dependencies */ - features = netdev_fix_features(dev, features); + netdev_fix_features(dev, &features);
/* some features can't be enabled if they're off on an upper device */ netdev_for_each_upper_dev_rcu(dev, upper, iter)
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_sync_upper_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/core/dev.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index ee5bf8620316..08437ec23861 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9772,8 +9772,9 @@ static void net_set_todo(struct net_device *dev) dev_net(dev)->dev_unreg_count++; }
-static netdev_features_t netdev_sync_upper_features(struct net_device *lower, - struct net_device *upper, netdev_features_t features) +static void netdev_sync_upper_features(struct net_device *lower, + struct net_device *upper, + netdev_features_t *features) { netdev_features_t upper_disables = NETIF_F_UPPER_DISABLES; netdev_features_t feature; @@ -9781,15 +9782,13 @@ static netdev_features_t netdev_sync_upper_features(struct net_device *lower,
for_each_netdev_feature(upper_disables, feature_bit) { feature = __NETIF_F_BIT(feature_bit); - if (!(upper->wanted_features & feature) - && (features & feature)) { + if (!(upper->wanted_features & feature) && + (*features & feature)) { netdev_dbg(lower, "Dropping feature %pNF, upper dev %s has it off.\n", &feature, upper->name); - features &= ~feature; + *features &= ~feature; } } - - return features; }
static void netdev_sync_lower_features(struct net_device *upper, @@ -9928,7 +9927,7 @@ int __netdev_update_features(struct net_device *dev)
/* some features can't be enabled if they're off on an upper device */ netdev_for_each_upper_dev_rcu(dev, upper, iter) - features = netdev_sync_upper_features(dev, upper, features); + netdev_sync_upper_features(dev, upper, &features);
if (dev->features == features) goto sync_lower;
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of br_features_recompute for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/bridge/br_device.c | 2 +- net/bridge/br_if.c | 17 +++++++---------- net/bridge/br_private.h | 3 +-- 3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 622559aff2dd..fc508b9cbaa9 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -292,7 +292,7 @@ static void br_fix_features(struct net_device *dev, netdev_features_t *features) { struct net_bridge *br = netdev_priv(dev);
- *features = br_features_recompute(br, *features); + br_features_recompute(br, features); }
#ifdef CONFIG_NET_POLL_CONTROLLER diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 4a02f8bb278a..b2afbea2133e 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -532,25 +532,22 @@ static void br_set_gso_limits(struct net_bridge *br) /* * Recomputes features using slave's features */ -netdev_features_t br_features_recompute(struct net_bridge *br, - netdev_features_t features) +void br_features_recompute(struct net_bridge *br, netdev_features_t *features) { struct net_bridge_port *p; netdev_features_t mask;
if (list_empty(&br->port_list)) - return features; + return;
- mask = features; - features &= ~NETIF_F_ONE_FOR_ALL; + mask = *features; + *features &= ~NETIF_F_ONE_FOR_ALL;
list_for_each_entry(p, &br->port_list, list) { - features = netdev_increment_features(features, - p->dev->features, mask); + *features = netdev_increment_features(*features, + p->dev->features, mask); } - features = netdev_add_tso_features(features, mask); - - return features; + *features = netdev_add_tso_features(*features, mask); }
/* called with RTNL */ diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index b4cef3a97f12..1f5cff791827 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -824,8 +824,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev, struct netlink_ext_ack *extack); int br_del_if(struct net_bridge *br, struct net_device *dev); void br_mtu_auto_adjust(struct net_bridge *br); -netdev_features_t br_features_recompute(struct net_bridge *br, - netdev_features_t features); +void br_features_recompute(struct net_bridge *br, netdev_features_t *features); void br_port_flags_change(struct net_bridge_port *port, unsigned long mask); void br_manage_promisc(struct net_bridge *br); int nbp_backup_change(struct net_bridge_port *p, struct net_device *backup_dev);
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_add_tso_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/bonding/bond_main.c | 2 +- drivers/net/team/team.c | 2 +- include/linux/netdevice.h | 6 +++--- net/bridge/br_if.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 469509260a51..878c92746ada 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1386,7 +1386,7 @@ static void bond_fix_features(struct net_device *dev, slave->dev->features, mask); } - *features = netdev_add_tso_features(*features, mask); + netdev_add_tso_features(features, mask); }
#define BOND_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 340be925d4eb..706572b7a313 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -2014,7 +2014,7 @@ static void team_fix_features(struct net_device *dev, } rcu_read_unlock();
- *features = netdev_add_tso_features(*features, mask); + netdev_add_tso_features(features, mask); }
static int team_change_carrier(struct net_device *dev, bool new_carrier) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 43eb57fa9434..e826435ab847 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5043,10 +5043,10 @@ netdev_features_t netdev_increment_features(netdev_features_t all, * Performing the GSO segmentation before last device * is a performance improvement. */ -static inline netdev_features_t netdev_add_tso_features(netdev_features_t features, - netdev_features_t mask) +static inline void netdev_add_tso_features(netdev_features_t *features, + netdev_features_t mask) { - return netdev_increment_features(features, NETIF_F_ALL_TSO, mask); + *features = netdev_increment_features(*features, NETIF_F_ALL_TSO, mask); }
int __netdev_update_features(struct net_device *dev); diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index b2afbea2133e..749971ab1088 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -547,7 +547,7 @@ void br_features_recompute(struct net_bridge *br, netdev_features_t *features) *features = netdev_increment_features(*features, p->dev->features, mask); } - *features = netdev_add_tso_features(*features, mask); + netdev_add_tso_features(features, mask); }
/* called with RTNL */
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of netdev_increment_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/bonding/bond_main.c | 28 ++++++++++++++-------------- drivers/net/ipvlan/ipvlan_main.c | 4 ++-- drivers/net/macvlan.c | 2 +- drivers/net/net_failover.c | 28 ++++++++++++---------------- drivers/net/team/team.c | 19 ++++++++----------- include/linux/netdevice.h | 6 +++--- net/bridge/br_if.c | 4 ++-- net/core/dev.c | 7 ++++--- net/hsr/hsr_device.c | 5 ++--- 9 files changed, 48 insertions(+), 55 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 878c92746ada..b1c13fa3c677 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1382,9 +1382,8 @@ static void bond_fix_features(struct net_device *dev, *features |= NETIF_F_ALL_FOR_ALL;
bond_for_each_slave(bond, slave, iter) { - *features = netdev_increment_features(*features, - slave->dev->features, - mask); + netdev_increment_features(features, *features, + slave->dev->features, mask); } netdev_add_tso_features(features, mask); } @@ -1423,22 +1422,23 @@ static void bond_compute_features(struct bonding *bond) mpls_features &= NETIF_F_ALL_FOR_ALL;
bond_for_each_slave(bond, slave, iter) { - vlan_features = netdev_increment_features(vlan_features, - slave->dev->vlan_features, BOND_VLAN_FEATURES); + netdev_increment_features(&vlan_features, vlan_features, + slave->dev->vlan_features, + BOND_VLAN_FEATURES);
- enc_features = netdev_increment_features(enc_features, - slave->dev->hw_enc_features, - BOND_ENC_FEATURES); + netdev_increment_features(&enc_features, enc_features, + slave->dev->hw_enc_features, + BOND_ENC_FEATURES);
#ifdef CONFIG_XFRM_OFFLOAD - xfrm_features = netdev_increment_features(xfrm_features, - slave->dev->hw_enc_features, - BOND_XFRM_FEATURES); + netdev_increment_features(&xfrm_features, xfrm_features, + slave->dev->hw_enc_features, + BOND_XFRM_FEATURES); #endif /* CONFIG_XFRM_OFFLOAD */
- mpls_features = netdev_increment_features(mpls_features, - slave->dev->mpls_features, - BOND_MPLS_FEATURES); + netdev_increment_features(&mpls_features, mpls_features, + slave->dev->mpls_features, + BOND_MPLS_FEATURES);
dst_release_flag &= slave->dev->priv_flags; if (slave->dev->hard_header_len > max_hard_header_len) diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 8fcc91c0b0f4..6a0b7bd2d3ae 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -242,8 +242,8 @@ static void ipvlan_fix_features(struct net_device *dev,
*features |= NETIF_F_ALL_FOR_ALL; *features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES); - *features = netdev_increment_features(ipvlan->phy_dev->features, - *features, *features); + netdev_increment_features(features, ipvlan->phy_dev->features, + *features, *features); *features |= IPVLAN_ALWAYS_ON; *features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON); } diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 27cd9c08bb1e..3c408653e864 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1079,7 +1079,7 @@ static void macvlan_fix_features(struct net_device *dev, mask = *features;
lowerdev_features &= (*features | ~NETIF_F_LRO); - *features = netdev_increment_features(lowerdev_features, *features, mask); + netdev_increment_features(features, lowerdev_features, *features, mask); *features |= ALWAYS_ON_FEATURES; *features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES); } diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c index 2a4892402ed8..878cad216aaf 100644 --- a/drivers/net/net_failover.c +++ b/drivers/net/net_failover.c @@ -390,14 +390,12 @@ static void net_failover_compute_features(struct net_device *dev)
primary_dev = rcu_dereference(nfo_info->primary_dev); if (primary_dev) { - vlan_features = - netdev_increment_features(vlan_features, - primary_dev->vlan_features, - FAILOVER_VLAN_FEATURES); - enc_features = - netdev_increment_features(enc_features, - primary_dev->hw_enc_features, - FAILOVER_ENC_FEATURES); + netdev_increment_features(&vlan_features, vlan_features, + primary_dev->vlan_features, + FAILOVER_VLAN_FEATURES); + netdev_increment_features(&enc_features, enc_features, + primary_dev->hw_enc_features, + FAILOVER_ENC_FEATURES);
dst_release_flag &= primary_dev->priv_flags; if (primary_dev->hard_header_len > max_hard_header_len) @@ -406,14 +404,12 @@ static void net_failover_compute_features(struct net_device *dev)
standby_dev = rcu_dereference(nfo_info->standby_dev); if (standby_dev) { - vlan_features = - netdev_increment_features(vlan_features, - standby_dev->vlan_features, - FAILOVER_VLAN_FEATURES); - enc_features = - netdev_increment_features(enc_features, - standby_dev->hw_enc_features, - FAILOVER_ENC_FEATURES); + netdev_increment_features(&vlan_features, vlan_features, + standby_dev->vlan_features, + FAILOVER_VLAN_FEATURES); + netdev_increment_features(&enc_features, enc_features, + standby_dev->hw_enc_features, + FAILOVER_ENC_FEATURES);
dst_release_flag &= standby_dev->priv_flags; if (standby_dev->hard_header_len > max_hard_header_len) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 706572b7a313..fa96ee62c91a 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -994,14 +994,12 @@ static void __team_compute_features(struct team *team)
rcu_read_lock(); list_for_each_entry_rcu(port, &team->port_list, list) { - vlan_features = netdev_increment_features(vlan_features, - port->dev->vlan_features, - TEAM_VLAN_FEATURES); - enc_features = - netdev_increment_features(enc_features, - port->dev->hw_enc_features, - TEAM_ENC_FEATURES); - + netdev_increment_features(&vlan_features, vlan_features, + port->dev->vlan_features, + TEAM_VLAN_FEATURES); + netdev_increment_features(&enc_features, enc_features, + port->dev->hw_enc_features, + TEAM_ENC_FEATURES);
dst_release_flag &= port->dev->priv_flags; if (port->dev->hard_header_len > max_hard_header_len) @@ -2008,9 +2006,8 @@ static void team_fix_features(struct net_device *dev,
rcu_read_lock(); list_for_each_entry_rcu(port, &team->port_list, list) { - *features = netdev_increment_features(*features, - port->dev->features, - mask); + netdev_increment_features(features, *features, + port->dev->features, mask); } rcu_read_unlock();
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e826435ab847..7e2678a9d769 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5036,8 +5036,8 @@ static inline void netdev_get_wanted_features(struct net_device *dev, { *wanted = (dev->features & ~dev->hw_features) | dev->wanted_features; } -netdev_features_t netdev_increment_features(netdev_features_t all, - netdev_features_t one, netdev_features_t mask); +void netdev_increment_features(netdev_features_t *ret, netdev_features_t all, + netdev_features_t one, netdev_features_t mask);
/* Allow TSO being used on stacked device : * Performing the GSO segmentation before last device @@ -5046,7 +5046,7 @@ netdev_features_t netdev_increment_features(netdev_features_t all, static inline void netdev_add_tso_features(netdev_features_t *features, netdev_features_t mask) { - *features = netdev_increment_features(*features, NETIF_F_ALL_TSO, mask); + netdev_increment_features(features, *features, NETIF_F_ALL_TSO, mask); }
int __netdev_update_features(struct net_device *dev); diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 749971ab1088..914ca4b2d07c 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -544,8 +544,8 @@ void br_features_recompute(struct net_bridge *br, netdev_features_t *features) *features &= ~NETIF_F_ONE_FOR_ALL;
list_for_each_entry(p, &br->port_list, list) { - *features = netdev_increment_features(*features, - p->dev->features, mask); + netdev_increment_features(features, *features, p->dev->features, + mask); } netdev_add_tso_features(features, mask); } diff --git a/net/core/dev.c b/net/core/dev.c index 08437ec23861..ee2b4dce0f3f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11301,6 +11301,7 @@ static int dev_cpu_dead(unsigned int oldcpu)
/** * netdev_increment_features - increment feature set by one + * @ret: result feature set * @all: current feature set * @one: new feature set * @mask: mask feature set @@ -11309,8 +11310,8 @@ static int dev_cpu_dead(unsigned int oldcpu) * @one to the master device with current feature set @all. Will not * enable anything that is off in @mask. Returns the new feature set. */ -netdev_features_t netdev_increment_features(netdev_features_t all, - netdev_features_t one, netdev_features_t mask) +void netdev_increment_features(netdev_features_t *ret, netdev_features_t all, + netdev_features_t one, netdev_features_t mask) { if (mask & NETIF_F_HW_CSUM) mask |= NETIF_F_CSUM_MASK; @@ -11323,7 +11324,7 @@ netdev_features_t netdev_increment_features(netdev_features_t all, if (all & NETIF_F_HW_CSUM) all &= ~(NETIF_F_CSUM_MASK & ~NETIF_F_HW_CSUM);
- return all; + *ret = all; } EXPORT_SYMBOL(netdev_increment_features);
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index acaf48a1e136..16e0efd8b528 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -194,9 +194,8 @@ static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr, */ features &= ~NETIF_F_ONE_FOR_ALL; hsr_for_each_port(hsr, port) - features = netdev_increment_features(features, - port->dev->features, - mask); + netdev_increment_features(&features, features, + port->dev->features, mask);
return features; }
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of hsr_features_recompute for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/hsr/hsr_device.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 16e0efd8b528..7e6dd372711f 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -177,13 +177,13 @@ static int hsr_dev_close(struct net_device *dev) return 0; }
-static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr, - netdev_features_t features) +static void hsr_features_recompute(struct hsr_priv *hsr, + netdev_features_t *features) { netdev_features_t mask; struct hsr_port *port;
- mask = features; + mask = *features;
/* Mask out all features that, if supported by one device, should be * enabled for all devices (see NETIF_F_ONE_FOR_ALL). @@ -192,12 +192,10 @@ static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr, * that were in features originally, and also is in NETIF_F_ONE_FOR_ALL, * may become enabled. */ - features &= ~NETIF_F_ONE_FOR_ALL; + *features &= ~NETIF_F_ONE_FOR_ALL; hsr_for_each_port(hsr, port) - netdev_increment_features(&features, features, + netdev_increment_features(features, *features, port->dev->features, mask); - - return features; }
static void hsr_fix_features(struct net_device *dev, @@ -205,7 +203,7 @@ static void hsr_fix_features(struct net_device *dev, { struct hsr_priv *hsr = netdev_priv(dev);
- *features = hsr_features_recompute(hsr, *features); + hsr_features_recompute(hsr, features); }
static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of mlx5e_tunnel_features_check, mlx5e_ipsec_feature_check and mlx5e_fix_uplink_rep_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h | 15 ++++---- .../net/ethernet/mellanox/mlx5/core/en_main.c | 34 +++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h index 5120a59361e6..62ab97cca915 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h @@ -93,8 +93,8 @@ static inline bool mlx5e_ipsec_eseg_meta(struct mlx5_wqe_eth_seg *eseg) void mlx5e_ipsec_tx_build_eseg(struct mlx5e_priv *priv, struct sk_buff *skb, struct mlx5_wqe_eth_seg *eseg);
-static inline netdev_features_t -mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t features) +static inline void +mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t *features) { struct xfrm_offload *xo = xfrm_offload(skb); struct sec_path *sp = skb_sec_path(skb); @@ -118,13 +118,12 @@ mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t features) goto out_disable; }
- return features; - + return; }
/* Disable CSUM and GSO for software IPsec */ out_disable: - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
#else @@ -140,9 +139,9 @@ static inline bool mlx5e_ipsec_eseg_meta(struct mlx5_wqe_eth_seg *eseg) }
static inline bool mlx5_ipsec_is_rx_flow(struct mlx5_cqe64 *cqe) { return false; } -static inline netdev_features_t -mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t features) -{ return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); } +static inline void +mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t *features) +{ *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); } #endif /* CONFIG_MLX5_EN_IPSEC */
#endif /* __MLX5E_IPSEC_RXTX_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 4092210fb079..07f88bc4be1c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3379,22 +3379,20 @@ int mlx5e_set_features(struct net_device *netdev, netdev_features_t features) return 0; }
-static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev, - netdev_features_t features) +static void mlx5e_fix_uplink_rep_features(struct net_device *netdev, + netdev_features_t *features) { - features &= ~NETIF_F_HW_TLS_RX; + *features &= ~NETIF_F_HW_TLS_RX; if (netdev->features & NETIF_F_HW_TLS_RX) netdev_warn(netdev, "Disabling hw_tls_rx, not supported in switchdev mode\n");
- features &= ~NETIF_F_HW_TLS_TX; + *features &= ~NETIF_F_HW_TLS_TX; if (netdev->features & NETIF_F_HW_TLS_TX) netdev_warn(netdev, "Disabling hw_tls_tx, not supported in switchdev mode\n");
- features &= ~NETIF_F_NTUPLE; + *features &= ~NETIF_F_NTUPLE; if (netdev->features & NETIF_F_NTUPLE) netdev_warn(netdev, "Disabling ntuple, not supported in switchdev mode\n"); - - return features; }
static void mlx5e_fix_features(struct net_device *netdev, @@ -3429,7 +3427,7 @@ static void mlx5e_fix_features(struct net_device *netdev, }
if (mlx5e_is_uplink_rep(priv)) - features = mlx5e_fix_uplink_rep_features(netdev, features); + mlx5e_fix_uplink_rep_features(netdev, &features);
mutex_unlock(&priv->state_lock); } @@ -3847,9 +3845,9 @@ static bool mlx5e_gre_tunnel_inner_proto_offload_supported(struct mlx5_core_dev return false; }
-static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, - struct sk_buff *skb, - netdev_features_t features) +static void mlx5e_tunnel_features_check(struct mlx5e_priv *priv, + struct sk_buff *skb, + netdev_features_t *features) { unsigned int offset = 0; struct udphdr *udph; @@ -3870,12 +3868,12 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, switch (proto) { case IPPROTO_GRE: if (mlx5e_gre_tunnel_inner_proto_offload_supported(priv->mdev, skb)) - return features; + return; break; case IPPROTO_IPIP: case IPPROTO_IPV6: if (mlx5e_tunnel_proto_supported_tx(priv->mdev, IPPROTO_IPIP)) - return features; + return; break; case IPPROTO_UDP: udph = udp_hdr(skb); @@ -3883,23 +3881,23 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
/* Verify if UDP port is being offloaded by HW */ if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port)) - return features; + return;
#if IS_ENABLED(CONFIG_GENEVE) /* Support Geneve offload for default UDP port */ if (port == GENEVE_UDP_PORT && mlx5_geneve_tx_allowed(priv->mdev)) - return features; + return; #endif break; #ifdef CONFIG_MLX5_EN_IPSEC case IPPROTO_ESP: - return mlx5e_ipsec_feature_check(skb, features); + mlx5e_ipsec_feature_check(skb, *features); #endif }
out: /* Disable CSUM and GSO if the udp dport is not offloaded by HW */ - return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); }
void mlx5e_features_check(struct sk_buff *skb, struct net_device *netdev, @@ -3913,7 +3911,7 @@ void mlx5e_features_check(struct sk_buff *skb, struct net_device *netdev, /* Validate if the tunneled packet is being offloaded by HW */ if (skb->encapsulation && (*features & NETIF_F_CSUM_MASK || *features & NETIF_F_GSO_MASK)) - *features = mlx5e_tunnel_features_check(priv, skb, *features); + mlx5e_tunnel_features_check(priv, skb, features); }
static void mlx5e_tx_timeout_work(struct work_struct *work)
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of xxx_supported_features for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ethernet/sfc/falcon/net_driver.h | 5 +++-- drivers/net/ethernet/sfc/mcdi_filters.c | 5 ++++- drivers/net/ethernet/sfc/net_driver.h | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/sfc/falcon/net_driver.h b/drivers/net/ethernet/sfc/falcon/net_driver.h index a381cf9ec4f3..6fabfe7f02f5 100644 --- a/drivers/net/ethernet/sfc/falcon/net_driver.h +++ b/drivers/net/ethernet/sfc/falcon/net_driver.h @@ -1298,11 +1298,12 @@ static inline struct ef4_rx_buffer *ef4_rx_buffer(struct ef4_rx_queue *rx_queue, * If a feature is fixed, it does not present in hw_features, but * always in features. */ -static inline netdev_features_t ef4_supported_features(const struct ef4_nic *efx) +static inline void ef4_supported_features(const struct ef4_nic *efx, + netdev_features_t *supported) { const struct net_device *net_dev = efx->net_dev;
- return net_dev->features | net_dev->hw_features; + *supported = net_dev->features | net_dev->hw_features; }
/* Get the current TX queue insert index. */ diff --git a/drivers/net/ethernet/sfc/mcdi_filters.c b/drivers/net/ethernet/sfc/mcdi_filters.c index 1523be77b9db..8e788c3a6f2a 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.c +++ b/drivers/net/ethernet/sfc/mcdi_filters.c @@ -1298,6 +1298,7 @@ int efx_mcdi_filter_table_probe(struct efx_nic *efx, bool multicast_chaining) { struct net_device *net_dev = efx->net_dev; struct efx_mcdi_filter_table *table; + netdev_features_t supported; int rc;
if (!efx_rwsem_assert_write_locked(&efx->filter_sem)) @@ -1319,7 +1320,9 @@ int efx_mcdi_filter_table_probe(struct efx_nic *efx, bool multicast_chaining) rc = efx_mcdi_filter_table_probe_matches(efx, table, true); if (rc) goto fail; - if ((efx_supported_features(efx) & NETIF_F_HW_VLAN_CTAG_FILTER) && + + efx_supported_features(efx, &supported); + if ((supported & NETIF_F_HW_VLAN_CTAG_FILTER) && !(efx_mcdi_filter_match_supported(table, false, (EFX_FILTER_MATCH_OUTER_VID | EFX_FILTER_MATCH_LOC_MAC)) && efx_mcdi_filter_match_supported(table, false, diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index f6981810039d..bf962ca160e7 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -1681,11 +1681,12 @@ efx_channel_tx_old_fill_level(struct efx_channel *channel) * If a feature is fixed, it does not present in hw_features, but * always in features. */ -static inline netdev_features_t efx_supported_features(const struct efx_nic *efx) +static inline void efx_supported_features(const struct efx_nic *efx, + netdev_features_t *supported) { const struct net_device *net_dev = efx->net_dev;
- return net_dev->features | net_dev->hw_features; + *supported = net_dev->features | net_dev->hw_features; }
/* Get the current TX queue insert index. */
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of qlcnic_process_flags for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- .../net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c index e6ed7f8413b4..2367923e3e3f 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c @@ -1020,37 +1020,35 @@ int qlcnic_change_mtu(struct net_device *netdev, int mtu) return rc; }
-static netdev_features_t qlcnic_process_flags(struct qlcnic_adapter *adapter, - netdev_features_t features) +static void qlcnic_process_flags(struct qlcnic_adapter *adapter, + netdev_features_t *features) { u32 offload_flags = adapter->offload_flags;
if (offload_flags & BIT_0) { - features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | - NETIF_F_IPV6_CSUM; + *features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | + NETIF_F_IPV6_CSUM; adapter->rx_csum = 1; if (QLCNIC_IS_TSO_CAPABLE(adapter)) { if (!(offload_flags & BIT_1)) - features &= ~NETIF_F_TSO; + *features &= ~NETIF_F_TSO; else - features |= NETIF_F_TSO; + *features |= NETIF_F_TSO;
if (!(offload_flags & BIT_2)) - features &= ~NETIF_F_TSO6; + *features &= ~NETIF_F_TSO6; else - features |= NETIF_F_TSO6; + *features |= NETIF_F_TSO6; } } else { - features &= ~(NETIF_F_RXCSUM | + *features &= ~(NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
if (QLCNIC_IS_TSO_CAPABLE(adapter)) - features &= ~(NETIF_F_TSO | NETIF_F_TSO6); + *features &= ~(NETIF_F_TSO | NETIF_F_TSO6); adapter->rx_csum = 0; } - - return features; }
void qlcnic_fix_features(struct net_device *netdev, netdev_features_t *features) @@ -1061,7 +1059,7 @@ void qlcnic_fix_features(struct net_device *netdev, netdev_features_t *features) if (qlcnic_82xx_check(adapter) && (adapter->flags & QLCNIC_ESWITCH_ENABLED)) { if (adapter->flags & QLCNIC_APP_CHANGED_FLAGS) { - *features = qlcnic_process_flags(adapter, *features); + qlcnic_process_flags(adapter, features); } else { changed = *features ^ netdev->features; *features ^= changed & (NETIF_F_RXCSUM |
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of rtl8168evl_fix_tso for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ethernet/realtek/r8169_main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 8affae2b55a6..c876246cf8c1 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4326,23 +4326,20 @@ static unsigned int rtl_last_frag_len(struct sk_buff *skb) }
/* Workaround for hw issues with TSO on RTL8168evl */ -static netdev_features_t rtl8168evl_fix_tso(struct sk_buff *skb, - netdev_features_t features) +static void rtl8168evl_fix_tso(struct sk_buff *skb, netdev_features_t *features) { /* IPv4 header has options field */ if (vlan_get_protocol(skb) == htons(ETH_P_IP) && ip_hdrlen(skb) > sizeof(struct iphdr)) - features &= ~NETIF_F_ALL_TSO; + *features &= ~NETIF_F_ALL_TSO;
/* IPv4 TCP header has options field */ else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4 && tcp_hdrlen(skb) > sizeof(struct tcphdr)) - features &= ~NETIF_F_ALL_TSO; + *features &= ~NETIF_F_ALL_TSO;
else if (rtl_last_frag_len(skb) <= 6) - features &= ~NETIF_F_ALL_TSO; - - return features; + *features &= ~NETIF_F_ALL_TSO; }
static void rtl8169_features_check(struct sk_buff *skb, struct net_device *dev, @@ -4353,7 +4350,7 @@ static void rtl8169_features_check(struct sk_buff *skb, struct net_device *dev,
if (skb_is_gso(skb)) { if (tp->mac_version == RTL_GIGA_MAC_VER_34) - *features = rtl8168evl_fix_tso(skb, *features); + rtl8168evl_fix_tso(skb, features);
if (transport_offset > GTTCPHO_MAX && rtl_chip_supports_csum_v2(tp))
For the origin type for netdev_features_t would be changed to be unsigned long * from u64, so changes the prototype of ethtool_get_feature_mask for adaption.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/ethtool/ioctl.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 999e2a6bed13..8817d761cb6b 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -194,30 +194,35 @@ static void __ethtool_get_strings(struct net_device *dev, ops->get_strings(dev, stringset, data); }
-static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd) +static void ethtool_get_feature_mask(u32 eth_cmd, netdev_features_t *mask) { /* feature masks of legacy discrete ethtool ops */
switch (eth_cmd) { case ETHTOOL_GTXCSUM: case ETHTOOL_STXCSUM: - return NETIF_F_CSUM_MASK | NETIF_F_FCOE_CRC | - NETIF_F_SCTP_CRC; + *mask = NETIF_F_CSUM_MASK | NETIF_F_FCOE_CRC | NETIF_F_SCTP_CRC; + break; case ETHTOOL_GRXCSUM: case ETHTOOL_SRXCSUM: - return NETIF_F_RXCSUM; + *mask = NETIF_F_RXCSUM; + break; case ETHTOOL_GSG: case ETHTOOL_SSG: - return NETIF_F_SG | NETIF_F_FRAGLIST; + *mask = NETIF_F_SG | NETIF_F_FRAGLIST; + break; case ETHTOOL_GTSO: case ETHTOOL_STSO: - return NETIF_F_ALL_TSO; + *mask = NETIF_F_ALL_TSO; + break; case ETHTOOL_GGSO: case ETHTOOL_SGSO: - return NETIF_F_GSO; + *mask = NETIF_F_GSO; + break; case ETHTOOL_GGRO: case ETHTOOL_SGRO: - return NETIF_F_GRO; + *mask = NETIF_F_GRO; + break; default: BUG(); } @@ -226,11 +231,12 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd) static int ethtool_get_one_feature(struct net_device *dev, char __user *useraddr, u32 ethcmd) { - netdev_features_t mask = ethtool_get_feature_mask(ethcmd); - struct ethtool_value edata = { - .cmd = ethcmd, - .data = !!(dev->features & mask), - }; + struct ethtool_value edata; + netdev_features_t mask; + + ethtool_get_feature_mask(ethcmd, &mask); + edata.cmd = ethcmd; + edata.data = !!(dev->features & mask);
if (copy_to_user(useraddr, &edata, sizeof(edata))) return -EFAULT; @@ -246,7 +252,7 @@ static int ethtool_set_one_feature(struct net_device *dev, if (copy_from_user(&edata, useraddr, sizeof(edata))) return -EFAULT;
- mask = ethtool_get_feature_mask(ethcmd); + ethtool_get_feature_mask(ethcmd, &mask); mask &= dev->hw_features; if (!mask) return -EOPNOTSUPP;
For the prototype of netdev_features_t will be changed from u64 to unsigned long *, so it's necessary to add a set of helpers to do the logic operation.
This is a temporary patch, used to compatible with the current prototype of netdev_features_t. The parameters styles are not consistent for among these helpers, in order to minimize the modification when change the netdev_features_t to bitmap.
It also introduce a new macro NETDEV_FEATURE_DWORDS, used for scenario define the features as an array, so it can be initialized when define structure.
Signed-off-by: Jian Shen shenjian15@huawei.com --- include/linux/netdev_features.h | 135 ++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index 2c6b9e416225..b3fa05c88eef 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h @@ -101,6 +101,8 @@ enum { /**/NETDEV_FEATURE_COUNT };
+#define NETDEV_FEATURE_DWORDS DIV_ROUND_UP(NETDEV_FEATURE_COUNT, 64) + /* copy'n'paste compression ;) */ #define __NETIF_F_BIT(bit) ((netdev_features_t)1 << (bit)) #define __NETIF_F(name) __NETIF_F_BIT(NETIF_F_##name##_BIT) @@ -261,4 +263,137 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start) NETIF_F_GSO_UDP_TUNNEL | \ NETIF_F_GSO_UDP_TUNNEL_CSUM)
+static inline void netdev_feature_zero(netdev_features_t *dst) +{ + *dst = 0; +} + +static inline void netdev_feature_fill(netdev_features_t *dst) +{ + *dst = ~0; +} + +static inline void netdev_feature_copy(netdev_features_t *dst, + const netdev_features_t src) +{ + *dst = src; +} + +static inline void netdev_feature_and(netdev_features_t *dst, + const netdev_features_t a, + const netdev_features_t b) +{ + *dst = a & b; +} + +static inline void netdev_feature_or(netdev_features_t *dst, + const netdev_features_t a, + const netdev_features_t b) +{ + *dst = a | b; +} + +static inline void netdev_feature_xor(netdev_features_t *dst, + const netdev_features_t a, + const netdev_features_t b) +{ + *dst = a ^ b; +} + +static inline bool netdev_feature_empty(netdev_features_t src) +{ + return src == 0; +} + +static inline bool netdev_feature_equal(const netdev_features_t src1, + const netdev_features_t src2) +{ + return src1 == src2; +} + +static inline int netdev_feature_andnot(netdev_features_t *dst, + const netdev_features_t src1, + const netdev_features_t src2) +{ + *dst = src1 & ~src2; + return 0; +} + +static inline void netdev_feature_set_bit(int nr, netdev_features_t *addr) +{ + *addr |= __NETIF_F_BIT(nr); +} + +static inline void netdev_feature_clear_bit(int nr, netdev_features_t *addr) +{ + *addr &= ~(__NETIF_F_BIT(nr)); +} + +static inline void netdev_feature_mod_bit(int nr, netdev_features_t *addr, + int set) +{ + if (set) + netdev_feature_set_bit(nr, addr); + else + netdev_feature_clear_bit(nr, addr); +} + +static inline void netdev_feature_change_bit(int nr, netdev_features_t *addr) +{ + *addr ^= __NETIF_F_BIT(nr); +} + +static inline int netdev_feature_test_bit(int nr, const netdev_features_t addr) +{ + return (addr & __NETIF_F_BIT(nr)) > 0; +} + +static inline void netdev_feature_set_bit_array(const int *array, + int array_size, + netdev_features_t *addr) +{ + int i; + + for (i = 0; i < array_size; i++) + netdev_feature_set_bit(array[i], addr); +} + +/* only be used for the first 64 bits features */ +static inline void netdev_feature_set_bits(u64 bits, netdev_features_t *addr) +{ + *addr |= bits; +} + +/* only be used for the first 64 bits features */ +static inline void netdev_feature_clear_bits(u64 bits, netdev_features_t *addr) +{ + *addr &= ~bits; +} + +/* only be used for the first 64 bits features */ +static inline bool netdev_feature_test_bits(u64 bits, + const netdev_features_t addr) +{ + return (addr & bits) > 0; +} + +/* only be used for the first 64 bits features */ +static inline void netdev_feature_and_bits(u64 bits, + netdev_features_t *addr) +{ + *addr &= bits; +} + +static inline int netdev_feature_intersects(const netdev_features_t src1, + const netdev_features_t src2) +{ + return (src1 & src2) > 0; +} + +static inline int netdev_feature_subset(const netdev_features_t src1, + const netdev_features_t src2) +{ + return (src1 & src2) == src2; +} + #endif /* _LINUX_NETDEV_FEATURES_H */
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- include/linux/netdevice.h | 78 ++++++---- net/core/dev.c | 315 +++++++++++++++++++++++--------------- 2 files changed, 236 insertions(+), 157 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7e2678a9d769..71caf078dcf0 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2271,7 +2271,8 @@ struct net_device {
static inline bool netif_elide_gro(const struct net_device *dev) { - if (!(dev->features & NETIF_F_GRO) || dev->xdp_prog) + if (!netdev_feature_test_bit(NETIF_F_GRO_BIT, dev->features) || + dev->xdp_prog) return true; return false; } @@ -4515,25 +4516,28 @@ static inline void netif_tx_unlock_bh(struct net_device *dev) local_bh_enable(); }
-#define HARD_TX_LOCK(dev, txq, cpu) { \ - if ((dev->features & NETIF_F_LLTX) == 0) { \ - __netif_tx_lock(txq, cpu); \ - } else { \ - __netif_tx_acquire(txq); \ - } \ +#define HARD_TX_LOCK(dev, txq, cpu) { \ + if (!netdev_feature_test_bit(NETIF_F_LLTX_BIT, \ + dev->features)) { \ + __netif_tx_lock(txq, cpu); \ + } else { \ + __netif_tx_acquire(txq); \ + } \ }
-#define HARD_TX_TRYLOCK(dev, txq) \ - (((dev->features & NETIF_F_LLTX) == 0) ? \ - __netif_tx_trylock(txq) : \ +#define HARD_TX_TRYLOCK(dev, txq) \ + (!netdev_feature_test_bit(NETIF_F_LLTX_BIT, \ + dev->features) ? \ + __netif_tx_trylock(txq) : \ __netif_tx_acquire(txq))
-#define HARD_TX_UNLOCK(dev, txq) { \ - if ((dev->features & NETIF_F_LLTX) == 0) { \ - __netif_tx_unlock(txq); \ - } else { \ - __netif_tx_release(txq); \ - } \ +#define HARD_TX_UNLOCK(dev, txq) { \ + if (!netdev_feature_test_bit(NETIF_F_LLTX_BIT, \ + dev->features)) { \ + __netif_tx_unlock(txq); \ + } else { \ + __netif_tx_release(txq); \ + } \ }
static inline void netif_tx_disable(struct net_device *dev) @@ -4943,20 +4947,20 @@ static inline bool can_checksum_protocol(netdev_features_t features, __be16 protocol) { if (protocol == htons(ETH_P_FCOE)) - return !!(features & NETIF_F_FCOE_CRC); + return netdev_feature_test_bit(NETIF_F_FCOE_CRC_BIT, features);
/* Assume this is an IP checksum (not SCTP CRC) */
- if (features & NETIF_F_HW_CSUM) { + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, features)) { /* Can checksum everything */ return true; }
switch (protocol) { case htons(ETH_P_IP): - return !!(features & NETIF_F_IP_CSUM); + return netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, features); case htons(ETH_P_IPV6): - return !!(features & NETIF_F_IPV6_CSUM); + return netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, features); default: return false; } @@ -5021,21 +5025,26 @@ static inline void netdev_intersect_features(netdev_features_t *ret, netdev_features_t f1, netdev_features_t f2) { - if ((f1 ^ f2) & NETIF_F_HW_CSUM) { - if (f1 & NETIF_F_HW_CSUM) - f1 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, f1) != + netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, f2)) { + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, f1)) + netdev_feature_set_bits(NETIF_F_IP_CSUM | + NETIF_F_IPV6_CSUM, &f1); else - f2 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM); + netdev_feature_set_bits(NETIF_F_IP_CSUM | + NETIF_F_IPV6_CSUM, &f2); }
- *ret = f1 & f2; + netdev_feature_and(ret, f1, f2); }
static inline void netdev_get_wanted_features(struct net_device *dev, netdev_features_t *wanted) { - *wanted = (dev->features & ~dev->hw_features) | dev->wanted_features; + netdev_feature_andnot(wanted, dev->features, dev->hw_features); + netdev_feature_or(wanted, *wanted, dev->wanted_features); } + void netdev_increment_features(netdev_features_t *ret, netdev_features_t all, netdev_features_t one, netdev_features_t mask);
@@ -5046,7 +5055,11 @@ void netdev_increment_features(netdev_features_t *ret, netdev_features_t all, static inline void netdev_add_tso_features(netdev_features_t *features, netdev_features_t mask) { - netdev_increment_features(features, *features, NETIF_F_ALL_TSO, mask); + netdev_features_t one; + + netdev_feature_zero(&one); + netdev_feature_set_bits(NETIF_F_ALL_TSO, &one); + netdev_increment_features(features, *features, one, mask); }
int __netdev_update_features(struct net_device *dev); @@ -5062,7 +5075,7 @@ void netif_skb_features(struct sk_buff *skb, netdev_features_t *features);
static inline bool net_gso_ok(netdev_features_t features, int gso_type) { - netdev_features_t feature = (netdev_features_t)gso_type << NETIF_F_GSO_SHIFT; + netdev_features_t feature;
/* check flags correspondence */ BUILD_BUG_ON(SKB_GSO_TCPV4 != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT)); @@ -5085,13 +5098,18 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type) BUILD_BUG_ON(SKB_GSO_UDP_L4 != (NETIF_F_GSO_UDP_L4 >> NETIF_F_GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_FRAGLIST != (NETIF_F_GSO_FRAGLIST >> NETIF_F_GSO_SHIFT));
- return (features & feature) == feature; + netdev_feature_zero(&feature); + netdev_feature_set_bit((u64)gso_type << NETIF_F_GSO_SHIFT, &feature); + + return netdev_feature_subset(features, feature); + }
static inline bool skb_gso_ok(struct sk_buff *skb, netdev_features_t features) { return net_gso_ok(features, skb_shinfo(skb)->gso_type) && - (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST)); + (!skb_has_frag_list(skb) || + netdev_feature_test_bit(NETIF_F_FRAGLIST_BIT, features)); }
static inline bool netif_needs_gso(struct sk_buff *skb, diff --git a/net/core/dev.c b/net/core/dev.c index ee2b4dce0f3f..b6fa5b5de8ed 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1636,10 +1636,10 @@ void dev_disable_lro(struct net_device *dev) struct net_device *lower_dev; struct list_head *iter;
- dev->wanted_features &= ~NETIF_F_LRO; + netdev_feature_clear_bit(NETIF_F_LRO_BIT, &dev->wanted_features); netdev_update_features(dev);
- if (unlikely(dev->features & NETIF_F_LRO)) + if (unlikely(netdev_feature_test_bit(NETIF_F_LRO_BIT, dev->features))) netdev_WARN(dev, "failed to disable LRO!\n");
netdev_for_each_lower_dev(dev, lower_dev, iter) @@ -1657,10 +1657,12 @@ EXPORT_SYMBOL(dev_disable_lro); */ static void dev_disable_gro_hw(struct net_device *dev) { - dev->wanted_features &= ~NETIF_F_GRO_HW; + netdev_feature_clear_bit(NETIF_F_GRO_HW_BIT, &dev->wanted_features); netdev_update_features(dev);
- if (unlikely(dev->features & NETIF_F_GRO_HW)) + if (unlikely(netdev_feature_test_bit(NETIF_F_GRO_HW_BIT, + dev->features))) + netdev_WARN(dev, "failed to disable GRO_HW!\n"); }
@@ -3379,13 +3381,19 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb, * support segmentation on this frame without needing additional * work. */ - if (features & NETIF_F_GSO_PARTIAL) { - netdev_features_t partial_features = NETIF_F_GSO_ROBUST; + if (netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, features)) { + netdev_features_t partial_features; struct net_device *dev = skb->dev;
- partial_features |= dev->features & dev->gso_partial_features; - if (!skb_gso_ok(skb, features | partial_features)) - features &= ~NETIF_F_GSO_PARTIAL; + netdev_feature_and(&partial_features, dev->features, + dev->gso_partial_features); + netdev_feature_set_bit(NETIF_F_GSO_ROBUST_BIT, + &partial_features); + netdev_feature_or(&partial_features, partial_features, + features); + if (!skb_gso_ok(skb, partial_features)) + netdev_feature_clear_bit(NETIF_F_GSO_PARTIAL_BIT, + &features); }
BUILD_BUG_ON(SKB_GSO_CB_OFFSET + @@ -3428,7 +3436,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) #ifdef CONFIG_HIGHMEM int i;
- if (!(dev->features & NETIF_F_HIGHDMA)) { + if (!netdev_feature_test_bit(NETIF_F_HIGHDMA_BIT, dev->features)) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
@@ -3448,7 +3456,8 @@ static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features, __be16 type) { if (eth_p_mpls(type)) - *features &= skb->dev->mpls_features; + netdev_feature_and(features, *features, + skb->dev->mpls_features); } #else static void net_mpls_features(struct sk_buff *skb, netdev_features_t *features, @@ -3466,10 +3475,11 @@ static void harmonize_features(struct sk_buff *skb, netdev_features_t *features)
if (skb->ip_summed != CHECKSUM_NONE && !can_checksum_protocol(*features, type)) { - *features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); + netdev_feature_clear_bits(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK, + features); } if (illegal_highdma(skb->dev, skb)) - *features &= ~NETIF_F_SG; + netdev_feature_clear_bit(NETIF_F_SG_BIT, features); }
void passthru_features_check(struct sk_buff *skb, struct net_device *dev, @@ -3492,13 +3502,13 @@ static void gso_features_check(const struct sk_buff *skb, u16 gso_segs = skb_shinfo(skb)->gso_segs;
if (gso_segs > dev->gso_max_segs) { - *features &= ~NETIF_F_GSO_MASK; + netdev_feature_clear_bits(NETIF_F_GSO_MASK, features); return; }
if (!skb_shinfo(skb)->gso_type) { skb_warn_bad_offload(skb); - *features &= ~NETIF_F_GSO_MASK; + netdev_feature_clear_bits(NETIF_F_GSO_MASK, features); return; }
@@ -3509,7 +3519,8 @@ static void gso_features_check(const struct sk_buff *skb, * segmented the frame. */ if (!(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL)) - *features &= ~dev->gso_partial_features; + netdev_feature_andnot(features, *features, + dev->gso_partial_features);
/* Make sure to clear the IPv4 ID mangling feature if the * IPv4 header has the potential to be fragmented. @@ -3519,7 +3530,8 @@ static void gso_features_check(const struct sk_buff *skb, inner_ip_hdr(skb) : ip_hdr(skb);
if (!(iph->frag_off & htons(IP_DF))) - *features &= ~NETIF_F_TSO_MANGLEID; + netdev_feature_clear_bit(NETIF_F_TSO_MANGLEID_BIT, + features); } }
@@ -3527,7 +3539,7 @@ void netif_skb_features(struct sk_buff *skb, netdev_features_t *features) { struct net_device *dev = skb->dev;
- *features = dev->features; + netdev_feature_copy(features, dev->features);
if (skb_is_gso(skb)) gso_features_check(skb, dev, features); @@ -3537,13 +3549,16 @@ void netif_skb_features(struct sk_buff *skb, netdev_features_t *features) * features for the netdev */ if (skb->encapsulation) - *features &= dev->hw_enc_features; + netdev_feature_and(features, *features, dev->hw_enc_features); + + if (skb_vlan_tagged(skb)) { + netdev_features_t tmp;
- if (skb_vlan_tagged(skb)) - netdev_intersect_features(features, *features, - dev->vlan_features | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX); + netdev_feature_copy(&tmp, dev->vlan_features); + netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX_BIT | + NETIF_F_HW_VLAN_STAG_TX_BIT, &tmp); + netdev_intersect_features(features, *features, tmp); + }
if (dev->netdev_ops->ndo_features_check) dev->netdev_ops->ndo_features_check(skb, dev, features); @@ -3613,13 +3628,14 @@ int skb_csum_hwoffload_help(struct sk_buff *skb, const netdev_features_t features) { if (unlikely(skb_csum_is_sctp(skb))) - return !!(features & NETIF_F_SCTP_CRC) ? 0 : - skb_crc32c_csum_help(skb); + return netdev_feature_test_bit(NETIF_F_SCTP_CRC_BIT, features) ? + 0 : skb_crc32c_csum_help(skb);
- if (features & NETIF_F_HW_CSUM) + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, features)) return 0;
- if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) { + if (netdev_feature_test_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM, + features)) { switch (skb->csum_offset) { case offsetof(struct tcphdr, check): case offsetof(struct udphdr, check): @@ -4351,7 +4367,8 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
/* Should we steer this flow to a different hardware queue? */ if (!skb_rx_queue_recorded(skb) || !dev->rx_cpu_rmap || - !(dev->features & NETIF_F_NTUPLE)) + !netdev_feature_test_bit(NETIF_F_NTUPLE_BIT, + dev->features)) goto out; rxq_index = cpu_rmap_lookup_index(dev->rx_cpu_rmap, next_cpu); if (rxq_index == skb_get_rx_queue(skb)) @@ -9776,17 +9793,19 @@ static void netdev_sync_upper_features(struct net_device *lower, struct net_device *upper, netdev_features_t *features) { - netdev_features_t upper_disables = NETIF_F_UPPER_DISABLES; - netdev_features_t feature; + netdev_features_t upper_disables; int feature_bit;
+ netdev_feature_zero(&upper_disables); + netdev_feature_set_bits(NETIF_F_UPPER_DISABLES, &upper_disables); + for_each_netdev_feature(upper_disables, feature_bit) { - feature = __NETIF_F_BIT(feature_bit); - if (!(upper->wanted_features & feature) && - (*features & feature)) { - netdev_dbg(lower, "Dropping feature %pNF, upper dev %s has it off.\n", - &feature, upper->name); - *features &= ~feature; + if (!netdev_feature_test_bit(feature_bit, + upper->wanted_features) && + netdev_feature_test_bit(feature_bit, *features)) { + netdev_dbg(lower, "Dropping feature bit %d, upper dev %s has it off.\n", + feature_bit, upper->name); + netdev_feature_clear_bit(feature_bit, features); } } } @@ -9794,21 +9813,25 @@ static void netdev_sync_upper_features(struct net_device *lower, static void netdev_sync_lower_features(struct net_device *upper, struct net_device *lower, netdev_features_t features) { - netdev_features_t upper_disables = NETIF_F_UPPER_DISABLES; - netdev_features_t feature; + netdev_features_t upper_disables; int feature_bit;
+ netdev_feature_zero(&upper_disables); + netdev_feature_set_bits(NETIF_F_UPPER_DISABLES, &upper_disables); + for_each_netdev_feature(upper_disables, feature_bit) { - feature = __NETIF_F_BIT(feature_bit); - if (!(features & feature) && (lower->features & feature)) { - netdev_dbg(upper, "Disabling feature %pNF on lower dev %s.\n", - &feature, lower->name); - lower->wanted_features &= ~feature; + if (!netdev_feature_test_bit(feature_bit, features) && + netdev_feature_test_bit(feature_bit, lower->features)) { + netdev_dbg(upper, "Disabling feature bit %d on lower dev %s.\n", + feature_bit, lower->name); + netdev_feature_clear_bit(feature_bit, + &lower->wanted_features); __netdev_update_features(lower);
- if (unlikely(lower->features & feature)) - netdev_WARN(upper, "failed to disable %pNF on %s!\n", - &feature, lower->name); + if (unlikely(netdev_feature_test_bit(feature_bit, + lower->features))) + netdev_WARN(upper, "failed to disable feature bit %d on %s!\n", + feature_bit, lower->name); else netdev_features_change(lower); } @@ -9819,92 +9842,102 @@ static void netdev_fix_features(struct net_device *dev, netdev_features_t *features) { /* Fix illegal checksum combinations */ - if ((*features & NETIF_F_HW_CSUM) && - (*features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))) { + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, *features) && + netdev_feature_test_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM, + *features)) { netdev_warn(dev, "mixed HW and IP checksum settings.\n"); - *features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); + netdev_feature_clear_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM, + features); }
/* TSO requires that SG is present as well. */ - if ((*features & NETIF_F_ALL_TSO) && !(*features & NETIF_F_SG)) { + if (netdev_feature_test_bits(NETIF_F_ALL_TSO, *features) && + !netdev_feature_test_bit(NETIF_F_SG_BIT, *features)) { netdev_dbg(dev, "Dropping TSO features since no SG feature.\n"); - *features &= ~NETIF_F_ALL_TSO; + netdev_feature_clear_bits(NETIF_F_ALL_TSO, features); }
- if ((*features & NETIF_F_TSO) && !(*features & NETIF_F_HW_CSUM) && - !(*features & NETIF_F_IP_CSUM)) { + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, *features)) { netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n"); - *features &= ~NETIF_F_TSO; - *features &= ~NETIF_F_TSO_ECN; + netdev_feature_clear_bit(NETIF_F_TSO_BIT, features); + netdev_feature_clear_bit(NETIF_F_TSO_ECN_BIT, features); }
- if ((*features & NETIF_F_TSO6) && !(*features & NETIF_F_HW_CSUM) && - !(*features & NETIF_F_IPV6_CSUM)) { + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, *features)) { netdev_dbg(dev, "Dropping TSO6 features since no CSUM feature.\n"); - *features &= ~NETIF_F_TSO6; + netdev_feature_clear_bit(NETIF_F_TSO6_BIT, features); }
/* TSO with IPv4 ID mangling requires IPv4 TSO be enabled */ - if ((*features & NETIF_F_TSO_MANGLEID) && !(*features & NETIF_F_TSO)) - *features &= ~NETIF_F_TSO_MANGLEID; + if (netdev_feature_test_bit(NETIF_F_TSO_MANGLEID_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_TSO_BIT, *features)) + netdev_feature_clear_bit(NETIF_F_TSO_MANGLEID_BIT, features);
/* TSO ECN requires that TSO is present as well. */ - if ((*features & NETIF_F_ALL_TSO) == NETIF_F_TSO_ECN) - *features &= ~NETIF_F_TSO_ECN; + if (netdev_feature_test_bit(NETIF_F_TSO_ECN_BIT, *features) && + !netdev_feature_test_bits(NETIF_F_ALL_TSO & ~NETIF_F_TSO_ECN, + *features)) + netdev_feature_clear_bit(NETIF_F_TSO_ECN_BIT, features);
/* Software GSO depends on SG. */ - if ((*features & NETIF_F_GSO) && !(*features & NETIF_F_SG)) { + if (netdev_feature_test_bit(NETIF_F_GSO_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_SG_BIT, *features)) { netdev_dbg(dev, "Dropping NETIF_F_GSO since no SG feature.\n"); - *features &= ~NETIF_F_GSO; + netdev_feature_clear_bit(NETIF_F_GSO_BIT, features); }
/* GSO partial features require GSO partial be set */ - if ((*features & dev->gso_partial_features) && - !(*features & NETIF_F_GSO_PARTIAL)) { + if (netdev_feature_intersects(*features, dev->gso_partial_features) && + !netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, *features)) { netdev_dbg(dev, "Dropping partially supported GSO features since no GSO partial.\n"); - *features &= ~dev->gso_partial_features; + netdev_feature_andnot(features, *features, + dev->gso_partial_features); }
- if (!(*features & NETIF_F_RXCSUM)) { + if (!netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, *features)) { /* NETIF_F_GRO_HW implies doing RXCSUM since every packet * successfully merged by hardware must also have the * checksum verified by hardware. If the user does not * want to enable RXCSUM, logically, we should disable GRO_HW. */ - if (*features & NETIF_F_GRO_HW) { + if (netdev_feature_test_bit(NETIF_F_GRO_HW_BIT, *features)) { netdev_dbg(dev, "Dropping NETIF_F_GRO_HW since no RXCSUM feature.\n"); - *features &= ~NETIF_F_GRO_HW; + netdev_feature_clear_bit(NETIF_F_GRO_HW_BIT, features); } }
/* LRO/HW-GRO features cannot be combined with RX-FCS */ - if (*features & NETIF_F_RXFCS) { - if (*features & NETIF_F_LRO) { + if (netdev_feature_test_bit(NETIF_F_RXFCS_BIT, *features)) { + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, *features)) { netdev_dbg(dev, "Dropping LRO feature since RX-FCS is requested.\n"); - *features &= ~NETIF_F_LRO; + netdev_feature_clear_bit(NETIF_F_LRO_BIT, features); }
- if (*features & NETIF_F_GRO_HW) { + if (netdev_feature_test_bit(NETIF_F_GRO_HW_BIT, *features)) { netdev_dbg(dev, "Dropping HW-GRO feature since RX-FCS is requested.\n"); - *features &= ~NETIF_F_GRO_HW; + netdev_feature_clear_bit(NETIF_F_GRO_HW_BIT, features); } }
- if (*features & NETIF_F_HW_TLS_TX) { - bool ip_csum = (*features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == - (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); - bool hw_csum = *features & NETIF_F_HW_CSUM; - - if (!ip_csum && !hw_csum) { + if (netdev_feature_test_bit(NETIF_F_HW_TLS_TX_BIT, *features)) { + if ((!netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, *features) || + !netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, *features)) && + !netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, *features)) { netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); - *features &= ~NETIF_F_HW_TLS_TX; + netdev_feature_clear_bit(NETIF_F_HW_TLS_TX_BIT, + features); } }
- if ((*features & NETIF_F_HW_TLS_RX) && !(*features & NETIF_F_RXCSUM)) { + if (netdev_feature_test_bit(NETIF_F_HW_TLS_RX_BIT, *features) && + !netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, *features)) { netdev_dbg(dev, "Dropping TLS RX HW offload feature since no RXCSUM feature.\n"); - *features &= ~NETIF_F_HW_TLS_RX; + netdev_feature_clear_bit(NETIF_F_HW_TLS_RX_BIT, features); } }
@@ -9929,7 +9962,7 @@ int __netdev_update_features(struct net_device *dev) netdev_for_each_upper_dev_rcu(dev, upper, iter) netdev_sync_upper_features(dev, upper, &features);
- if (dev->features == features) + if (netdev_feature_equal(dev->features, features)) goto sync_lower;
netdev_dbg(dev, "Features changed: %pNF -> %pNF\n", @@ -9958,9 +9991,11 @@ int __netdev_update_features(struct net_device *dev) netdev_sync_lower_features(dev, lower, features);
if (!err) { - netdev_features_t diff = features ^ dev->features; + netdev_features_t diff; + + netdev_feature_xor(&diff, features, dev->features);
- if (diff & NETIF_F_RX_UDP_TUNNEL_PORT) { + if (netdev_feature_test_bit(NETIF_F_RX_UDP_TUNNEL_PORT_BIT, diff)) { /* udp_tunnel_{get,drop}_rx_info both need * NETIF_F_RX_UDP_TUNNEL_PORT enabled on the * device, or they won't do anything. @@ -9968,33 +10003,36 @@ int __netdev_update_features(struct net_device *dev) * *before* calling udp_tunnel_get_rx_info, * but *after* calling udp_tunnel_drop_rx_info. */ - if (features & NETIF_F_RX_UDP_TUNNEL_PORT) { - dev->features = features; + if (netdev_feature_test_bit(NETIF_F_RX_UDP_TUNNEL_PORT_BIT, + features)) { + netdev_feature_copy(&dev->features, features); udp_tunnel_get_rx_info(dev); } else { udp_tunnel_drop_rx_info(dev); } }
- if (diff & NETIF_F_HW_VLAN_CTAG_FILTER) { - if (features & NETIF_F_HW_VLAN_CTAG_FILTER) { - dev->features = features; + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, diff)) { + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + features)) { + netdev_feature_copy(&dev->features, features); err |= vlan_get_rx_ctag_filter_info(dev); } else { vlan_drop_rx_ctag_filter_info(dev); } }
- if (diff & NETIF_F_HW_VLAN_STAG_FILTER) { - if (features & NETIF_F_HW_VLAN_STAG_FILTER) { - dev->features = features; + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_FILTER_BIT, diff)) { + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_FILTER_BIT, + features)) { + netdev_feature_copy(&dev->features, features); err |= vlan_get_rx_stag_filter_info(dev); } else { vlan_drop_rx_stag_filter_info(dev); } }
- dev->features = features; + netdev_feature_copy(&dev->features, features); }
return err < 0 ? 0 : 1; @@ -10220,8 +10258,10 @@ int register_netdevice(struct net_device *dev) } }
- if (((dev->hw_features | dev->features) & - NETIF_F_HW_VLAN_CTAG_FILTER) && + if ((netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + dev->hw_features) || + netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + dev->features)) && (!dev->netdev_ops->ndo_vlan_rx_add_vid || !dev->netdev_ops->ndo_vlan_rx_kill_vid)) { netdev_WARN(dev, "Buggy VLAN acceleration in driver!\n"); @@ -10238,44 +10278,54 @@ int register_netdevice(struct net_device *dev) /* Transfer changeable features to wanted_features and enable * software offloads (GSO and GRO). */ - dev->hw_features |= (NETIF_F_SOFT_FEATURES | NETIF_F_SOFT_FEATURES_OFF); - dev->features |= NETIF_F_SOFT_FEATURES; + netdev_feature_set_bits(NETIF_F_SOFT_FEATURES | NETIF_F_SOFT_FEATURES_OFF, + &dev->hw_features); + netdev_feature_set_bits(NETIF_F_SOFT_FEATURES, &dev->features);
if (dev->udp_tunnel_nic_info) { - dev->features |= NETIF_F_RX_UDP_TUNNEL_PORT; - dev->hw_features |= NETIF_F_RX_UDP_TUNNEL_PORT; + netdev_feature_set_bit(NETIF_F_RX_UDP_TUNNEL_PORT_BIT, + &dev->features); + netdev_feature_set_bit(NETIF_F_RX_UDP_TUNNEL_PORT_BIT, + &dev->hw_features); }
- dev->wanted_features = dev->features & dev->hw_features; + netdev_feature_and(&dev->wanted_features, dev->features, + dev->hw_features);
if (!(dev->flags & IFF_LOOPBACK)) - dev->hw_features |= NETIF_F_NOCACHE_COPY; + netdev_feature_set_bit(NETIF_F_NOCACHE_COPY_BIT, + &dev->hw_features);
/* If IPv4 TCP segmentation offload is supported we should also * allow the device to enable segmenting the frame with the option * of ignoring a static IP ID value. This doesn't enable the * feature itself but allows the user to enable it later. */ - if (dev->hw_features & NETIF_F_TSO) - dev->hw_features |= NETIF_F_TSO_MANGLEID; - if (dev->vlan_features & NETIF_F_TSO) - dev->vlan_features |= NETIF_F_TSO_MANGLEID; - if (dev->mpls_features & NETIF_F_TSO) - dev->mpls_features |= NETIF_F_TSO_MANGLEID; - if (dev->hw_enc_features & NETIF_F_TSO) - dev->hw_enc_features |= NETIF_F_TSO_MANGLEID; + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, dev->hw_features)) + netdev_feature_set_bit(NETIF_F_TSO_MANGLEID_BIT, + &dev->hw_features); + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, dev->vlan_features)) + netdev_feature_set_bit(NETIF_F_TSO_MANGLEID_BIT, + &dev->vlan_features); + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, dev->mpls_features)) + netdev_feature_set_bit(NETIF_F_TSO_MANGLEID_BIT, + &dev->mpls_features); + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, dev->hw_enc_features)) + netdev_feature_set_bit(NETIF_F_TSO_MANGLEID_BIT, + &dev->hw_enc_features);
/* Make NETIF_F_HIGHDMA inheritable to VLAN devices. */ - dev->vlan_features |= NETIF_F_HIGHDMA; + netdev_feature_set_bit(NETIF_F_HIGHDMA_BIT, &dev->vlan_features);
/* Make NETIF_F_SG inheritable to tunnel devices. */ - dev->hw_enc_features |= NETIF_F_SG | NETIF_F_GSO_PARTIAL; + netdev_feature_set_bits(NETIF_F_SG | NETIF_F_GSO_PARTIAL, + &dev->hw_enc_features);
/* Make NETIF_F_SG inheritable to MPLS. */ - dev->mpls_features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->mpls_features);
ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); ret = notifier_to_errno(ret); @@ -11116,7 +11166,7 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
/* Don't allow namespace local devices to be moved. */ err = -EINVAL; - if (dev->features & NETIF_F_NETNS_LOCAL) + if (netdev_feature_test_bit(NETIF_F_NETNS_LOCAL_BIT, dev->features)) goto out;
/* Ensure the device has been registrered */ @@ -11313,18 +11363,28 @@ static int dev_cpu_dead(unsigned int oldcpu) void netdev_increment_features(netdev_features_t *ret, netdev_features_t all, netdev_features_t one, netdev_features_t mask) { - if (mask & NETIF_F_HW_CSUM) - mask |= NETIF_F_CSUM_MASK; - mask |= NETIF_F_VLAN_CHALLENGED; + netdev_features_t tmp;
- all |= one & (NETIF_F_ONE_FOR_ALL | NETIF_F_CSUM_MASK) & mask; - all &= one | ~NETIF_F_ALL_FOR_ALL; + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, mask)) + netdev_feature_set_bits(NETIF_F_CSUM_MASK, &mask); + netdev_feature_set_bit(NETIF_F_VLAN_CHALLENGED_BIT, &mask);
- /* If one device supports hw checksumming, set for all. */ - if (all & NETIF_F_HW_CSUM) - all &= ~(NETIF_F_CSUM_MASK & ~NETIF_F_HW_CSUM); + netdev_feature_copy(ret, all); + netdev_feature_zero(&tmp); + netdev_feature_set_bits(NETIF_F_ONE_FOR_ALL | NETIF_F_CSUM_MASK, &tmp); + netdev_feature_and(&tmp, tmp, one); + netdev_feature_and(&tmp, tmp, mask); + netdev_feature_or(ret, *ret, tmp);
- *ret = all; + netdev_feature_fill(&tmp); + netdev_feature_clear_bits(NETIF_F_ALL_FOR_ALL, &tmp); + netdev_feature_or(&tmp, tmp, one); + netdev_feature_and(ret, *ret, tmp); + + /* If one device supports hw checksumming, set for all. */ + if (netdev_feature_test_bit(NETIF_F_HW_CSUM_BIT, *ret)) + netdev_feature_clear_bits(NETIF_F_CSUM_MASK & ~NETIF_F_HW_CSUM, + ret); } EXPORT_SYMBOL(netdev_increment_features);
@@ -11477,7 +11537,8 @@ static void __net_exit default_device_exit(struct net *net) char fb_name[IFNAMSIZ];
/* Ignore unmoveable devices (i.e. loopback) */ - if (dev->features & NETIF_F_NETNS_LOCAL) + if (netdev_feature_test_bit(NETIF_F_NETNS_LOCAL_BIT, + dev->features)) continue;
/* Leave virtual devices for the generic cleanup */
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- include/linux/skbuff.h | 6 ++++-- net/core/skbuff.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 841e2f0f5240..5dbb04a5f29f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3730,8 +3730,10 @@ static inline bool skb_needs_linearize(struct sk_buff *skb, netdev_features_t features) { return skb_is_nonlinear(skb) && - ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) || - (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG))); + ((skb_has_frag_list(skb) && + !netdev_feature_test_bit(NETIF_F_FRAGLIST_BIT, features)) || + (skb_shinfo(skb)->nr_frags && + !netdev_feature_test_bit(NETIF_F_SG_BIT, features))); }
static inline void skb_copy_from_linear_data(const struct sk_buff *skb, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 7c2ab27fcbf9..4e1f14667d1f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3990,7 +3990,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, * skbs; we do so by disabling SG. */ if (mss != GSO_BY_FRAGS && mss != skb_headlen(head_skb)) - features &= ~NETIF_F_SG; + netdev_feature_clear_bit(NETIF_F_SG_BIT, &features); }
__skb_push(head_skb, doffset); @@ -3998,11 +3998,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, if (unlikely(!proto)) return ERR_PTR(-EINVAL);
- sg = !!(features & NETIF_F_SG); + sg = !!netdev_feature_test_bit(NETIF_F_SG_BIT, features); csum = !!can_checksum_protocol(features, proto);
if (sg && csum && (mss != GSO_BY_FRAGS)) { - if (!(features & NETIF_F_GSO_PARTIAL)) { + if (!netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, + features)) { struct sk_buff *iter; unsigned int frag_len;
@@ -4259,7 +4260,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, unsigned short gso_size = skb_shinfo(head_skb)->gso_size;
/* Update type to add partial and then remove dodgy if set */ - type |= (features & NETIF_F_GSO_PARTIAL) / NETIF_F_GSO_PARTIAL * SKB_GSO_PARTIAL; + type |= netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, + features) * SKB_GSO_PARTIAL; type &= ~SKB_GSO_DODGY;
/* Update GSO info and prepare to start updating headers on
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
include/linux/skbuff.h | 6 ++++-- net/core/skbuff.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 841e2f0f5240..5dbb04a5f29f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3730,8 +3730,10 @@ static inline bool skb_needs_linearize(struct sk_buff *skb, netdev_features_t features) { return skb_is_nonlinear(skb) &&
((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) ||
(skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG)));
((skb_has_frag_list(skb) &&
!netdev_feature_test_bit(NETIF_F_FRAGLIST_BIT, features)) ||
(skb_shinfo(skb)->nr_frags &&
!netdev_feature_test_bit(NETIF_F_SG_BIT, features)));
}
static inline void skb_copy_from_linear_data(const struct sk_buff *skb, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 7c2ab27fcbf9..4e1f14667d1f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3990,7 +3990,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, * skbs; we do so by disabling SG. */ if (mss != GSO_BY_FRAGS && mss != skb_headlen(head_skb))
features &= ~NETIF_F_SG;
netdev_feature_clear_bit(NETIF_F_SG_BIT, &features);
}
__skb_push(head_skb, doffset);
@@ -3998,11 +3998,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, if (unlikely(!proto)) return ERR_PTR(-EINVAL);
- sg = !!(features & NETIF_F_SG);
sg = !!netdev_feature_test_bit(NETIF_F_SG_BIT, features); csum = !!can_checksum_protocol(features, proto);
if (sg && csum && (mss != GSO_BY_FRAGS)) {
if (!(features & NETIF_F_GSO_PARTIAL)) {
if (!netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT,
features)) { struct sk_buff *iter; unsigned int frag_len;
@@ -4259,7 +4260,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, unsigned short gso_size = skb_shinfo(head_skb)->gso_size;
/* Update type to add partial and then remove dodgy if set */
type |= (features & NETIF_F_GSO_PARTIAL) / NETIF_F_GSO_PARTIAL * SKB_GSO_PARTIAL;
type |= netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT,
features) * SKB_GSO_PARTIAL;
this replacement removed the "/ NETIF_F_GSO_PARTIAL" process?
type &= ~SKB_GSO_DODGY; /* Update GSO info and prepare to start updating headers on
在 2021/9/23 20:57, wangjie (L) 写道:
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
include/linux/skbuff.h | 6 ++++-- net/core/skbuff.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 841e2f0f5240..5dbb04a5f29f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3730,8 +3730,10 @@ static inline bool skb_needs_linearize(struct sk_buff *skb, netdev_features_t features) { return skb_is_nonlinear(skb) && - ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) || - (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG))); + ((skb_has_frag_list(skb) && + !netdev_feature_test_bit(NETIF_F_FRAGLIST_BIT, features)) || + (skb_shinfo(skb)->nr_frags && + !netdev_feature_test_bit(NETIF_F_SG_BIT, features))); }
static inline void skb_copy_from_linear_data(const struct sk_buff *skb, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 7c2ab27fcbf9..4e1f14667d1f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3990,7 +3990,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, * skbs; we do so by disabling SG. */ if (mss != GSO_BY_FRAGS && mss != skb_headlen(head_skb)) - features &= ~NETIF_F_SG; + netdev_feature_clear_bit(NETIF_F_SG_BIT, &features); }
__skb_push(head_skb, doffset); @@ -3998,11 +3998,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, if (unlikely(!proto)) return ERR_PTR(-EINVAL);
- sg = !!(features & NETIF_F_SG); + sg = !!netdev_feature_test_bit(NETIF_F_SG_BIT, features); csum = !!can_checksum_protocol(features, proto);
if (sg && csum && (mss != GSO_BY_FRAGS)) { - if (!(features & NETIF_F_GSO_PARTIAL)) { + if (!netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, + features)) { struct sk_buff *iter; unsigned int frag_len;
@@ -4259,7 +4260,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, unsigned short gso_size = skb_shinfo(head_skb)->gso_size;
/* Update type to add partial and then remove dodgy if set */ - type |= (features & NETIF_F_GSO_PARTIAL) / NETIF_F_GSO_PARTIAL * SKB_GSO_PARTIAL; + type |= netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, + features) * SKB_GSO_PARTIAL;
this replacement removed the "/ NETIF_F_GSO_PARTIAL" process?
(features & NETIF_F_GSO_PARTIAL) / NETIF_F_GSO_PARTIAL returns 0 or 1,
for netdev_feature_test_bit(NETIF_F_GSO_PARTIAL_BIT, features) return 0 or 1 already, if divide by NETIF_F_GSO_PARTIAL, it will always return 0.
type &= ~SKB_GSO_DODGY;
/* Update GSO info and prepare to start updating headers on
.
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- include/linux/if_vlan.h | 16 ++++++++------ net/8021q/vlan.c | 11 ++++++---- net/8021q/vlan.h | 24 ++++++++++++--------- net/8021q/vlan_core.c | 6 ++++-- net/8021q/vlan_dev.c | 47 ++++++++++++++++++++++++----------------- 5 files changed, 63 insertions(+), 41 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 2337538ef015..9696e7adbb8c 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -313,9 +313,11 @@ static inline bool eth_type_vlan(__be16 ethertype) static inline bool vlan_hw_offload_capable(netdev_features_t features, __be16 proto) { - if (proto == htons(ETH_P_8021Q) && features & NETIF_F_HW_VLAN_CTAG_TX) + if (proto == htons(ETH_P_8021Q) && + netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, features)) return true; - if (proto == htons(ETH_P_8021AD) && features & NETIF_F_HW_VLAN_STAG_TX) + if (proto == htons(ETH_P_8021AD) && + netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_TX_BIT, features)) return true; return false; } @@ -563,7 +565,8 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, */ static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) { - if (skb->dev->features & NETIF_F_HW_VLAN_CTAG_TX) { + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, + skb->dev->features)) { return __vlan_hwaccel_get_tag(skb, vlan_tci); } else { return __vlan_get_tag(skb, vlan_tci); @@ -736,9 +739,10 @@ static inline void vlan_features_check(struct sk_buff *skb, * sure that only devices supporting NETIF_F_HW_CSUM will * have checksum offloading support. */ - *features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | - NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; + netdev_feature_clear_bits(NETIF_F_SG | NETIF_F_HIGHDMA | + NETIF_F_HW_CSUM | NETIF_F_FRAGLIST | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, features); } }
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 55275ef9a31a..8a50deff286a 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -134,7 +134,8 @@ int vlan_check_real_dev(struct net_device *real_dev, { const char *name = real_dev->name;
- if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { + if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, + real_dev->features)) { pr_info("VLANs not supported on %s\n", name); NL_SET_ERR_MSG_MOD(extack, "VLANs not supported on device"); return -EOPNOTSUPP; @@ -339,7 +340,7 @@ static void vlan_transfer_features(struct net_device *dev,
vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE; vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE); - vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev); + vlan_tnl_features(vlan->real_dev, &vlandev->hw_enc_features);
netdev_update_features(vlandev); } @@ -386,13 +387,15 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, }
if ((event == NETDEV_UP) && - (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { + netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + dev->features)) { pr_info("adding VLAN 0 to HW filter on device %s\n", dev->name); vlan_vid_add(dev, htons(ETH_P_8021Q), 0); } if (event == NETDEV_DOWN && - (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) + netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + dev->features)) vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
vlan_info = rtnl_dereference(dev->vlan_info); diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 1a705a4ef7fa..9ed1d1c8f547 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -103,17 +103,21 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev, return NULL; }
-static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev) +static inline void vlan_tnl_features(struct net_device *real_dev, + netdev_features_t *tnl) { - netdev_features_t ret; - - ret = real_dev->hw_enc_features & - (NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE | - NETIF_F_GSO_ENCAP_ALL); - - if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK)) - return (ret & ~NETIF_F_CSUM_MASK) | NETIF_F_HW_CSUM; - return 0; + netdev_feature_zero(tnl); + netdev_feature_set_bits(NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE | + NETIF_F_GSO_ENCAP_ALL, tnl); + netdev_feature_and(tnl, *tnl, real_dev->hw_enc_features); + + if (netdev_feature_test_bits(NETIF_F_GSO_ENCAP_ALL, *tnl) && + netdev_feature_test_bits(NETIF_F_CSUM_MASK, *tnl)) { + netdev_feature_clear_bits(NETIF_F_CSUM_MASK, tnl); + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, tnl); + return; + } + netdev_feature_zero(tnl); }
#define vlan_group_for_each_dev(grp, i, dev) \ diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 59bc13b5f14f..757b2f18978f 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -169,10 +169,12 @@ struct vlan_vid_info { static bool vlan_hw_filter_capable(const struct net_device *dev, __be16 proto) { if (proto == htons(ETH_P_8021Q) && - dev->features & NETIF_F_HW_VLAN_CTAG_FILTER) + netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + dev->features)) return true; if (proto == htons(ETH_P_8021AD) && - dev->features & NETIF_F_HW_VLAN_STAG_FILTER) + netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_FILTER_BIT, + dev->features)) return true; return false; } diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 9f90a587d4e5..a010612cf27b 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -566,21 +566,24 @@ static int vlan_dev_init(struct net_device *dev) if (vlan->flags & VLAN_FLAG_BRIDGE_BINDING) dev->state |= (1 << __LINK_STATE_NOCARRIER);
- dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG | - NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | - NETIF_F_GSO_ENCAP_ALL | - NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC | - NETIF_F_ALL_FCOE; - - dev->features |= dev->hw_features | NETIF_F_LLTX; + netdev_feature_zero(&dev->hw_features); + netdev_feature_set_bits(NETIF_F_HW_CSUM | NETIF_F_SG | + NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | + NETIF_F_GSO_ENCAP_ALL | + NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC | + NETIF_F_ALL_FCOE, &dev->hw_features); + + netdev_feature_or(&dev->features, dev->features, dev->hw_features); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features); dev->gso_max_size = real_dev->gso_max_size; dev->gso_max_segs = real_dev->gso_max_segs; - if (dev->features & NETIF_F_VLAN_FEATURES) + if (netdev_feature_test_bits(NETIF_F_VLAN_FEATURES, dev->features)) netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
- dev->vlan_features = real_dev->vlan_features & ~NETIF_F_ALL_FCOE; - dev->hw_enc_features = vlan_tnl_features(real_dev); - dev->mpls_features = real_dev->mpls_features; + netdev_feature_copy(&dev->vlan_features, real_dev->vlan_features); + netdev_feature_clear_bits(NETIF_F_ALL_FCOE, &dev->vlan_features); + vlan_tnl_features(real_dev, &dev->hw_enc_features); + netdev_feature_copy(&dev->mpls_features, real_dev->mpls_features);
/* ipv6 shared card related stuff */ dev->dev_id = real_dev->dev_id; @@ -637,21 +640,27 @@ static void vlan_dev_fix_features(struct net_device *dev, netdev_features_t *features) { struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; - netdev_features_t old_features = *features; netdev_features_t lower_features; + netdev_features_t old_features; + netdev_features_t tmp;
- netdev_intersect_features(&lower_features, - (real_dev->vlan_features | NETIF_F_RXCSUM), - real_dev->features); + netdev_feature_copy(&tmp, real_dev->vlan_features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &tmp); + netdev_feature_copy(&old_features, *features); + netdev_intersect_features(&lower_features, tmp, real_dev->features);
/* Add HW_CSUM setting to preserve user ability to control * checksum offload on the vlan device. */ - if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) - lower_features |= NETIF_F_HW_CSUM; + if (netdev_feature_test_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM, + lower_features)) + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &lower_features); netdev_intersect_features(features, *features, lower_features); - *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); - *features |= NETIF_F_LLTX; + + netdev_feature_and_bits(NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE, + &old_features); + netdev_feature_or(features, *features, old_features); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, features); }
static int vlan_ethtool_get_link_ksettings(struct net_device *dev,
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
include/linux/if_vlan.h | 16 ++++++++------ net/8021q/vlan.c | 11 ++++++---- net/8021q/vlan.h | 24 ++++++++++++--------- net/8021q/vlan_core.c | 6 ++++-- net/8021q/vlan_dev.c | 47 ++++++++++++++++++++++++----------------- 5 files changed, 63 insertions(+), 41 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 2337538ef015..9696e7adbb8c 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -313,9 +313,11 @@ static inline bool eth_type_vlan(__be16 ethertype) static inline bool vlan_hw_offload_capable(netdev_features_t features, __be16 proto) {
- if (proto == htons(ETH_P_8021Q) && features & NETIF_F_HW_VLAN_CTAG_TX)
- if (proto == htons(ETH_P_8021Q) &&
return true;netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, features))
- if (proto == htons(ETH_P_8021AD) && features & NETIF_F_HW_VLAN_STAG_TX)
- if (proto == htons(ETH_P_8021AD) &&
return true; return false;netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_TX_BIT, features))
} @@ -563,7 +565,8 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, */ static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) {
- if (skb->dev->features & NETIF_F_HW_VLAN_CTAG_TX) {
- if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT,
return __vlan_hwaccel_get_tag(skb, vlan_tci); } else { return __vlan_get_tag(skb, vlan_tci);skb->dev->features)) {
@@ -736,9 +739,10 @@ static inline void vlan_features_check(struct sk_buff *skb, * sure that only devices supporting NETIF_F_HW_CSUM will * have checksum offloading support. */
*features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM |
NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
netdev_feature_clear_bits(NETIF_F_SG | NETIF_F_HIGHDMA |
NETIF_F_HW_CSUM | NETIF_F_FRAGLIST |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX, features);
netdev_feature_clear_bits -> netdev_feature_and_bits ?
} }
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 55275ef9a31a..8a50deff286a 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -134,7 +134,8 @@ int vlan_check_real_dev(struct net_device *real_dev, { const char *name = real_dev->name;
- if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
- if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT,
pr_info("VLANs not supported on %s\n", name); NL_SET_ERR_MSG_MOD(extack, "VLANs not supported on device"); return -EOPNOTSUPP;real_dev->features)) {
@@ -339,7 +340,7 @@ static void vlan_transfer_features(struct net_device *dev,
vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE; vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE);
- vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev);
vlan_tnl_features(vlan->real_dev, &vlandev->hw_enc_features);
netdev_update_features(vlandev);
} @@ -386,13 +387,15 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, }
if ((event == NETDEV_UP) &&
(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) {
netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
pr_info("adding VLAN 0 to HW filter on device %s\n", dev->name); vlan_vid_add(dev, htons(ETH_P_8021Q), 0); } if (event == NETDEV_DOWN &&dev->features)) {
(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER))
netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
dev->features))
vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
vlan_info = rtnl_dereference(dev->vlan_info);
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 1a705a4ef7fa..9ed1d1c8f547 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -103,17 +103,21 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev, return NULL; }
-static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev) +static inline void vlan_tnl_features(struct net_device *real_dev,
netdev_features_t *tnl)
{
- netdev_features_t ret;
- ret = real_dev->hw_enc_features &
(NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE |
NETIF_F_GSO_ENCAP_ALL);
- if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK))
return (ret & ~NETIF_F_CSUM_MASK) | NETIF_F_HW_CSUM;
- return 0;
- netdev_feature_zero(tnl);
- netdev_feature_set_bits(NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE |
NETIF_F_GSO_ENCAP_ALL, tnl);
- netdev_feature_and(tnl, *tnl, real_dev->hw_enc_features);
- if (netdev_feature_test_bits(NETIF_F_GSO_ENCAP_ALL, *tnl) &&
netdev_feature_test_bits(NETIF_F_CSUM_MASK, *tnl)) {
netdev_feature_clear_bits(NETIF_F_CSUM_MASK, tnl);
netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, tnl);
return;
- }
- netdev_feature_zero(tnl);
}
#define vlan_group_for_each_dev(grp, i, dev) \ diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 59bc13b5f14f..757b2f18978f 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -169,10 +169,12 @@ struct vlan_vid_info { static bool vlan_hw_filter_capable(const struct net_device *dev, __be16 proto) { if (proto == htons(ETH_P_8021Q) &&
dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
return true; if (proto == htons(ETH_P_8021AD) &&dev->features))
dev->features & NETIF_F_HW_VLAN_STAG_FILTER)
netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_FILTER_BIT,
return true; return false;dev->features))
} diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 9f90a587d4e5..a010612cf27b 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -566,21 +566,24 @@ static int vlan_dev_init(struct net_device *dev) if (vlan->flags & VLAN_FLAG_BRIDGE_BINDING) dev->state |= (1 << __LINK_STATE_NOCARRIER);
- dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG |
NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE |
NETIF_F_GSO_ENCAP_ALL |
NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC |
NETIF_F_ALL_FCOE;
- dev->features |= dev->hw_features | NETIF_F_LLTX;
- netdev_feature_zero(&dev->hw_features);
- netdev_feature_set_bits(NETIF_F_HW_CSUM | NETIF_F_SG |
NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE |
NETIF_F_GSO_ENCAP_ALL |
NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC |
NETIF_F_ALL_FCOE, &dev->hw_features);
- netdev_feature_or(&dev->features, dev->features, dev->hw_features);
- netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features); dev->gso_max_size = real_dev->gso_max_size; dev->gso_max_segs = real_dev->gso_max_segs;
- if (dev->features & NETIF_F_VLAN_FEATURES)
- if (netdev_feature_test_bits(NETIF_F_VLAN_FEATURES, dev->features)) netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
- dev->vlan_features = real_dev->vlan_features & ~NETIF_F_ALL_FCOE;
- dev->hw_enc_features = vlan_tnl_features(real_dev);
- dev->mpls_features = real_dev->mpls_features;
netdev_feature_copy(&dev->vlan_features, real_dev->vlan_features);
netdev_feature_clear_bits(NETIF_F_ALL_FCOE, &dev->vlan_features);
vlan_tnl_features(real_dev, &dev->hw_enc_features);
netdev_feature_copy(&dev->mpls_features, real_dev->mpls_features);
/* ipv6 shared card related stuff */ dev->dev_id = real_dev->dev_id;
@@ -637,21 +640,27 @@ static void vlan_dev_fix_features(struct net_device *dev, netdev_features_t *features) { struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
- netdev_features_t old_features = *features; netdev_features_t lower_features;
- netdev_features_t old_features;
- netdev_features_t tmp;
- netdev_intersect_features(&lower_features,
(real_dev->vlan_features | NETIF_F_RXCSUM),
real_dev->features);
netdev_feature_copy(&tmp, real_dev->vlan_features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &tmp);
netdev_feature_copy(&old_features, *features);
netdev_intersect_features(&lower_features, tmp, real_dev->features);
/* Add HW_CSUM setting to preserve user ability to control
- checksum offload on the vlan device.
*/
- if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
lower_features |= NETIF_F_HW_CSUM;
- if (netdev_feature_test_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM,
lower_features))
netdev_intersect_features(features, *features, lower_features);netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &lower_features);
- *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE);
- *features |= NETIF_F_LLTX;
- netdev_feature_and_bits(NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE,
&old_features);
- netdev_feature_or(features, *features, old_features);
- netdev_feature_set_bit(NETIF_F_LLTX_BIT, features);
}
static int vlan_ethtool_get_link_ksettings(struct net_device *dev,
在 2021/9/24 10:04, wangjie (L) 写道:
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
include/linux/if_vlan.h | 16 ++++++++------ net/8021q/vlan.c | 11 ++++++---- net/8021q/vlan.h | 24 ++++++++++++--------- net/8021q/vlan_core.c | 6 ++++-- net/8021q/vlan_dev.c | 47 ++++++++++++++++++++++++----------------- 5 files changed, 63 insertions(+), 41 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 2337538ef015..9696e7adbb8c 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -313,9 +313,11 @@ static inline bool eth_type_vlan(__be16 ethertype) static inline bool vlan_hw_offload_capable(netdev_features_t features, __be16 proto) { - if (proto == htons(ETH_P_8021Q) && features & NETIF_F_HW_VLAN_CTAG_TX) + if (proto == htons(ETH_P_8021Q) && + netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, features)) return true; - if (proto == htons(ETH_P_8021AD) && features & NETIF_F_HW_VLAN_STAG_TX) + if (proto == htons(ETH_P_8021AD) && + netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_TX_BIT, features)) return true; return false; } @@ -563,7 +565,8 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, */ static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) { - if (skb->dev->features & NETIF_F_HW_VLAN_CTAG_TX) { + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, + skb->dev->features)) { return __vlan_hwaccel_get_tag(skb, vlan_tci); } else { return __vlan_get_tag(skb, vlan_tci); @@ -736,9 +739,10 @@ static inline void vlan_features_check(struct sk_buff *skb, * sure that only devices supporting NETIF_F_HW_CSUM will * have checksum offloading support. */ - *features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | - NETIF_F_FRAGLIST | NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; + netdev_feature_clear_bits(NETIF_F_SG | NETIF_F_HIGHDMA | + NETIF_F_HW_CSUM | NETIF_F_FRAGLIST | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, features);
netdev_feature_clear_bits -> netdev_feature_and_bits ?
Thanks, will fix it next version.
} }
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 55275ef9a31a..8a50deff286a 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -134,7 +134,8 @@ int vlan_check_real_dev(struct net_device *real_dev, { const char *name = real_dev->name;
- if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { + if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, + real_dev->features)) { pr_info("VLANs not supported on %s\n", name); NL_SET_ERR_MSG_MOD(extack, "VLANs not supported on device"); return -EOPNOTSUPP; @@ -339,7 +340,7 @@ static void vlan_transfer_features(struct net_device *dev,
vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE; vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE); - vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev); + vlan_tnl_features(vlan->real_dev, &vlandev->hw_enc_features);
netdev_update_features(vlandev); } @@ -386,13 +387,15 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, }
if ((event == NETDEV_UP) && - (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) {
- netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ dev->features)) { pr_info("adding VLAN 0 to HW filter on device %s\n", dev->name); vlan_vid_add(dev, htons(ETH_P_8021Q), 0); } if (event == NETDEV_DOWN && - (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER))
- netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ dev->features)) vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
vlan_info = rtnl_dereference(dev->vlan_info); diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 1a705a4ef7fa..9ed1d1c8f547 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -103,17 +103,21 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev, return NULL; }
-static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev) +static inline void vlan_tnl_features(struct net_device *real_dev, + netdev_features_t *tnl) { - netdev_features_t ret;
- ret = real_dev->hw_enc_features & - (NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE | - NETIF_F_GSO_ENCAP_ALL);
- if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK)) - return (ret & ~NETIF_F_CSUM_MASK) | NETIF_F_HW_CSUM; - return 0; + netdev_feature_zero(tnl); + netdev_feature_set_bits(NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE | + NETIF_F_GSO_ENCAP_ALL, tnl); + netdev_feature_and(tnl, *tnl, real_dev->hw_enc_features);
+ if (netdev_feature_test_bits(NETIF_F_GSO_ENCAP_ALL, *tnl) && + netdev_feature_test_bits(NETIF_F_CSUM_MASK, *tnl)) { + netdev_feature_clear_bits(NETIF_F_CSUM_MASK, tnl); + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, tnl); + return; + } + netdev_feature_zero(tnl); }
#define vlan_group_for_each_dev(grp, i, dev) \ diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 59bc13b5f14f..757b2f18978f 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -169,10 +169,12 @@ struct vlan_vid_info { static bool vlan_hw_filter_capable(const struct net_device *dev, __be16 proto) { if (proto == htons(ETH_P_8021Q) && - dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
- netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ dev->features)) return true; if (proto == htons(ETH_P_8021AD) && - dev->features & NETIF_F_HW_VLAN_STAG_FILTER)
- netdev_feature_test_bit(NETIF_F_HW_VLAN_STAG_FILTER_BIT,
+ dev->features)) return true; return false; } diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 9f90a587d4e5..a010612cf27b 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -566,21 +566,24 @@ static int vlan_dev_init(struct net_device *dev) if (vlan->flags & VLAN_FLAG_BRIDGE_BINDING) dev->state |= (1 << __LINK_STATE_NOCARRIER);
- dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG | - NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | - NETIF_F_GSO_ENCAP_ALL | - NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC | - NETIF_F_ALL_FCOE;
- dev->features |= dev->hw_features | NETIF_F_LLTX; + netdev_feature_zero(&dev->hw_features); + netdev_feature_set_bits(NETIF_F_HW_CSUM | NETIF_F_SG | + NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | + NETIF_F_GSO_ENCAP_ALL | + NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC | + NETIF_F_ALL_FCOE, &dev->hw_features);
+ netdev_feature_or(&dev->features, dev->features, dev->hw_features); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features); dev->gso_max_size = real_dev->gso_max_size; dev->gso_max_segs = real_dev->gso_max_segs; - if (dev->features & NETIF_F_VLAN_FEATURES) + if (netdev_feature_test_bits(NETIF_F_VLAN_FEATURES, dev->features)) netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
- dev->vlan_features = real_dev->vlan_features & ~NETIF_F_ALL_FCOE; - dev->hw_enc_features = vlan_tnl_features(real_dev); - dev->mpls_features = real_dev->mpls_features; + netdev_feature_copy(&dev->vlan_features, real_dev->vlan_features); + netdev_feature_clear_bits(NETIF_F_ALL_FCOE, &dev->vlan_features); + vlan_tnl_features(real_dev, &dev->hw_enc_features); + netdev_feature_copy(&dev->mpls_features, real_dev->mpls_features);
/* ipv6 shared card related stuff */ dev->dev_id = real_dev->dev_id; @@ -637,21 +640,27 @@ static void vlan_dev_fix_features(struct net_device *dev, netdev_features_t *features) { struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; - netdev_features_t old_features = *features; netdev_features_t lower_features; + netdev_features_t old_features; + netdev_features_t tmp;
- netdev_intersect_features(&lower_features, - (real_dev->vlan_features | NETIF_F_RXCSUM), - real_dev->features); + netdev_feature_copy(&tmp, real_dev->vlan_features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &tmp); + netdev_feature_copy(&old_features, *features); + netdev_intersect_features(&lower_features, tmp, real_dev->features);
/* Add HW_CSUM setting to preserve user ability to control * checksum offload on the vlan device. */ - if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) - lower_features |= NETIF_F_HW_CSUM; + if (netdev_feature_test_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM, + lower_features)) + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &lower_features); netdev_intersect_features(features, *features, lower_features); - *features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); - *features |= NETIF_F_LLTX;
+ netdev_feature_and_bits(NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE, + &old_features); + netdev_feature_or(features, *features, old_features); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, features); }
static int vlan_ethtool_get_link_ksettings(struct net_device *dev,
.
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- net/bridge/br_device.c | 16 +++++++++++----- net/bridge/br_if.c | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index fc508b9cbaa9..c9894b9944ab 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -490,11 +490,17 @@ void br_dev_setup(struct net_device *dev) SET_NETDEV_DEVTYPE(dev, &br_type); dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE;
- dev->features = COMMON_FEATURES | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL | - NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; - dev->hw_features = COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; - dev->vlan_features = COMMON_FEATURES; + netdev_feature_zero(&dev->features); + netdev_feature_set_bits(COMMON_FEATURES | NETIF_F_LLTX | + NETIF_F_NETNS_LOCAL | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, + &dev->features); + netdev_feature_zero(&dev->hw_features); + netdev_feature_set_bits(COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, &dev->hw_features); + netdev_feature_zero(&dev->vlan_features); + netdev_feature_set_bits(COMMON_FEATURES, &dev->vlan_features);
br->dev = dev; spin_lock_init(&br->lock); diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 914ca4b2d07c..c0a71fd6f772 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -540,8 +540,8 @@ void br_features_recompute(struct net_bridge *br, netdev_features_t *features) if (list_empty(&br->port_list)) return;
- mask = *features; - *features &= ~NETIF_F_ONE_FOR_ALL; + netdev_feature_copy(&mask, *features); + netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features);
list_for_each_entry(p, &br->port_list, list) { netdev_increment_features(features, *features, p->dev->features,
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, 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/bridge/br_device.c | 16 +++++++++++----- net/bridge/br_if.c | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index fc508b9cbaa9..c9894b9944ab 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -490,11 +490,17 @@ void br_dev_setup(struct net_device *dev) SET_NETDEV_DEVTYPE(dev, &br_type); dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE;
- dev->features = COMMON_FEATURES | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL |
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
- dev->hw_features = COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
- dev->vlan_features = COMMON_FEATURES;
netdev_feature_zero(&dev->features);
netdev_feature_set_bits(COMMON_FEATURES | NETIF_F_LLTX |
NETIF_F_NETNS_LOCAL |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX,
&dev->features);
netdev_feature_zero(&dev->hw_features);
netdev_feature_set_bits(COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX, &dev->hw_features);
netdev_feature_zero(&dev->vlan_features);
netdev_feature_set_bits(COMMON_FEATURES, &dev->vlan_features);
br->dev = dev; spin_lock_init(&br->lock);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 914ca4b2d07c..c0a71fd6f772 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -540,8 +540,8 @@ void br_features_recompute(struct net_bridge *br, netdev_features_t *features) if (list_empty(&br->port_list)) return;
- mask = *features;
- *features &= ~NETIF_F_ONE_FOR_ALL;
netdev_feature_copy(&mask, *features);
netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features);
list_for_each_entry(p, &br->port_list, list) { netdev_increment_features(features, *features, p->dev->features,
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/ipvlan/ipvlan_main.c | 28 ++++++++++++++++++---------- drivers/net/ipvlan/ipvtap.c | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 6a0b7bd2d3ae..84ad786ae18d 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -135,11 +135,14 @@ static int ipvlan_init(struct net_device *dev)
dev->state = (dev->state & ~IPVLAN_STATE_MASK) | (phy_dev->state & IPVLAN_STATE_MASK); - dev->features = phy_dev->features & IPVLAN_FEATURES; - dev->features |= IPVLAN_ALWAYS_ON; - dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES; - dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS; - dev->hw_enc_features |= dev->features; + netdev_feature_copy(&dev->features, phy_dev->features); + netdev_feature_and_bits(IPVLAN_FEATURES, &dev->features); + netdev_feature_set_bits(IPVLAN_ALWAYS_ON, &dev->features); + netdev_feature_copy(&dev->vlan_features, phy_dev->vlan_features); + netdev_feature_and_bits(IPVLAN_FEATURES, &dev->vlan_features); + netdev_feature_set_bits(IPVLAN_ALWAYS_ON_OFLOADS, &dev->vlan_features); + netdev_feature_or(&dev->hw_enc_features, dev->hw_enc_features, + dev->features); dev->gso_max_size = phy_dev->gso_max_size; dev->gso_max_segs = phy_dev->gso_max_segs; dev->hard_header_len = phy_dev->hard_header_len; @@ -239,13 +242,17 @@ static void ipvlan_fix_features(struct net_device *dev, netdev_features_t *features) { struct ipvl_dev *ipvlan = netdev_priv(dev); + netdev_features_t tmp;
- *features |= NETIF_F_ALL_FOR_ALL; - *features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES); + netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features); + netdev_feature_fill(&tmp); + netdev_feature_clear_bits(IPVLAN_FEATURES, &tmp); + netdev_feature_or(&tmp, tmp, ipvlan->sfeatures); + netdev_feature_and(features, *features, tmp); netdev_increment_features(features, ipvlan->phy_dev->features, *features, *features); - *features |= IPVLAN_ALWAYS_ON; - *features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON); + netdev_feature_set_bits(IPVLAN_ALWAYS_ON, features); + netdev_feature_and_bits(IPVLAN_FEATURES | IPVLAN_ALWAYS_ON, features); }
static void ipvlan_change_rx_flags(struct net_device *dev, int change) @@ -567,7 +574,8 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
ipvlan->phy_dev = phy_dev; ipvlan->dev = dev; - ipvlan->sfeatures = IPVLAN_FEATURES; + netdev_feature_zero(&ipvlan->sfeatures); + netdev_feature_set_bits(IPVLAN_FEATURES, &ipvlan->sfeatures); if (!tb[IFLA_MTU]) ipvlan_adjust_mtu(ipvlan, phy_dev); INIT_LIST_HEAD(&ipvlan->addrs); diff --git a/drivers/net/ipvlan/ipvtap.c b/drivers/net/ipvlan/ipvtap.c index 1cedb634f4f7..fd11ce806cc7 100644 --- a/drivers/net/ipvlan/ipvtap.c +++ b/drivers/net/ipvlan/ipvtap.c @@ -70,7 +70,7 @@ static void ipvtap_update_features(struct tap_dev *tap, struct ipvtap_dev *vlantap = container_of(tap, struct ipvtap_dev, tap); struct ipvl_dev *vlan = &vlantap->vlan;
- vlan->sfeatures = features; + netdev_feature_copy(&vlan->sfeatures, features); netdev_update_features(vlan->dev); }
@@ -86,7 +86,8 @@ static int ipvtap_newlink(struct net *src_net, struct net_device *dev, /* Since macvlan supports all offloads by default, make * tap support all offloads also. */ - vlantap->tap.tap_features = TUN_OFFLOADS; + netdev_feature_zero(&vlantap->tap.tap_features); + netdev_feature_set_bits(TUN_OFFLOADS, &vlantap->tap.tap_features); vlantap->tap.count_tx_dropped = ipvtap_count_tx_dropped; vlantap->tap.update_features = ipvtap_update_features; vlantap->tap.count_rx_dropped = ipvtap_count_rx_dropped;
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ipvlan/ipvlan_main.c | 28 ++++++++++++++++++---------- drivers/net/ipvlan/ipvtap.c | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 6a0b7bd2d3ae..84ad786ae18d 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -135,11 +135,14 @@ static int ipvlan_init(struct net_device *dev)
dev->state = (dev->state & ~IPVLAN_STATE_MASK) | (phy_dev->state & IPVLAN_STATE_MASK);
- dev->features = phy_dev->features & IPVLAN_FEATURES;
- dev->features |= IPVLAN_ALWAYS_ON;
- dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
- dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
- dev->hw_enc_features |= dev->features;
- netdev_feature_copy(&dev->features, phy_dev->features);
- netdev_feature_and_bits(IPVLAN_FEATURES, &dev->features);
- netdev_feature_set_bits(IPVLAN_ALWAYS_ON, &dev->features);
- netdev_feature_copy(&dev->vlan_features, phy_dev->vlan_features);
- netdev_feature_and_bits(IPVLAN_FEATURES, &dev->vlan_features);
- netdev_feature_set_bits(IPVLAN_ALWAYS_ON_OFLOADS, &dev->vlan_features);
- netdev_feature_or(&dev->hw_enc_features, dev->hw_enc_features,
dev->gso_max_size = phy_dev->gso_max_size; dev->gso_max_segs = phy_dev->gso_max_segs; dev->hard_header_len = phy_dev->hard_header_len;dev->features);
@@ -239,13 +242,17 @@ static void ipvlan_fix_features(struct net_device *dev, netdev_features_t *features) { struct ipvl_dev *ipvlan = netdev_priv(dev);
- netdev_features_t tmp;
- *features |= NETIF_F_ALL_FOR_ALL;
- *features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
- netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
- netdev_feature_fill(&tmp);
- netdev_feature_clear_bits(IPVLAN_FEATURES, &tmp);
- netdev_feature_or(&tmp, tmp, ipvlan->sfeatures);
- netdev_feature_and(features, *features, tmp); netdev_increment_features(features, ipvlan->phy_dev->features, *features, *features);
- *features |= IPVLAN_ALWAYS_ON;
- *features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
- netdev_feature_set_bits(IPVLAN_ALWAYS_ON, features);
- netdev_feature_and_bits(IPVLAN_FEATURES | IPVLAN_ALWAYS_ON, features);
}
static void ipvlan_change_rx_flags(struct net_device *dev, int change) @@ -567,7 +574,8 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
ipvlan->phy_dev = phy_dev; ipvlan->dev = dev;
- ipvlan->sfeatures = IPVLAN_FEATURES;
- netdev_feature_zero(&ipvlan->sfeatures);
- netdev_feature_set_bits(IPVLAN_FEATURES, &ipvlan->sfeatures); if (!tb[IFLA_MTU]) ipvlan_adjust_mtu(ipvlan, phy_dev); INIT_LIST_HEAD(&ipvlan->addrs);
diff --git a/drivers/net/ipvlan/ipvtap.c b/drivers/net/ipvlan/ipvtap.c index 1cedb634f4f7..fd11ce806cc7 100644 --- a/drivers/net/ipvlan/ipvtap.c +++ b/drivers/net/ipvlan/ipvtap.c @@ -70,7 +70,7 @@ static void ipvtap_update_features(struct tap_dev *tap, struct ipvtap_dev *vlantap = container_of(tap, struct ipvtap_dev, tap); struct ipvl_dev *vlan = &vlantap->vlan;
- vlan->sfeatures = features;
- netdev_feature_copy(&vlan->sfeatures, features); netdev_update_features(vlan->dev);
}
@@ -86,7 +86,8 @@ static int ipvtap_newlink(struct net *src_net, struct net_device *dev, /* Since macvlan supports all offloads by default, make * tap support all offloads also. */
- vlantap->tap.tap_features = TUN_OFFLOADS;
- netdev_feature_zero(&vlantap->tap.tap_features);
- netdev_feature_set_bits(TUN_OFFLOADS, &vlantap->tap.tap_features); vlantap->tap.count_tx_dropped = ipvtap_count_tx_dropped; vlantap->tap.update_features = ipvtap_update_features; vlantap->tap.count_rx_dropped = ipvtap_count_rx_dropped;
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/veth.c | 61 ++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 24 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 82c900d7ba7b..39bfa024861c 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -310,9 +310,10 @@ static bool veth_skb_is_eligible_for_gro(const struct net_device *dev, const struct net_device *rcv, const struct sk_buff *skb) { - return !(dev->features & NETIF_F_ALL_TSO) || + return !netdev_feature_test_bits(NETIF_F_ALL_TSO, dev->features) || (skb->destructor == sock_wfree && - rcv->features & (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD)); + netdev_feature_test_bits(NETIF_F_GRO_FRAGLIST | + NETIF_F_GRO_UDP_FWD, rcv->features)); }
static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) @@ -993,7 +994,7 @@ static void veth_napi_del(struct net_device *dev)
static bool veth_gro_requested(const struct net_device *dev) { - return !!(dev->wanted_features & NETIF_F_GRO); + return netdev_feature_test_bit(NETIF_F_GRO_BIT, dev->wanted_features); }
static int veth_enable_xdp_range(struct net_device *dev, int start, int end, @@ -1075,7 +1076,8 @@ static int veth_enable_xdp(struct net_device *dev) /* user-space did not require GRO, but adding XDP * is supposed to get GRO working */ - dev->features |= NETIF_F_GRO; + netdev_feature_set_bit(NETIF_F_GRO_BIT, + &dev->features); netdev_features_change(dev); } } @@ -1104,7 +1106,8 @@ static void veth_disable_xdp(struct net_device *dev) * enabled it, clear it now */ if (!veth_gro_requested(dev) && netif_running(dev)) { - dev->features &= ~NETIF_F_GRO; + netdev_feature_clear_bit(NETIF_F_GRO_BIT, + &dev->features); netdev_features_change(dev); } } @@ -1393,23 +1396,27 @@ static void veth_fix_features(struct net_device *dev, struct veth_priv *peer_priv = netdev_priv(peer);
if (peer_priv->_xdp_prog) - *features &= ~NETIF_F_GSO_SOFTWARE; + netdev_feature_clear_bits(NETIF_F_GSO_SOFTWARE, + features); } if (priv->_xdp_prog) - *features |= NETIF_F_GRO; + netdev_feature_set_bit(NETIF_F_GRO_BIT, features); }
static int veth_set_features(struct net_device *dev, netdev_features_t features) { - netdev_features_t changed = features ^ dev->features; struct veth_priv *priv = netdev_priv(dev); + netdev_features_t changed; int err;
- if (!(changed & NETIF_F_GRO) || !(dev->flags & IFF_UP) || priv->_xdp_prog) + netdev_feature_xor(&changed, features, dev->features); + + if (!netdev_feature_test_bit(NETIF_F_GRO_BIT, changed) || + !(dev->flags & IFF_UP) || priv->_xdp_prog) return 0;
- if (features & NETIF_F_GRO) { + if (netdev_feature_test_bit(NETIF_F_GRO_BIT, features)) { err = veth_napi_enable(dev); if (err) return err; @@ -1486,7 +1493,8 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog, }
if (!old_prog) { - peer->hw_features &= ~NETIF_F_GSO_SOFTWARE; + netdev_feature_clear_bits(NETIF_F_GSO_SOFTWARE, + &peer->hw_features); peer->max_mtu = max_mtu; } } @@ -1497,7 +1505,8 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog, veth_disable_xdp(dev);
if (peer) { - peer->hw_features |= NETIF_F_GSO_SOFTWARE; + netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE, + &peer->hw_features); peer->max_mtu = ETH_MAX_MTU; } } @@ -1562,20 +1571,24 @@ static void veth_setup(struct net_device *dev)
dev->netdev_ops = &veth_netdev_ops; dev->ethtool_ops = &veth_ethtool_ops; - dev->features |= NETIF_F_LLTX; - dev->features |= VETH_FEATURES; - dev->vlan_features = dev->features & - ~(NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX | - NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_VLAN_STAG_RX); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features); + netdev_feature_set_bits(VETH_FEATURES, &dev->features); + netdev_feature_copy(&dev->vlan_features, dev->features); + netdev_feature_clear_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX | + NETIF_F_HW_VLAN_CTAG_RX | + NETIF_F_HW_VLAN_STAG_RX, + &dev->vlan_features); dev->needs_free_netdev = true; dev->priv_destructor = veth_dev_free; dev->max_mtu = ETH_MAX_MTU;
- dev->hw_features = VETH_FEATURES; - dev->hw_enc_features = VETH_FEATURES; - dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE; + netdev_feature_zero(&dev->hw_features); + netdev_feature_set_bits(VETH_FEATURES, &dev->hw_features); + netdev_feature_copy(&dev->hw_enc_features, dev->hw_features); + netdev_feature_zero(&dev->mpls_features); + netdev_feature_set_bits(NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE, + &dev->mpls_features); }
/* @@ -1602,8 +1615,8 @@ static struct rtnl_link_ops veth_link_ops;
static void veth_disable_gro(struct net_device *dev) { - dev->features &= ~NETIF_F_GRO; - dev->wanted_features &= ~NETIF_F_GRO; + netdev_feature_clear_bit(NETIF_F_GRO_BIT, &dev->features); + netdev_feature_clear_bit(NETIF_F_GRO_BIT, &dev->wanted_features); netdev_update_features(dev); }
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/veth.c | 61 ++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 24 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 82c900d7ba7b..39bfa024861c 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -310,9 +310,10 @@ static bool veth_skb_is_eligible_for_gro(const struct net_device *dev, const struct net_device *rcv, const struct sk_buff *skb) {
- return !(dev->features & NETIF_F_ALL_TSO) ||
- return !netdev_feature_test_bits(NETIF_F_ALL_TSO, dev->features) || (skb->destructor == sock_wfree &&
rcv->features & (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD));
netdev_feature_test_bits(NETIF_F_GRO_FRAGLIST |
NETIF_F_GRO_UDP_FWD, rcv->features));
}
static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) @@ -993,7 +994,7 @@ static void veth_napi_del(struct net_device *dev)
static bool veth_gro_requested(const struct net_device *dev) {
- return !!(dev->wanted_features & NETIF_F_GRO);
- return netdev_feature_test_bit(NETIF_F_GRO_BIT, dev->wanted_features);
}
static int veth_enable_xdp_range(struct net_device *dev, int start, int end, @@ -1075,7 +1076,8 @@ static int veth_enable_xdp(struct net_device *dev) /* user-space did not require GRO, but adding XDP * is supposed to get GRO working */
dev->features |= NETIF_F_GRO;
netdev_feature_set_bit(NETIF_F_GRO_BIT,
}&dev->features); netdev_features_change(dev); }
@@ -1104,7 +1106,8 @@ static void veth_disable_xdp(struct net_device *dev) * enabled it, clear it now */ if (!veth_gro_requested(dev) && netif_running(dev)) {
dev->features &= ~NETIF_F_GRO;
netdev_feature_clear_bit(NETIF_F_GRO_BIT,
} }&dev->features); netdev_features_change(dev);
@@ -1393,23 +1396,27 @@ static void veth_fix_features(struct net_device *dev, struct veth_priv *peer_priv = netdev_priv(peer);
if (peer_priv->_xdp_prog)
*features &= ~NETIF_F_GSO_SOFTWARE;
netdev_feature_clear_bits(NETIF_F_GSO_SOFTWARE,
} if (priv->_xdp_prog)features);
*features |= NETIF_F_GRO;
netdev_feature_set_bit(NETIF_F_GRO_BIT, features);
}
static int veth_set_features(struct net_device *dev, netdev_features_t features) {
- netdev_features_t changed = features ^ dev->features; struct veth_priv *priv = netdev_priv(dev);
- netdev_features_t changed; int err;
- if (!(changed & NETIF_F_GRO) || !(dev->flags & IFF_UP) || priv->_xdp_prog)
- netdev_feature_xor(&changed, features, dev->features);
- if (!netdev_feature_test_bit(NETIF_F_GRO_BIT, changed) ||
return 0;!(dev->flags & IFF_UP) || priv->_xdp_prog)
- if (features & NETIF_F_GRO) {
- if (netdev_feature_test_bit(NETIF_F_GRO_BIT, features)) { err = veth_napi_enable(dev); if (err) return err;
@@ -1486,7 +1493,8 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog, }
if (!old_prog) {
peer->hw_features &= ~NETIF_F_GSO_SOFTWARE;
netdev_feature_clear_bits(NETIF_F_GSO_SOFTWARE,
} }&peer->hw_features); peer->max_mtu = max_mtu;
@@ -1497,7 +1505,8 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog, veth_disable_xdp(dev);
if (peer) {
peer->hw_features |= NETIF_F_GSO_SOFTWARE;
netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE,
}&peer->hw_features); peer->max_mtu = ETH_MAX_MTU; }
@@ -1562,20 +1571,24 @@ static void veth_setup(struct net_device *dev)
dev->netdev_ops = &veth_netdev_ops; dev->ethtool_ops = &veth_ethtool_ops;
- dev->features |= NETIF_F_LLTX;
- dev->features |= VETH_FEATURES;
- dev->vlan_features = dev->features &
~(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX |
NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_STAG_RX);
- netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features);
- netdev_feature_set_bits(VETH_FEATURES, &dev->features);
- netdev_feature_copy(&dev->vlan_features, dev->features);
- netdev_feature_clear_bits(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX |
NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_STAG_RX,
dev->needs_free_netdev = true; dev->priv_destructor = veth_dev_free; dev->max_mtu = ETH_MAX_MTU;&dev->vlan_features);
- dev->hw_features = VETH_FEATURES;
- dev->hw_enc_features = VETH_FEATURES;
- dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE;
- netdev_feature_zero(&dev->hw_features);
- netdev_feature_set_bits(VETH_FEATURES, &dev->hw_features);
- netdev_feature_copy(&dev->hw_enc_features, dev->hw_features);
- netdev_feature_zero(&dev->mpls_features);
- netdev_feature_set_bits(NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE,
&dev->mpls_features);
}
/* @@ -1602,8 +1615,8 @@ static struct rtnl_link_ops veth_link_ops;
static void veth_disable_gro(struct net_device *dev) {
- dev->features &= ~NETIF_F_GRO;
- dev->wanted_features &= ~NETIF_F_GRO;
- netdev_feature_clear_bit(NETIF_F_GRO_BIT, &dev->features);
- netdev_feature_clear_bit(NETIF_F_GRO_BIT, &dev->wanted_features); netdev_update_features(dev);
}
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/bonding/bond_main.c | 106 ++++++++++++++++++----------- drivers/net/bonding/bond_options.c | 12 ++-- 2 files changed, 76 insertions(+), 42 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b1c13fa3c677..e9e00cec2206 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1371,15 +1371,15 @@ static void bond_fix_features(struct net_device *dev,
#if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond)) - *features |= BOND_TLS_FEATURES; + netdev_feature_set_bits(BOND_TLS_FEATURES, features); else - *features &= ~BOND_TLS_FEATURES; + netdev_feature_clear_bits(BOND_TLS_FEATURES, features); #endif
- mask = *features; + netdev_feature_copy(&mask, *features);
- *features &= ~NETIF_F_ONE_FOR_ALL; - *features |= NETIF_F_ALL_FOR_ALL; + netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features); + netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
bond_for_each_slave(bond, slave, iter) { netdev_increment_features(features, *features, @@ -1403,12 +1403,16 @@ static void bond_compute_features(struct bonding *bond) { unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM; - netdev_features_t vlan_features = BOND_VLAN_FEATURES; - netdev_features_t enc_features = BOND_ENC_FEATURES; + netdev_features_t vlan_features; + netdev_features_t enc_features; + netdev_features_t vlan_mask; + netdev_features_t enc_mask; #ifdef CONFIG_XFRM_OFFLOAD - netdev_features_t xfrm_features = BOND_XFRM_FEATURES; + netdev_features_t xfrm_features; + netdev_features_t xfrm_mask; #endif /* CONFIG_XFRM_OFFLOAD */ - netdev_features_t mpls_features = BOND_MPLS_FEATURES; + netdev_features_t mpls_features; + netdev_features_t mpls_mask; struct net_device *bond_dev = bond->dev; struct list_head *iter; struct slave *slave; @@ -1416,29 +1420,44 @@ static void bond_compute_features(struct bonding *bond) unsigned int gso_max_size = GSO_MAX_SIZE; u16 gso_max_segs = GSO_MAX_SEGS;
+ netdev_feature_zero(&vlan_features); + netdev_feature_set_bits(BOND_VLAN_FEATURES, &vlan_features); + netdev_feature_copy(&vlan_mask, vlan_features); + netdev_feature_zero(&enc_features); + netdev_feature_set_bits(BOND_ENC_FEATURES, &enc_features); + netdev_feature_copy(&enc_mask, enc_features); +#ifdef CONFIG_XFRM_OFFLOAD + netdev_feature_zero(&xfrm_features); + netdev_feature_set_bits(BOND_XFRM_FEATURES, &xfrm_features); + netdev_feature_copy(&xfrm_mask, xfrm_features); +#endif /* CONFIG_XFRM_OFFLOAD */ + netdev_feature_zero(&mpls_features); + netdev_feature_set_bits(BOND_MPLS_FEATURES, &mpls_features); + netdev_feature_copy(&mpls_mask, mpls_features); + if (!bond_has_slaves(bond)) goto done; - vlan_features &= NETIF_F_ALL_FOR_ALL; - mpls_features &= NETIF_F_ALL_FOR_ALL; + netdev_feature_and_bits(NETIF_F_ALL_FOR_ALL, &vlan_features); + netdev_feature_and_bits(NETIF_F_ALL_FOR_ALL, &mpls_features);
bond_for_each_slave(bond, slave, iter) { netdev_increment_features(&vlan_features, vlan_features, slave->dev->vlan_features, - BOND_VLAN_FEATURES); + vlan_mask);
netdev_increment_features(&enc_features, enc_features, slave->dev->hw_enc_features, - BOND_ENC_FEATURES); + enc_mask);
#ifdef CONFIG_XFRM_OFFLOAD netdev_increment_features(&xfrm_features, xfrm_features, slave->dev->hw_enc_features, - BOND_XFRM_FEATURES); + xfrm_mask); #endif /* CONFIG_XFRM_OFFLOAD */
netdev_increment_features(&mpls_features, mpls_features, slave->dev->mpls_features, - BOND_MPLS_FEATURES); + mpls_mask);
dst_release_flag &= slave->dev->priv_flags; if (slave->dev->hard_header_len > max_hard_header_len) @@ -1450,14 +1469,16 @@ static void bond_compute_features(struct bonding *bond) bond_dev->hard_header_len = max_hard_header_len;
done: - bond_dev->vlan_features = vlan_features; - bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; + netdev_feature_copy(&bond_dev->vlan_features, vlan_features); + netdev_feature_copy(&bond_dev->hw_enc_features, enc_features); + netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, &mpls_features); #ifdef CONFIG_XFRM_OFFLOAD - bond_dev->hw_enc_features |= xfrm_features; + netdev_feature_or(&bond_dev->vlan_features, bond_dev->vlan_features, + xfrm_features); #endif /* CONFIG_XFRM_OFFLOAD */ - bond_dev->mpls_features = mpls_features; + netdev_feature_copy(&bond_dev->mpls_features, mpls_features); bond_dev->gso_max_segs = gso_max_segs; netif_set_gso_max_size(bond_dev, gso_max_size);
@@ -1781,7 +1802,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
/* vlan challenged mutual exclusion */ /* no need to lock since we're protected by rtnl_lock */ - if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { + if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, + slave_dev->features)) { slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n"); if (vlan_uses_dev(bond_dev)) { SLAVE_NL_ERR(bond_dev, slave_dev, extack, @@ -1794,7 +1816,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, slave_dbg(bond_dev, slave_dev, "is !NETIF_F_VLAN_CHALLENGED\n"); }
- if (slave_dev->features & NETIF_F_HW_ESP) + if (netdev_feature_test_bit(NETIF_F_HW_ESP_BIT, slave_dev->features)) slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n");
/* Old ifenslave binaries are no longer supported. These can @@ -2087,7 +2109,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, } #endif
- if (!(bond_dev->features & NETIF_F_LRO)) + if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, bond_dev->features)) dev_disable_lro(slave_dev);
res = netdev_rx_handler_register(slave_dev, bond_handle_frame, @@ -2285,8 +2307,9 @@ static int __bond_release_one(struct net_device *bond_dev, struct slave *slave, *oldcurrent; struct sockaddr_storage ss; int old_flags = bond_dev->flags; - netdev_features_t old_features = bond_dev->features; + netdev_features_t old_features;
+ netdev_feature_copy(&old_features, bond_dev->features); /* slave is not a slave or master is not master of this slave */ if (!(slave_dev->flags & IFF_SLAVE) || !netdev_has_upper_dev(slave_dev, bond_dev)) { @@ -2390,8 +2413,9 @@ static int __bond_release_one(struct net_device *bond_dev, }
bond_compute_features(bond); - if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && - (old_features & NETIF_F_VLAN_CHALLENGED)) + if (!netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, + bond_dev->features) && + netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, old_features)) slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n");
vlan_vids_del_by_dev(slave_dev, bond_dev); @@ -5406,7 +5430,7 @@ void bond_setup(struct net_device *bond_dev) #endif /* CONFIG_XFRM_OFFLOAD */
/* don't acquire bond device's netif_tx_lock when transmitting */ - bond_dev->features |= NETIF_F_LLTX; + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &bond_dev->features);
/* By default, we declare the bond to be fully * VLAN hardware accelerated capable. Special @@ -5416,24 +5440,30 @@ void bond_setup(struct net_device *bond_dev) */
/* Don't allow bond devices to change network namespaces. */ - bond_dev->features |= NETIF_F_NETNS_LOCAL; + netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT, &bond_dev->features);
- bond_dev->hw_features = BOND_VLAN_FEATURES | + netdev_feature_zero(&bond_dev->hw_features); + netdev_feature_set_bits(BOND_VLAN_FEATURES | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_VLAN_CTAG_FILTER; - - bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL; - bond_dev->features |= bond_dev->hw_features; - bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; + NETIF_F_HW_VLAN_CTAG_FILTER, + &bond_dev->hw_features); + + netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL, &bond_dev->hw_features); + netdev_feature_or(&bond_dev->features, bond_dev->features, + bond_dev->hw_features); + netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, + &bond_dev->features); #ifdef CONFIG_XFRM_OFFLOAD - bond_dev->hw_features |= BOND_XFRM_FEATURES; + netdev_feature_set_bits(BOND_XFRM_FEATURES, &bond_dev->hw_features); /* Only enable XFRM features if this is an active-backup config */ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) - bond_dev->features |= BOND_XFRM_FEATURES; + netdev_feature_set_bits(BOND_XFRM_FEATURES, + &bond_dev->features); #endif /* CONFIG_XFRM_OFFLOAD */ #if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond)) - bond_dev->features |= BOND_TLS_FEATURES; + netdev_feature_set_bits(BOND_TLS_FEATURES, &bond_dev->features); #endif }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index a8fde3bc458f..b0c3a28c2448 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -778,9 +778,11 @@ static bool bond_set_xfrm_features(struct bonding *bond) return false;
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) - bond->dev->wanted_features |= BOND_XFRM_FEATURES; + netdev_feature_set_bits(BOND_XFRM_FEATURES, + &bond->dev->wanted_features); else - bond->dev->wanted_features &= ~BOND_XFRM_FEATURES; + netdev_feature_clear_bits(BOND_XFRM_FEATURES, + &bond->dev->wanted_features);
return true; } @@ -791,9 +793,11 @@ static bool bond_set_tls_features(struct bonding *bond) return false;
if (bond_sk_check(bond)) - bond->dev->wanted_features |= BOND_TLS_FEATURES; + netdev_feature_set_bits(BOND_TLS_FEATURES, + &bond->dev->wanted_features); else - bond->dev->wanted_features &= ~BOND_TLS_FEATURES; + netdev_feature_clear_bits(BOND_TLS_FEATURES, + &bond->dev->wanted_features);
return true; }
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/bonding/bond_main.c | 106 ++++++++++++++++++----------- drivers/net/bonding/bond_options.c | 12 ++-- 2 files changed, 76 insertions(+), 42 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b1c13fa3c677..e9e00cec2206 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1371,15 +1371,15 @@ static void bond_fix_features(struct net_device *dev,
#if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond))
*features |= BOND_TLS_FEATURES;
elsenetdev_feature_set_bits(BOND_TLS_FEATURES, features);
*features &= ~BOND_TLS_FEATURES;
netdev_feature_clear_bits(BOND_TLS_FEATURES, features);
#endif
- mask = *features;
- netdev_feature_copy(&mask, *features);
- *features &= ~NETIF_F_ONE_FOR_ALL;
- *features |= NETIF_F_ALL_FOR_ALL;
netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features);
netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
bond_for_each_slave(bond, slave, iter) { netdev_increment_features(features, *features,
@@ -1403,12 +1403,16 @@ static void bond_compute_features(struct bonding *bond) { unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM;
- netdev_features_t vlan_features = BOND_VLAN_FEATURES;
- netdev_features_t enc_features = BOND_ENC_FEATURES;
- netdev_features_t vlan_features;
- netdev_features_t enc_features;
- netdev_features_t vlan_mask;
- netdev_features_t enc_mask;
#ifdef CONFIG_XFRM_OFFLOAD
- netdev_features_t xfrm_features = BOND_XFRM_FEATURES;
- netdev_features_t xfrm_features;
- netdev_features_t xfrm_mask;
#endif /* CONFIG_XFRM_OFFLOAD */
- netdev_features_t mpls_features = BOND_MPLS_FEATURES;
- netdev_features_t mpls_features;
- netdev_features_t mpls_mask; struct net_device *bond_dev = bond->dev; struct list_head *iter; struct slave *slave;
@@ -1416,29 +1420,44 @@ static void bond_compute_features(struct bonding *bond) unsigned int gso_max_size = GSO_MAX_SIZE; u16 gso_max_segs = GSO_MAX_SEGS;
- netdev_feature_zero(&vlan_features);
- netdev_feature_set_bits(BOND_VLAN_FEATURES, &vlan_features);
- netdev_feature_copy(&vlan_mask, vlan_features);
- netdev_feature_zero(&enc_features);
- netdev_feature_set_bits(BOND_ENC_FEATURES, &enc_features);
- netdev_feature_copy(&enc_mask, enc_features);
+#ifdef CONFIG_XFRM_OFFLOAD
- netdev_feature_zero(&xfrm_features);
- netdev_feature_set_bits(BOND_XFRM_FEATURES, &xfrm_features);
- netdev_feature_copy(&xfrm_mask, xfrm_features);
+#endif /* CONFIG_XFRM_OFFLOAD */
- netdev_feature_zero(&mpls_features);
- netdev_feature_set_bits(BOND_MPLS_FEATURES, &mpls_features);
- netdev_feature_copy(&mpls_mask, mpls_features);
- if (!bond_has_slaves(bond)) goto done;
- vlan_features &= NETIF_F_ALL_FOR_ALL;
- mpls_features &= NETIF_F_ALL_FOR_ALL;
netdev_feature_and_bits(NETIF_F_ALL_FOR_ALL, &vlan_features);
netdev_feature_and_bits(NETIF_F_ALL_FOR_ALL, &mpls_features);
bond_for_each_slave(bond, slave, iter) { netdev_increment_features(&vlan_features, vlan_features, slave->dev->vlan_features,
BOND_VLAN_FEATURES);
vlan_mask);
netdev_increment_features(&enc_features, enc_features, slave->dev->hw_enc_features,
BOND_ENC_FEATURES);
enc_mask);
#ifdef CONFIG_XFRM_OFFLOAD netdev_increment_features(&xfrm_features, xfrm_features, slave->dev->hw_enc_features,
BOND_XFRM_FEATURES);
xfrm_mask);
#endif /* CONFIG_XFRM_OFFLOAD */
netdev_increment_features(&mpls_features, mpls_features, slave->dev->mpls_features,
BOND_MPLS_FEATURES);
mpls_mask);
dst_release_flag &= slave->dev->priv_flags; if (slave->dev->hard_header_len > max_hard_header_len)
@@ -1450,14 +1469,16 @@ static void bond_compute_features(struct bonding *bond) bond_dev->hard_header_len = max_hard_header_len;
done:
- bond_dev->vlan_features = vlan_features;
- bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
- netdev_feature_copy(&bond_dev->vlan_features, vlan_features);
- netdev_feature_copy(&bond_dev->hw_enc_features, enc_features);
- netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX, &mpls_features);
#ifdef CONFIG_XFRM_OFFLOAD
- bond_dev->hw_enc_features |= xfrm_features;
- netdev_feature_or(&bond_dev->vlan_features, bond_dev->vlan_features,
xfrm_features);
bond_dev->vlan_features -> ond_dev->hw_enc_features ?
#endif /* CONFIG_XFRM_OFFLOAD */
- bond_dev->mpls_features = mpls_features;
- netdev_feature_copy(&bond_dev->mpls_features, mpls_features); bond_dev->gso_max_segs = gso_max_segs; netif_set_gso_max_size(bond_dev, gso_max_size);
@@ -1781,7 +1802,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
/* vlan challenged mutual exclusion */ /* no need to lock since we're protected by rtnl_lock */
- if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
- if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT,
slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n"); if (vlan_uses_dev(bond_dev)) { SLAVE_NL_ERR(bond_dev, slave_dev, extack,slave_dev->features)) {
@@ -1794,7 +1816,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, slave_dbg(bond_dev, slave_dev, "is !NETIF_F_VLAN_CHALLENGED\n"); }
- if (slave_dev->features & NETIF_F_HW_ESP)
if (netdev_feature_test_bit(NETIF_F_HW_ESP_BIT, slave_dev->features)) slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n");
/* Old ifenslave binaries are no longer supported. These can
@@ -2087,7 +2109,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, } #endif
- if (!(bond_dev->features & NETIF_F_LRO))
if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, bond_dev->features)) dev_disable_lro(slave_dev);
res = netdev_rx_handler_register(slave_dev, bond_handle_frame,
@@ -2285,8 +2307,9 @@ static int __bond_release_one(struct net_device *bond_dev, struct slave *slave, *oldcurrent; struct sockaddr_storage ss; int old_flags = bond_dev->flags;
- netdev_features_t old_features = bond_dev->features;
netdev_features_t old_features;
netdev_feature_copy(&old_features, bond_dev->features); /* slave is not a slave or master is not master of this slave */ if (!(slave_dev->flags & IFF_SLAVE) || !netdev_has_upper_dev(slave_dev, bond_dev)) {
@@ -2390,8 +2413,9 @@ static int __bond_release_one(struct net_device *bond_dev, }
bond_compute_features(bond);
- if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
(old_features & NETIF_F_VLAN_CHALLENGED))
if (!netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT,
bond_dev->features) &&
netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, old_features))
slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n");
vlan_vids_del_by_dev(slave_dev, bond_dev);
@@ -5406,7 +5430,7 @@ void bond_setup(struct net_device *bond_dev) #endif /* CONFIG_XFRM_OFFLOAD */
/* don't acquire bond device's netif_tx_lock when transmitting */
- bond_dev->features |= NETIF_F_LLTX;
netdev_feature_set_bit(NETIF_F_LLTX_BIT, &bond_dev->features);
/* By default, we declare the bond to be fully
- VLAN hardware accelerated capable. Special
@@ -5416,24 +5440,30 @@ void bond_setup(struct net_device *bond_dev) */
/* Don't allow bond devices to change network namespaces. */
- bond_dev->features |= NETIF_F_NETNS_LOCAL;
- netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT, &bond_dev->features);
- bond_dev->hw_features = BOND_VLAN_FEATURES |
- netdev_feature_zero(&bond_dev->hw_features);
- netdev_feature_set_bits(BOND_VLAN_FEATURES | NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_CTAG_FILTER;
- bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
- bond_dev->features |= bond_dev->hw_features;
- bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
NETIF_F_HW_VLAN_CTAG_FILTER,
&bond_dev->hw_features);
- netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL, &bond_dev->hw_features);
- netdev_feature_or(&bond_dev->features, bond_dev->features,
bond_dev->hw_features);
- netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX,
&bond_dev->features);
#ifdef CONFIG_XFRM_OFFLOAD
- bond_dev->hw_features |= BOND_XFRM_FEATURES;
- netdev_feature_set_bits(BOND_XFRM_FEATURES, &bond_dev->hw_features); /* Only enable XFRM features if this is an active-backup config */ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
bond_dev->features |= BOND_XFRM_FEATURES;
netdev_feature_set_bits(BOND_XFRM_FEATURES,
&bond_dev->features);
#endif /* CONFIG_XFRM_OFFLOAD */ #if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond))
bond_dev->features |= BOND_TLS_FEATURES;
netdev_feature_set_bits(BOND_TLS_FEATURES, &bond_dev->features);
#endif }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index a8fde3bc458f..b0c3a28c2448 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -778,9 +778,11 @@ static bool bond_set_xfrm_features(struct bonding *bond) return false;
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
bond->dev->wanted_features |= BOND_XFRM_FEATURES;
netdev_feature_set_bits(BOND_XFRM_FEATURES,
else&bond->dev->wanted_features);
bond->dev->wanted_features &= ~BOND_XFRM_FEATURES;
netdev_feature_clear_bits(BOND_XFRM_FEATURES,
&bond->dev->wanted_features);
return true;
} @@ -791,9 +793,11 @@ static bool bond_set_tls_features(struct bonding *bond) return false;
if (bond_sk_check(bond))
bond->dev->wanted_features |= BOND_TLS_FEATURES;
netdev_feature_set_bits(BOND_TLS_FEATURES,
else&bond->dev->wanted_features);
bond->dev->wanted_features &= ~BOND_TLS_FEATURES;
netdev_feature_clear_bits(BOND_TLS_FEATURES,
&bond->dev->wanted_features);
return true;
}
在 2021/9/24 10:52, wangjie (L) 写道:
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/bonding/bond_main.c | 106 ++++++++++++++++++----------- drivers/net/bonding/bond_options.c | 12 ++-- 2 files changed, 76 insertions(+), 42 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b1c13fa3c677..e9e00cec2206 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1371,15 +1371,15 @@ static void bond_fix_features(struct net_device *dev,
#if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond)) - *features |= BOND_TLS_FEATURES; + netdev_feature_set_bits(BOND_TLS_FEATURES, features); else - *features &= ~BOND_TLS_FEATURES; + netdev_feature_clear_bits(BOND_TLS_FEATURES, features); #endif
- mask = *features; + netdev_feature_copy(&mask, *features);
- *features &= ~NETIF_F_ONE_FOR_ALL; - *features |= NETIF_F_ALL_FOR_ALL; + netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features); + netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
bond_for_each_slave(bond, slave, iter) { netdev_increment_features(features, *features, @@ -1403,12 +1403,16 @@ static void bond_compute_features(struct bonding *bond) { unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM; - netdev_features_t vlan_features = BOND_VLAN_FEATURES; - netdev_features_t enc_features = BOND_ENC_FEATURES; + netdev_features_t vlan_features; + netdev_features_t enc_features; + netdev_features_t vlan_mask; + netdev_features_t enc_mask; #ifdef CONFIG_XFRM_OFFLOAD - netdev_features_t xfrm_features = BOND_XFRM_FEATURES; + netdev_features_t xfrm_features; + netdev_features_t xfrm_mask; #endif /* CONFIG_XFRM_OFFLOAD */ - netdev_features_t mpls_features = BOND_MPLS_FEATURES; + netdev_features_t mpls_features; + netdev_features_t mpls_mask; struct net_device *bond_dev = bond->dev; struct list_head *iter; struct slave *slave; @@ -1416,29 +1420,44 @@ static void bond_compute_features(struct bonding *bond) unsigned int gso_max_size = GSO_MAX_SIZE; u16 gso_max_segs = GSO_MAX_SEGS;
+ netdev_feature_zero(&vlan_features); + netdev_feature_set_bits(BOND_VLAN_FEATURES, &vlan_features); + netdev_feature_copy(&vlan_mask, vlan_features); + netdev_feature_zero(&enc_features); + netdev_feature_set_bits(BOND_ENC_FEATURES, &enc_features); + netdev_feature_copy(&enc_mask, enc_features); +#ifdef CONFIG_XFRM_OFFLOAD + netdev_feature_zero(&xfrm_features); + netdev_feature_set_bits(BOND_XFRM_FEATURES, &xfrm_features); + netdev_feature_copy(&xfrm_mask, xfrm_features); +#endif /* CONFIG_XFRM_OFFLOAD */ + netdev_feature_zero(&mpls_features); + netdev_feature_set_bits(BOND_MPLS_FEATURES, &mpls_features); + netdev_feature_copy(&mpls_mask, mpls_features);
if (!bond_has_slaves(bond)) goto done; - vlan_features &= NETIF_F_ALL_FOR_ALL; - mpls_features &= NETIF_F_ALL_FOR_ALL; + netdev_feature_and_bits(NETIF_F_ALL_FOR_ALL, &vlan_features); + netdev_feature_and_bits(NETIF_F_ALL_FOR_ALL, &mpls_features);
bond_for_each_slave(bond, slave, iter) { netdev_increment_features(&vlan_features, vlan_features, slave->dev->vlan_features, - BOND_VLAN_FEATURES); + vlan_mask);
netdev_increment_features(&enc_features, enc_features, slave->dev->hw_enc_features, - BOND_ENC_FEATURES); + enc_mask);
#ifdef CONFIG_XFRM_OFFLOAD netdev_increment_features(&xfrm_features, xfrm_features, slave->dev->hw_enc_features, - BOND_XFRM_FEATURES); + xfrm_mask); #endif /* CONFIG_XFRM_OFFLOAD */
netdev_increment_features(&mpls_features, mpls_features, slave->dev->mpls_features, - BOND_MPLS_FEATURES); + mpls_mask);
dst_release_flag &= slave->dev->priv_flags; if (slave->dev->hard_header_len > max_hard_header_len) @@ -1450,14 +1469,16 @@ static void bond_compute_features(struct bonding *bond) bond_dev->hard_header_len = max_hard_header_len;
done: - bond_dev->vlan_features = vlan_features; - bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL | - NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; + netdev_feature_copy(&bond_dev->vlan_features, vlan_features); + netdev_feature_copy(&bond_dev->hw_enc_features, enc_features); + netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, &mpls_features); #ifdef CONFIG_XFRM_OFFLOAD - bond_dev->hw_enc_features |= xfrm_features; + netdev_feature_or(&bond_dev->vlan_features, bond_dev->vlan_features, + xfrm_features);
bond_dev->vlan_features -> ond_dev->hw_enc_features ?
yes, will fix it next version
#endif /* CONFIG_XFRM_OFFLOAD */ - bond_dev->mpls_features = mpls_features; + netdev_feature_copy(&bond_dev->mpls_features, mpls_features); bond_dev->gso_max_segs = gso_max_segs; netif_set_gso_max_size(bond_dev, gso_max_size);
@@ -1781,7 +1802,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
/* vlan challenged mutual exclusion */ /* no need to lock since we're protected by rtnl_lock */ - if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { + if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, + slave_dev->features)) { slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n"); if (vlan_uses_dev(bond_dev)) { SLAVE_NL_ERR(bond_dev, slave_dev, extack, @@ -1794,7 +1816,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, slave_dbg(bond_dev, slave_dev, "is !NETIF_F_VLAN_CHALLENGED\n"); }
- if (slave_dev->features & NETIF_F_HW_ESP) + if (netdev_feature_test_bit(NETIF_F_HW_ESP_BIT, slave_dev->features)) slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n");
/* Old ifenslave binaries are no longer supported. These can @@ -2087,7 +2109,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, } #endif
- if (!(bond_dev->features & NETIF_F_LRO)) + if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, bond_dev->features)) dev_disable_lro(slave_dev);
res = netdev_rx_handler_register(slave_dev, bond_handle_frame, @@ -2285,8 +2307,9 @@ static int __bond_release_one(struct net_device *bond_dev, struct slave *slave, *oldcurrent; struct sockaddr_storage ss; int old_flags = bond_dev->flags; - netdev_features_t old_features = bond_dev->features; + netdev_features_t old_features;
+ netdev_feature_copy(&old_features, bond_dev->features); /* slave is not a slave or master is not master of this slave */ if (!(slave_dev->flags & IFF_SLAVE) || !netdev_has_upper_dev(slave_dev, bond_dev)) { @@ -2390,8 +2413,9 @@ static int __bond_release_one(struct net_device *bond_dev, }
bond_compute_features(bond); - if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && - (old_features & NETIF_F_VLAN_CHALLENGED)) + if (!netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, + bond_dev->features) && + netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT, old_features)) slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n");
vlan_vids_del_by_dev(slave_dev, bond_dev); @@ -5406,7 +5430,7 @@ void bond_setup(struct net_device *bond_dev) #endif /* CONFIG_XFRM_OFFLOAD */
/* don't acquire bond device's netif_tx_lock when transmitting */ - bond_dev->features |= NETIF_F_LLTX; + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &bond_dev->features);
/* By default, we declare the bond to be fully * VLAN hardware accelerated capable. Special @@ -5416,24 +5440,30 @@ void bond_setup(struct net_device *bond_dev) */
/* Don't allow bond devices to change network namespaces. */ - bond_dev->features |= NETIF_F_NETNS_LOCAL; + netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT, &bond_dev->features);
- bond_dev->hw_features = BOND_VLAN_FEATURES | + netdev_feature_zero(&bond_dev->hw_features); + netdev_feature_set_bits(BOND_VLAN_FEATURES | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_VLAN_CTAG_FILTER;
- bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL; - bond_dev->features |= bond_dev->hw_features; - bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; + NETIF_F_HW_VLAN_CTAG_FILTER, + &bond_dev->hw_features);
+ netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL, &bond_dev->hw_features); + netdev_feature_or(&bond_dev->features, bond_dev->features, + bond_dev->hw_features); + netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, + &bond_dev->features); #ifdef CONFIG_XFRM_OFFLOAD - bond_dev->hw_features |= BOND_XFRM_FEATURES; + netdev_feature_set_bits(BOND_XFRM_FEATURES, &bond_dev->hw_features); /* Only enable XFRM features if this is an active-backup config */ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) - bond_dev->features |= BOND_XFRM_FEATURES; + netdev_feature_set_bits(BOND_XFRM_FEATURES, + &bond_dev->features); #endif /* CONFIG_XFRM_OFFLOAD */ #if IS_ENABLED(CONFIG_TLS_DEVICE) if (bond_sk_check(bond)) - bond_dev->features |= BOND_TLS_FEATURES; + netdev_feature_set_bits(BOND_TLS_FEATURES, &bond_dev->features); #endif }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index a8fde3bc458f..b0c3a28c2448 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -778,9 +778,11 @@ static bool bond_set_xfrm_features(struct bonding *bond) return false;
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) - bond->dev->wanted_features |= BOND_XFRM_FEATURES; + netdev_feature_set_bits(BOND_XFRM_FEATURES, + &bond->dev->wanted_features); else - bond->dev->wanted_features &= ~BOND_XFRM_FEATURES; + netdev_feature_clear_bits(BOND_XFRM_FEATURES, + &bond->dev->wanted_features);
return true; } @@ -791,9 +793,11 @@ static bool bond_set_tls_features(struct bonding *bond) return false;
if (bond_sk_check(bond)) - bond->dev->wanted_features |= BOND_TLS_FEATURES; + netdev_feature_set_bits(BOND_TLS_FEATURES, + &bond->dev->wanted_features); else - bond->dev->wanted_features &= ~BOND_TLS_FEATURES; + netdev_feature_clear_bits(BOND_TLS_FEATURES, + &bond->dev->wanted_features);
return true; }
.
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/tun.c | 48 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index d89a9874eb37..9e9cbafc870b 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1083,9 +1083,11 @@ static void tun_net_fix_features(struct net_device *dev, netdev_features_t *features) { struct tun_struct *tun = netdev_priv(dev); + netdev_features_t tmp;
- *features = (*features & tun->set_features) | - (*features & ~TUN_USER_FEATURES); + netdev_feature_and(&tmp, *features, tun->set_features); + netdev_feature_clear_bits(TUN_USER_FEATURES, features); + netdev_feature_or(features, *features, tmp); }
static void tun_set_headroom(struct net_device *dev, int new_hr) @@ -2727,13 +2729,18 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) tun_net_init(dev); tun_flow_init(tun);
- dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | - TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX; - dev->features = dev->hw_features | NETIF_F_LLTX; - dev->vlan_features = dev->features & - ~(NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_STAG_TX); + netdev_feature_zero(&dev->hw_features); + netdev_feature_set_bits(NETIF_F_SG | NETIF_F_FRAGLIST | + TUN_USER_FEATURES | + NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, + &dev->hw_features); + netdev_feature_copy(&dev->features, dev->hw_features); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features); + netdev_feature_copy(&dev->vlan_features, dev->features); + netdev_feature_clear_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX, + &dev->vlan_features);
tun->flags = (tun->flags & ~TUN_FEATURES) | (ifr->ifr_flags & TUN_FEATURES); @@ -2795,21 +2802,26 @@ static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr) * privs required. */ static int set_offload(struct tun_struct *tun, unsigned long arg) { - netdev_features_t features = 0; + netdev_features_t features; + + netdev_feature_zero(&features);
if (arg & TUN_F_CSUM) { - features |= NETIF_F_HW_CSUM; + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &features); arg &= ~TUN_F_CSUM;
if (arg & (TUN_F_TSO4|TUN_F_TSO6)) { if (arg & TUN_F_TSO_ECN) { - features |= NETIF_F_TSO_ECN; + netdev_feature_set_bit(NETIF_F_TSO_ECN_BIT, + &features); arg &= ~TUN_F_TSO_ECN; } if (arg & TUN_F_TSO4) - features |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &features); if (arg & TUN_F_TSO6) - features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &features); arg &= ~(TUN_F_TSO4|TUN_F_TSO6); }
@@ -2821,9 +2833,11 @@ static int set_offload(struct tun_struct *tun, unsigned long arg) if (arg) return -EINVAL;
- tun->set_features = features; - tun->dev->wanted_features &= ~TUN_USER_FEATURES; - tun->dev->wanted_features |= features; + netdev_feature_copy(&tun->set_features, features); + netdev_feature_clear_bits(TUN_USER_FEATURES, + &tun->dev->wanted_features); + netdev_feature_or(&tun->dev->wanted_features, + tun->dev->wanted_features, features); netdev_update_features(tun->dev);
return 0;
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/tun.c | 48 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index d89a9874eb37..9e9cbafc870b 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1083,9 +1083,11 @@ static void tun_net_fix_features(struct net_device *dev, netdev_features_t *features) { struct tun_struct *tun = netdev_priv(dev);
- netdev_features_t tmp;
- *features = (*features & tun->set_features) |
(*features & ~TUN_USER_FEATURES);
- netdev_feature_and(&tmp, *features, tun->set_features);
- netdev_feature_clear_bits(TUN_USER_FEATURES, features);
- netdev_feature_or(features, *features, tmp);
}
static void tun_set_headroom(struct net_device *dev, int new_hr) @@ -2727,13 +2729,18 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) tun_net_init(dev); tun_flow_init(tun);
dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
dev->features = dev->hw_features | NETIF_F_LLTX;
dev->vlan_features = dev->features &
~(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
netdev_feature_zero(&dev->hw_features);
netdev_feature_set_bits(NETIF_F_SG | NETIF_F_FRAGLIST |
TUN_USER_FEATURES |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX,
&dev->hw_features);
netdev_feature_copy(&dev->features, dev->hw_features);
netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features);
netdev_feature_copy(&dev->vlan_features, dev->features);
netdev_feature_clear_bits(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX,
&dev->vlan_features);
tun->flags = (tun->flags & ~TUN_FEATURES) | (ifr->ifr_flags & TUN_FEATURES);
@@ -2795,21 +2802,26 @@ static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr)
- privs required. */
static int set_offload(struct tun_struct *tun, unsigned long arg) {
- netdev_features_t features = 0;
netdev_features_t features;
netdev_feature_zero(&features);
if (arg & TUN_F_CSUM) {
features |= NETIF_F_HW_CSUM;
netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &features);
arg &= ~TUN_F_CSUM;
if (arg & (TUN_F_TSO4|TUN_F_TSO6)) { if (arg & TUN_F_TSO_ECN) {
features |= NETIF_F_TSO_ECN;
netdev_feature_set_bit(NETIF_F_TSO_ECN_BIT,
&features); arg &= ~TUN_F_TSO_ECN; } if (arg & TUN_F_TSO4)
features |= NETIF_F_TSO;
netdev_feature_set_bit(NETIF_F_TSO_BIT,
&features); if (arg & TUN_F_TSO6)
features |= NETIF_F_TSO6;
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
}&features); arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
@@ -2821,9 +2833,11 @@ static int set_offload(struct tun_struct *tun, unsigned long arg) if (arg) return -EINVAL;
- tun->set_features = features;
- tun->dev->wanted_features &= ~TUN_USER_FEATURES;
- tun->dev->wanted_features |= features;
netdev_feature_copy(&tun->set_features, features);
netdev_feature_clear_bits(TUN_USER_FEATURES,
&tun->dev->wanted_features);
netdev_feature_or(&tun->dev->wanted_features,
tun->dev->wanted_features, features);
netdev_update_features(tun->dev);
return 0;
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/tap.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 8e3a28ba6b28..03158fa9476c 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -321,7 +321,10 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) struct net_device *dev = skb->dev; struct tap_dev *tap; struct tap_queue *q; - netdev_features_t features = TAP_FEATURES; + netdev_features_t features; + + netdev_feature_zero(&features); + netdev_feature_set_bits(TAP_FEATURES, &features);
tap = tap_dev_get_rcu(dev); if (!tap) @@ -338,7 +341,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) * enabled. */ if (q->flags & IFF_VNET_HDR) - features |= tap->tap_features; + netdev_feature_or(&features, features, tap->tap_features); if (netif_needs_gso(skb, features)) { struct sk_buff *segs = __skb_gso_segment(skb, features, false); struct sk_buff *next; @@ -368,7 +371,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) * check, we either support them all or none. */ if (skb->ip_summed == CHECKSUM_PARTIAL && - !(features & NETIF_F_CSUM_MASK) && + !netdev_feature_test_bits(NETIF_F_CSUM_MASK, features) && skb_checksum_help(skb)) goto drop; if (ptr_ring_produce(&q->ring, skb)) @@ -536,7 +539,8 @@ static int tap_open(struct inode *inode, struct file *file) * The macvlan supports zerocopy iff the lower device supports zero * copy so we don't have to look at the lower device directly. */ - if ((tap->dev->features & NETIF_F_HIGHDMA) && (tap->dev->features & NETIF_F_SG)) + if (netdev_feature_test_bit(NETIF_F_HIGHDMA_BIT, tap->dev->features) && + netdev_feature_test_bit(NETIF_F_SG_BIT, tap->dev->features)) sock_set_flag(&q->sk, SOCK_ZEROCOPY);
err = tap_set_queue(tap, file, q); @@ -921,24 +925,28 @@ static int set_offload(struct tap_queue *q, unsigned long arg) { struct tap_dev *tap; netdev_features_t features; - netdev_features_t feature_mask = 0; + netdev_features_t feature_mask;
tap = rtnl_dereference(q->tap); if (!tap) return -ENOLINK;
- features = tap->dev->features; + netdev_feature_zero(&feature_mask); + netdev_feature_copy(&features, tap->dev->features);
if (arg & TUN_F_CSUM) { - feature_mask = NETIF_F_HW_CSUM; + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &feature_mask);
if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) { if (arg & TUN_F_TSO_ECN) - feature_mask |= NETIF_F_TSO_ECN; + netdev_feature_set_bit(NETIF_F_TSO_ECN_BIT, + &feature_mask); if (arg & TUN_F_TSO4) - feature_mask |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &feature_mask); if (arg & TUN_F_TSO6) - feature_mask |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &feature_mask); } }
@@ -950,15 +958,15 @@ static int set_offload(struct tap_queue *q, unsigned long arg) * When user space turns off TSO, we turn off GSO/LRO so that * user-space will not receive TSO frames. */ - if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6)) - features |= RX_OFFLOADS; + if (netdev_feature_test_bits(NETIF_F_TSO | NETIF_F_TSO6, feature_mask)) + netdev_feature_set_bits(RX_OFFLOADS, &features); else - features &= ~RX_OFFLOADS; + netdev_feature_clear_bits(RX_OFFLOADS, &features);
/* tap_features are the same as features on tun/tap and * reflect user expectations. */ - tap->tap_features = feature_mask; + netdev_feature_copy(&tap->tap_features, feature_mask); if (tap->update_features) tap->update_features(tap, features);
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/tap.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 8e3a28ba6b28..03158fa9476c 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -321,7 +321,10 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) struct net_device *dev = skb->dev; struct tap_dev *tap; struct tap_queue *q;
- netdev_features_t features = TAP_FEATURES;
netdev_features_t features;
netdev_feature_zero(&features);
netdev_feature_set_bits(TAP_FEATURES, &features);
tap = tap_dev_get_rcu(dev); if (!tap)
@@ -338,7 +341,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) * enabled. */ if (q->flags & IFF_VNET_HDR)
features |= tap->tap_features;
if (netif_needs_gso(skb, features)) { struct sk_buff *segs = __skb_gso_segment(skb, features, false); struct sk_buff *next;netdev_feature_or(&features, features, tap->tap_features);
@@ -368,7 +371,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) * check, we either support them all or none. */ if (skb->ip_summed == CHECKSUM_PARTIAL &&
!(features & NETIF_F_CSUM_MASK) &&
skb_checksum_help(skb)) goto drop; if (ptr_ring_produce(&q->ring, skb))!netdev_feature_test_bits(NETIF_F_CSUM_MASK, features) &&
@@ -536,7 +539,8 @@ static int tap_open(struct inode *inode, struct file *file) * The macvlan supports zerocopy iff the lower device supports zero * copy so we don't have to look at the lower device directly. */
- if ((tap->dev->features & NETIF_F_HIGHDMA) && (tap->dev->features & NETIF_F_SG))
if (netdev_feature_test_bit(NETIF_F_HIGHDMA_BIT, tap->dev->features) &&
netdev_feature_test_bit(NETIF_F_SG_BIT, tap->dev->features))
sock_set_flag(&q->sk, SOCK_ZEROCOPY);
err = tap_set_queue(tap, file, q);
@@ -921,24 +925,28 @@ static int set_offload(struct tap_queue *q, unsigned long arg) { struct tap_dev *tap; netdev_features_t features;
- netdev_features_t feature_mask = 0;
netdev_features_t feature_mask;
tap = rtnl_dereference(q->tap); if (!tap) return -ENOLINK;
- features = tap->dev->features;
netdev_feature_zero(&feature_mask);
netdev_feature_copy(&features, tap->dev->features);
if (arg & TUN_F_CSUM) {
feature_mask = NETIF_F_HW_CSUM;
netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &feature_mask);
if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) { if (arg & TUN_F_TSO_ECN)
feature_mask |= NETIF_F_TSO_ECN;
netdev_feature_set_bit(NETIF_F_TSO_ECN_BIT,
&feature_mask); if (arg & TUN_F_TSO4)
feature_mask |= NETIF_F_TSO;
netdev_feature_set_bit(NETIF_F_TSO_BIT,
&feature_mask); if (arg & TUN_F_TSO6)
feature_mask |= NETIF_F_TSO6;
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
} }&feature_mask);
@@ -950,15 +958,15 @@ static int set_offload(struct tap_queue *q, unsigned long arg) * When user space turns off TSO, we turn off GSO/LRO so that * user-space will not receive TSO frames. */
- if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
features |= RX_OFFLOADS;
- if (netdev_feature_test_bits(NETIF_F_TSO | NETIF_F_TSO6, feature_mask))
elsenetdev_feature_set_bits(RX_OFFLOADS, &features);
features &= ~RX_OFFLOADS;
netdev_feature_clear_bits(RX_OFFLOADS, &features);
/* tap_features are the same as features on tun/tap and
- reflect user expectations.
*/
- tap->tap_features = feature_mask;
- netdev_feature_copy(&tap->tap_features, feature_mask); if (tap->update_features) tap->update_features(tap, features);
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/geneve.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 1ab94b5f9bbf..d2179c103300 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -1219,14 +1219,16 @@ static void geneve_setup(struct net_device *dev)
SET_NETDEV_DEVTYPE(dev, &geneve_type);
- dev->features |= NETIF_F_LLTX; - dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST; - dev->features |= NETIF_F_RXCSUM; - dev->features |= NETIF_F_GSO_SOFTWARE; - - dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST; - dev->hw_features |= NETIF_F_RXCSUM; - dev->hw_features |= NETIF_F_GSO_SOFTWARE; + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features); + netdev_feature_set_bits(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST, + &dev->features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &dev->features); + netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE, &dev->features); + + netdev_feature_set_bits(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST, + &dev->hw_features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &dev->hw_features); + netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE, &dev->hw_features);
/* MTU range: 68 - (something less than 65535) */ dev->min_mtu = ETH_MIN_MTU;
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/geneve.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 1ab94b5f9bbf..d2179c103300 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -1219,14 +1219,16 @@ static void geneve_setup(struct net_device *dev)
SET_NETDEV_DEVTYPE(dev, &geneve_type);
- dev->features |= NETIF_F_LLTX;
- dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
- dev->features |= NETIF_F_RXCSUM;
- dev->features |= NETIF_F_GSO_SOFTWARE;
- dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
- dev->hw_features |= NETIF_F_RXCSUM;
- dev->hw_features |= NETIF_F_GSO_SOFTWARE;
netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features);
netdev_feature_set_bits(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST,
&dev->features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &dev->features);
netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE, &dev->features);
netdev_feature_set_bits(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST,
&dev->hw_features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &dev->hw_features);
netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE, &dev->hw_features);
/* MTU range: 68 - (something less than 65535) */ dev->min_mtu = ETH_MIN_MTU;
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/hyperv/netvsc_bpf.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 38 ++++++++++++++++++------------- drivers/net/hyperv/rndis_filter.c | 30 +++++++++++++++--------- 3 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_bpf.c b/drivers/net/hyperv/netvsc_bpf.c index aa877da113f8..058a92696cbc 100644 --- a/drivers/net/hyperv/netvsc_bpf.c +++ b/drivers/net/hyperv/netvsc_bpf.c @@ -114,7 +114,7 @@ int netvsc_xdp_set(struct net_device *dev, struct bpf_prog *prog, return -EOPNOTSUPP; }
- if (prog && (dev->features & NETIF_F_LRO)) { + if (prog && netdev_feature_test_bit(NETIF_F_LRO_BIT, dev->features)) { netdev_err(dev, "XDP: not support LRO\n"); NL_SET_ERR_MSG_MOD(extack, "XDP: not support LRO");
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 5371328422ec..22875a7ef1ff 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -892,13 +892,15 @@ static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net, }
/* Do L4 checksum offload if enabled and present. */ - if ((ppi_flags & NVSC_RSC_CSUM_INFO) && (net->features & NETIF_F_RXCSUM)) { + if ((ppi_flags & NVSC_RSC_CSUM_INFO) && + netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, net->features)) { if (csum_info->receive.tcp_checksum_succeeded || csum_info->receive.udp_checksum_succeeded) skb->ip_summed = CHECKSUM_UNNECESSARY; }
- if ((ppi_flags & NVSC_RSC_HASH_INFO) && (net->features & NETIF_F_RXHASH)) + if ((ppi_flags & NVSC_RSC_HASH_INFO) && + netdev_feature_test_bit(NETIF_F_RXHASH_BIT, net->features)) skb_set_hash(skb, *hash_info, PKT_HASH_TYPE_L4);
if (ppi_flags & NVSC_RSC_VLAN) { @@ -1205,7 +1207,8 @@ static void netvsc_init_settings(struct net_device *dev) ndc->speed = SPEED_UNKNOWN; ndc->duplex = DUPLEX_FULL;
- dev->features = NETIF_F_LRO; + netdev_feature_zero(&dev->features); + netdev_feature_set_bit(NETIF_F_LRO_BIT, &dev->features); }
static int netvsc_get_link_ksettings(struct net_device *dev, @@ -1928,8 +1931,9 @@ static void netvsc_fix_features(struct net_device *ndev, if (!nvdev || nvdev->destroy) return;
- if ((*features & NETIF_F_LRO) && netvsc_xdp_get(nvdev)) { - *features ^= NETIF_F_LRO; + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, *features) && + netvsc_xdp_get(nvdev)) { + netdev_feature_change_bit(NETIF_F_LRO_BIT, features); netdev_info(ndev, "Skip LRO - unsupported with XDP\n"); } } @@ -1937,22 +1941,24 @@ static void netvsc_fix_features(struct net_device *ndev, static int netvsc_set_features(struct net_device *ndev, netdev_features_t features) { - netdev_features_t change = features ^ ndev->features; struct net_device_context *ndevctx = netdev_priv(ndev); struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev); struct ndis_offload_params offloads; + netdev_features_t change; int ret = 0;
if (!nvdev || nvdev->destroy) return -ENODEV;
- if (!(change & NETIF_F_LRO)) + netdev_feature_xor(&change, features, ndev->features); + + if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, change)) goto syncvf;
memset(&offloads, 0, sizeof(struct ndis_offload_params));
- if (features & NETIF_F_LRO) { + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, features)) { offloads.rsc_ip_v4 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; offloads.rsc_ip_v6 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; } else { @@ -1963,15 +1969,15 @@ static int netvsc_set_features(struct net_device *ndev, ret = rndis_filter_set_offload_params(ndev, nvdev, &offloads);
if (ret) { - features ^= NETIF_F_LRO; - ndev->features = features; + netdev_feature_change_bit(NETIF_F_LRO_BIT, &features); + netdev_feature_copy(&ndev->features, features); }
syncvf: if (!vf_netdev) return ret;
- vf_netdev->wanted_features = features; + netdev_feature_copy(&vf_netdev->wanted_features, features); netdev_update_features(vf_netdev);
return ret; @@ -2385,7 +2391,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev) if (ndev->needed_headroom < vf_netdev->needed_headroom) ndev->needed_headroom = vf_netdev->needed_headroom;
- vf_netdev->wanted_features = ndev->features; + netdev_feature_copy(&vf_netdev->wanted_features, ndev->features); netdev_update_features(vf_netdev);
prog = netvsc_xdp_get(netvsc_dev); @@ -2550,10 +2556,10 @@ static int netvsc_probe(struct hv_device *dev, schedule_work(&nvdev->subchan_work);
/* hw_features computed in rndis_netdev_set_hwcaps() */ - net->features = net->hw_features | - NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_CTAG_RX; - net->vlan_features = net->features; + netdev_feature_copy(&net->features, net->hw_features); + netdev_feature_set_bits(NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_RX, &net->features); + netdev_feature_copy(&net->vlan_features, net->features);
netdev_lockdep_set_classes(net);
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index f6c9c2a670f9..115ebe0b970a 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1348,6 +1348,7 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, struct ndis_offload hwcaps; struct ndis_offload_params offloads; unsigned int gso_max_size = GSO_MAX_SIZE; + netdev_features_t tmp; int ret;
/* Find HW offload capabilities */ @@ -1362,24 +1363,26 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, offloads.ip_v4_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED;
/* Reset previously set hw_features flags */ - net->hw_features &= ~NETVSC_SUPPORTED_HW_FEATURES; + netdev_feature_clear_bits(NETVSC_SUPPORTED_HW_FEATURES, + &net->hw_features); net_device_ctx->tx_checksum_mask = 0;
/* Compute tx offload settings based on hw capabilities */ - net->hw_features |= NETIF_F_RXCSUM; - net->hw_features |= NETIF_F_SG; - net->hw_features |= NETIF_F_RXHASH; + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &net->hw_features); + netdev_feature_set_bit(NETIF_F_SG_BIT, &net->hw_features); + netdev_feature_set_bit(NETIF_F_RXHASH_BIT, &net->hw_features);
if ((hwcaps.csum.ip4_txcsum & NDIS_TXCSUM_ALL_TCP4) == NDIS_TXCSUM_ALL_TCP4) { /* Can checksum TCP */ - net->hw_features |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, &net->hw_features); net_device_ctx->tx_checksum_mask |= TRANSPORT_INFO_IPV4_TCP;
offloads.tcp_ip_v4_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED;
if (hwcaps.lsov2.ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { offloads.lso_v2_ipv4 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED; - net->hw_features |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &net->hw_features);
if (hwcaps.lsov2.ip4_maxsz < gso_max_size) gso_max_size = hwcaps.lsov2.ip4_maxsz; @@ -1392,7 +1395,8 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, }
if ((hwcaps.csum.ip6_txcsum & NDIS_TXCSUM_ALL_TCP6) == NDIS_TXCSUM_ALL_TCP6) { - net->hw_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &net->hw_features);
offloads.tcp_ip_v6_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; net_device_ctx->tx_checksum_mask |= TRANSPORT_INFO_IPV6_TCP; @@ -1400,7 +1404,8 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, if ((hwcaps.lsov2.ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && (hwcaps.lsov2.ip6_opts & NDIS_LSOV2_CAP_IP6) == NDIS_LSOV2_CAP_IP6) { offloads.lso_v2_ipv6 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED; - net->hw_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &net->hw_features);
if (hwcaps.lsov2.ip6_maxsz < gso_max_size) gso_max_size = hwcaps.lsov2.ip6_maxsz; @@ -1413,9 +1418,9 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, }
if (hwcaps.rsc.ip4 && hwcaps.rsc.ip6) { - net->hw_features |= NETIF_F_LRO; + netdev_feature_set_bit(NETIF_F_LRO_BIT, &net->hw_features);
- if (net->features & NETIF_F_LRO) { + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, net->features)) { offloads.rsc_ip_v4 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; offloads.rsc_ip_v6 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; } else { @@ -1427,7 +1432,10 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, /* In case some hw_features disappeared we need to remove them from * net->features list as they're no longer supported. */ - net->features &= ~NETVSC_SUPPORTED_HW_FEATURES | net->hw_features; + netdev_feature_fill(&tmp); + netdev_feature_clear_bits(NETVSC_SUPPORTED_HW_FEATURES, &tmp); + netdev_feature_or(&tmp, tmp, net->hw_features); + netdev_feature_and(&net->features, net->features, tmp);
netif_set_gso_max_size(net, gso_max_size);
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/hyperv/netvsc_bpf.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 38 ++++++++++++++++++------------- drivers/net/hyperv/rndis_filter.c | 30 +++++++++++++++--------- 3 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_bpf.c b/drivers/net/hyperv/netvsc_bpf.c index aa877da113f8..058a92696cbc 100644 --- a/drivers/net/hyperv/netvsc_bpf.c +++ b/drivers/net/hyperv/netvsc_bpf.c @@ -114,7 +114,7 @@ int netvsc_xdp_set(struct net_device *dev, struct bpf_prog *prog, return -EOPNOTSUPP; }
- if (prog && (dev->features & NETIF_F_LRO)) {
- if (prog && netdev_feature_test_bit(NETIF_F_LRO_BIT, dev->features)) { netdev_err(dev, "XDP: not support LRO\n"); NL_SET_ERR_MSG_MOD(extack, "XDP: not support LRO");
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 5371328422ec..22875a7ef1ff 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -892,13 +892,15 @@ static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net, }
/* Do L4 checksum offload if enabled and present. */
- if ((ppi_flags & NVSC_RSC_CSUM_INFO) && (net->features & NETIF_F_RXCSUM)) {
- if ((ppi_flags & NVSC_RSC_CSUM_INFO) &&
if (csum_info->receive.tcp_checksum_succeeded || csum_info->receive.udp_checksum_succeeded) skb->ip_summed = CHECKSUM_UNNECESSARY; }netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, net->features)) {
- if ((ppi_flags & NVSC_RSC_HASH_INFO) && (net->features & NETIF_F_RXHASH))
if ((ppi_flags & NVSC_RSC_HASH_INFO) &&
netdev_feature_test_bit(NETIF_F_RXHASH_BIT, net->features))
skb_set_hash(skb, *hash_info, PKT_HASH_TYPE_L4);
if (ppi_flags & NVSC_RSC_VLAN) {
@@ -1205,7 +1207,8 @@ static void netvsc_init_settings(struct net_device *dev) ndc->speed = SPEED_UNKNOWN; ndc->duplex = DUPLEX_FULL;
- dev->features = NETIF_F_LRO;
- netdev_feature_zero(&dev->features);
- netdev_feature_set_bit(NETIF_F_LRO_BIT, &dev->features);
}
static int netvsc_get_link_ksettings(struct net_device *dev, @@ -1928,8 +1931,9 @@ static void netvsc_fix_features(struct net_device *ndev, if (!nvdev || nvdev->destroy) return;
- if ((*features & NETIF_F_LRO) && netvsc_xdp_get(nvdev)) {
*features ^= NETIF_F_LRO;
- if (netdev_feature_test_bit(NETIF_F_LRO_BIT, *features) &&
netvsc_xdp_get(nvdev)) {
netdev_info(ndev, "Skip LRO - unsupported with XDP\n"); }netdev_feature_change_bit(NETIF_F_LRO_BIT, features);
} @@ -1937,22 +1941,24 @@ static void netvsc_fix_features(struct net_device *ndev, static int netvsc_set_features(struct net_device *ndev, netdev_features_t features) {
- netdev_features_t change = features ^ ndev->features; struct net_device_context *ndevctx = netdev_priv(ndev); struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev); struct ndis_offload_params offloads;
netdev_features_t change; int ret = 0;
if (!nvdev || nvdev->destroy) return -ENODEV;
- if (!(change & NETIF_F_LRO))
netdev_feature_xor(&change, features, ndev->features);
if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, change)) goto syncvf;
memset(&offloads, 0, sizeof(struct ndis_offload_params));
- if (features & NETIF_F_LRO) {
- if (netdev_feature_test_bit(NETIF_F_LRO_BIT, features)) { offloads.rsc_ip_v4 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; offloads.rsc_ip_v6 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; } else {
@@ -1963,15 +1969,15 @@ static int netvsc_set_features(struct net_device *ndev, ret = rndis_filter_set_offload_params(ndev, nvdev, &offloads);
if (ret) {
features ^= NETIF_F_LRO;
ndev->features = features;
netdev_feature_change_bit(NETIF_F_LRO_BIT, &features);
}netdev_feature_copy(&ndev->features, features);
syncvf: if (!vf_netdev) return ret;
- vf_netdev->wanted_features = features;
netdev_feature_copy(&vf_netdev->wanted_features, features); netdev_update_features(vf_netdev);
return ret;
@@ -2385,7 +2391,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev) if (ndev->needed_headroom < vf_netdev->needed_headroom) ndev->needed_headroom = vf_netdev->needed_headroom;
- vf_netdev->wanted_features = ndev->features;
netdev_feature_copy(&vf_netdev->wanted_features, ndev->features); netdev_update_features(vf_netdev);
prog = netvsc_xdp_get(netvsc_dev);
@@ -2550,10 +2556,10 @@ static int netvsc_probe(struct hv_device *dev, schedule_work(&nvdev->subchan_work);
/* hw_features computed in rndis_netdev_set_hwcaps() */
- net->features = net->hw_features |
NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX;
- net->vlan_features = net->features;
netdev_feature_copy(&net->features, net->hw_features);
netdev_feature_set_bits(NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX, &net->features);
netdev_feature_copy(&net->vlan_features, net->features);
netdev_lockdep_set_classes(net);
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index f6c9c2a670f9..115ebe0b970a 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1348,6 +1348,7 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, struct ndis_offload hwcaps; struct ndis_offload_params offloads; unsigned int gso_max_size = GSO_MAX_SIZE;
netdev_features_t tmp; int ret;
/* Find HW offload capabilities */
@@ -1362,24 +1363,26 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, offloads.ip_v4_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED;
/* Reset previously set hw_features flags */
- net->hw_features &= ~NETVSC_SUPPORTED_HW_FEATURES;
netdev_feature_clear_bits(NETVSC_SUPPORTED_HW_FEATURES,
&net->hw_features);
net_device_ctx->tx_checksum_mask = 0;
/* Compute tx offload settings based on hw capabilities */
- net->hw_features |= NETIF_F_RXCSUM;
- net->hw_features |= NETIF_F_SG;
- net->hw_features |= NETIF_F_RXHASH;
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &net->hw_features);
netdev_feature_set_bit(NETIF_F_SG_BIT, &net->hw_features);
netdev_feature_set_bit(NETIF_F_RXHASH_BIT, &net->hw_features);
if ((hwcaps.csum.ip4_txcsum & NDIS_TXCSUM_ALL_TCP4) == NDIS_TXCSUM_ALL_TCP4) { /* Can checksum TCP */
net->hw_features |= NETIF_F_IP_CSUM;
netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, &net->hw_features);
net_device_ctx->tx_checksum_mask |= TRANSPORT_INFO_IPV4_TCP;
offloads.tcp_ip_v4_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED;
if (hwcaps.lsov2.ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { offloads.lso_v2_ipv4 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED;
net->hw_features |= NETIF_F_TSO;
netdev_feature_set_bit(NETIF_F_TSO_BIT,
&net->hw_features); if (hwcaps.lsov2.ip4_maxsz < gso_max_size) gso_max_size = hwcaps.lsov2.ip4_maxsz;
@@ -1392,7 +1395,8 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, }
if ((hwcaps.csum.ip6_txcsum & NDIS_TXCSUM_ALL_TCP6) == NDIS_TXCSUM_ALL_TCP6) {
net->hw_features |= NETIF_F_IPV6_CSUM;
netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
&net->hw_features);
offloads.tcp_ip_v6_csum = NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; net_device_ctx->tx_checksum_mask |= TRANSPORT_INFO_IPV6_TCP;
@@ -1400,7 +1404,8 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, if ((hwcaps.lsov2.ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && (hwcaps.lsov2.ip6_opts & NDIS_LSOV2_CAP_IP6) == NDIS_LSOV2_CAP_IP6) { offloads.lso_v2_ipv6 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED;
net->hw_features |= NETIF_F_TSO6;
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
&net->hw_features); if (hwcaps.lsov2.ip6_maxsz < gso_max_size) gso_max_size = hwcaps.lsov2.ip6_maxsz;
@@ -1413,9 +1418,9 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, }
if (hwcaps.rsc.ip4 && hwcaps.rsc.ip6) {
net->hw_features |= NETIF_F_LRO;
netdev_feature_set_bit(NETIF_F_LRO_BIT, &net->hw_features);
if (net->features & NETIF_F_LRO) {
} else {if (netdev_feature_test_bit(NETIF_F_LRO_BIT, net->features)) { offloads.rsc_ip_v4 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED; offloads.rsc_ip_v6 = NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED;
@@ -1427,7 +1432,10 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device, /* In case some hw_features disappeared we need to remove them from * net->features list as they're no longer supported. */
- net->features &= ~NETVSC_SUPPORTED_HW_FEATURES | net->hw_features;
netdev_feature_fill(&tmp);
netdev_feature_clear_bits(NETVSC_SUPPORTED_HW_FEATURES, &tmp);
netdev_feature_or(&tmp, tmp, net->hw_features);
netdev_feature_and(&net->features, net->features, tmp);
netif_set_gso_max_size(net, gso_max_size);
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/macvlan.c | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 3c408653e864..9ac38e22ccfc 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -620,7 +620,8 @@ static int macvlan_open(struct net_device *dev) /* Attempt to populate accel_priv which is used to offload the L2 * forwarding requests for unicast packets. */ - if (lowerdev->features & NETIF_F_HW_L2FW_DOFFLOAD) + if (netdev_feature_test_bit(NETIF_F_HW_L2FW_DOFFLOAD_BIT, + lowerdev->features)) vlan->accel_priv = lowerdev->netdev_ops->ndo_dfwd_add_station(lowerdev, dev);
@@ -893,12 +894,15 @@ static int macvlan_init(struct net_device *dev)
dev->state = (dev->state & ~MACVLAN_STATE_MASK) | (lowerdev->state & MACVLAN_STATE_MASK); - dev->features = lowerdev->features & MACVLAN_FEATURES; - dev->features |= ALWAYS_ON_FEATURES; - dev->hw_features |= NETIF_F_LRO; - dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES; - dev->vlan_features |= ALWAYS_ON_OFFLOADS; - dev->hw_enc_features |= dev->features; + netdev_feature_copy(&dev->features, lowerdev->features); + netdev_feature_and_bits(MACVLAN_FEATURES, &dev->features); + netdev_feature_set_bits(ALWAYS_ON_FEATURES, &dev->features); + netdev_feature_set_bit(NETIF_F_LRO_BIT, &dev->hw_features); + netdev_feature_copy(&dev->vlan_features, lowerdev->vlan_features); + netdev_feature_and_bits(MACVLAN_FEATURES, &dev->vlan_features); + netdev_feature_set_bits(ALWAYS_ON_OFFLOADS, &dev->vlan_features); + netdev_feature_or(&dev->hw_enc_features, dev->hw_enc_features, + dev->features); dev->gso_max_size = lowerdev->gso_max_size; dev->gso_max_segs = lowerdev->gso_max_segs; dev->hard_header_len = lowerdev->hard_header_len; @@ -1071,17 +1075,25 @@ static void macvlan_fix_features(struct net_device *dev, netdev_features_t *features) { struct macvlan_dev *vlan = netdev_priv(dev); - netdev_features_t lowerdev_features = vlan->lowerdev->features; - netdev_features_t mask; - - *features |= NETIF_F_ALL_FOR_ALL; - *features &= (vlan->set_features | ~MACVLAN_FEATURES); - mask = *features; - - lowerdev_features &= (*features | ~NETIF_F_LRO); + netdev_features_t lowerdev_features; + netdev_features_t mask, tmp; + + netdev_feature_copy(&lowerdev_features, vlan->lowerdev->features); + netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features); + netdev_feature_fill(&tmp); + netdev_feature_clear_bits(MACVLAN_FEATURES, &tmp); + netdev_feature_or(&tmp, tmp, vlan->set_features); + netdev_feature_and(features, *features, tmp); + netdev_feature_copy(&mask, *features); + + netdev_feature_fill(&tmp); + netdev_feature_clear_bit(NETIF_F_LRO_BIT, &tmp); + netdev_feature_or(&tmp, tmp, *features); + netdev_feature_and(&lowerdev_features, lowerdev_features, tmp); netdev_increment_features(features, lowerdev_features, *features, mask); - *features |= ALWAYS_ON_FEATURES; - *features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES); + netdev_feature_set_bits(ALWAYS_ON_FEATURES, features); + netdev_feature_and_bits(ALWAYS_ON_FEATURES | MACVLAN_FEATURES, + features); }
#ifdef CONFIG_NET_POLL_CONTROLLER @@ -1458,7 +1470,8 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, vlan->lowerdev = lowerdev; vlan->dev = dev; vlan->port = port; - vlan->set_features = MACVLAN_FEATURES; + netdev_feature_zero(&vlan->set_features); + netdev_feature_set_bits(MACVLAN_FEATURES, &vlan->set_features);
vlan->mode = MACVLAN_MODE_VEPA; if (data && data[IFLA_MACVLAN_MODE])
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/macvlan.c | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 3c408653e864..9ac38e22ccfc 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -620,7 +620,8 @@ static int macvlan_open(struct net_device *dev) /* Attempt to populate accel_priv which is used to offload the L2 * forwarding requests for unicast packets. */
- if (lowerdev->features & NETIF_F_HW_L2FW_DOFFLOAD)
- if (netdev_feature_test_bit(NETIF_F_HW_L2FW_DOFFLOAD_BIT,
vlan->accel_priv = lowerdev->netdev_ops->ndo_dfwd_add_station(lowerdev, dev);lowerdev->features))
@@ -893,12 +894,15 @@ static int macvlan_init(struct net_device *dev)
dev->state = (dev->state & ~MACVLAN_STATE_MASK) | (lowerdev->state & MACVLAN_STATE_MASK);
- dev->features = lowerdev->features & MACVLAN_FEATURES;
- dev->features |= ALWAYS_ON_FEATURES;
- dev->hw_features |= NETIF_F_LRO;
- dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
- dev->vlan_features |= ALWAYS_ON_OFFLOADS;
- dev->hw_enc_features |= dev->features;
- netdev_feature_copy(&dev->features, lowerdev->features);
- netdev_feature_and_bits(MACVLAN_FEATURES, &dev->features);
- netdev_feature_set_bits(ALWAYS_ON_FEATURES, &dev->features);
- netdev_feature_set_bit(NETIF_F_LRO_BIT, &dev->hw_features);
- netdev_feature_copy(&dev->vlan_features, lowerdev->vlan_features);
- netdev_feature_and_bits(MACVLAN_FEATURES, &dev->vlan_features);
- netdev_feature_set_bits(ALWAYS_ON_OFFLOADS, &dev->vlan_features);
- netdev_feature_or(&dev->hw_enc_features, dev->hw_enc_features,
dev->gso_max_size = lowerdev->gso_max_size; dev->gso_max_segs = lowerdev->gso_max_segs; dev->hard_header_len = lowerdev->hard_header_len;dev->features);
@@ -1071,17 +1075,25 @@ static void macvlan_fix_features(struct net_device *dev, netdev_features_t *features) { struct macvlan_dev *vlan = netdev_priv(dev);
- netdev_features_t lowerdev_features = vlan->lowerdev->features;
- netdev_features_t mask;
- *features |= NETIF_F_ALL_FOR_ALL;
- *features &= (vlan->set_features | ~MACVLAN_FEATURES);
- mask = *features;
- lowerdev_features &= (*features | ~NETIF_F_LRO);
- netdev_features_t lowerdev_features;
- netdev_features_t mask, tmp;
- netdev_feature_copy(&lowerdev_features, vlan->lowerdev->features);
- netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
- netdev_feature_fill(&tmp);
- netdev_feature_clear_bits(MACVLAN_FEATURES, &tmp);
- netdev_feature_or(&tmp, tmp, vlan->set_features);
- netdev_feature_and(features, *features, tmp);
- netdev_feature_copy(&mask, *features);
- netdev_feature_fill(&tmp);
- netdev_feature_clear_bit(NETIF_F_LRO_BIT, &tmp);
- netdev_feature_or(&tmp, tmp, *features);
- netdev_feature_and(&lowerdev_features, lowerdev_features, tmp); netdev_increment_features(features, lowerdev_features, *features, mask);
- *features |= ALWAYS_ON_FEATURES;
- *features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES);
- netdev_feature_set_bits(ALWAYS_ON_FEATURES, features);
- netdev_feature_and_bits(ALWAYS_ON_FEATURES | MACVLAN_FEATURES,
features);
}
#ifdef CONFIG_NET_POLL_CONTROLLER @@ -1458,7 +1470,8 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, vlan->lowerdev = lowerdev; vlan->dev = dev; vlan->port = port;
- vlan->set_features = MACVLAN_FEATURES;
netdev_feature_zero(&vlan->set_features);
netdev_feature_set_bits(MACVLAN_FEATURES, &vlan->set_features);
vlan->mode = MACVLAN_MODE_VEPA; if (data && data[IFLA_MACVLAN_MODE])
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/macsec.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 601b833a40bd..5526d54c0a14 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -347,7 +347,8 @@ static bool macsec_check_offload(enum macsec_offload offload, return macsec->real_dev->phydev && macsec->real_dev->phydev->macsec_ops; else if (offload == MACSEC_OFFLOAD_MAC) - return macsec->real_dev->features & NETIF_F_HW_MACSEC && + return netdev_feature_test_bit(NETIF_F_HW_MACSEC_BIT, + macsec->real_dev->features) && macsec->real_dev->macsec_ops;
return false; @@ -3419,13 +3420,6 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, #define SW_MACSEC_FEATURES \ (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST)
-/* If h/w offloading is enabled, use real device features save for - * VLAN_FEATURES - they require additional ops - * HW_MACSEC - no reason to report it - */ -#define REAL_DEV_FEATURES(dev) \ - ((dev)->features & ~(NETIF_F_VLAN_FEATURES | NETIF_F_HW_MACSEC)) - static int macsec_dev_init(struct net_device *dev) { struct macsec_dev *macsec = macsec_priv(dev); @@ -3443,10 +3437,19 @@ static int macsec_dev_init(struct net_device *dev) }
if (macsec_is_offloaded(macsec)) { - dev->features = REAL_DEV_FEATURES(real_dev); + /* If h/w offloading is enabled, use real device features save for + * VLAN_FEATURES - they require additional ops + * HW_MACSEC - no reason to report it + */ + netdev_feature_copy(&dev->features, real_dev->features); + netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES | + NETIF_F_HW_MACSEC, + &dev->features); } else { - dev->features = real_dev->features & SW_MACSEC_FEATURES; - dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE; + netdev_feature_copy(&dev->features, real_dev->features); + netdev_feature_and_bits(SW_MACSEC_FEATURES, &dev->features); + netdev_feature_set_bits(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE, + &dev->features); }
dev->needed_headroom = real_dev->needed_headroom + @@ -3475,15 +3478,21 @@ static void macsec_fix_features(struct net_device *dev, { struct macsec_dev *macsec = macsec_priv(dev); struct net_device *real_dev = macsec->real_dev; + netdev_features_t tmp;
if (macsec_is_offloaded(macsec)) { - *features = REAL_DEV_FEATURES(real_dev); + netdev_feature_copy(features, real_dev->features); + netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES | + NETIF_F_HW_MACSEC, features); return; }
- *features &= (real_dev->features & SW_MACSEC_FEATURES) | - NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES; - *features |= NETIF_F_LLTX; + netdev_feature_copy(&tmp, real_dev->features); + netdev_feature_and_bits(SW_MACSEC_FEATURES, &tmp); + netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES, + &tmp); + netdev_feature_and(features, *features, tmp); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, features); }
static int macsec_dev_open(struct net_device *dev)
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/macsec.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 601b833a40bd..5526d54c0a14 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -347,7 +347,8 @@ static bool macsec_check_offload(enum macsec_offload offload, return macsec->real_dev->phydev && macsec->real_dev->phydev->macsec_ops; else if (offload == MACSEC_OFFLOAD_MAC)
return macsec->real_dev->features & NETIF_F_HW_MACSEC &&
return netdev_feature_test_bit(NETIF_F_HW_MACSEC_BIT,
macsec->real_dev->features) && macsec->real_dev->macsec_ops;
return false;
@@ -3419,13 +3420,6 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, #define SW_MACSEC_FEATURES \ (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST)
-/* If h/w offloading is enabled, use real device features save for
- VLAN_FEATURES - they require additional ops
- HW_MACSEC - no reason to report it
- */
-#define REAL_DEV_FEATURES(dev) \
- ((dev)->features & ~(NETIF_F_VLAN_FEATURES | NETIF_F_HW_MACSEC))
static int macsec_dev_init(struct net_device *dev) { struct macsec_dev *macsec = macsec_priv(dev); @@ -3443,10 +3437,19 @@ static int macsec_dev_init(struct net_device *dev) }
if (macsec_is_offloaded(macsec)) {
dev->features = REAL_DEV_FEATURES(real_dev);
/* If h/w offloading is enabled, use real device features save for
* VLAN_FEATURES - they require additional ops
* HW_MACSEC - no reason to report it
*/
netdev_feature_copy(&dev->features, real_dev->features);
netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES |
NETIF_F_HW_MACSEC,
} else {&dev->features);
dev->features = real_dev->features & SW_MACSEC_FEATURES;
dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE;
netdev_feature_copy(&dev->features, real_dev->features);
netdev_feature_and_bits(SW_MACSEC_FEATURES, &dev->features);
netdev_feature_set_bits(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE,
&dev->features);
}
dev->needed_headroom = real_dev->needed_headroom +
@@ -3475,15 +3478,21 @@ static void macsec_fix_features(struct net_device *dev, { struct macsec_dev *macsec = macsec_priv(dev); struct net_device *real_dev = macsec->real_dev;
netdev_features_t tmp;
if (macsec_is_offloaded(macsec)) {
*features = REAL_DEV_FEATURES(real_dev);
netdev_feature_copy(features, real_dev->features);
netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES |
return; }NETIF_F_HW_MACSEC, features);
- *features &= (real_dev->features & SW_MACSEC_FEATURES) |
NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES;
- *features |= NETIF_F_LLTX;
- netdev_feature_copy(&tmp, real_dev->features);
- netdev_feature_and_bits(SW_MACSEC_FEATURES, &tmp);
- netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES,
&tmp);
- netdev_feature_and(features, *features, tmp);
- netdev_feature_set_bit(NETIF_F_LLTX_BIT, features);
}
static int macsec_dev_open(struct net_device *dev)
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;
Review-by: Jie Wang wangjie125@huawei.com
On 2021/9/22 22:56, 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/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->tlsdev_ops->tls_dev_resync) return NOTIFY_BAD;dev->features) &&
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/s390/net/qeth_core_main.c | 122 ++++++++++++++++++------------ drivers/s390/net/qeth_l2_main.c | 44 +++++++---- drivers/s390/net/qeth_l3_main.c | 41 ++++++---- 3 files changed, 130 insertions(+), 77 deletions(-)
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index d8269f4f7a83..a1fea5111860 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -5612,7 +5612,8 @@ static void qeth_receive_skb(struct qeth_card *card, struct sk_buff *skb, return; }
- if (is_cso && (card->dev->features & NETIF_F_RXCSUM)) { + if (is_cso && netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, + card->dev->features)) { skb->ip_summed = CHECKSUM_UNNECESSARY; QETH_CARD_STAT_INC(card, rx_skb_csum); } else { @@ -6389,10 +6390,10 @@ static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
dev->ethtool_ops = &qeth_ethtool_ops; dev->priv_flags &= ~IFF_TX_SKB_SHARING; - dev->hw_features |= NETIF_F_SG; - dev->vlan_features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->hw_features); + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->vlan_features); if (IS_IQD(card)) - dev->features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->features);
return dev; } @@ -6839,18 +6840,21 @@ void qeth_enable_hw_features(struct net_device *dev) struct qeth_card *card = dev->ml_priv; netdev_features_t features;
- features = dev->features; + netdev_feature_copy(&features, dev->features); /* force-off any feature that might need an IPA sequence. * netdev_update_features() will restart them. */ - dev->features &= ~dev->hw_features; + netdev_feature_andnot(&dev->features, dev->features, + dev->hw_features); /* toggle VLAN filter, so that VIDs are re-programmed: */ if (IS_LAYER2(card) && IS_VM_NIC(card)) { - dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; - dev->wanted_features |= NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &dev->features); + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &dev->wanted_features); } netdev_update_features(dev); - if (features != dev->features) + if (!netdev_feature_equal(features, dev->features)) dev_warn(&card->gdev->dev, "Device recovery failed to restore all offload features\n"); } @@ -6860,69 +6864,88 @@ static void qeth_check_restricted_features(struct qeth_card *card, netdev_features_t changed, netdev_features_t actual) { - netdev_features_t ipv6_features = NETIF_F_TSO6; - netdev_features_t ipv4_features = NETIF_F_TSO; + netdev_features_t ipv6_features; + netdev_features_t ipv4_features;
+ netdev_features_zero(&ipv6_features); + netdev_features_zero(&ipv4_features); + netdev_features_set_bit(NETIF_F_TSO6_BIT, &ipv6_features); + netdev_features_set_bit(NETIF_F_TSO_BIT, &ipv6_features); if (!card->info.has_lp2lp_cso_v6) - ipv6_features |= NETIF_F_IPV6_CSUM; + netdev_features_set_bit(NETIF_F_IPV6_CSUM_BIT, &ipv6_features); if (!card->info.has_lp2lp_cso_v4) - ipv4_features |= NETIF_F_IP_CSUM; + netdev_features_set_bit(NETIF_F_IP_CSUM_BIT, &ipv4_features);
- if ((changed & ipv6_features) && !(actual & ipv6_features)) + if (netdev_feature_intersects(ipv6_features, changed) && + !netdev_feature_intersects(ipv6_features, actual)) qeth_flush_local_addrs6(card); - if ((changed & ipv4_features) && !(actual & ipv4_features)) + if (netdev_feature_intersects(ipv4_features, changed) && + !netdev_feature_intersects(ipv4_features, actual)) qeth_flush_local_addrs4(card); }
int qeth_set_features(struct net_device *dev, netdev_features_t features) { struct qeth_card *card = dev->ml_priv; - netdev_features_t changed = dev->features ^ features; + netdev_features_t changed, tmp1, tmp2; int rc = 0;
QETH_CARD_TEXT(card, 2, "setfeat"); QETH_CARD_HEX(card, 2, &features, sizeof(features));
- if ((changed & NETIF_F_IP_CSUM)) { - rc = qeth_set_ipa_csum(card, features & NETIF_F_IP_CSUM, + netdev_feature_xor(&changed, dev->features, features); + if (netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, changed)) { + rc = qeth_set_ipa_csum(card, + netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, + features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV4, &card->info.has_lp2lp_cso_v4); if (rc) - changed ^= NETIF_F_IP_CSUM; + netdev_feature_change_bit(NETIF_F_IP_CSUM_BIT, &changed); } - if (changed & NETIF_F_IPV6_CSUM) { - rc = qeth_set_ipa_csum(card, features & NETIF_F_IPV6_CSUM, + if (netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, changed)) { + rc = qeth_set_ipa_csum(card, + netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, + features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV6, &card->info.has_lp2lp_cso_v6); if (rc) - changed ^= NETIF_F_IPV6_CSUM; + netdev_feature_change_bit(NETIF_F_IPV6_CSUM_BIT, &changed); } - if (changed & NETIF_F_RXCSUM) { - rc = qeth_set_ipa_rx_csum(card, features & NETIF_F_RXCSUM); + if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, changed)) { + rc = qeth_set_ipa_rx_csum(card, + netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, + features)); if (rc) - changed ^= NETIF_F_RXCSUM; + netdev_feature_change_bit(NETIF_F_RXCSUM_BIT, &changed); } - if (changed & NETIF_F_TSO) { - rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO, + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, changed)) { + rc = qeth_set_ipa_tso(card, + netdev_feature_test_bit(NETIF_F_TSO_BIT, + features), QETH_PROT_IPV4); if (rc) - changed ^= NETIF_F_TSO; + netdev_feature_change_bit(NETIF_F_TSO_BIT, &changed); } - if (changed & NETIF_F_TSO6) { - rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO6, + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, changed)) { + rc = qeth_set_ipa_tso(card, + netdev_feature_test_bit(NETIF_F_TSO6_BIT, + features), QETH_PROT_IPV6); if (rc) - changed ^= NETIF_F_TSO6; + netdev_feature_change_bit(NETIF_F_TSO6_BIT, &changed); }
- qeth_check_restricted_features(card, dev->features ^ features, - dev->features ^ changed); + netdev_feature_xor(&tmp1, dev->features, features); + netdev_feature_xor(&tmp2, dev->features, changed); + qeth_check_restricted_features(card, tmp1, tmp2);
/* everything changed successfully? */ - if ((dev->features ^ features) == changed) + netdev_feature_xor(&tmp1, dev->features, features); + if (netdev_feature_equal(tmp1, changed)) return 0; /* something went wrong. save changed features and return error */ - dev->features ^= changed; + netdev_feature_xor(&dev->features, dev->features, changed); return -EIO; } EXPORT_SYMBOL_GPL(qeth_set_features); @@ -6933,16 +6956,16 @@ void qeth_fix_features(struct net_device *dev, netdev_features_t *features)
QETH_CARD_TEXT(card, 2, "fixfeat"); if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) - *features &= ~NETIF_F_IP_CSUM; + netdev_feature_clear_bit(NETIF_F_IP_CSUM_BIT, features); if (!qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) - *features &= ~NETIF_F_IPV6_CSUM; + netdev_feature_clear_bit(NETIF_F_IPV6_CSUM_BIT, features); if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM) && !qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) - *features &= ~NETIF_F_RXCSUM; + netdev_feature_clear_bit(NETIF_F_RXCSUM_BIT, features); if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) - *features &= ~NETIF_F_TSO; + netdev_feature_clear_bit(NETIF_F_TSO_BIT, features); if (!qeth_is_supported6(card, IPA_OUTBOUND_TSO)) - *features &= ~NETIF_F_TSO6; + netdev_feature_clear_bit(NETIF_F_TSO6_BIT, features);
QETH_CARD_HEX(card, 2, features, sizeof(*features)); } @@ -6956,25 +6979,30 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev, /* Traffic with local next-hop is not eligible for some offloads: */ if (skb->ip_summed == CHECKSUM_PARTIAL && READ_ONCE(card->options.isolation) != ISOLATION_MODE_FWD) { - netdev_features_t restricted = 0; + netdev_features_t restricted;
+ netdev_feature_zero(&restricted); if (skb_is_gso(skb) && !netif_needs_gso(skb, *features)) - restricted |= NETIF_F_ALL_TSO; + netdev_feature_set_bits(NETIF_F_ALL_TSO, &restricted);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!card->info.has_lp2lp_cso_v4) - restricted |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &restricted);
if (restricted && qeth_next_hop_is_local_v4(card, skb)) - *features &= ~restricted; + netdev_feature_andnot(features, features, + &restricted); break; case htons(ETH_P_IPV6): if (!card->info.has_lp2lp_cso_v6) - restricted |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &restricted);
if (restricted && qeth_next_hop_is_local_v6(card, skb)) - *features &= ~restricted; + netdev_feature_andnot(features, *features, + restricted); break; default: break; @@ -6996,7 +7024,7 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
/* linearize only if resulting skb allocations are order-0: */ if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0)) - *features &= ~NETIF_F_SG; + netdev_feature_clear_bit(NETIF_F_SG_BIT, features); }
vlan_features_check(skb, features); diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 72e84ff9fea5..d3763d4df2e4 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -1079,40 +1079,54 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) card->dev->priv_flags |= IFF_UNICAST_FLT;
if (IS_OSM(card)) { - card->dev->features |= NETIF_F_VLAN_CHALLENGED; + netdev_feature_set_bit(NETIF_F_VLAN_CHALLENGED_BIT, + &card->dev->features); } else { if (!IS_VM_NIC(card)) - card->dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; - card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &card->dev->features); }
if (IS_OSD(card) && !IS_VM_NIC(card)) { - card->dev->features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &card->dev->features); /* OSA 3S and earlier has no RX/TX support */ if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) { - card->dev->hw_features |= NETIF_F_IP_CSUM; - card->dev->vlan_features |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &card->dev->vlan_features); } } if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_IPV6_CSUM; - card->dev->vlan_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM) || qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_RXCSUM; - card->dev->vlan_features |= NETIF_F_RXCSUM; + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO; - card->dev->vlan_features |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &card->dev->vlan_features); } if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO6; - card->dev->vlan_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->vlan_features); }
- if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) { + if (netdev_feature_test_bits(NETIF_F_TSO | NETIF_F_TSO6, + card->dev->hw_features)) { card->dev->needed_headroom = sizeof(struct qeth_hdr_tso); netif_keep_dst(card->dev); netif_set_gso_max_size(card->dev, diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 76c37eedf614..71feb9075a57 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1809,7 +1809,8 @@ static void qeth_l3_osa_features_check(struct sk_buff *skb, netdev_features_t *features) { if (vlan_get_protocol(skb) != htons(ETH_P_IP)) - *features &= ~NETIF_F_HW_VLAN_CTAG_TX; + netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, + features); qeth_features_check(skb, dev, features); }
@@ -1878,26 +1879,35 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) dev->dev_id = qeth_l3_get_unique_id(card, dev->dev_id);
if (!IS_VM_NIC(card)) { - card->dev->features |= NETIF_F_SG; - card->dev->hw_features |= NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_IP_CSUM; - card->dev->vlan_features |= NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_SG_BIT, + &card->dev->features); + netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM | + NETIF_F_IP_CSUM, + &card->dev->hw_features); + netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM | + NETIF_F_IP_CSUM, + &card->dev->vlan_features); }
if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_IPV6_CSUM; - card->dev->vlan_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO6; - card->dev->vlan_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->vlan_features); }
/* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */ - if (card->dev->hw_features & NETIF_F_TSO6) + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, + card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso) + VLAN_HLEN; - else if (card->dev->hw_features & NETIF_F_TSO) + else if (netdev_feature_test_bit(NETIF_F_TSO_BIT, + card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso); else headroom = sizeof(struct qeth_hdr) + VLAN_HLEN; @@ -1913,11 +1923,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) return -ENODEV;
card->dev->needed_headroom = headroom; - card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_CTAG_RX; + netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_RX, &card->dev->features);
netif_keep_dst(card->dev); - if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) + if (netdev_feature_test_bit(NETIF_F_TSO | NETIF_F_TSO6, + card->dev->hw_features)) netif_set_gso_max_size(card->dev, PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1));
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/s390/net/qeth_core_main.c | 122 ++++++++++++++++++------------ drivers/s390/net/qeth_l2_main.c | 44 +++++++---- drivers/s390/net/qeth_l3_main.c | 41 ++++++---- 3 files changed, 130 insertions(+), 77 deletions(-)
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index d8269f4f7a83..a1fea5111860 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -5612,7 +5612,8 @@ static void qeth_receive_skb(struct qeth_card *card, struct sk_buff *skb, return; }
- if (is_cso && (card->dev->features & NETIF_F_RXCSUM)) {
- if (is_cso && netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
skb->ip_summed = CHECKSUM_UNNECESSARY; QETH_CARD_STAT_INC(card, rx_skb_csum); } else {card->dev->features)) {
@@ -6389,10 +6390,10 @@ static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
dev->ethtool_ops = &qeth_ethtool_ops; dev->priv_flags &= ~IFF_TX_SKB_SHARING;
- dev->hw_features |= NETIF_F_SG;
- dev->vlan_features |= NETIF_F_SG;
- netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->hw_features);
- netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->vlan_features); if (IS_IQD(card))
dev->features |= NETIF_F_SG;
netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->features);
return dev;
} @@ -6839,18 +6840,21 @@ void qeth_enable_hw_features(struct net_device *dev) struct qeth_card *card = dev->ml_priv; netdev_features_t features;
- features = dev->features;
- netdev_feature_copy(&features, dev->features); /* force-off any feature that might need an IPA sequence.
*/
- netdev_update_features() will restart them.
- dev->features &= ~dev->hw_features;
- netdev_feature_andnot(&dev->features, dev->features,
/* toggle VLAN filter, so that VIDs are re-programmed: */ if (IS_LAYER2(card) && IS_VM_NIC(card)) {dev->hw_features);
dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
dev->wanted_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
&dev->features);
netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
} netdev_update_features(dev);&dev->wanted_features);
- if (features != dev->features)
- if (!netdev_feature_equal(features, dev->features)) dev_warn(&card->gdev->dev, "Device recovery failed to restore all offload features\n");
} @@ -6860,69 +6864,88 @@ static void qeth_check_restricted_features(struct qeth_card *card, netdev_features_t changed, netdev_features_t actual) {
- netdev_features_t ipv6_features = NETIF_F_TSO6;
- netdev_features_t ipv4_features = NETIF_F_TSO;
netdev_features_t ipv6_features;
netdev_features_t ipv4_features;
netdev_features_zero(&ipv6_features);
netdev_features_zero(&ipv4_features);
netdev_features_set_bit(NETIF_F_TSO6_BIT, &ipv6_features);
netdev_features_set_bit(NETIF_F_TSO_BIT, &ipv6_features);
ipv6_features -> ipv4_features ?
if (!card->info.has_lp2lp_cso_v6)
ipv6_features |= NETIF_F_IPV6_CSUM;
if (!card->info.has_lp2lp_cso_v4)netdev_features_set_bit(NETIF_F_IPV6_CSUM_BIT, &ipv6_features);
ipv4_features |= NETIF_F_IP_CSUM;
netdev_features_set_bit(NETIF_F_IP_CSUM_BIT, &ipv4_features);
- if ((changed & ipv6_features) && !(actual & ipv6_features))
- if (netdev_feature_intersects(ipv6_features, changed) &&
qeth_flush_local_addrs6(card);!netdev_feature_intersects(ipv6_features, actual))
- if ((changed & ipv4_features) && !(actual & ipv4_features))
- if (netdev_feature_intersects(ipv4_features, changed) &&
qeth_flush_local_addrs4(card);!netdev_feature_intersects(ipv4_features, actual))
}
int qeth_set_features(struct net_device *dev, netdev_features_t features) { struct qeth_card *card = dev->ml_priv;
- netdev_features_t changed = dev->features ^ features;
netdev_features_t changed, tmp1, tmp2; int rc = 0;
QETH_CARD_TEXT(card, 2, "setfeat"); QETH_CARD_HEX(card, 2, &features, sizeof(features));
- if ((changed & NETIF_F_IP_CSUM)) {
rc = qeth_set_ipa_csum(card, features & NETIF_F_IP_CSUM,
- netdev_feature_xor(&changed, dev->features, features);
- if (netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, changed)) {
rc = qeth_set_ipa_csum(card,
netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT,
if (rc)features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV4, &card->info.has_lp2lp_cso_v4);
changed ^= NETIF_F_IP_CSUM;
}netdev_feature_change_bit(NETIF_F_IP_CSUM_BIT, &changed);
- if (changed & NETIF_F_IPV6_CSUM) {
rc = qeth_set_ipa_csum(card, features & NETIF_F_IPV6_CSUM,
- if (netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, changed)) {
rc = qeth_set_ipa_csum(card,
netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT,
if (rc)features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV6, &card->info.has_lp2lp_cso_v6);
changed ^= NETIF_F_IPV6_CSUM;
}netdev_feature_change_bit(NETIF_F_IPV6_CSUM_BIT, &changed);
- if (changed & NETIF_F_RXCSUM) {
rc = qeth_set_ipa_rx_csum(card, features & NETIF_F_RXCSUM);
- if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, changed)) {
rc = qeth_set_ipa_rx_csum(card,
netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
if (rc)features));
changed ^= NETIF_F_RXCSUM;
}netdev_feature_change_bit(NETIF_F_RXCSUM_BIT, &changed);
- if (changed & NETIF_F_TSO) {
rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO,
- if (netdev_feature_test_bit(NETIF_F_TSO_BIT, changed)) {
rc = qeth_set_ipa_tso(card,
netdev_feature_test_bit(NETIF_F_TSO_BIT,
if (rc)features), QETH_PROT_IPV4);
changed ^= NETIF_F_TSO;
}netdev_feature_change_bit(NETIF_F_TSO_BIT, &changed);
- if (changed & NETIF_F_TSO6) {
rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO6,
- if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, changed)) {
rc = qeth_set_ipa_tso(card,
netdev_feature_test_bit(NETIF_F_TSO6_BIT,
if (rc)features), QETH_PROT_IPV6);
changed ^= NETIF_F_TSO6;
}netdev_feature_change_bit(NETIF_F_TSO6_BIT, &changed);
- qeth_check_restricted_features(card, dev->features ^ features,
dev->features ^ changed);
netdev_feature_xor(&tmp1, dev->features, features);
netdev_feature_xor(&tmp2, dev->features, changed);
qeth_check_restricted_features(card, tmp1, tmp2);
/* everything changed successfully? */
- if ((dev->features ^ features) == changed)
- netdev_feature_xor(&tmp1, dev->features, features);
- if (netdev_feature_equal(tmp1, changed)) return 0; /* something went wrong. save changed features and return error */
- dev->features ^= changed;
- netdev_feature_xor(&dev->features, dev->features, changed); return -EIO;
} EXPORT_SYMBOL_GPL(qeth_set_features); @@ -6933,16 +6956,16 @@ void qeth_fix_features(struct net_device *dev, netdev_features_t *features)
QETH_CARD_TEXT(card, 2, "fixfeat"); if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM))
*features &= ~NETIF_F_IP_CSUM;
if (!qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6))netdev_feature_clear_bit(NETIF_F_IP_CSUM_BIT, features);
*features &= ~NETIF_F_IPV6_CSUM;
if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM) && !qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6))netdev_feature_clear_bit(NETIF_F_IPV6_CSUM_BIT, features);
*features &= ~NETIF_F_RXCSUM;
if (!qeth_is_supported(card, IPA_OUTBOUND_TSO))netdev_feature_clear_bit(NETIF_F_RXCSUM_BIT, features);
*features &= ~NETIF_F_TSO;
if (!qeth_is_supported6(card, IPA_OUTBOUND_TSO))netdev_feature_clear_bit(NETIF_F_TSO_BIT, features);
*features &= ~NETIF_F_TSO6;
netdev_feature_clear_bit(NETIF_F_TSO6_BIT, features);
QETH_CARD_HEX(card, 2, features, sizeof(*features));
} @@ -6956,25 +6979,30 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev, /* Traffic with local next-hop is not eligible for some offloads: */ if (skb->ip_summed == CHECKSUM_PARTIAL && READ_ONCE(card->options.isolation) != ISOLATION_MODE_FWD) {
netdev_features_t restricted = 0;
netdev_features_t restricted;
netdev_feature_zero(&restricted);
if (skb_is_gso(skb) && !netif_needs_gso(skb, *features))
restricted |= NETIF_F_ALL_TSO;
netdev_feature_set_bits(NETIF_F_ALL_TSO, &restricted);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!card->info.has_lp2lp_cso_v4)
restricted |= NETIF_F_IP_CSUM;
netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT,
&restricted); if (restricted && qeth_next_hop_is_local_v4(card, skb))
*features &= ~restricted;
netdev_feature_andnot(features, features,
case htons(ETH_P_IPV6): if (!card->info.has_lp2lp_cso_v6)&restricted); break;
restricted |= NETIF_F_IPV6_CSUM;
netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
&restricted); if (restricted && qeth_next_hop_is_local_v6(card, skb))
*features &= ~restricted;
netdev_feature_andnot(features, *features,
default: break;restricted); break;
@@ -6996,7 +7024,7 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
/* linearize only if resulting skb allocations are order-0: */ if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0))
*features &= ~NETIF_F_SG;
netdev_feature_clear_bit(NETIF_F_SG_BIT, features);
}
vlan_features_check(skb, features);
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 72e84ff9fea5..d3763d4df2e4 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -1079,40 +1079,54 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) card->dev->priv_flags |= IFF_UNICAST_FLT;
if (IS_OSM(card)) {
card->dev->features |= NETIF_F_VLAN_CHALLENGED;
netdev_feature_set_bit(NETIF_F_VLAN_CHALLENGED_BIT,
} else { if (!IS_VM_NIC(card))&card->dev->features);
card->dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
&card->dev->features);
}
if (IS_OSD(card) && !IS_VM_NIC(card)) {
card->dev->features |= NETIF_F_SG;
/* OSA 3S and earlier has no RX/TX support */ if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) {netdev_feature_set_bit(NETIF_F_SG_BIT, &card->dev->features);
card->dev->hw_features |= NETIF_F_IP_CSUM;
card->dev->vlan_features |= NETIF_F_IP_CSUM;
netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT,
} } if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) {&card->dev->vlan_features);
card->dev->hw_features |= NETIF_F_IPV6_CSUM;
card->dev->vlan_features |= NETIF_F_IPV6_CSUM;
netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
} if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM) || qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) {&card->dev->vlan_features);
card->dev->hw_features |= NETIF_F_RXCSUM;
card->dev->vlan_features |= NETIF_F_RXCSUM;
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_RXCSUM_BIT,
} if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) {&card->dev->vlan_features);
card->dev->hw_features |= NETIF_F_TSO;
card->dev->vlan_features |= NETIF_F_TSO;
netdev_feature_set_bit(NETIF_F_TSO_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_TSO_BIT,
} if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) {&card->dev->vlan_features);
card->dev->hw_features |= NETIF_F_TSO6;
card->dev->vlan_features |= NETIF_F_TSO6;
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
}&card->dev->vlan_features);
- if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) {
- if (netdev_feature_test_bits(NETIF_F_TSO | NETIF_F_TSO6,
card->dev->needed_headroom = sizeof(struct qeth_hdr_tso); netif_keep_dst(card->dev); netif_set_gso_max_size(card->dev,card->dev->hw_features)) {
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 76c37eedf614..71feb9075a57 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1809,7 +1809,8 @@ static void qeth_l3_osa_features_check(struct sk_buff *skb, netdev_features_t *features) { if (vlan_get_protocol(skb) != htons(ETH_P_IP))
*features &= ~NETIF_F_HW_VLAN_CTAG_TX;
netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT,
qeth_features_check(skb, dev, features);features);
}
@@ -1878,26 +1879,35 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) dev->dev_id = qeth_l3_get_unique_id(card, dev->dev_id);
if (!IS_VM_NIC(card)) {
card->dev->features |= NETIF_F_SG;
card->dev->hw_features |= NETIF_F_TSO |
NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
card->dev->vlan_features |= NETIF_F_TSO |
NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
netdev_feature_set_bit(NETIF_F_SG_BIT,
&card->dev->features);
netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM |
NETIF_F_IP_CSUM,
&card->dev->hw_features);
netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM |
NETIF_F_IP_CSUM,
&card->dev->vlan_features);
}
if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) {
card->dev->hw_features |= NETIF_F_IPV6_CSUM;
card->dev->vlan_features |= NETIF_F_IPV6_CSUM;
netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
} if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) {&card->dev->vlan_features);
card->dev->hw_features |= NETIF_F_TSO6;
card->dev->vlan_features |= NETIF_F_TSO6;
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
&card->dev->hw_features);
netdev_feature_set_bit(NETIF_F_TSO6_BIT,
&card->dev->vlan_features);
}
/* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */
if (card->dev->hw_features & NETIF_F_TSO6)
if (netdev_feature_test_bit(NETIF_F_TSO6_BIT,
card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso) + VLAN_HLEN;
else if (card->dev->hw_features & NETIF_F_TSO)
else if (netdev_feature_test_bit(NETIF_F_TSO_BIT,
else headroom = sizeof(struct qeth_hdr) + VLAN_HLEN;card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso);
@@ -1913,11 +1923,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) return -ENODEV;
card->dev->needed_headroom = headroom;
- card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX;
netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX, &card->dev->features);
netif_keep_dst(card->dev);
- if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6))
- if (netdev_feature_test_bit(NETIF_F_TSO | NETIF_F_TSO6,
card->dev->hw_features))
netdev_feature_test_bit -> netdev_feature_test_bits ?
netif_set_gso_max_size(card->dev, PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1));
在 2021/9/24 14:32, wangjie (L) 写道:
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/s390/net/qeth_core_main.c | 122 ++++++++++++++++++------------ drivers/s390/net/qeth_l2_main.c | 44 +++++++---- drivers/s390/net/qeth_l3_main.c | 41 ++++++---- 3 files changed, 130 insertions(+), 77 deletions(-)
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index d8269f4f7a83..a1fea5111860 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -5612,7 +5612,8 @@ static void qeth_receive_skb(struct qeth_card *card, struct sk_buff *skb, return; }
- if (is_cso && (card->dev->features & NETIF_F_RXCSUM)) { + if (is_cso && netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, + card->dev->features)) { skb->ip_summed = CHECKSUM_UNNECESSARY; QETH_CARD_STAT_INC(card, rx_skb_csum); } else { @@ -6389,10 +6390,10 @@ static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
dev->ethtool_ops = &qeth_ethtool_ops; dev->priv_flags &= ~IFF_TX_SKB_SHARING; - dev->hw_features |= NETIF_F_SG; - dev->vlan_features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->hw_features); + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->vlan_features); if (IS_IQD(card)) - dev->features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->features);
return dev; } @@ -6839,18 +6840,21 @@ void qeth_enable_hw_features(struct net_device *dev) struct qeth_card *card = dev->ml_priv; netdev_features_t features;
- features = dev->features; + netdev_feature_copy(&features, dev->features); /* force-off any feature that might need an IPA sequence. * netdev_update_features() will restart them. */ - dev->features &= ~dev->hw_features; + netdev_feature_andnot(&dev->features, dev->features, + dev->hw_features); /* toggle VLAN filter, so that VIDs are re-programmed: */ if (IS_LAYER2(card) && IS_VM_NIC(card)) { - dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; - dev->wanted_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ &dev->features); + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &dev->wanted_features); } netdev_update_features(dev); - if (features != dev->features) + if (!netdev_feature_equal(features, dev->features)) dev_warn(&card->gdev->dev, "Device recovery failed to restore all offload features\n"); } @@ -6860,69 +6864,88 @@ static void qeth_check_restricted_features(struct qeth_card *card, netdev_features_t changed, netdev_features_t actual) { - netdev_features_t ipv6_features = NETIF_F_TSO6; - netdev_features_t ipv4_features = NETIF_F_TSO; + netdev_features_t ipv6_features; + netdev_features_t ipv4_features;
+ netdev_features_zero(&ipv6_features); + netdev_features_zero(&ipv4_features); + netdev_features_set_bit(NETIF_F_TSO6_BIT, &ipv6_features); + netdev_features_set_bit(NETIF_F_TSO_BIT, &ipv6_features);
ipv6_features -> ipv4_features ?
Yes, will fix it, thanks!
if (!card->info.has_lp2lp_cso_v6) - ipv6_features |= NETIF_F_IPV6_CSUM; + netdev_features_set_bit(NETIF_F_IPV6_CSUM_BIT, &ipv6_features); if (!card->info.has_lp2lp_cso_v4) - ipv4_features |= NETIF_F_IP_CSUM; + netdev_features_set_bit(NETIF_F_IP_CSUM_BIT, &ipv4_features);
- if ((changed & ipv6_features) && !(actual & ipv6_features)) + if (netdev_feature_intersects(ipv6_features, changed) && + !netdev_feature_intersects(ipv6_features, actual)) qeth_flush_local_addrs6(card); - if ((changed & ipv4_features) && !(actual & ipv4_features)) + if (netdev_feature_intersects(ipv4_features, changed) && + !netdev_feature_intersects(ipv4_features, actual)) qeth_flush_local_addrs4(card); }
int qeth_set_features(struct net_device *dev, netdev_features_t features) { struct qeth_card *card = dev->ml_priv; - netdev_features_t changed = dev->features ^ features; + netdev_features_t changed, tmp1, tmp2; int rc = 0;
QETH_CARD_TEXT(card, 2, "setfeat"); QETH_CARD_HEX(card, 2, &features, sizeof(features));
- if ((changed & NETIF_F_IP_CSUM)) { - rc = qeth_set_ipa_csum(card, features & NETIF_F_IP_CSUM, + netdev_feature_xor(&changed, dev->features, features); + if (netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, changed)) { + rc = qeth_set_ipa_csum(card,
- netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT,
+ features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV4, &card->info.has_lp2lp_cso_v4); if (rc) - changed ^= NETIF_F_IP_CSUM; + netdev_feature_change_bit(NETIF_F_IP_CSUM_BIT, &changed); } - if (changed & NETIF_F_IPV6_CSUM) { - rc = qeth_set_ipa_csum(card, features & NETIF_F_IPV6_CSUM, + if (netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, changed)) { + rc = qeth_set_ipa_csum(card,
- netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT,
+ features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV6, &card->info.has_lp2lp_cso_v6); if (rc) - changed ^= NETIF_F_IPV6_CSUM; + netdev_feature_change_bit(NETIF_F_IPV6_CSUM_BIT, &changed); } - if (changed & NETIF_F_RXCSUM) { - rc = qeth_set_ipa_rx_csum(card, features & NETIF_F_RXCSUM); + if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, changed)) { + rc = qeth_set_ipa_rx_csum(card,
- netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
+ features)); if (rc) - changed ^= NETIF_F_RXCSUM; + netdev_feature_change_bit(NETIF_F_RXCSUM_BIT, &changed); } - if (changed & NETIF_F_TSO) { - rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO, + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, changed)) { + rc = qeth_set_ipa_tso(card, + netdev_feature_test_bit(NETIF_F_TSO_BIT, + features), QETH_PROT_IPV4); if (rc) - changed ^= NETIF_F_TSO; + netdev_feature_change_bit(NETIF_F_TSO_BIT, &changed); } - if (changed & NETIF_F_TSO6) { - rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO6, + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, changed)) { + rc = qeth_set_ipa_tso(card, + netdev_feature_test_bit(NETIF_F_TSO6_BIT, + features), QETH_PROT_IPV6); if (rc) - changed ^= NETIF_F_TSO6; + netdev_feature_change_bit(NETIF_F_TSO6_BIT, &changed); }
- qeth_check_restricted_features(card, dev->features ^ features, - dev->features ^ changed); + netdev_feature_xor(&tmp1, dev->features, features); + netdev_feature_xor(&tmp2, dev->features, changed); + qeth_check_restricted_features(card, tmp1, tmp2);
/* everything changed successfully? */ - if ((dev->features ^ features) == changed) + netdev_feature_xor(&tmp1, dev->features, features); + if (netdev_feature_equal(tmp1, changed)) return 0; /* something went wrong. save changed features and return error */ - dev->features ^= changed; + netdev_feature_xor(&dev->features, dev->features, changed); return -EIO; } EXPORT_SYMBOL_GPL(qeth_set_features); @@ -6933,16 +6956,16 @@ void qeth_fix_features(struct net_device *dev, netdev_features_t *features)
QETH_CARD_TEXT(card, 2, "fixfeat"); if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) - *features &= ~NETIF_F_IP_CSUM; + netdev_feature_clear_bit(NETIF_F_IP_CSUM_BIT, features); if (!qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) - *features &= ~NETIF_F_IPV6_CSUM; + netdev_feature_clear_bit(NETIF_F_IPV6_CSUM_BIT, features); if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM) && !qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) - *features &= ~NETIF_F_RXCSUM; + netdev_feature_clear_bit(NETIF_F_RXCSUM_BIT, features); if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) - *features &= ~NETIF_F_TSO; + netdev_feature_clear_bit(NETIF_F_TSO_BIT, features); if (!qeth_is_supported6(card, IPA_OUTBOUND_TSO)) - *features &= ~NETIF_F_TSO6; + netdev_feature_clear_bit(NETIF_F_TSO6_BIT, features);
QETH_CARD_HEX(card, 2, features, sizeof(*features)); } @@ -6956,25 +6979,30 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev, /* Traffic with local next-hop is not eligible for some offloads: */ if (skb->ip_summed == CHECKSUM_PARTIAL && READ_ONCE(card->options.isolation) != ISOLATION_MODE_FWD) { - netdev_features_t restricted = 0; + netdev_features_t restricted;
+ netdev_feature_zero(&restricted); if (skb_is_gso(skb) && !netif_needs_gso(skb, *features)) - restricted |= NETIF_F_ALL_TSO; + netdev_feature_set_bits(NETIF_F_ALL_TSO, &restricted);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!card->info.has_lp2lp_cso_v4) - restricted |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &restricted);
if (restricted && qeth_next_hop_is_local_v4(card, skb)) - *features &= ~restricted; + netdev_feature_andnot(features, features, + &restricted); break; case htons(ETH_P_IPV6): if (!card->info.has_lp2lp_cso_v6) - restricted |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &restricted);
if (restricted && qeth_next_hop_is_local_v6(card, skb)) - *features &= ~restricted; + netdev_feature_andnot(features, *features, + restricted); break; default: break; @@ -6996,7 +7024,7 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
/* linearize only if resulting skb allocations are order-0: */ if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0)) - *features &= ~NETIF_F_SG; + netdev_feature_clear_bit(NETIF_F_SG_BIT, features); }
vlan_features_check(skb, features); diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 72e84ff9fea5..d3763d4df2e4 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -1079,40 +1079,54 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) card->dev->priv_flags |= IFF_UNICAST_FLT;
if (IS_OSM(card)) { - card->dev->features |= NETIF_F_VLAN_CHALLENGED; + netdev_feature_set_bit(NETIF_F_VLAN_CHALLENGED_BIT, + &card->dev->features); } else { if (!IS_VM_NIC(card)) - card->dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; - card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &card->dev->features); }
if (IS_OSD(card) && !IS_VM_NIC(card)) { - card->dev->features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &card->dev->features); /* OSA 3S and earlier has no RX/TX support */ if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) { - card->dev->hw_features |= NETIF_F_IP_CSUM; - card->dev->vlan_features |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT,
- &card->dev->vlan_features);
} } if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_IPV6_CSUM; - card->dev->vlan_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM) || qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_RXCSUM; - card->dev->vlan_features |= NETIF_F_RXCSUM; + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO; - card->dev->vlan_features |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &card->dev->vlan_features); } if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO6; - card->dev->vlan_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->vlan_features); }
- if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) { + if (netdev_feature_test_bits(NETIF_F_TSO | NETIF_F_TSO6, + card->dev->hw_features)) { card->dev->needed_headroom = sizeof(struct qeth_hdr_tso); netif_keep_dst(card->dev); netif_set_gso_max_size(card->dev, diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 76c37eedf614..71feb9075a57 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1809,7 +1809,8 @@ static void qeth_l3_osa_features_check(struct sk_buff *skb, netdev_features_t *features) { if (vlan_get_protocol(skb) != htons(ETH_P_IP)) - *features &= ~NETIF_F_HW_VLAN_CTAG_TX; + netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, + features); qeth_features_check(skb, dev, features); }
@@ -1878,26 +1879,35 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) dev->dev_id = qeth_l3_get_unique_id(card, dev->dev_id);
if (!IS_VM_NIC(card)) { - card->dev->features |= NETIF_F_SG; - card->dev->hw_features |= NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_IP_CSUM; - card->dev->vlan_features |= NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_SG_BIT, + &card->dev->features); + netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM | + NETIF_F_IP_CSUM, + &card->dev->hw_features); + netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM | + NETIF_F_IP_CSUM, + &card->dev->vlan_features); }
if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_IPV6_CSUM; - card->dev->vlan_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
- &card->dev->vlan_features);
} if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO6; - card->dev->vlan_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO6_BIT,
- &card->dev->vlan_features);
}
/* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */ - if (card->dev->hw_features & NETIF_F_TSO6) + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, + card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso) + VLAN_HLEN; - else if (card->dev->hw_features & NETIF_F_TSO) + else if (netdev_feature_test_bit(NETIF_F_TSO_BIT, + card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso); else headroom = sizeof(struct qeth_hdr) + VLAN_HLEN; @@ -1913,11 +1923,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) return -ENODEV;
card->dev->needed_headroom = headroom; - card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_CTAG_RX; + netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_RX, &card->dev->features);
netif_keep_dst(card->dev); - if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) + if (netdev_feature_test_bit(NETIF_F_TSO | NETIF_F_TSO6, + card->dev->hw_features))
netdev_feature_test_bit -> netdev_feature_test_bits ?
netif_set_gso_max_size(card->dev, PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1));
.
在 2021/9/24 14:32, wangjie (L) 写道:
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/s390/net/qeth_core_main.c | 122 ++++++++++++++++++------------ drivers/s390/net/qeth_l2_main.c | 44 +++++++---- drivers/s390/net/qeth_l3_main.c | 41 ++++++---- 3 files changed, 130 insertions(+), 77 deletions(-)
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index d8269f4f7a83..a1fea5111860 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -5612,7 +5612,8 @@ static void qeth_receive_skb(struct qeth_card *card, struct sk_buff *skb, return; }
- if (is_cso && (card->dev->features & NETIF_F_RXCSUM)) { + if (is_cso && netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, + card->dev->features)) { skb->ip_summed = CHECKSUM_UNNECESSARY; QETH_CARD_STAT_INC(card, rx_skb_csum); } else { @@ -6389,10 +6390,10 @@ static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
dev->ethtool_ops = &qeth_ethtool_ops; dev->priv_flags &= ~IFF_TX_SKB_SHARING; - dev->hw_features |= NETIF_F_SG; - dev->vlan_features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->hw_features); + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->vlan_features); if (IS_IQD(card)) - dev->features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &dev->features);
return dev; } @@ -6839,18 +6840,21 @@ void qeth_enable_hw_features(struct net_device *dev) struct qeth_card *card = dev->ml_priv; netdev_features_t features;
- features = dev->features; + netdev_feature_copy(&features, dev->features); /* force-off any feature that might need an IPA sequence. * netdev_update_features() will restart them. */ - dev->features &= ~dev->hw_features; + netdev_feature_andnot(&dev->features, dev->features, + dev->hw_features); /* toggle VLAN filter, so that VIDs are re-programmed: */ if (IS_LAYER2(card) && IS_VM_NIC(card)) { - dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; - dev->wanted_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ &dev->features); + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &dev->wanted_features); } netdev_update_features(dev); - if (features != dev->features) + if (!netdev_feature_equal(features, dev->features)) dev_warn(&card->gdev->dev, "Device recovery failed to restore all offload features\n"); } @@ -6860,69 +6864,88 @@ static void qeth_check_restricted_features(struct qeth_card *card, netdev_features_t changed, netdev_features_t actual) { - netdev_features_t ipv6_features = NETIF_F_TSO6; - netdev_features_t ipv4_features = NETIF_F_TSO; + netdev_features_t ipv6_features; + netdev_features_t ipv4_features;
+ netdev_features_zero(&ipv6_features); + netdev_features_zero(&ipv4_features); + netdev_features_set_bit(NETIF_F_TSO6_BIT, &ipv6_features); + netdev_features_set_bit(NETIF_F_TSO_BIT, &ipv6_features);
ipv6_features -> ipv4_features ?
if (!card->info.has_lp2lp_cso_v6) - ipv6_features |= NETIF_F_IPV6_CSUM; + netdev_features_set_bit(NETIF_F_IPV6_CSUM_BIT, &ipv6_features); if (!card->info.has_lp2lp_cso_v4) - ipv4_features |= NETIF_F_IP_CSUM; + netdev_features_set_bit(NETIF_F_IP_CSUM_BIT, &ipv4_features);
- if ((changed & ipv6_features) && !(actual & ipv6_features)) + if (netdev_feature_intersects(ipv6_features, changed) && + !netdev_feature_intersects(ipv6_features, actual)) qeth_flush_local_addrs6(card); - if ((changed & ipv4_features) && !(actual & ipv4_features)) + if (netdev_feature_intersects(ipv4_features, changed) && + !netdev_feature_intersects(ipv4_features, actual)) qeth_flush_local_addrs4(card); }
int qeth_set_features(struct net_device *dev, netdev_features_t features) { struct qeth_card *card = dev->ml_priv; - netdev_features_t changed = dev->features ^ features; + netdev_features_t changed, tmp1, tmp2; int rc = 0;
QETH_CARD_TEXT(card, 2, "setfeat"); QETH_CARD_HEX(card, 2, &features, sizeof(features));
- if ((changed & NETIF_F_IP_CSUM)) { - rc = qeth_set_ipa_csum(card, features & NETIF_F_IP_CSUM, + netdev_feature_xor(&changed, dev->features, features); + if (netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT, changed)) { + rc = qeth_set_ipa_csum(card,
- netdev_feature_test_bit(NETIF_F_IP_CSUM_BIT,
+ features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV4, &card->info.has_lp2lp_cso_v4); if (rc) - changed ^= NETIF_F_IP_CSUM; + netdev_feature_change_bit(NETIF_F_IP_CSUM_BIT, &changed); } - if (changed & NETIF_F_IPV6_CSUM) { - rc = qeth_set_ipa_csum(card, features & NETIF_F_IPV6_CSUM, + if (netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT, changed)) { + rc = qeth_set_ipa_csum(card,
- netdev_feature_test_bit(NETIF_F_IPV6_CSUM_BIT,
+ features), IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV6, &card->info.has_lp2lp_cso_v6); if (rc) - changed ^= NETIF_F_IPV6_CSUM; + netdev_feature_change_bit(NETIF_F_IPV6_CSUM_BIT, &changed); } - if (changed & NETIF_F_RXCSUM) { - rc = qeth_set_ipa_rx_csum(card, features & NETIF_F_RXCSUM); + if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT, changed)) { + rc = qeth_set_ipa_rx_csum(card,
- netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
+ features)); if (rc) - changed ^= NETIF_F_RXCSUM; + netdev_feature_change_bit(NETIF_F_RXCSUM_BIT, &changed); } - if (changed & NETIF_F_TSO) { - rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO, + if (netdev_feature_test_bit(NETIF_F_TSO_BIT, changed)) { + rc = qeth_set_ipa_tso(card, + netdev_feature_test_bit(NETIF_F_TSO_BIT, + features), QETH_PROT_IPV4); if (rc) - changed ^= NETIF_F_TSO; + netdev_feature_change_bit(NETIF_F_TSO_BIT, &changed); } - if (changed & NETIF_F_TSO6) { - rc = qeth_set_ipa_tso(card, features & NETIF_F_TSO6, + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, changed)) { + rc = qeth_set_ipa_tso(card, + netdev_feature_test_bit(NETIF_F_TSO6_BIT, + features), QETH_PROT_IPV6); if (rc) - changed ^= NETIF_F_TSO6; + netdev_feature_change_bit(NETIF_F_TSO6_BIT, &changed); }
- qeth_check_restricted_features(card, dev->features ^ features, - dev->features ^ changed); + netdev_feature_xor(&tmp1, dev->features, features); + netdev_feature_xor(&tmp2, dev->features, changed); + qeth_check_restricted_features(card, tmp1, tmp2);
/* everything changed successfully? */ - if ((dev->features ^ features) == changed) + netdev_feature_xor(&tmp1, dev->features, features); + if (netdev_feature_equal(tmp1, changed)) return 0; /* something went wrong. save changed features and return error */ - dev->features ^= changed; + netdev_feature_xor(&dev->features, dev->features, changed); return -EIO; } EXPORT_SYMBOL_GPL(qeth_set_features); @@ -6933,16 +6956,16 @@ void qeth_fix_features(struct net_device *dev, netdev_features_t *features)
QETH_CARD_TEXT(card, 2, "fixfeat"); if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) - *features &= ~NETIF_F_IP_CSUM; + netdev_feature_clear_bit(NETIF_F_IP_CSUM_BIT, features); if (!qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) - *features &= ~NETIF_F_IPV6_CSUM; + netdev_feature_clear_bit(NETIF_F_IPV6_CSUM_BIT, features); if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM) && !qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) - *features &= ~NETIF_F_RXCSUM; + netdev_feature_clear_bit(NETIF_F_RXCSUM_BIT, features); if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) - *features &= ~NETIF_F_TSO; + netdev_feature_clear_bit(NETIF_F_TSO_BIT, features); if (!qeth_is_supported6(card, IPA_OUTBOUND_TSO)) - *features &= ~NETIF_F_TSO6; + netdev_feature_clear_bit(NETIF_F_TSO6_BIT, features);
QETH_CARD_HEX(card, 2, features, sizeof(*features)); } @@ -6956,25 +6979,30 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev, /* Traffic with local next-hop is not eligible for some offloads: */ if (skb->ip_summed == CHECKSUM_PARTIAL && READ_ONCE(card->options.isolation) != ISOLATION_MODE_FWD) { - netdev_features_t restricted = 0; + netdev_features_t restricted;
+ netdev_feature_zero(&restricted); if (skb_is_gso(skb) && !netif_needs_gso(skb, *features)) - restricted |= NETIF_F_ALL_TSO; + netdev_feature_set_bits(NETIF_F_ALL_TSO, &restricted);
switch (vlan_get_protocol(skb)) { case htons(ETH_P_IP): if (!card->info.has_lp2lp_cso_v4) - restricted |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &restricted);
if (restricted && qeth_next_hop_is_local_v4(card, skb)) - *features &= ~restricted; + netdev_feature_andnot(features, features, + &restricted); break; case htons(ETH_P_IPV6): if (!card->info.has_lp2lp_cso_v6) - restricted |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &restricted);
if (restricted && qeth_next_hop_is_local_v6(card, skb)) - *features &= ~restricted; + netdev_feature_andnot(features, *features, + restricted); break; default: break; @@ -6996,7 +7024,7 @@ void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
/* linearize only if resulting skb allocations are order-0: */ if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0)) - *features &= ~NETIF_F_SG; + netdev_feature_clear_bit(NETIF_F_SG_BIT, features); }
vlan_features_check(skb, features); diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 72e84ff9fea5..d3763d4df2e4 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -1079,40 +1079,54 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) card->dev->priv_flags |= IFF_UNICAST_FLT;
if (IS_OSM(card)) { - card->dev->features |= NETIF_F_VLAN_CHALLENGED; + netdev_feature_set_bit(NETIF_F_VLAN_CHALLENGED_BIT, + &card->dev->features); } else { if (!IS_VM_NIC(card)) - card->dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; - card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+ &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &card->dev->features); }
if (IS_OSD(card) && !IS_VM_NIC(card)) { - card->dev->features |= NETIF_F_SG; + netdev_feature_set_bit(NETIF_F_SG_BIT, &card->dev->features); /* OSA 3S and earlier has no RX/TX support */ if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) { - card->dev->hw_features |= NETIF_F_IP_CSUM; - card->dev->vlan_features |= NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IP_CSUM_BIT,
- &card->dev->vlan_features);
} } if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_IPV6_CSUM; - card->dev->vlan_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM) || qeth_is_supported6(card, IPA_INBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_RXCSUM; - card->dev->vlan_features |= NETIF_F_RXCSUM; + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, + &card->dev->vlan_features); } if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO; - card->dev->vlan_features |= NETIF_F_TSO; + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO_BIT, + &card->dev->vlan_features); } if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO6; - card->dev->vlan_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->vlan_features); }
- if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) { + if (netdev_feature_test_bits(NETIF_F_TSO | NETIF_F_TSO6, + card->dev->hw_features)) { card->dev->needed_headroom = sizeof(struct qeth_hdr_tso); netif_keep_dst(card->dev); netif_set_gso_max_size(card->dev, diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 76c37eedf614..71feb9075a57 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1809,7 +1809,8 @@ static void qeth_l3_osa_features_check(struct sk_buff *skb, netdev_features_t *features) { if (vlan_get_protocol(skb) != htons(ETH_P_IP)) - *features &= ~NETIF_F_HW_VLAN_CTAG_TX; + netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_TX_BIT, + features); qeth_features_check(skb, dev, features); }
@@ -1878,26 +1879,35 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) dev->dev_id = qeth_l3_get_unique_id(card, dev->dev_id);
if (!IS_VM_NIC(card)) { - card->dev->features |= NETIF_F_SG; - card->dev->hw_features |= NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_IP_CSUM; - card->dev->vlan_features |= NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_IP_CSUM; + netdev_feature_set_bit(NETIF_F_SG_BIT, + &card->dev->features); + netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM | + NETIF_F_IP_CSUM, + &card->dev->hw_features); + netdev_feature_set_bits(NETIF_F_TSO | NETIF_F_RXCSUM | + NETIF_F_IP_CSUM, + &card->dev->vlan_features); }
if (qeth_is_supported6(card, IPA_OUTBOUND_CHECKSUM_V6)) { - card->dev->hw_features |= NETIF_F_IPV6_CSUM; - card->dev->vlan_features |= NETIF_F_IPV6_CSUM; + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_IPV6_CSUM_BIT,
- &card->dev->vlan_features);
} if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { - card->dev->hw_features |= NETIF_F_TSO6; - card->dev->vlan_features |= NETIF_F_TSO6; + netdev_feature_set_bit(NETIF_F_TSO6_BIT, + &card->dev->hw_features); + netdev_feature_set_bit(NETIF_F_TSO6_BIT,
- &card->dev->vlan_features);
}
/* allow for de-acceleration of NETIF_F_HW_VLAN_CTAG_TX: */ - if (card->dev->hw_features & NETIF_F_TSO6) + if (netdev_feature_test_bit(NETIF_F_TSO6_BIT, + card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso) + VLAN_HLEN; - else if (card->dev->hw_features & NETIF_F_TSO) + else if (netdev_feature_test_bit(NETIF_F_TSO_BIT, + card->dev->hw_features)) headroom = sizeof(struct qeth_hdr_tso); else headroom = sizeof(struct qeth_hdr) + VLAN_HLEN; @@ -1913,11 +1923,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) return -ENODEV;
card->dev->needed_headroom = headroom; - card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | - NETIF_F_HW_VLAN_CTAG_RX; + netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_RX, &card->dev->features);
netif_keep_dst(card->dev); - if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) + if (netdev_feature_test_bit(NETIF_F_TSO | NETIF_F_TSO6, + card->dev->hw_features))
netdev_feature_test_bit -> netdev_feature_test_bits ?
yes, thanks, will fix it
netif_set_gso_max_size(card->dev, PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1));
.
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com --- drivers/net/dsa/xrs700x/xrs700x.c | 6 ++++-- net/dsa/slave.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index 130abb0f1438..898426ca415c 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -639,7 +639,8 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port, hsr_pair[1] = partner->index; for (i = 0; i < ARRAY_SIZE(hsr_pair); i++) { slave = dsa_to_port(ds, hsr_pair[i])->slave; - slave->features |= XRS7000X_SUPPORTED_HSR_FEATURES; + netdev_feature_set_bits(XRS7000X_SUPPORTED_HSR_FEATURES, + &slave->features); }
return 0; @@ -693,7 +694,8 @@ static int xrs700x_hsr_leave(struct dsa_switch *ds, int port, hsr_pair[1] = partner->index; for (i = 0; i < ARRAY_SIZE(hsr_pair); i++) { slave = dsa_to_port(ds, hsr_pair[i])->slave; - slave->features &= ~XRS7000X_SUPPORTED_HSR_FEATURES; + netdev_feature_clear_bits(XRS7000X_SUPPORTED_HSR_FEATURES, + &slave->features); }
return 0; diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a2bf2d8ac65b..8138b54dd105 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1460,12 +1460,14 @@ int dsa_slave_manage_vlan_filtering(struct net_device *slave, int err;
if (vlan_filtering) { - slave->features |= NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &slave->features);
err = vlan_for_each(slave, dsa_slave_restore_vlan, slave); if (err) { vlan_for_each(slave, dsa_slave_clear_vlan, slave); - slave->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &slave->features); return err; } } else { @@ -1473,7 +1475,8 @@ int dsa_slave_manage_vlan_filtering(struct net_device *slave, if (err) return err;
- slave->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_clear_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &slave->features); }
return 0; @@ -1883,13 +1886,16 @@ void dsa_slave_setup_tagger(struct net_device *slave)
p->xmit = cpu_dp->tag_ops->xmit;
- slave->features = master->vlan_features | NETIF_F_HW_TC; - slave->hw_features |= NETIF_F_HW_TC; - slave->features |= NETIF_F_LLTX; + netdev_feature_copy(&slave->features, master->vlan_features); + netdev_feature_set_bit(NETIF_F_HW_TC_BIT, &slave->features); + netdev_feature_set_bit(NETIF_F_HW_TC_BIT, &slave->hw_features); + netdev_feature_set_bit(NETIF_F_LLTX_BIT, &slave->features); if (slave->needed_tailroom) - slave->features &= ~(NETIF_F_SG | NETIF_F_FRAGLIST); + netdev_feature_clear_bits(NETIF_F_SG | NETIF_F_FRAGLIST, + &slave->features); if (ds->needs_standalone_vlan_filtering) - slave->features |= NETIF_F_HW_VLAN_CTAG_FILTER; + netdev_feature_set_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, + &slave->features); }
static struct lock_class_key dsa_slave_netdev_xmit_lock_key; @@ -1968,7 +1974,7 @@ int dsa_slave_create(struct dsa_port *port)
SET_NETDEV_DEV(slave_dev, port->ds->dev); slave_dev->dev.of_node = port->dn; - slave_dev->vlan_features = master->vlan_features; + netdev_feature_copy(&slave_dev->features, master->vlan_features);
p = netdev_priv(slave_dev); slave_dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
On 2021/9/22 22:56, Jian Shen wrote:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/dsa/xrs700x/xrs700x.c | 6 ++++-- net/dsa/slave.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index 130abb0f1438..898426ca415c 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -639,7 +639,8 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port, hsr_pair[1] = partner->index; for (i = 0; i < ARRAY_SIZE(hsr_pair); i++) { slave = dsa_to_port(ds, hsr_pair[i])->slave;
slave->features |= XRS7000X_SUPPORTED_HSR_FEATURES;
netdev_feature_set_bits(XRS7000X_SUPPORTED_HSR_FEATURES,
&slave->features);
}
return 0;
@@ -693,7 +694,8 @@ static int xrs700x_hsr_leave(struct dsa_switch *ds, int port, hsr_pair[1] = partner->index; for (i = 0; i < ARRAY_SIZE(hsr_pair); i++) { slave = dsa_to_port(ds, hsr_pair[i])->slave;
slave->features &= ~XRS7000X_SUPPORTED_HSR_FEATURES;