Unverified Commit 7f325203 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1571 【openEuler-1.0-LTS】net: hns: fix wrong head when modify the tx feature when sending packets

Merge Pull Request from: @liuyonglong86 
 
This patch set fix wrong head when modify the tx feature when sending
packets problem and modify the driver version. 
 
Link:https://gitee.com/openeuler/kernel/pulls/1571

 

Reviewed-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents 5f3ca709 571ae661
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
#include <linux/phy.h>
#include <linux/types.h>

#define HNAE_DRIVER_VERSION "21.12.1"
#define HNAE_DRIVER_VERSION "23.7.1"
#define HNAE_DRIVER_NAME "hns"
#define HNAE_COPYRIGHT "Copyright(c) 2015 Huawei Corporation."
#define HNAE_DRIVER_STRING "Hisilicon Network Subsystem Driver"
+36 −24
Original line number Diff line number Diff line
@@ -147,7 +147,8 @@ MODULE_DEVICE_TABLE(acpi, hns_enet_acpi_match);

static void fill_desc(struct hnae_ring *ring, void *priv,
		      int size, dma_addr_t dma, int frag_end,
		      int buf_num, enum hns_desc_type type, int mtu)
		      int buf_num, enum hns_desc_type type, int mtu,
		      bool is_gso)
{
	struct hnae_desc *desc = &ring->desc[ring->next_to_use];
	struct hnae_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use];
@@ -280,6 +281,15 @@ static int hns_nic_maybe_stop_tso(
	return 0;
}

static int hns_nic_maybe_stop_tx_v2(struct sk_buff **out_skb, int *bnum,
				    struct hnae_ring *ring)
{
	if (skb_is_gso(*out_skb))
		return hns_nic_maybe_stop_tso(out_skb, bnum, ring);
	else
		return hns_nic_maybe_stop_tx(out_skb, bnum, ring);
}

static void fill_tso_desc(struct hnae_ring *ring, void *priv,
			  int size, dma_addr_t dma, int frag_end,
			  int buf_num, enum hns_desc_type type, int mtu)
@@ -305,6 +315,19 @@ static void fill_tso_desc(struct hnae_ring *ring, void *priv,
				mtu);
}

static void fill_desc_v2(struct hnae_ring *ring, void *priv,
			 int size, dma_addr_t dma, int frag_end,
			 int buf_num, enum hns_desc_type type, int mtu,
			 bool is_gso)
{
	if (is_gso)
		fill_tso_desc(ring, priv, size, dma, frag_end, buf_num, type,
			      mtu);
	else
		fill_v2_desc(ring, priv, size, dma, frag_end, buf_num, type,
			     mtu);
}

netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
				struct sk_buff *skb,
				struct hns_nic_ring_data *ring_data)
@@ -318,6 +341,7 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
	int seg_num;
	dma_addr_t dma;
	int size, next_to_use;
	bool is_gso;
	int i;

	switch (priv->ops.maybe_stop_tx(&skb, &buf_num, ring)) {
@@ -344,8 +368,9 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
		ring->stats.sw_err_cnt++;
		goto out_err_tx_ok;
	}
	is_gso = skb_is_gso(skb);
	priv->ops.fill_desc(ring, skb, size, dma, seg_num == 1 ? 1 : 0,
			    buf_num, DESC_TYPE_SKB, ndev->mtu);
			    buf_num, DESC_TYPE_SKB, ndev->mtu, is_gso);

	/* fill the fragments */
	for (i = 1; i < seg_num; i++) {
@@ -359,7 +384,7 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
		}
		priv->ops.fill_desc(ring, skb_frag_page(frag), size, dma,
				    seg_num - 1 == i ? 1 : 0, buf_num,
				    DESC_TYPE_PAGE, ndev->mtu);
				    DESC_TYPE_PAGE, ndev->mtu, is_gso);
	}

	/*complete translate all packets*/
@@ -965,8 +990,11 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,
		return 0; /* no data to poll */

	if (!is_valid_clean_head(ring, head)) {
		netdev_err(ndev, "wrong head (%d, %d-%d)\n", head,
			   ring->next_to_use, ring->next_to_clean);
		netdev_err(ndev, "wrong head (%u-%u, %u-%u) fbd:%u offset:%u\n",
			   readl_relaxed(ring->io_base + RCB_REG_TAIL), head,
			   ring->next_to_use, ring->next_to_clean,
			   readl_relaxed(ring->io_base + RCB_REG_FBDNUM),
			   readl_relaxed(ring->io_base + RCB_REG_OFFSET));
		ring->stats.io_err_cnt++;
		return -EIO;
	}
@@ -1816,15 +1844,6 @@ static int hns_nic_set_features(struct net_device *netdev,
			netdev_info(netdev, "enet v1 do not support tso!\n");
		break;
	default:
		if (features & (NETIF_F_TSO | NETIF_F_TSO6)) {
			priv->ops.fill_desc = fill_tso_desc;
			priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tso;
			/* The chip only support 7*4096 */
			netif_set_gso_max_size(netdev, 7 * 4096);
		} else {
			priv->ops.fill_desc = fill_v2_desc;
			priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx;
		}
		break;
	}
	netdev->features = features;
@@ -2264,16 +2283,9 @@ static void hns_nic_set_priv_ops(struct net_device *netdev)
		priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx;
	} else {
		priv->ops.get_rxd_bnum = get_v2rx_desc_bnum;
		if ((netdev->features & NETIF_F_TSO) ||
		    (netdev->features & NETIF_F_TSO6)) {
			priv->ops.fill_desc = fill_tso_desc;
			priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tso;
			/* This chip only support 7*4096 */
		priv->ops.fill_desc = fill_desc_v2;
		priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx_v2;
		netif_set_gso_max_size(netdev, 7 * 4096);
		} else {
			priv->ops.fill_desc = fill_v2_desc;
			priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx;
		}
		/* enable tso when init
		 * control tso on/off through TSE bit in bd
		 */
+2 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ struct hns_nic_ring_data {
struct hns_nic_ops {
	void (*fill_desc)(struct hnae_ring *ring, void *priv,
			  int size, dma_addr_t dma, int frag_end,
			  int buf_num, enum hns_desc_type type, int mtu);
			  int buf_num, enum hns_desc_type type, int mtu,
			  bool is_gso);
	int (*maybe_stop_tx)(struct sk_buff **out_skb,
			     int *bnum, struct hnae_ring *ring);
	void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

#define MDIO_DRV_NAME "Hi-HNS_MDIO"
#define MDIO_BUS_NAME "Hisilicon MII Bus"
#define MDIO_MOD_VERSION "21.12.1"
#define MDIO_MOD_VERSION "23.7.1"

#define MDIO_TIMEOUT			1000000