Commit 1a292d7b authored by Haibin Lu's avatar Haibin Lu Committed by mufengyan
Browse files

HNS3: Modify the io process of unic to improve bandwidth

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


CVE: NA

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

This patch optimizes the unic bandwidth in the following aspects:

1.Unic does not have flow table and VLAN functions. However, these
functions are processed when desc field is filled in the TX direction.
This patch deletes the unnecessary steps.
2.Add necessary unlikely() in the TX direction.
3.In the RX direction, reduce the length of pull_len to reduce the impact
of memcpy on the performance.

Signed-off-by: default avatarHaibin Lu <luhaibin10@hisilicon.com>
parent 9d1c9c54
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -1782,16 +1782,7 @@ static bool hns3_check_hw_tx_csum(struct sk_buff *skb)
	return true;
}

struct hns3_desc_param {
	u32 paylen_fdop_ol4cs;
	u32 ol_type_vlan_len_msec;
	u32 type_cs_vlan_tso;
	u16 mss_hw_csum;
	u16 inner_vtag;
	u16 out_vtag;
};

static void hns3_init_desc_data(struct sk_buff *skb, struct hns3_desc_param *pa)
void hns3_init_desc_data(struct sk_buff *skb, struct hns3_desc_param *pa)
{
	pa->paylen_fdop_ol4cs = skb->len;
	pa->ol_type_vlan_len_msec = 0;
@@ -1918,10 +1909,6 @@ static int hns3_fill_skb_desc(struct hns3_nic_priv *priv,
	}

	/* Set txbd */
#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(priv->ae_handle))
		hns3_unic_set_l3_type(skb, &param.type_cs_vlan_tso);
#endif
	desc->tx.ol_type_vlan_len_msec =
		cpu_to_le32(param.ol_type_vlan_len_msec);
	desc->tx.type_cs_vlan_tso_len = cpu_to_le32(param.type_cs_vlan_tso);
@@ -2534,8 +2521,19 @@ static int hns3_handle_skb_desc(struct hns3_nic_priv *priv,
{
	int ret;

#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(priv->ae_handle))
		ret = hns3_unic_fill_skb_desc(priv, ring, skb,
					      &ring->desc[ring->next_to_use],
					      desc_cb);
	else
		ret = hns3_fill_skb_desc(priv, ring, skb,
					 &ring->desc[ring->next_to_use],
					 desc_cb);
#else
	ret = hns3_fill_skb_desc(priv, ring, skb,
				 &ring->desc[ring->next_to_use], desc_cb);
#endif
	if (unlikely(ret < 0))
		goto fill_err;

@@ -2585,7 +2583,7 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
	}
#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(hns3_get_handle(netdev))) {
		if (!ubl_rmv_sw_ctype(skb))
		if (unlikely(!ubl_rmv_sw_ctype(skb)))
			goto out_err_tx_ok;

		hns3_unic_set_default_cc(skb);
@@ -4387,7 +4385,7 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, unsigned int length,
	hns3_ring_stats_update(ring, seg_pkt_cnt);
#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(hns3_get_handle(netdev)))
		ring->pull_len = HNS3_RX_HEAD_SIZE;
		ring->pull_len = HNS3_UNIC_RX_HEAD_SIZE;
	else
		ring->pull_len = eth_get_headlen(netdev, va, HNS3_RX_HEAD_SIZE);
#else
+10 −0
Original line number Diff line number Diff line
@@ -693,6 +693,15 @@ struct hns3_reset_type_map {
	enum hnae3_reset_type rst_type;
};

struct hns3_desc_param {
	u32 paylen_fdop_ol4cs;
	u32 ol_type_vlan_len_msec;
	u32 type_cs_vlan_tso;
	u16 mss_hw_csum;
	u16 inner_vtag;
	u16 out_vtag;
};

static inline int ring_space(struct hns3_enet_ring *ring)
{
	/* This smp_load_acquire() pairs with smp_store_release() in
@@ -834,4 +843,5 @@ void hns3_cq_period_mode_init(struct hns3_nic_priv *priv,
void hns3_external_lb_prepare(struct net_device *ndev, bool if_running);
void hns3_external_lb_restore(struct net_device *ndev, bool if_running);
bool hns3_is_page_pool_enabled(void);
void hns3_init_desc_data(struct sk_buff *skb, struct hns3_desc_param *pa);
#endif
+17 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ int hns3_unic_init(struct net_device *netdev)
 * to actively inform the chip of the message type, which is unrelated
 * to checksum offloading.
 */
void hns3_unic_set_l3_type(struct sk_buff *skb, u32 *type_cs_vlan_tso)
static void hns3_unic_set_l3_type(struct sk_buff *skb, u32 *type_cs_vlan_tso)
{
	if (skb->protocol == htons(ETH_P_IP))
		hnae3_set_field(*type_cs_vlan_tso, HNS3_TXD_L3T_M,
@@ -359,3 +359,19 @@ int hns3_unic_init_guid(struct net_device *netdev)

	return 0;
}

int hns3_unic_fill_skb_desc(struct hns3_nic_priv *priv,
			    struct hns3_enet_ring *ring,
			    struct sk_buff *skb, struct hns3_desc *desc,
			    struct hns3_desc_cb *desc_cb)
{
	struct hns3_desc_param param;

	desc_cb->send_bytes = skb->len;

	hns3_init_desc_data(skb, &param);
	hns3_unic_set_l3_type(skb, &param.type_cs_vlan_tso);
	desc->tx.type_cs_vlan_tso_len = cpu_to_le32(param.type_cs_vlan_tso);

	return 0;
}
+5 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "ubl.h"

#define UNIC_CC_DEFAULT_FECN_MODE 0x4000
#define HNS3_UNIC_RX_HEAD_SIZE 128

struct ub_nip_ctrl_fld {
	__be16 proto;
@@ -52,7 +53,6 @@ static inline void hns3_unic_format_sim_guid_addr(char *format_simple_guid_addr,

void hns3_unic_set_default_cc(struct sk_buff *skb);
int hns3_unic_init(struct net_device *netdev);
void hns3_unic_set_l3_type(struct sk_buff *skb, u32 *type_cs_vlan_tso);
u8 hns3_unic_get_l3_type(struct net_device *netdev, u32 ol_info, u32 l234info);
void hns3_unic_lp_setup_skb(struct sk_buff *skb);
void hns3_unic_lb_check_skb_data(struct hns3_enet_ring *ring,
@@ -61,5 +61,9 @@ void register_ipaddr_notifier(void);
void unregister_ipaddr_notifier(void);
void hns3_unic_set_rx_mode(struct net_device *netdev);
int hns3_unic_init_guid(struct net_device *netdev);
int hns3_unic_fill_skb_desc(struct hns3_nic_priv *priv,
			    struct hns3_enet_ring *ring,
			    struct sk_buff *skb, struct hns3_desc *desc,
			    struct hns3_desc_cb *desc_cb);

#endif