Merge branch 'hns3-bug-fixes'

Salil Mehta says:

====================
Misc. Bug fixes for HNS3 Ethernet Driver

This patch-set fixes various bugs reported by community.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2017-08-18 10:31:56 -07:00
commit 66ff5fa08b
2 changed files with 59 additions and 40 deletions

View File

@ -436,7 +436,7 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen,
return 0; return 0;
} }
static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
u8 *il4_proto) u8 *il4_proto)
{ {
union { union {
@ -461,6 +461,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
&l4_proto_tmp, &frag_off); &l4_proto_tmp, &frag_off);
} else if (skb->protocol == htons(ETH_P_IP)) { } else if (skb->protocol == htons(ETH_P_IP)) {
l4_proto_tmp = l3.v4->protocol; l4_proto_tmp = l3.v4->protocol;
} else {
return -EINVAL;
} }
*ol4_proto = l4_proto_tmp; *ol4_proto = l4_proto_tmp;
@ -468,7 +470,7 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
/* tunnel packet */ /* tunnel packet */
if (!skb->encapsulation) { if (!skb->encapsulation) {
*il4_proto = 0; *il4_proto = 0;
return; return 0;
} }
/* find inner header point */ /* find inner header point */
@ -486,6 +488,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
} }
*il4_proto = l4_proto_tmp; *il4_proto = l4_proto_tmp;
return 0;
} }
static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto, static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto,
@ -757,7 +761,9 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
protocol = vlan_get_protocol(skb); protocol = vlan_get_protocol(skb);
skb->protocol = protocol; skb->protocol = protocol;
} }
hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto); ret = hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto);
if (ret)
return ret;
hns3_set_l2l3l4_len(skb, ol4_proto, il4_proto, hns3_set_l2l3l4_len(skb, ol4_proto, il4_proto,
&type_cs_vlan_tso, &type_cs_vlan_tso,
&ol_type_vlan_len_msec); &ol_type_vlan_len_msec);
@ -1054,6 +1060,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
/* fetch the tx stats */ /* fetch the tx stats */
ring = priv->ring_data[idx].ring; ring = priv->ring_data[idx].ring;
do { do {
start = u64_stats_fetch_begin_irq(&ring->syncp);
tx_bytes += ring->stats.tx_bytes; tx_bytes += ring->stats.tx_bytes;
tx_pkts += ring->stats.tx_pkts; tx_pkts += ring->stats.tx_pkts;
} while (u64_stats_fetch_retry_irq(&ring->syncp, start)); } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
@ -1061,6 +1068,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
/* fetch the rx stats */ /* fetch the rx stats */
ring = priv->ring_data[idx + queue_num].ring; ring = priv->ring_data[idx + queue_num].ring;
do { do {
start = u64_stats_fetch_begin_irq(&ring->syncp);
rx_bytes += ring->stats.rx_bytes; rx_bytes += ring->stats.rx_bytes;
rx_pkts += ring->stats.rx_pkts; rx_pkts += ring->stats.rx_pkts;
} while (u64_stats_fetch_retry_irq(&ring->syncp, start)); } while (u64_stats_fetch_retry_irq(&ring->syncp, start));

View File

@ -329,31 +329,41 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
} }
/* 2.media_type get from bios parameter block */ /* 2.media_type get from bios parameter block */
if (h->ae_algo->ops->get_media_type) if (h->ae_algo->ops->get_media_type) {
h->ae_algo->ops->get_media_type(h, &media_type); h->ae_algo->ops->get_media_type(h, &media_type);
switch (media_type) { switch (media_type) {
case HNAE3_MEDIA_TYPE_FIBER: case HNAE3_MEDIA_TYPE_FIBER:
cmd->base.port = PORT_FIBRE; cmd->base.port = PORT_FIBRE;
supported_caps = HNS3_LM_FIBRE_BIT | HNS3_LM_AUTONEG_BIT | supported_caps = HNS3_LM_FIBRE_BIT |
HNS3_LM_PAUSE_BIT | HNS3_LM_1000BASET_FULL_BIT; HNS3_LM_AUTONEG_BIT |
HNS3_LM_PAUSE_BIT |
HNS3_LM_1000BASET_FULL_BIT;
advertised_caps = supported_caps; advertised_caps = supported_caps;
break; break;
case HNAE3_MEDIA_TYPE_COPPER: case HNAE3_MEDIA_TYPE_COPPER:
cmd->base.port = PORT_TP; cmd->base.port = PORT_TP;
supported_caps = HNS3_LM_TP_BIT | HNS3_LM_AUTONEG_BIT | supported_caps = HNS3_LM_TP_BIT |
HNS3_LM_PAUSE_BIT | HNS3_LM_1000BASET_FULL_BIT | HNS3_LM_AUTONEG_BIT |
HNS3_LM_100BASET_FULL_BIT | HNS3_LM_100BASET_HALF_BIT | HNS3_LM_PAUSE_BIT |
HNS3_LM_10BASET_FULL_BIT | HNS3_LM_10BASET_HALF_BIT; HNS3_LM_1000BASET_FULL_BIT |
HNS3_LM_100BASET_FULL_BIT |
HNS3_LM_100BASET_HALF_BIT |
HNS3_LM_10BASET_FULL_BIT |
HNS3_LM_10BASET_HALF_BIT;
advertised_caps = supported_caps; advertised_caps = supported_caps;
break; break;
case HNAE3_MEDIA_TYPE_BACKPLANE: case HNAE3_MEDIA_TYPE_BACKPLANE:
cmd->base.port = PORT_NONE; cmd->base.port = PORT_NONE;
supported_caps = HNS3_LM_BACKPLANE_BIT | HNS3_LM_PAUSE_BIT | supported_caps = HNS3_LM_BACKPLANE_BIT |
HNS3_LM_AUTONEG_BIT | HNS3_LM_1000BASET_FULL_BIT | HNS3_LM_PAUSE_BIT |
HNS3_LM_100BASET_FULL_BIT | HNS3_LM_100BASET_HALF_BIT | HNS3_LM_AUTONEG_BIT |
HNS3_LM_10BASET_FULL_BIT | HNS3_LM_10BASET_HALF_BIT; HNS3_LM_1000BASET_FULL_BIT |
HNS3_LM_100BASET_FULL_BIT |
HNS3_LM_100BASET_HALF_BIT |
HNS3_LM_10BASET_FULL_BIT |
HNS3_LM_10BASET_HALF_BIT;
advertised_caps = supported_caps; advertised_caps = supported_caps;
break; break;
@ -368,6 +378,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
/* now, map driver link modes to ethtool link modes */ /* now, map driver link modes to ethtool link modes */
hns3_driv_to_eth_caps(supported_caps, cmd, false); hns3_driv_to_eth_caps(supported_caps, cmd, false);
hns3_driv_to_eth_caps(advertised_caps, cmd, true); hns3_driv_to_eth_caps(advertised_caps, cmd, true);
}
/* 3.mdix_ctrl&mdix get from phy reg */ /* 3.mdix_ctrl&mdix get from phy reg */
if (h->ae_algo->ops->get_mdix_mode) if (h->ae_algo->ops->get_mdix_mode)