Commit c60b240e authored by Duanqiang Wen's avatar Duanqiang Wen
Browse files

net: wangxun: change netdev uc addr num maxmium

wangxun inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IBCARJ


CVE: NA

------------------------------

txgbe has 128 entries in mac table, so we will add new
uticast addr to mac table when netdev_uc_addr is less
than 128. Otherwise if netdev_uc_addr is more than 128,
we will open promisc mode to promise packets can be
received.
ngbe has 32 entries in mac table, so we will add new
unicast addr to mac table when netdev_uc_addr is less
than 32. Otherwise if netdev_uc_addr is more than 32,
we will open promisc mode to promise packets can be
received.

Signed-off-by: default avatarDuanqiang Wen <duanqiangwen@net-swift.com>
parent d4353bc9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -880,9 +880,9 @@ int ngbe_get_settings(struct net_device *netdev,
int ngbe_write_uc_addr_list(struct net_device *netdev, int pool);
void ngbe_full_sync_mac_table(struct ngbe_adapter *adapter);
int ngbe_add_mac_filter(struct ngbe_adapter *adapter,
				u8 *addr, u16 pool);
				const u8 *addr, u16 pool);
int ngbe_del_mac_filter(struct ngbe_adapter *adapter,
				u8 *addr, u16 pool);
				const u8 *addr, u16 pool);
int ngbe_available_rars(struct ngbe_adapter *adapter);
void ngbe_vlan_mode(struct net_device *, u32);

+23 −5
Original line number Diff line number Diff line
@@ -2841,7 +2841,7 @@ static void ngbe_mac_set_default_filter(struct ngbe_adapter *adapter,
			    NGBE_PSR_MAC_SWC_AD_H_AV);
}

int ngbe_add_mac_filter(struct ngbe_adapter *adapter, u8 *addr, u16 pool)
int ngbe_add_mac_filter(struct ngbe_adapter *adapter, const u8 *addr, u16 pool)
{
	struct ngbe_hw *hw = &adapter->hw;
	u32 i;
@@ -2877,7 +2877,7 @@ static void ngbe_flush_sw_mac_table(struct ngbe_adapter *adapter)
	ngbe_sync_mac_table(adapter);
}

int ngbe_del_mac_filter(struct ngbe_adapter *adapter, u8 *addr, u16 pool)
int ngbe_del_mac_filter(struct ngbe_adapter *adapter, const u8 *addr, u16 pool)
{
	/* search table for addr, if found, set to 0 and sync */
	u32 i;
@@ -2900,6 +2900,25 @@ int ngbe_del_mac_filter(struct ngbe_adapter *adapter, u8 *addr, u16 pool)
	return -ENOMEM;
}

static int ngbe_uc_sync(struct net_device *netdev, const unsigned char *addr)
{
	struct ngbe_adapter *adapter = netdev_priv(netdev);
	int ret;

	ret = ngbe_add_mac_filter(adapter, addr, VMDQ_P(0));

	return min_t(int, ret, 0);
}

static int ngbe_uc_unsync(struct net_device *netdev, const unsigned char *addr)
{
	struct ngbe_adapter *adapter = netdev_priv(netdev);

	ngbe_del_mac_filter(adapter, addr, VMDQ_P(0));

	return 0;
}

/**
 * ngbe_write_uc_addr_list - write unicast addresses to RAR table
 * @netdev: network interface device structure
@@ -2995,10 +3014,9 @@ void ngbe_set_rx_mode(struct net_device *netdev)
	 * sufficient space to store all the addresses then enable
	 * unicast promiscuous mode
	 */
	count = ngbe_write_uc_addr_list(netdev, VMDQ_P(0));
	if (count < 0) {
	if (__dev_uc_sync(netdev, ngbe_uc_sync, ngbe_uc_unsync)) {
		vmolr &= ~NGBE_PSR_VM_L2CTL_ROPE;
		vmolr |= NGBE_PSR_VM_L2CTL_UPE;
		fctrl |= NGBE_PSR_CTL_UPE;
	}

	/*
+2 −2
Original line number Diff line number Diff line
@@ -987,9 +987,9 @@ int txgbe_get_settings(struct net_device *netdev,
int txgbe_write_uc_addr_list(struct net_device *netdev, int pool);
void txgbe_full_sync_mac_table(struct txgbe_adapter *adapter);
int txgbe_add_mac_filter(struct txgbe_adapter *adapter,
				u8 *addr, u16 pool);
				const u8 *addr, u16 pool);
int txgbe_del_mac_filter(struct txgbe_adapter *adapter,
				u8 *addr, u16 pool);
				const u8 *addr, u16 pool);
int txgbe_available_rars(struct txgbe_adapter *adapter);
void txgbe_vlan_mode(struct net_device *, u32);

+25 −5
Original line number Diff line number Diff line
@@ -3207,7 +3207,8 @@ static void txgbe_mac_set_default_filter(struct txgbe_adapter *adapter,
			    TXGBE_PSR_MAC_SWC_AD_H_AV);
}

int txgbe_add_mac_filter(struct txgbe_adapter *adapter, u8 *addr, u16 pool)
int txgbe_add_mac_filter(struct txgbe_adapter *adapter,
			 const u8 *addr, u16 pool)
{
	struct txgbe_hw *hw = &adapter->hw;
	u32 i;
@@ -3243,7 +3244,8 @@ static void txgbe_flush_sw_mac_table(struct txgbe_adapter *adapter)
	txgbe_sync_mac_table(adapter);
}

int txgbe_del_mac_filter(struct txgbe_adapter *adapter, u8 *addr, u16 pool)
int txgbe_del_mac_filter(struct txgbe_adapter *adapter,
			 const u8 *addr, u16 pool)
{
	/* search table for addr, if found, set to 0 and sync */
	u32 i;
@@ -3266,6 +3268,25 @@ int txgbe_del_mac_filter(struct txgbe_adapter *adapter, u8 *addr, u16 pool)
	return -ENOMEM;
}

static int txgbe_uc_sync(struct net_device *netdev, const unsigned char *addr)
{
	struct txgbe_adapter *adapter = netdev_priv(netdev);
	int ret;

	ret = txgbe_add_mac_filter(adapter, addr, VMDQ_P(0));

	return min_t(int, ret, 0);
}

static int txgbe_uc_unsync(struct net_device *netdev, const unsigned char *addr)
{
	struct txgbe_adapter *adapter = netdev_priv(netdev);

	txgbe_del_mac_filter(adapter, addr, VMDQ_P(0));

	return 0;
}

/**
 * txgbe_write_uc_addr_list - write unicast addresses to RAR table
 * @netdev: network interface device structure
@@ -3392,10 +3413,9 @@ void txgbe_set_rx_mode(struct net_device *netdev)
	 * sufficient space to store all the addresses then enable
	 * unicast promiscuous mode
	 */
	count = txgbe_write_uc_addr_list(netdev, VMDQ_P(0));
	if (count < 0) {
	if (__dev_uc_sync(netdev, txgbe_uc_sync, txgbe_uc_unsync)) {
		vmolr &= ~TXGBE_PSR_VM_L2CTL_ROPE;
		vmolr |= TXGBE_PSR_VM_L2CTL_UPE;
		fctrl |= TXGBE_PSR_CTL_UPE;
	}

	/*