Commit ab85539e authored by David S. Miller's avatar David S. Miller

Merge branch 'hns3-fixes'

Salil Mehta says:

====================
Misc bug fixes for HNS3 Ethernet driver

This patch-set presents some miscellaneous bug fixs and cleanups for
HNS3 Ethernet Driver.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b086ff87 dbecc779
...@@ -502,7 +502,7 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, ...@@ -502,7 +502,7 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
/* find outer header point */ /* find outer header point */
l3.hdr = skb_network_header(skb); l3.hdr = skb_network_header(skb);
l4_hdr = skb_inner_transport_header(skb); l4_hdr = skb_transport_header(skb);
if (skb->protocol == htons(ETH_P_IPV6)) { if (skb->protocol == htons(ETH_P_IPV6)) {
exthdr = l3.hdr + sizeof(*l3.v6); exthdr = l3.hdr + sizeof(*l3.v6);
......
...@@ -31,6 +31,17 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring) ...@@ -31,6 +31,17 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring)
return ring->desc_num - used - 1; return ring->desc_num - used - 1;
} }
static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int h)
{
int u = ring->next_to_use;
int c = ring->next_to_clean;
if (unlikely(h >= ring->desc_num))
return 0;
return u > c ? (h > c && h <= u) : (h > c || h <= u);
}
static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring) static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring)
{ {
int size = ring->desc_num * sizeof(struct hclge_desc); int size = ring->desc_num * sizeof(struct hclge_desc);
...@@ -141,6 +152,7 @@ static void hclge_cmd_init_regs(struct hclge_hw *hw) ...@@ -141,6 +152,7 @@ static void hclge_cmd_init_regs(struct hclge_hw *hw)
static int hclge_cmd_csq_clean(struct hclge_hw *hw) static int hclge_cmd_csq_clean(struct hclge_hw *hw)
{ {
struct hclge_dev *hdev = (struct hclge_dev *)hw->back;
struct hclge_cmq_ring *csq = &hw->cmq.csq; struct hclge_cmq_ring *csq = &hw->cmq.csq;
u16 ntc = csq->next_to_clean; u16 ntc = csq->next_to_clean;
struct hclge_desc *desc; struct hclge_desc *desc;
...@@ -149,6 +161,13 @@ static int hclge_cmd_csq_clean(struct hclge_hw *hw) ...@@ -149,6 +161,13 @@ static int hclge_cmd_csq_clean(struct hclge_hw *hw)
desc = &csq->desc[ntc]; desc = &csq->desc[ntc];
head = hclge_read_dev(hw, HCLGE_NIC_CSQ_HEAD_REG); head = hclge_read_dev(hw, HCLGE_NIC_CSQ_HEAD_REG);
rmb(); /* Make sure head is ready before touch any data */
if (!is_valid_csq_clean_head(csq, head)) {
dev_warn(&hdev->pdev->dev, "wrong head (%d, %d-%d)\n", head,
csq->next_to_use, csq->next_to_clean);
return 0;
}
while (head != ntc) { while (head != ntc) {
memset(desc, 0, sizeof(*desc)); memset(desc, 0, sizeof(*desc));
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/if_vlan.h>
#include "hclge_cmd.h" #include "hclge_cmd.h"
#include "hnae3.h" #include "hnae3.h"
...@@ -406,9 +408,9 @@ struct hclge_mac_stats { ...@@ -406,9 +408,9 @@ struct hclge_mac_stats {
u64 mac_tx_1519_2047_oct_pkt_num; u64 mac_tx_1519_2047_oct_pkt_num;
u64 mac_tx_2048_4095_oct_pkt_num; u64 mac_tx_2048_4095_oct_pkt_num;
u64 mac_tx_4096_8191_oct_pkt_num; u64 mac_tx_4096_8191_oct_pkt_num;
u64 mac_tx_8192_12287_oct_pkt_num; /* valid for GE MAC only */ u64 rsv0;
u64 mac_tx_8192_9216_oct_pkt_num; /* valid for LGE & CGE MAC only */ u64 mac_tx_8192_9216_oct_pkt_num;
u64 mac_tx_9217_12287_oct_pkt_num; /* valid for LGE & CGE MAC */ u64 mac_tx_9217_12287_oct_pkt_num;
u64 mac_tx_12288_16383_oct_pkt_num; u64 mac_tx_12288_16383_oct_pkt_num;
u64 mac_tx_1519_max_good_oct_pkt_num; u64 mac_tx_1519_max_good_oct_pkt_num;
u64 mac_tx_1519_max_bad_oct_pkt_num; u64 mac_tx_1519_max_bad_oct_pkt_num;
...@@ -433,9 +435,9 @@ struct hclge_mac_stats { ...@@ -433,9 +435,9 @@ struct hclge_mac_stats {
u64 mac_rx_1519_2047_oct_pkt_num; u64 mac_rx_1519_2047_oct_pkt_num;
u64 mac_rx_2048_4095_oct_pkt_num; u64 mac_rx_2048_4095_oct_pkt_num;
u64 mac_rx_4096_8191_oct_pkt_num; u64 mac_rx_4096_8191_oct_pkt_num;
u64 mac_rx_8192_12287_oct_pkt_num;/* valid for GE MAC only */ u64 rsv1;
u64 mac_rx_8192_9216_oct_pkt_num; /* valid for LGE & CGE MAC only */ u64 mac_rx_8192_9216_oct_pkt_num;
u64 mac_rx_9217_12287_oct_pkt_num; /* valid for LGE & CGE MAC only */ u64 mac_rx_9217_12287_oct_pkt_num;
u64 mac_rx_12288_16383_oct_pkt_num; u64 mac_rx_12288_16383_oct_pkt_num;
u64 mac_rx_1519_max_good_oct_pkt_num; u64 mac_rx_1519_max_good_oct_pkt_num;
u64 mac_rx_1519_max_bad_oct_pkt_num; u64 mac_rx_1519_max_bad_oct_pkt_num;
...@@ -471,6 +473,7 @@ struct hclge_vlan_type_cfg { ...@@ -471,6 +473,7 @@ struct hclge_vlan_type_cfg {
u16 tx_in_vlan_type; u16 tx_in_vlan_type;
}; };
#define HCLGE_VPORT_NUM 256
struct hclge_dev { struct hclge_dev {
struct pci_dev *pdev; struct pci_dev *pdev;
struct hnae3_ae_dev *ae_dev; struct hnae3_ae_dev *ae_dev;
...@@ -562,6 +565,7 @@ struct hclge_dev { ...@@ -562,6 +565,7 @@ struct hclge_dev {
u64 rx_pkts_for_led; u64 rx_pkts_for_led;
u64 tx_pkts_for_led; u64 tx_pkts_for_led;
unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)];
}; };
/* VPort level vlan tag configuration for TX direction */ /* VPort level vlan tag configuration for TX direction */
...@@ -646,8 +650,8 @@ static inline int hclge_get_queue_id(struct hnae3_queue *queue) ...@@ -646,8 +650,8 @@ static inline int hclge_get_queue_id(struct hnae3_queue *queue)
} }
int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex); int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex);
int hclge_set_vf_vlan_common(struct hclge_dev *vport, int vfid, int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
bool is_kill, u16 vlan, u8 qos, __be16 proto); u16 vlan_id, bool is_kill);
int hclge_buffer_alloc(struct hclge_dev *hdev); int hclge_buffer_alloc(struct hclge_dev *hdev);
int hclge_rss_init_hw(struct hclge_dev *hdev); int hclge_rss_init_hw(struct hclge_dev *hdev);
......
...@@ -264,19 +264,18 @@ static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport, ...@@ -264,19 +264,18 @@ static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_mbx_vf_to_pf_cmd *mbx_req,
bool gen_resp) bool gen_resp)
{ {
struct hclge_dev *hdev = vport->back;
int status = 0; int status = 0;
if (mbx_req->msg[1] == HCLGE_MBX_VLAN_FILTER) { if (mbx_req->msg[1] == HCLGE_MBX_VLAN_FILTER) {
struct hnae3_handle *handle = &vport->nic;
u16 vlan, proto; u16 vlan, proto;
bool is_kill; bool is_kill;
is_kill = !!mbx_req->msg[2]; is_kill = !!mbx_req->msg[2];
memcpy(&vlan, &mbx_req->msg[3], sizeof(vlan)); memcpy(&vlan, &mbx_req->msg[3], sizeof(vlan));
memcpy(&proto, &mbx_req->msg[5], sizeof(proto)); memcpy(&proto, &mbx_req->msg[5], sizeof(proto));
status = hclge_set_vf_vlan_common(hdev, vport->vport_id, status = hclge_set_vlan_filter(handle, cpu_to_be16(proto),
is_kill, vlan, 0, vlan, is_kill);
cpu_to_be16(proto));
} }
if (gen_resp) if (gen_resp)
......
...@@ -140,8 +140,11 @@ int hclge_mac_mdio_config(struct hclge_dev *hdev) ...@@ -140,8 +140,11 @@ int hclge_mac_mdio_config(struct hclge_dev *hdev)
struct mii_bus *mdio_bus; struct mii_bus *mdio_bus;
int ret; int ret;
if (hdev->hw.mac.phy_addr >= PHY_MAX_ADDR) if (hdev->hw.mac.phy_addr >= PHY_MAX_ADDR) {
return 0; dev_err(&hdev->pdev->dev, "phy_addr(%d) is too large.\n",
hdev->hw.mac.phy_addr);
return -EINVAL;
}
mdio_bus = devm_mdiobus_alloc(&hdev->pdev->dev); mdio_bus = devm_mdiobus_alloc(&hdev->pdev->dev);
if (!mdio_bus) if (!mdio_bus)
......
...@@ -134,11 +134,8 @@ static int hclge_pfc_stats_get(struct hclge_dev *hdev, ...@@ -134,11 +134,8 @@ static int hclge_pfc_stats_get(struct hclge_dev *hdev,
} }
ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM); ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM);
if (ret) { if (ret)
dev_err(&hdev->pdev->dev,
"Get pfc pause stats fail, ret = %d.\n", ret);
return ret; return ret;
}
for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) { for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) {
struct hclge_pfc_stats_cmd *pfc_stats = struct hclge_pfc_stats_cmd *pfc_stats =
......
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