@@ -167,6 +167,7 @@ static int aq_ndev_set_features(struct net_device *ndev,
struct aq_nic_s *aq_nic = netdev_priv(ndev);
bool need_ndev_restart = false;
struct aq_nic_cfg_s *aq_cfg;
+ netdev_features_t changed;
bool is_lro = false;
int err = 0;
@@ -198,7 +199,8 @@ static int aq_ndev_set_features(struct net_device *ndev,
}
}
- if ((aq_nic->ndev->features ^ features) & NETIF_F_RXCSUM) {
+ netdev_features_xor(changed, aq_nic->ndev->features, features);
+ if (changed & NETIF_F_RXCSUM) {
err = aq_nic->aq_hw_ops->hw_set_offload(aq_nic->aq_hw,
aq_cfg);
@@ -924,8 +924,9 @@ static int
ax88796c_set_features(struct net_device *ndev, netdev_features_t features)
{
struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
- netdev_features_t changed = features ^ ndev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, ndev->features, features);
if (!(changed & ax88796c_features))
return 0;
@@ -531,8 +531,9 @@ static netdev_features_t atl1c_fix_features(struct net_device *netdev,
static int atl1c_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
atl1c_vlan_mode(netdev, features);
@@ -400,8 +400,9 @@ static netdev_features_t atl1e_fix_features(struct net_device *netdev,
static int atl1e_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
atl1e_vlan_mode(netdev, features);
@@ -390,8 +390,9 @@ static netdev_features_t atl2_fix_features(struct net_device *netdev,
static int atl2_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
atl2_vlan_mode(netdev, features);
@@ -255,8 +255,9 @@ static netdev_features_t atlx_fix_features(struct net_device *netdev,
static int atlx_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
atlx_vlan_mode(netdev, features);
@@ -4905,8 +4905,9 @@ netdev_features_t bnx2x_fix_features(struct net_device *dev,
struct bnx2x *bp = netdev_priv(dev);
if (pci_num_vf(bp->pdev)) {
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
/* Revert the requested changes in features if they
* would require internal reload of PF in bnx2x_set_features().
*/
@@ -4940,10 +4941,12 @@ netdev_features_t bnx2x_fix_features(struct net_device *dev,
int bnx2x_set_features(struct net_device *dev, netdev_features_t features)
{
struct bnx2x *bp = netdev_priv(dev);
- netdev_features_t changes = features ^ dev->features;
+ netdev_features_t changes;
bool bnx2x_reload = false;
int rc;
+ netdev_features_xor(changes, features, dev->features);
+
/* VFs or non SRIOV PFs should be able to change loopback feature */
if (!pci_num_vf(bp->pdev)) {
if (features & NETIF_F_LOOPBACK) {
@@ -8317,8 +8317,9 @@ static netdev_features_t tg3_fix_features(struct net_device *dev,
static int tg3_set_features(struct net_device *dev, netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if ((changed & NETIF_F_LOOPBACK) && netif_running(dev))
tg3_set_loopback(dev, features);
@@ -3347,8 +3347,9 @@ bnad_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
static int bnad_set_features(struct net_device *dev, netdev_features_t features)
{
struct bnad *bnad = netdev_priv(dev);
- netdev_features_t changed = features ^ dev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if ((changed & NETIF_F_HW_VLAN_CTAG_RX) && netif_running(dev)) {
unsigned long flags;
@@ -3743,7 +3743,9 @@ static int macb_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct macb *bp = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+
+ netdev_features_xor(changed, netdev->features, features);
/* TX checksum offload */
if (changed & NETIF_F_HW_CSUM)
@@ -1492,8 +1492,9 @@ static int xgmac_set_features(struct net_device *dev, netdev_features_t features
u32 ctrl;
struct xgmac_priv *priv = netdev_priv(dev);
void __iomem *ioaddr = priv->base;
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_RXCSUM))
return 0;
@@ -1850,9 +1850,10 @@ static netdev_features_t liquidio_fix_features(struct net_device *netdev,
static int liquidio_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
struct lio *lio = netdev_priv(netdev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (!(changed & NETIF_F_LRO))
return 0;
@@ -1789,8 +1789,9 @@ static int nicvf_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct nicvf *nic = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
nicvf_config_vlan_stripping(nic, features);
@@ -880,9 +880,10 @@ static netdev_features_t t1_fix_features(struct net_device *dev,
static int t1_set_features(struct net_device *dev, netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
struct adapter *adapter = dev->ml_priv;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
t1_vlan_mode(adapter, features);
@@ -2605,8 +2605,9 @@ static netdev_features_t cxgb_fix_features(struct net_device *dev,
static int cxgb_set_features(struct net_device *dev, netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
cxgb_vlan_mode(dev, features);
@@ -1273,10 +1273,11 @@ int cxgb4_set_rspq_intr_params(struct sge_rspq *q,
static int cxgb_set_features(struct net_device *dev, netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
const struct port_info *pi = netdev_priv(dev);
+ netdev_features_t changed;
int err;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_HW_VLAN_CTAG_RX))
return 0;
@@ -1193,8 +1193,9 @@ static int cxgb4vf_set_features(struct net_device *dev,
netdev_features_t features)
{
struct port_info *pi = netdev_priv(dev);
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
t4vf_set_rxmode(pi->adapter, pi->viid, -1, -1, -1, -1,
features & NETIF_F_HW_VLAN_CTAG_TX, 0);
@@ -587,9 +587,10 @@ static int dm9000_set_features(struct net_device *dev,
netdev_features_t features)
{
struct board_info *dm = to_dm9000_board(dev);
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
unsigned long flags;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_RXCSUM))
return 0;
@@ -1056,10 +1056,11 @@ static int tsnep_netdev_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct tsnep_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
bool enable;
int retval = 0;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_LOOPBACK) {
enable = !!(features & NETIF_F_LOOPBACK);
retval = tsnep_phy_loopback(adapter, enable);
@@ -1597,11 +1597,12 @@ static int ftgmac100_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct ftgmac100 *priv = netdev_priv(netdev);
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
if (!netif_running(netdev))
return 0;
+ netdev_features_xor(changed, netdev->features, features);
/* Update the vlan filtering bit */
if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
u32 maccr;
@@ -2422,10 +2422,11 @@ static int dpaa2_eth_set_features(struct net_device *net_dev,
netdev_features_t features)
{
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
- netdev_features_t changed = features ^ net_dev->features;
+ netdev_features_t changed;
bool enable;
int err;
+ netdev_features_xor(changed, net_dev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
enable = !!(features & NETIF_F_HW_VLAN_CTAG_FILTER);
err = dpaa2_eth_set_rx_vlan_filtering(priv, enable);
@@ -2644,9 +2644,10 @@ static void enetc_enable_txvlan(struct net_device *ndev, bool en)
int enetc_set_features(struct net_device *ndev,
netdev_features_t features)
{
- netdev_features_t changed = ndev->features ^ features;
+ netdev_features_t changed;
int err = 0;
+ netdev_features_xor(changed, ndev->features, features);
if (changed & NETIF_F_RXHASH)
enetc_set_rss(ndev, !!(features & NETIF_F_RXHASH));
@@ -708,9 +708,10 @@ static int enetc_sriov_configure(struct pci_dev *pdev, int num_vfs)
static int enetc_pf_set_features(struct net_device *ndev,
netdev_features_t features)
{
- netdev_features_t changed = ndev->features ^ features;
struct enetc_ndev_priv *priv = netdev_priv(ndev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, ndev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
struct enetc_pf *pf = enetc_si_priv(priv->si);
@@ -3450,8 +3450,9 @@ static inline void fec_enet_set_netdev_features(struct net_device *netdev,
netdev_features_t features)
{
struct fec_enet_private *fep = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
netdev->features = features;
/* Receive checksum has been changed */
@@ -3467,8 +3468,9 @@ static int fec_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct fec_enet_private *fep = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (netif_running(netdev) && changed & NETIF_F_RXCSUM) {
napi_disable(&fep->napi);
netif_tx_lock_bh(netdev);
@@ -21,6 +21,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
+#include <linux/netdev_feature_helpers.h>
#include <linux/etherdevice.h>
#include <linux/net_tstamp.h>
#include <linux/skbuff.h>
@@ -507,10 +508,11 @@ static int gfar_spauseparam(struct net_device *dev,
int gfar_set_features(struct net_device *dev, netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
struct gfar_private *priv = netdev_priv(dev);
+ netdev_features_t changed;
int err = 0;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & netdev_ctag_vlan_offload_features) &&
!(changed & NETIF_F_RXCSUM))
return 0;
@@ -2405,12 +2405,13 @@ static int hns3_nic_do_ioctl(struct net_device *netdev,
static int hns3_nic_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle;
+ netdev_features_t changed;
bool enable;
int ret;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_GRO_HW && h->ae_algo->ops->set_gro_en) {
enable = !!(features & NETIF_F_GRO_HW);
ret = h->ae_algo->ops->set_gro_en(h, enable);
@@ -1061,12 +1061,17 @@ static int set_features(struct hinic_dev *nic_dev,
netdev_features_t pre_features,
netdev_features_t features, bool force_change)
{
- netdev_features_t changed = force_change ? ~0 : pre_features ^ features;
u32 csum_en = HINIC_RX_CSUM_OFFLOAD_EN;
netdev_features_t failed_features;
+ netdev_features_t changed;
int ret = 0;
int err = 0;
+ if (force_change)
+ netdev_features_fill(changed);
+ else
+ netdev_features_xor(changed, pre_features, features);
+
netdev_features_zero(failed_features);
if (changed & NETIF_F_TSO) {
ret = hinic_port_set_tso(nic_dev, (features & NETIF_F_TSO) ?
@@ -1109,7 +1114,8 @@ static int set_features(struct hinic_dev *nic_dev,
}
if (err) {
- nic_dev->netdev->features = features ^ failed_features;
+ netdev_active_features_xor(nic_dev->netdev, features,
+ failed_features);
return -EIO;
}
@@ -4899,7 +4899,8 @@ static void send_control_ip_offload(struct ibmvnic_adapter *adapter)
/* disable features no longer supported */
adapter->netdev->features &= adapter->netdev->hw_features;
/* turn on features now supported if previously enabled */
- tmp = old_hw_features ^ adapter->netdev->hw_features;
+ netdev_features_xor(tmp, old_hw_features,
+ adapter->netdev->hw_features);
tmp &= adapter->netdev->hw_features;
tmp &= adapter->netdev->wanted_features;
netdev_active_features_set(adapter->netdev, tmp);
@@ -2804,8 +2804,9 @@ static int e100_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct nic *nic = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (!(changed & NETIF_F_RXFCS && changed & NETIF_F_RXALL))
return 0;
@@ -805,8 +805,9 @@ static int e1000_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
e1000_vlan_mode(netdev, features);
@@ -7316,9 +7316,10 @@ static int e1000_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
netdev_features_t changeable;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & netdev_general_tso_features)
adapter->flags |= FLAG_TSO_FORCE;
@@ -5964,7 +5964,8 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
current_vlan_features = netdev->features & NETIF_VLAN_OFFLOAD_FEATURES;
requested_vlan_features = features & NETIF_VLAN_OFFLOAD_FEATURES;
- diff = current_vlan_features ^ requested_vlan_features;
+ netdev_features_xor(diff, current_vlan_features,
+ requested_vlan_features);
if (diff) {
if ((features & NETIF_F_RXFCS) &&
(features & NETIF_VLAN_STRIPPING_FEATURES)) {
@@ -5981,7 +5982,8 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
current_vlan_features = netdev->features &
NETIF_VLAN_FILTERING_FEATURES;
requested_vlan_features = features & NETIF_VLAN_FILTERING_FEATURES;
- diff = current_vlan_features ^ requested_vlan_features;
+ netdev_features_xor(diff, current_vlan_features,
+ requested_vlan_features);
if (diff) {
err = ice_set_vlan_filtering_features(vsi, features);
if (err)
@@ -6025,10 +6027,10 @@ static int ice_set_loopback(struct ice_vsi *vsi, bool ena)
static int
ice_set_features(struct net_device *netdev, netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi;
struct ice_pf *pf = vsi->back;
+ netdev_features_t changed;
int ret = 0;
/* Don't set any netdev advanced features with device in Safe Mode */
@@ -6045,6 +6047,8 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
return -EBUSY;
}
+ netdev_features_xor(changed, netdev->features, features);
+
/* Multiple features can be changed in one call so keep features in
* separate if/else statements to guarantee each feature is checked
*/
@@ -2449,9 +2449,10 @@ static netdev_features_t igb_fix_features(struct net_device *netdev,
static int igb_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
struct igb_adapter *adapter = netdev_priv(netdev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
igb_vlan_mode(netdev, features);
@@ -4989,9 +4989,10 @@ static netdev_features_t igc_fix_features(struct net_device *netdev,
static int igc_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
struct igc_adapter *adapter = netdev_priv(netdev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
igc_vlan_mode(netdev, features);
@@ -311,8 +311,9 @@ static int
ixgb_set_features(struct net_device *netdev, netdev_features_t features)
{
struct ixgb_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (!(changed & NETIF_F_RXCSUM) && !(changed & NETIF_F_HW_VLAN_CTAG_RX))
return 0;
@@ -9871,9 +9871,11 @@ static int ixgbe_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = netdev->features ^ features;
+ netdev_features_t changed;
bool need_reset = false;
+ netdev_features_xor(changed, netdev->features, features);
+
/* Make sure RSC matches LRO, reset if change */
if (!(features & NETIF_F_LRO)) {
if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
@@ -5279,9 +5279,10 @@ static int mvpp2_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
static int mvpp2_set_features(struct net_device *dev,
netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
struct mvpp2_port *port = netdev_priv(dev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
if (features & NETIF_F_HW_VLAN_CTAG_FILTER) {
mvpp2_prs_vid_enable_filtering(port);
@@ -1769,11 +1769,12 @@ EXPORT_SYMBOL(otx2_get_max_mtu);
int otx2_handle_ntuple_tc_features(struct net_device *netdev, netdev_features_t features)
{
- netdev_features_t changed = features ^ netdev->features;
struct otx2_nic *pfvf = netdev_priv(netdev);
bool ntuple = !!(features & NETIF_F_NTUPLE);
bool tc = !!(features & NETIF_F_HW_TC);
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if ((changed & NETIF_F_NTUPLE) && !ntuple)
otx2_destroy_ntuple_flows(pfvf);
@@ -1933,9 +1933,10 @@ static void otx2_rx_mode_wrk_handler(struct work_struct *work)
static int otx2_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = features ^ netdev->features;
struct otx2_nic *pf = netdev_priv(netdev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if ((changed & NETIF_F_LOOPBACK) && netif_running(netdev))
return otx2_cgx_config_loopback(pf,
features & NETIF_F_LOOPBACK);
@@ -4335,8 +4335,9 @@ static netdev_features_t sky2_fix_features(struct net_device *dev,
static int sky2_set_features(struct net_device *dev, netdev_features_t features)
{
struct sky2_port *sky2 = netdev_priv(dev);
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if ((changed & NETIF_F_RXCSUM) &&
!(sky2->hw->flags & SKY2_HW_NEW_LE)) {
sky2_write32(sky2->hw,
@@ -2716,9 +2716,11 @@ static netdev_features_t mtk_fix_features(struct net_device *dev,
static int mtk_set_features(struct net_device *dev, netdev_features_t features)
{
+ netdev_features_t changed;
int err = 0;
- if (!((dev->features ^ features) & NETIF_F_LRO))
+ netdev_features_xor(changed, dev->features, features);
+ if (!(changed & NETIF_F_LRO))
return 0;
if (!(features & NETIF_F_LRO))
@@ -3842,10 +3842,11 @@ static int mlx5e_handle_feature(struct net_device *netdev,
unsigned short feature_bit,
mlx5e_feature_handler feature_handler)
{
- netdev_features_t changes = *features ^ netdev->features;
bool enable = netdev_feature_test(feature_bit, *features);
+ netdev_features_t changes;
int err;
+ netdev_features_xor(changes, netdev->features, *features);
if (!netdev_feature_test(feature_bit, changes))
return 0;
@@ -1220,10 +1220,11 @@ static int mlxsw_sp_handle_feature(struct net_device *dev,
int feature_bit,
mlxsw_sp_feature_handler feature_handler)
{
- netdev_features_t changes = wanted_features ^ dev->features;
bool enable = netdev_feature_test(feature_bit, wanted_features);
+ netdev_features_t changes;
int err;
+ netdev_features_xor(changes, dev->features, wanted_features);
if (!netdev_feature_test(feature_bit, changes))
return 0;
@@ -859,11 +859,12 @@ static void ocelot_vlan_mode(struct ocelot *ocelot, int port,
static int ocelot_set_features(struct net_device *dev,
netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->port.index;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if ((dev->features & NETIF_F_HW_TC) && !(features & NETIF_F_HW_TC) &&
priv->tc.offload_cnt) {
netdev_err(dev,
@@ -6571,8 +6571,9 @@ static void s2io_ethtool_get_strings(struct net_device *dev,
static int s2io_set_features(struct net_device *dev, netdev_features_t features)
{
struct s2io_nic *sp = netdev_priv(dev);
- netdev_features_t changed = features ^ dev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (changed & NETIF_F_LRO && netif_running(dev)) {
int rc;
@@ -1666,8 +1666,8 @@ static void nfp_net_stat64(struct net_device *netdev,
static int nfp_net_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = netdev->features ^ features;
struct nfp_net *nn = netdev_priv(netdev);
+ netdev_features_t changed;
u32 new_ctrl;
int err;
@@ -1675,6 +1675,7 @@ static int nfp_net_set_features(struct net_device *netdev,
new_ctrl = nn->dp.ctrl;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_RXCSUM) {
if (features & NETIF_F_RXCSUM)
new_ctrl |= nn->cap & NFP_NET_CFG_CTRL_RXCSUM_ANY;
@@ -4962,9 +4962,10 @@ static int nv_set_features(struct net_device *dev, netdev_features_t features)
{
struct fe_priv *np = netdev_priv(dev);
u8 __iomem *base = get_hwbase(dev);
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
int retval;
+ netdev_features_xor(changed, dev->features, features);
if ((changed & NETIF_F_LOOPBACK) && netif_running(dev)) {
retval = nv_set_loopback(dev, features);
if (retval != 0)
@@ -2206,8 +2206,9 @@ static int pch_gbe_set_features(struct net_device *netdev,
netdev_features_t features)
{
struct pch_gbe_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = features ^ netdev->features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (!(changed & NETIF_F_RXCSUM))
return 0;
@@ -539,7 +539,7 @@ static int netxen_set_features(struct net_device *dev,
netdev_features_t changed;
int hw_lro;
- changed = dev->features ^ features;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_LRO))
return 0;
@@ -925,9 +925,10 @@ netdev_features_t qede_fix_features(struct net_device *dev,
int qede_set_features(struct net_device *dev, netdev_features_t features)
{
struct qede_dev *edev = netdev_priv(dev);
- netdev_features_t changes = features ^ dev->features;
+ netdev_features_t changes;
bool need_reload = false;
+ netdev_features_xor(changes, dev->features, features);
if (changes & NETIF_F_GRO_HW)
need_reload = true;
@@ -1070,7 +1070,8 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev,
if (adapter->flags & QLCNIC_APP_CHANGED_FLAGS) {
features = qlcnic_process_flags(adapter, features);
} else {
- changed = features ^ netdev->features;
+ netdev_features_xor(changed, netdev->features,
+ features);
netdev_features_zero(changeable);
netdev_features_set_set(changeable,
NETIF_F_RXCSUM_BIT,
@@ -1079,7 +1080,7 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev,
NETIF_F_TSO_BIT,
NETIF_F_TSO6_BIT);
changed &= changeable;
- features ^= changed;
+ netdev_features_toggle(features, changed);
}
}
@@ -1093,9 +1094,10 @@ netdev_features_t qlcnic_fix_features(struct net_device *netdev,
int qlcnic_set_features(struct net_device *netdev, netdev_features_t features)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
- netdev_features_t changed = netdev->features ^ features;
int hw_lro = (features & NETIF_F_LRO) ? QLCNIC_LRO_ENABLED : 0;
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
if (!(changed & NETIF_F_LRO))
return 0;
@@ -176,9 +176,10 @@ static irqreturn_t emac_isr(int _irq, void *data)
static int emac_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = features ^ netdev->features;
struct emac_adapter *adpt = netdev_priv(netdev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, netdev->features, features);
/* We only need to reprogram the hardware if the VLAN tag features
* have changed, and if it's already running.
*/
@@ -1461,10 +1461,11 @@ static void cp_set_msglevel(struct net_device *dev, u32 value)
static int cp_set_features(struct net_device *dev, netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
struct cp_private *cp = netdev_priv(dev);
+ netdev_features_t changed;
unsigned long flags;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_RXCSUM))
return 0;
@@ -902,9 +902,10 @@ static int rtl8139_set_features(struct net_device *dev, netdev_features_t featur
{
struct rtl8139_private *tp = netdev_priv(dev);
unsigned long flags;
- netdev_features_t changed = features ^ dev->features;
+ netdev_features_t changed;
void __iomem *ioaddr = tp->mmio_addr;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_RXALL))
return 0;
@@ -2336,8 +2336,9 @@ static int ravb_set_features_gbeth(struct net_device *ndev,
static int ravb_set_features_rcar(struct net_device *ndev,
netdev_features_t features)
{
- netdev_features_t changed = ndev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, ndev->features, features);
if (changed & NETIF_F_RXCSUM)
ravb_set_rx_csum(ndev, features & NETIF_F_RXCSUM);
@@ -2932,9 +2932,10 @@ static void sh_eth_set_rx_csum(struct net_device *ndev, bool enable)
static int sh_eth_set_features(struct net_device *ndev,
netdev_features_t features)
{
- netdev_features_t changed = ndev->features ^ features;
struct sh_eth_private *mdp = netdev_priv(ndev);
+ netdev_features_t changed;
+ netdev_features_xor(changed, ndev->features, features);
if (changed & NETIF_F_RXCSUM && mdp->cd->rx_csum)
sh_eth_set_rx_csum(ndev, features & NETIF_F_RXCSUM);
@@ -1779,8 +1779,9 @@ static int sxgbe_set_features(struct net_device *dev,
netdev_features_t features)
{
struct sxgbe_priv_data *priv = netdev_priv(dev);
- netdev_features_t changed = dev->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, dev->features, features);
if (changed & NETIF_F_RXCSUM) {
if (features & NETIF_F_RXCSUM) {
priv->hw->mac->enable_rx_csum(priv->ioaddr);
@@ -227,7 +227,7 @@ int efx_set_features(struct net_device *net_dev, netdev_features_t data)
/* If Rx VLAN filter is changed, update filters via mac_reconfigure.
* If rx-fcs is changed, mac_reconfigure updates that too.
*/
- tmp = net_dev->features ^ data;
+ netdev_features_xor(tmp, net_dev->features, data);
if (tmp & NETIF_F_HW_VLAN_CTAG_FILTER ||
tmp & NETIF_F_RXFCS) {
/* efx_set_rx_mode() will schedule MAC work to update filters
@@ -2194,7 +2194,7 @@ static int ef4_set_features(struct net_device *net_dev, netdev_features_t data)
}
/* If Rx VLAN filter is changed, update filters via mac_reconfigure */
- tmp = net_dev->features ^ data;
+ netdev_features_xor(tmp, net_dev->features, data);
if (tmp & NETIF_F_HW_VLAN_CTAG_FILTER) {
/* ef4_set_rx_mode() will schedule MAC work to update filters
* when a new features are finally set in net_dev.
@@ -225,7 +225,7 @@ int efx_siena_set_features(struct net_device *net_dev, netdev_features_t data)
/* If Rx VLAN filter is changed, update filters via mac_reconfigure.
* If rx-fcs is changed, mac_reconfigure updates that too.
*/
- features = net_dev->features ^ data;
+ netdev_features_xor(features, net_dev->features, data);
if ((features & NETIF_F_HW_VLAN_CTAG_FILTER) || (features & NETIF_F_RXFCS)) {
/* efx_siena_set_rx_mode() will schedule MAC work to update filters
* when a new features are finally set in net_dev.
@@ -1922,16 +1922,17 @@ static netdev_features_t 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;
+ netdev_features_xor(change, ndev->features, features);
if (!(change & NETIF_F_LRO))
goto syncvf;
@@ -593,10 +593,11 @@ static int aqc111_set_features(struct net_device *net,
{
struct usbnet *dev = netdev_priv(net);
struct aqc111_data *aqc111_data = dev->driver_priv;
- netdev_features_t changed = net->features ^ features;
+ netdev_features_t changed;
u16 reg16 = 0;
u8 reg8 = 0;
+ netdev_features_xor(changed, net->features, features);
if (changed & NETIF_F_IP_CSUM) {
aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_TXCOE_CTL, 1, 1, ®8);
reg8 ^= SFR_TXCOE_TCP | SFR_TXCOE_UDP;
@@ -898,8 +898,9 @@ ax88179_set_features(struct net_device *net, netdev_features_t features)
{
u8 tmp;
struct usbnet *dev = netdev_priv(net);
- netdev_features_t changed = net->features ^ features;
+ netdev_features_t changed;
+ netdev_features_xor(changed, net->features, features);
if (changed & NETIF_F_IP_CSUM) {
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;
@@ -3255,14 +3255,16 @@ static void rtl_rx_vlan_en(struct r8152 *tp, bool enable)
static int rtl8152_set_features(struct net_device *dev,
netdev_features_t features)
{
- netdev_features_t changed = features ^ dev->features;
struct r8152 *tp = netdev_priv(dev);
+ netdev_features_t changed;
int ret;
ret = usb_autopm_get_interface(tp->intf);
if (ret < 0)
goto out;
+ netdev_features_xor(changed, dev->features, features);
+
mutex_lock(&tp->control);
if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
@@ -1471,10 +1471,11 @@ static netdev_features_t veth_fix_features(struct net_device *dev,
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;
+ netdev_features_xor(changed, dev->features, features);
if (!(changed & NETIF_F_GRO) || !(dev->flags & IFF_UP) || priv->_xdp_prog)
return 0;
@@ -3212,10 +3212,12 @@ static int virtnet_set_features(struct net_device *dev,
netdev_features_t features)
{
struct virtnet_info *vi = netdev_priv(dev);
+ netdev_features_t changed;
u64 offloads;
int err;
- if ((dev->features ^ features) & NETIF_F_GRO_HW) {
+ netdev_features_xor(changed, dev->features, features);
+ if (changed & NETIF_F_GRO_HW) {
if (vi->xdp_enabled)
return -EBUSY;
@@ -3231,7 +3233,7 @@ static int virtnet_set_features(struct net_device *dev,
vi->guest_offloads = offloads;
}
- if ((dev->features ^ features) & NETIF_F_RXHASH) {
+ if (changed & NETIF_F_RXHASH) {
if (features & NETIF_F_RXHASH)
vi->ctrl->rss.hash_types = vi->rss_hash_types_saved;
else
@@ -411,8 +411,8 @@ int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features)
{
struct vmxnet3_adapter *adapter = netdev_priv(netdev);
unsigned long flags;
- netdev_features_t changed = features ^ netdev->features;
netdev_features_t tun_offload_mask;
+ netdev_features_t changed;
u8 udp_tun_enabled;
netdev_features_zero(tun_offload_mask);
@@ -420,6 +420,7 @@ int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features)
netdev_feature_add(NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT, tun_offload_mask);
udp_tun_enabled = (netdev->features & tun_offload_mask) != 0;
+ netdev_features_xor(changed, netdev->features, features);
if (changed & NETIF_F_RXCSUM ||
changed & NETIF_F_LRO ||
changed & NETIF_F_HW_VLAN_CTAG_RX ||
@@ -6789,12 +6789,15 @@ static void qeth_check_restricted_features(struct qeth_card *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;
+ netdev_features_t diff1;
+ netdev_features_t diff2;
int rc = 0;
QETH_CARD_TEXT(card, 2, "setfeat");
QETH_CARD_HEX(card, 2, &features, sizeof(features));
+ netdev_features_xor(changed, dev->features, features);
if ((changed & NETIF_F_IP_CSUM)) {
rc = qeth_set_ipa_csum(card, features & NETIF_F_IP_CSUM,
IPA_OUTBOUND_CHECKSUM, QETH_PROT_IPV4,
@@ -6827,14 +6830,15 @@ int qeth_set_features(struct net_device *dev, netdev_features_t features)
netdev_feature_change(NETIF_F_TSO6_BIT, changed);
}
- qeth_check_restricted_features(card, dev->features ^ features,
- dev->features ^ changed);
+ netdev_features_xor(diff1, dev->features, features);
+ netdev_features_xor(diff2, dev->features, changed);
+ qeth_check_restricted_features(card, diff1, diff2);
/* everything changed successfully? */
- if ((dev->features ^ features) == changed)
+ if (diff1 == changed)
return 0;
/* something went wrong. save changed features and return error */
- dev->features ^= changed;
+ netdev_active_features_toggle(dev, changed);
return -EIO;
}
EXPORT_SYMBOL_GPL(qeth_set_features);
@@ -2270,9 +2270,10 @@ static int qlge_update_hw_vlan_features(struct net_device *ndev,
static int qlge_set_features(struct net_device *ndev,
netdev_features_t features)
{
- netdev_features_t changed = ndev->features ^ features;
+ netdev_features_t changed;
int err;
+ netdev_features_xor(changed, ndev->features, features);
if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
/* Update the behavior of vlan accel in the adapter */
err = qlge_update_hw_vlan_features(ndev, features);
@@ -9761,8 +9761,9 @@ 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_features_xor(diff, dev->features, features);
if (diff & NETIF_F_RX_UDP_TUNNEL_PORT) {
/* udp_tunnel_{get,drop}_rx_info both need
* NETIF_F_RX_UDP_TUNNEL_PORT enabled on the
@@ -162,7 +162,8 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
netdev_wanted_features_set(dev, tmp);
__netdev_update_features(dev);
- tmp = dev->wanted_features ^ dev->features;
+ netdev_features_xor(tmp, dev->wanted_features, dev->features);
+
if (tmp & valid)
ret |= ETHTOOL_F_WISH;
@@ -355,7 +356,7 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
NETIF_F_NTUPLE_BIT, NETIF_F_RXHASH_BIT);
/* allow changing only bits set in hw_features */
- changed = dev->features ^ features;
+ netdev_features_xor(changed, dev->features, features);
changed &= eth_all_features;
netdev_features_andnot(tmp, changed, dev->hw_features);
if (tmp)
Replace the 'f1 = f2 ^ f3' features expressions by netdev_features_xor helpers, and replace the 'f1 ^= f2' feautres expressions by netdev_features_toggle helpers. Signed-off-by: Jian Shen <shenjian15@huawei.com> --- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 4 +++- drivers/net/ethernet/asix/ax88796c_main.c | 3 ++- drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 3 ++- drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 3 ++- drivers/net/ethernet/atheros/atlx/atl2.c | 3 ++- drivers/net/ethernet/atheros/atlx/atlx.c | 3 ++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 +++++-- drivers/net/ethernet/broadcom/tg3.c | 3 ++- drivers/net/ethernet/brocade/bna/bnad.c | 3 ++- drivers/net/ethernet/cadence/macb_main.c | 4 +++- drivers/net/ethernet/calxeda/xgmac.c | 3 ++- drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 3 ++- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 3 ++- drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 3 ++- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 3 ++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 ++- .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 3 ++- drivers/net/ethernet/davicom/dm9000.c | 3 ++- drivers/net/ethernet/engleder/tsnep_main.c | 3 ++- drivers/net/ethernet/faraday/ftgmac100.c | 3 ++- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 3 ++- drivers/net/ethernet/freescale/enetc/enetc.c | 3 ++- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 3 ++- drivers/net/ethernet/freescale/fec_main.c | 6 ++++-- drivers/net/ethernet/freescale/gianfar_ethtool.c | 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 ++- drivers/net/ethernet/huawei/hinic/hinic_main.c | 10 ++++++++-- drivers/net/ethernet/ibm/ibmvnic.c | 3 ++- drivers/net/ethernet/intel/e100.c | 3 ++- drivers/net/ethernet/intel/e1000/e1000_main.c | 3 ++- drivers/net/ethernet/intel/e1000e/netdev.c | 3 ++- drivers/net/ethernet/intel/ice/ice_main.c | 10 +++++++--- drivers/net/ethernet/intel/igb/igb_main.c | 3 ++- drivers/net/ethernet/intel/igc/igc_main.c | 3 ++- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 3 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +++- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 3 ++- .../ethernet/marvell/octeontx2/nic/otx2_common.c | 3 ++- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 3 ++- drivers/net/ethernet/marvell/sky2.c | 3 ++- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 +++- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 ++- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 3 ++- drivers/net/ethernet/mscc/ocelot_net.c | 3 ++- drivers/net/ethernet/neterion/s2io.c | 3 ++- .../net/ethernet/netronome/nfp/nfp_net_common.c | 3 ++- drivers/net/ethernet/nvidia/forcedeth.c | 3 ++- .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 3 ++- .../net/ethernet/qlogic/netxen/netxen_nic_main.c | 2 +- drivers/net/ethernet/qlogic/qede/qede_filter.c | 3 ++- drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 8 +++++--- drivers/net/ethernet/qualcomm/emac/emac.c | 3 ++- drivers/net/ethernet/realtek/8139cp.c | 3 ++- drivers/net/ethernet/realtek/8139too.c | 3 ++- drivers/net/ethernet/renesas/ravb_main.c | 3 ++- drivers/net/ethernet/renesas/sh_eth.c | 3 ++- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 3 ++- drivers/net/ethernet/sfc/efx_common.c | 2 +- drivers/net/ethernet/sfc/falcon/efx.c | 2 +- drivers/net/ethernet/sfc/siena/efx_common.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 3 ++- drivers/net/usb/aqc111.c | 3 ++- drivers/net/usb/ax88179_178a.c | 3 ++- drivers/net/usb/r8152.c | 4 +++- drivers/net/veth.c | 3 ++- drivers/net/virtio_net.c | 6 ++++-- drivers/net/vmxnet3/vmxnet3_ethtool.c | 3 ++- drivers/s390/net/qeth_core_main.c | 14 +++++++++----- drivers/staging/qlge/qlge_main.c | 3 ++- net/core/dev.c | 3 ++- net/ethtool/ioctl.c | 5 +++-- 71 files changed, 173 insertions(+), 84 deletions(-)