Unverified Commit 195d7bd1 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!6257 HNS3: Do some optimizing job and support fast path

Merge Pull Request from: @mufengyan 
 
HNS3:Do some cleancode job and support fastpath

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


CVE: NA

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

1、Fix up magic numbers problems in ip table function, due to
the number 1 has meaning as not found.
2、Move assignment of value behind the judge, which leads to
return a error number.
3、Change the function which creates net device name from ubn
to ubl, aimed to be consistent with the protocol stack name.
Do some cleancode job to eliminate warnings,including
delete useless blank lines, Keep variable types consistent.
4、optimizes the unic bandwidth.
5、Solve the problem that the tc qdisc configuration in
 the hardware registration cannot be cleared.
6、Support configuration of fastpath feature and support debugfs dump
fastpath info.

Signed-off-by: default avatarFengyan Mu <mufengyan@hisilicon.com>
Signed-off-by: default avatarHaibin Lu <luhaibin10@hisilicon.com>
Signed-off-by: default avatarHaiqing Fang <fanghaiqing@huawei.com>
Signed-off-by: default avatarZihao Sheng <shengzihao1@huawei.com>
 
Link:https://gitee.com/openeuler/kernel/pulls/6257

 

Reviewed-by: default avatarLin Yunsheng <linyunsheng@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 4da80f1b 4c3ae347
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -387,6 +387,7 @@ enum hnae3_dbg_cmd {
	HNAE3_DBG_CMD_GUID_SPEC,
	HNAE3_DBG_CMD_IP_LIST,
	HNAE3_DBG_CMD_GUID_LIST,
	HNAE3_DBG_CMD_FASTPATH_INFO,
	HNAE3_DBG_CMD_UNKNOWN,
};

@@ -867,6 +868,7 @@ struct hnae3_ae_ops {
		       enum hnae3_unic_addr_type addr_type);
	int (*get_func_guid)(struct hnae3_handle *handle, u8 *guid);
	void (*set_func_guid)(struct hnae3_handle *handle, u8 *guid);
	int (*set_fastpath)(struct hnae3_ae_dev *ae_dev, bool fastpath_en);
};

struct hnae3_dcb_ops {
+1 −0
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ enum hclge_opcode_type {

	/* UB commands */
	HCLGE_OPC_COMM_GET_FUNC_GUID	= 0xA001,
	HCLGE_OPC_COMM_CFG_FASTPATH	= 0xA003,
	HCLGE_OPC_ADD_IP_TBL		= 0xA100,
	HCLGE_OPC_DEL_IP_TBL		= 0xA101,
	HCLGE_OPC_COMM_CFG_FUNC_GUID	= 0xA122,
+51 −21
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);
@@ -3456,6 +3454,23 @@ static void hns3_remove(struct pci_dev *pdev)
	pci_set_drvdata(pdev, NULL);
}

#if IS_ENABLED(CONFIG_UB_UDMA_HNS3)
static int hns3_fastpath_configure(struct pci_dev *pdev, bool fastpath_en)
{
	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
	int ret;

	if (!hnae3_dev_udma_supported(ae_dev) || !ae_dev->ops->set_fastpath)
		return 0;

	rtnl_lock();
	ret = ae_dev->ops->set_fastpath(ae_dev, fastpath_en);
	rtnl_unlock();

	return ret;
}
#endif

/**
 * hns3_pci_sriov_configure
 * @pdev: pointer to a pci_dev structure
@@ -3466,6 +3481,7 @@ static void hns3_remove(struct pci_dev *pdev)
 **/
static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
{
	int num_vfs_pre;
	int ret;

	if (!(hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV))) {
@@ -3475,12 +3491,26 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)

	if (num_vfs) {
		ret = pci_enable_sriov(pdev, num_vfs);
		if (ret)
		if (ret) {
			dev_err(&pdev->dev, "SRIOV enable failed %d\n", ret);
		else
			return 0;
		}

#if IS_ENABLED(CONFIG_UB_UDMA_HNS3)
		ret = hns3_fastpath_configure(pdev, false);
		if (ret) {
			pci_disable_sriov(pdev);
			return 0;
		}
#endif

		return num_vfs;
	} else if (!pci_vfs_assigned(pdev)) {
		int num_vfs_pre = pci_num_vf(pdev);
#if IS_ENABLED(CONFIG_UB_UDMA_HNS3)
		(void)hns3_fastpath_configure(pdev, true);
#endif

		num_vfs_pre = pci_num_vf(pdev);

		pci_disable_sriov(pdev);
		hns3_clean_vf_config(pdev, num_vfs_pre);
@@ -4387,7 +4417,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
@@ -5660,7 +5690,7 @@ static int hns3_client_init(struct hnae3_handle *handle)
						    &max_rss_size);
#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(handle))
		netdev = alloc_ubndev_mq(sizeof(struct hns3_nic_priv), alloc_tqps);
		netdev = alloc_ubldev_mq(sizeof(struct hns3_nic_priv), alloc_tqps);
	else
		netdev = alloc_etherdev_mq(sizeof(struct hns3_nic_priv), alloc_tqps);
#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
+21 −4
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,
@@ -79,7 +79,6 @@ u8 hns3_unic_get_l3_type(struct net_device *netdev, u32 ol_info, u32 l234info)
	u32 l3_type;

	l3_type = hns3_get_l3_type(priv, l234info, ol_info);

	if (l3_type == HNS3_L3_TYPE_IPV4)
		return UB_IPV4_CFG_TYPE;
	else if (l3_type == HNS3_L3_TYPE_IPV6)
@@ -209,6 +208,8 @@ void hns3_unic_lp_setup_skb(struct sk_buff *skb)
void hns3_unic_lb_check_skb_data(struct hns3_enet_ring *ring,
				 struct sk_buff *skb)
{
#define HNS3_UNIC_DUMP_ROW_SIZE 16

	unsigned int nip_ctrl_len = sizeof(struct ub_nip_ctrl_fld);
	struct hns3_enet_tqp_vector *tqp_vector = ring->tqp_vector;
	struct net_device *ndev = skb->dev;
@@ -238,8 +239,8 @@ void hns3_unic_lb_check_skb_data(struct hns3_enet_ring *ring,
	if (is_success)
		tqp_vector->rx_group.total_packets++;
	else
		print_hex_dump(KERN_ERR, "ubn selftest:", DUMP_PREFIX_OFFSET,
			       16, 1, skb->data, len, true);
		print_hex_dump(KERN_ERR, "ubl selftest:", DUMP_PREFIX_OFFSET,
			       HNS3_UNIC_DUMP_ROW_SIZE, 1, skb->data, len, true);

	dev_kfree_skb_any(skb);
}
@@ -358,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;
}
Loading