Commit f6f25eeb authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'wangxun-fixes'



Jiawen Wu says:

====================
Wangxun fixes

Fixed some bugs when using ethtool to operate network devices.

v4 -> v5:
- Simplify if...else... to fix features.

v3 -> v4:
- Require both ctag and stag to be enabled or disabled.

v2 -> v3:
- Drop the first patch.

v1 -> v2:
- Factor out the same code.
- Remove statistics printing with more than 64 queues.
- Detail the commit logs to describe issues.
- Remove reset flag check in wx_update_stats().
- Change to set VLAN CTAG and STAG to be consistent.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 581073f6 1d3c6414
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1958,6 +1958,8 @@ int wx_sw_init(struct wx *wx)
		return -ENOMEM;
	}

	bitmap_zero(wx->state, WX_STATE_NBITS);

	return 0;
}
EXPORT_SYMBOL(wx_sw_init);
+52 −4
Original line number Diff line number Diff line
@@ -2690,15 +2690,63 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features)
		wx->rss_enabled = false;
	}

	if (changed &
	    (NETIF_F_HW_VLAN_CTAG_RX |
	     NETIF_F_HW_VLAN_STAG_RX))
	netdev->features = features;

	if (wx->mac.type == wx_mac_sp && changed & NETIF_F_HW_VLAN_CTAG_RX)
		wx->do_reset(netdev);
	else if (changed & (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER))
		wx_set_rx_mode(netdev);

	return 1;
	return 0;
}
EXPORT_SYMBOL(wx_set_features);

#define NETIF_VLAN_STRIPPING_FEATURES	(NETIF_F_HW_VLAN_CTAG_RX | \
					 NETIF_F_HW_VLAN_STAG_RX)

#define NETIF_VLAN_INSERTION_FEATURES	(NETIF_F_HW_VLAN_CTAG_TX | \
					 NETIF_F_HW_VLAN_STAG_TX)

#define NETIF_VLAN_FILTERING_FEATURES	(NETIF_F_HW_VLAN_CTAG_FILTER | \
					 NETIF_F_HW_VLAN_STAG_FILTER)

netdev_features_t wx_fix_features(struct net_device *netdev,
				  netdev_features_t features)
{
	netdev_features_t changed = netdev->features ^ features;
	struct wx *wx = netdev_priv(netdev);

	if (changed & NETIF_VLAN_STRIPPING_FEATURES) {
		if ((features & NETIF_VLAN_STRIPPING_FEATURES) != NETIF_VLAN_STRIPPING_FEATURES &&
		    (features & NETIF_VLAN_STRIPPING_FEATURES) != 0) {
			features &= ~NETIF_VLAN_STRIPPING_FEATURES;
			features |= netdev->features & NETIF_VLAN_STRIPPING_FEATURES;
			wx_err(wx, "802.1Q and 802.1ad VLAN stripping must be either both on or both off.");
		}
	}

	if (changed & NETIF_VLAN_INSERTION_FEATURES) {
		if ((features & NETIF_VLAN_INSERTION_FEATURES) != NETIF_VLAN_INSERTION_FEATURES &&
		    (features & NETIF_VLAN_INSERTION_FEATURES) != 0) {
			features &= ~NETIF_VLAN_INSERTION_FEATURES;
			features |= netdev->features & NETIF_VLAN_INSERTION_FEATURES;
			wx_err(wx, "802.1Q and 802.1ad VLAN insertion must be either both on or both off.");
		}
	}

	if (changed & NETIF_VLAN_FILTERING_FEATURES) {
		if ((features & NETIF_VLAN_FILTERING_FEATURES) != NETIF_VLAN_FILTERING_FEATURES &&
		    (features & NETIF_VLAN_FILTERING_FEATURES) != 0) {
			features &= ~NETIF_VLAN_FILTERING_FEATURES;
			features |= netdev->features & NETIF_VLAN_FILTERING_FEATURES;
			wx_err(wx, "802.1Q and 802.1ad VLAN filtering must be either both on or both off.");
		}
	}

	return features;
}
EXPORT_SYMBOL(wx_fix_features);

void wx_set_ring(struct wx *wx, u32 new_tx_count,
		 u32 new_rx_count, struct wx_ring *temp_ring)
{
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ int wx_setup_resources(struct wx *wx);
void wx_get_stats64(struct net_device *netdev,
		    struct rtnl_link_stats64 *stats);
int wx_set_features(struct net_device *netdev, netdev_features_t features);
netdev_features_t wx_fix_features(struct net_device *netdev,
				  netdev_features_t features);
void wx_set_ring(struct wx *wx, u32 new_tx_count,
		 u32 new_rx_count, struct wx_ring *temp_ring);

+22 −0
Original line number Diff line number Diff line
@@ -982,8 +982,13 @@ struct wx_hw_stats {
	u64 qmprc;
};

enum wx_state {
	WX_STATE_RESETTING,
	WX_STATE_NBITS,		/* must be last */
};
struct wx {
	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
	DECLARE_BITMAP(state, WX_STATE_NBITS);

	void *priv;
	u8 __iomem *hw_addr;
@@ -1071,6 +1076,8 @@ struct wx {
	u64 hw_csum_rx_good;
	u64 hw_csum_rx_error;
	u64 alloc_rx_buff_failed;

	void (*do_reset)(struct net_device *netdev);
};

#define WX_INTR_ALL (~0ULL)
@@ -1131,4 +1138,19 @@ static inline struct wx *phylink_to_wx(struct phylink_config *config)
	return container_of(config, struct wx, phylink_config);
}

static inline int wx_set_state_reset(struct wx *wx)
{
	u8 timeout = 50;

	while (test_and_set_bit(WX_STATE_RESETTING, wx->state)) {
		timeout--;
		if (!timeout)
			return -EBUSY;

		usleep_range(1000, 2000);
	}

	return 0;
}

#endif /* _WX_TYPE_H_ */
+13 −5
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ static int ngbe_set_ringparam(struct net_device *netdev,
	struct wx *wx = netdev_priv(netdev);
	u32 new_rx_count, new_tx_count;
	struct wx_ring *temp_ring;
	int i;
	int i, err = 0;

	new_tx_count = clamp_t(u32, ring->tx_pending, WX_MIN_TXD, WX_MAX_TXD);
	new_tx_count = ALIGN(new_tx_count, WX_REQ_TX_DESCRIPTOR_MULTIPLE);
@@ -64,6 +64,10 @@ static int ngbe_set_ringparam(struct net_device *netdev,
	    new_rx_count == wx->rx_ring_count)
		return 0;

	err = wx_set_state_reset(wx);
	if (err)
		return err;

	if (!netif_running(wx->netdev)) {
		for (i = 0; i < wx->num_tx_queues; i++)
			wx->tx_ring[i]->count = new_tx_count;
@@ -72,14 +76,16 @@ static int ngbe_set_ringparam(struct net_device *netdev,
		wx->tx_ring_count = new_tx_count;
		wx->rx_ring_count = new_rx_count;

		return 0;
		goto clear_reset;
	}

	/* allocate temporary buffer to store rings in */
	i = max_t(int, wx->num_tx_queues, wx->num_rx_queues);
	temp_ring = kvmalloc_array(i, sizeof(struct wx_ring), GFP_KERNEL);
	if (!temp_ring)
		return -ENOMEM;
	if (!temp_ring) {
		err = -ENOMEM;
		goto clear_reset;
	}

	ngbe_down(wx);

@@ -89,7 +95,9 @@ static int ngbe_set_ringparam(struct net_device *netdev,
	wx_configure(wx);
	ngbe_up(wx);

	return 0;
clear_reset:
	clear_bit(WX_STATE_RESETTING, wx->state);
	return err;
}

static int ngbe_set_channels(struct net_device *dev,
Loading