Commit 90993e84 authored by Peiyang Wang's avatar Peiyang Wang Committed by Jiantao Xiao
Browse files

net: hns3: add arp proxy switch in ethtool

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8GQDK


CVE: NA

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

To use arp proxy more conviency, add an arp proxy switch in ethool. Use
followed command to open or close arp proxy:
ethtool --set-priv-flags <device_name> roh_arp_proxy_enable <on/off>

Use followed command to find current state of arp proxy switch:
ethtool --show-priv-flags <device_name>

The results are showed as followed:
...
roh_arp_proxy_enable: on

Upstream: Yes
Bugfix or Feature: Feature
AR20230919193847

Signed-off-by: default avatarPeiyang Wang <wangpeiyang1@huawei.com>
parent 0b68f477
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -984,6 +984,7 @@ enum hnae3_pflag {
	HNAE3_PFLAG_LIMIT_PROMISC,
	HNAE3_PFLAG_PUSH_ENABLE,
	HNAE3_PFLAG_FD_QB_ENABLE,
	HNAE3_PFLAG_ROH_ARP_PROXY_ENABLE,
	HNAE3_PFLAG_MAX
};

+11 −2
Original line number Diff line number Diff line
@@ -2589,7 +2589,9 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
		hns3_unic_set_default_cc(skb);
	}
#endif
	if (hns3_need_to_handle_roh_arp_req(skb))
	if (test_bit(HNAE3_PFLAG_ROH_ARP_PROXY_ENABLE,
		     &priv->ae_handle->priv_flags) &&
	    hns3_need_to_handle_roh_arp_req(skb))
		return hns3_handle_roh_arp_req(skb, priv);

	ret = hns3_handle_skb_desc(priv, ring, skb, desc_cb, ring->next_to_use);
@@ -4825,6 +4827,7 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget)
	if (tqp_vector->num_tqps > 1)
		rx_budget = max(budget / tqp_vector->num_tqps, 1);

	if (hnae3_check_roh_mac_type(priv->ae_handle))
		hns3_handle_roh_arp_reply(tqp_vector, priv);

	hns3_for_each_ring(ring, tqp_vector->rx_group) {
@@ -5627,6 +5630,12 @@ static void hns3_state_init(struct hnae3_handle *handle)

	if (hnae3_ae_dev_rxd_adv_layout_supported(ae_dev))
		set_bit(HNS3_NIC_STATE_RXD_ADV_LAYOUT_ENABLE, &priv->state);

	if (hnae3_check_roh_mac_type(handle)) {
		set_bit(HNAE3_PFLAG_ROH_ARP_PROXY_ENABLE,
			&handle->supported_pflags);
		set_bit(HNAE3_PFLAG_ROH_ARP_PROXY_ENABLE, &handle->priv_flags);
	}
}

static void hns3_state_uninit(struct hnae3_handle *handle)
+8 −0
Original line number Diff line number Diff line
@@ -523,10 +523,18 @@ static void hns3_update_push_state(struct net_device *netdev, bool enable)
	hns3_update_state(netdev, HNS3_NIC_STATE_TX_PUSH_ENABLE, enable);
}

static void hns3_update_roh_arp_proxy_enable(struct net_device *netdev,
					     bool enable)
{
	netdev_info(netdev, "%s roh arp proxy\n",
		    enable ? "enable" : "disable");
}

static const struct hns3_pflag_desc hns3_priv_flags[HNAE3_PFLAG_MAX] = {
	{ "limit_promisc",	hns3_update_limit_promisc_mode },
	{ "tx_push_enable",	hns3_update_push_state },
	{ "qb_enable",		hns3_update_fd_qb_state },
	{ "roh_arp_proxy_enable",	hns3_update_roh_arp_proxy_enable },
};

static int hns3_get_sset_count(struct net_device *netdev, int stringset)