Commit 84757d08 authored by Yonglong Liu's avatar Yonglong Liu Committed by Paolo Abeni

net: hns: fix wrong head when modify the tx feature when sending packets

Upon changing the tx feature, the hns driver will modify the
maybe_stop_tx() and fill_desc() functions, if the modify happens
during packet sending, will cause the hardware and software
pointers do not match, and the port can not work anymore.

This patch deletes the maybe_stop_tx() and fill_desc() functions
modification when setting tx feature, and use the skb_is_gro()
to determine which functions to use in the tx path.

Fixes: 38f616da ("net:hns: Add support of ethtool TSO set option for Hip06 in HNS")
Signed-off-by: default avatarYonglong Liu <liuyonglong@huawei.com>
Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent cbe860be
...@@ -142,7 +142,8 @@ MODULE_DEVICE_TABLE(acpi, hns_enet_acpi_match); ...@@ -142,7 +142,8 @@ MODULE_DEVICE_TABLE(acpi, hns_enet_acpi_match);
static void fill_desc(struct hnae_ring *ring, void *priv, static void fill_desc(struct hnae_ring *ring, void *priv,
int size, dma_addr_t dma, int frag_end, 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 *desc = &ring->desc[ring->next_to_use];
struct hnae_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use]; struct hnae_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use];
...@@ -275,6 +276,15 @@ static int hns_nic_maybe_stop_tso( ...@@ -275,6 +276,15 @@ static int hns_nic_maybe_stop_tso(
return 0; 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, static void fill_tso_desc(struct hnae_ring *ring, void *priv,
int size, dma_addr_t dma, int frag_end, 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)
...@@ -300,6 +310,19 @@ static void fill_tso_desc(struct hnae_ring *ring, void *priv, ...@@ -300,6 +310,19 @@ static void fill_tso_desc(struct hnae_ring *ring, void *priv,
mtu); 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, netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
struct sk_buff *skb, struct sk_buff *skb,
struct hns_nic_ring_data *ring_data) struct hns_nic_ring_data *ring_data)
...@@ -313,6 +336,7 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev, ...@@ -313,6 +336,7 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
int seg_num; int seg_num;
dma_addr_t dma; dma_addr_t dma;
int size, next_to_use; int size, next_to_use;
bool is_gso;
int i; int i;
switch (priv->ops.maybe_stop_tx(&skb, &buf_num, ring)) { switch (priv->ops.maybe_stop_tx(&skb, &buf_num, ring)) {
...@@ -339,8 +363,9 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev, ...@@ -339,8 +363,9 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
ring->stats.sw_err_cnt++; ring->stats.sw_err_cnt++;
goto out_err_tx_ok; goto out_err_tx_ok;
} }
is_gso = skb_is_gso(skb);
priv->ops.fill_desc(ring, skb, size, dma, seg_num == 1 ? 1 : 0, 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 */ /* fill the fragments */
for (i = 1; i < seg_num; i++) { for (i = 1; i < seg_num; i++) {
...@@ -354,7 +379,7 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev, ...@@ -354,7 +379,7 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
} }
priv->ops.fill_desc(ring, skb_frag_page(frag), size, dma, priv->ops.fill_desc(ring, skb_frag_page(frag), size, dma,
seg_num - 1 == i ? 1 : 0, buf_num, seg_num - 1 == i ? 1 : 0, buf_num,
DESC_TYPE_PAGE, ndev->mtu); DESC_TYPE_PAGE, ndev->mtu, is_gso);
} }
/*complete translate all packets*/ /*complete translate all packets*/
...@@ -1776,15 +1801,6 @@ static int hns_nic_set_features(struct net_device *netdev, ...@@ -1776,15 +1801,6 @@ static int hns_nic_set_features(struct net_device *netdev,
netdev_info(netdev, "enet v1 do not support tso!\n"); netdev_info(netdev, "enet v1 do not support tso!\n");
break; break;
default: 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_tso_max_size(netdev, 7 * 4096);
} else {
priv->ops.fill_desc = fill_v2_desc;
priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx;
}
break; break;
} }
netdev->features = features; netdev->features = features;
...@@ -2159,16 +2175,9 @@ static void hns_nic_set_priv_ops(struct net_device *netdev) ...@@ -2159,16 +2175,9 @@ static void hns_nic_set_priv_ops(struct net_device *netdev)
priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx; priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx;
} else { } else {
priv->ops.get_rxd_bnum = get_v2rx_desc_bnum; priv->ops.get_rxd_bnum = get_v2rx_desc_bnum;
if ((netdev->features & NETIF_F_TSO) || priv->ops.fill_desc = fill_desc_v2;
(netdev->features & NETIF_F_TSO6)) { priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx_v2;
priv->ops.fill_desc = fill_tso_desc; netif_set_tso_max_size(netdev, 7 * 4096);
priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tso;
/* This chip only support 7*4096 */
netif_set_tso_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 /* enable tso when init
* control tso on/off through TSE bit in bd * control tso on/off through TSE bit in bd
*/ */
......
...@@ -44,7 +44,8 @@ struct hns_nic_ring_data { ...@@ -44,7 +44,8 @@ struct hns_nic_ring_data {
struct hns_nic_ops { struct hns_nic_ops {
void (*fill_desc)(struct hnae_ring *ring, void *priv, void (*fill_desc)(struct hnae_ring *ring, void *priv,
int size, dma_addr_t dma, int frag_end, 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 (*maybe_stop_tx)(struct sk_buff **out_skb,
int *bnum, struct hnae_ring *ring); int *bnum, struct hnae_ring *ring);
void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum); void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment