forked from Minki/linux
Merge branch 'net-hns3-add-some-fixes-for-net'
Guangbin Huang says: ==================== net: hns3: add some fixes for -net This series adds some fixes for the HNS3 ethernet driver. ==================== Link: https://lore.kernel.org/r/1629976921-43438-1-git-send-email-huangguangbin2@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
57f8178292
@ -938,20 +938,19 @@ static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hns3_dbg_get_cmd_index(struct hnae3_handle *handle,
|
||||
const unsigned char *name, u32 *index)
|
||||
static int hns3_dbg_get_cmd_index(struct hns3_dbg_data *dbg_data, u32 *index)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) {
|
||||
if (!strncmp(name, hns3_dbg_cmd[i].name,
|
||||
strlen(hns3_dbg_cmd[i].name))) {
|
||||
if (hns3_dbg_cmd[i].cmd == dbg_data->cmd) {
|
||||
*index = i;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
dev_err(&handle->pdev->dev, "unknown command(%s)\n", name);
|
||||
dev_err(&dbg_data->handle->pdev->dev, "unknown command(%d)\n",
|
||||
dbg_data->cmd);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -1019,8 +1018,7 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
|
||||
u32 index;
|
||||
int ret;
|
||||
|
||||
ret = hns3_dbg_get_cmd_index(handle, filp->f_path.dentry->d_iname,
|
||||
&index);
|
||||
ret = hns3_dbg_get_cmd_index(dbg_data, &index);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -1090,6 +1088,7 @@ static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd)
|
||||
char name[HNS3_DBG_FILE_NAME_LEN];
|
||||
|
||||
data[i].handle = handle;
|
||||
data[i].cmd = hns3_dbg_cmd[cmd].cmd;
|
||||
data[i].qid = i;
|
||||
sprintf(name, "%s%u", hns3_dbg_cmd[cmd].name, i);
|
||||
debugfs_create_file(name, 0400, entry_dir, &data[i],
|
||||
@ -1110,6 +1109,7 @@ hns3_dbg_common_file_init(struct hnae3_handle *handle, u32 cmd)
|
||||
return -ENOMEM;
|
||||
|
||||
data->handle = handle;
|
||||
data->cmd = hns3_dbg_cmd[cmd].cmd;
|
||||
entry_dir = hns3_dbg_dentry[hns3_dbg_cmd[cmd].dentry].dentry;
|
||||
debugfs_create_file(hns3_dbg_cmd[cmd].name, 0400, entry_dir,
|
||||
data, &hns3_dbg_fops);
|
||||
|
@ -22,6 +22,7 @@ struct hns3_dbg_item {
|
||||
|
||||
struct hns3_dbg_data {
|
||||
struct hnae3_handle *handle;
|
||||
enum hnae3_dbg_cmd cmd;
|
||||
u16 qid;
|
||||
};
|
||||
|
||||
|
@ -573,9 +573,13 @@ static void hclge_cmd_uninit_regs(struct hclge_hw *hw)
|
||||
|
||||
void hclge_cmd_uninit(struct hclge_dev *hdev)
|
||||
{
|
||||
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
|
||||
/* wait to ensure that the firmware completes the possible left
|
||||
* over commands.
|
||||
*/
|
||||
msleep(HCLGE_CMDQ_CLEAR_WAIT_TIME);
|
||||
spin_lock_bh(&hdev->hw.cmq.csq.lock);
|
||||
spin_lock(&hdev->hw.cmq.crq.lock);
|
||||
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
|
||||
hclge_cmd_uninit_regs(&hdev->hw);
|
||||
spin_unlock(&hdev->hw.cmq.crq.lock);
|
||||
spin_unlock_bh(&hdev->hw.cmq.csq.lock);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "hnae3.h"
|
||||
|
||||
#define HCLGE_CMDQ_TX_TIMEOUT 30000
|
||||
#define HCLGE_CMDQ_CLEAR_WAIT_TIME 200
|
||||
#define HCLGE_DESC_DATA_LEN 6
|
||||
|
||||
struct hclge_dev;
|
||||
@ -270,6 +271,9 @@ enum hclge_opcode_type {
|
||||
/* Led command */
|
||||
HCLGE_OPC_LED_STATUS_CFG = 0xB000,
|
||||
|
||||
/* clear hardware resource command */
|
||||
HCLGE_OPC_CLEAR_HW_RESOURCE = 0x700B,
|
||||
|
||||
/* NCL config command */
|
||||
HCLGE_OPC_QUERY_NCL_CONFIG = 0x7011,
|
||||
|
||||
|
@ -255,21 +255,12 @@ static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
|
||||
u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC];
|
||||
struct hclge_vport *vport = hclge_get_vport(h);
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
u8 i, j, pfc_map, *prio_tc;
|
||||
int ret;
|
||||
u8 i;
|
||||
|
||||
memset(pfc, 0, sizeof(*pfc));
|
||||
pfc->pfc_cap = hdev->pfc_max;
|
||||
prio_tc = hdev->tm_info.prio_tc;
|
||||
pfc_map = hdev->tm_info.hw_pfc_map;
|
||||
|
||||
/* Pfc setting is based on TC */
|
||||
for (i = 0; i < hdev->tm_info.num_tc; i++) {
|
||||
for (j = 0; j < HNAE3_MAX_USER_PRIO; j++) {
|
||||
if ((prio_tc[j] == i) && (pfc_map & BIT(i)))
|
||||
pfc->pfc_en |= BIT(j);
|
||||
}
|
||||
}
|
||||
pfc->pfc_en = hdev->tm_info.pfc_en;
|
||||
|
||||
ret = hclge_pfc_tx_stats_get(hdev, requests);
|
||||
if (ret)
|
||||
|
@ -1550,6 +1550,7 @@ static int hclge_configure(struct hclge_dev *hdev)
|
||||
hdev->tm_info.hw_pfc_map = 0;
|
||||
hdev->wanted_umv_size = cfg.umv_space;
|
||||
hdev->tx_spare_buf_size = cfg.tx_spare_buf_size;
|
||||
hdev->gro_en = true;
|
||||
if (cfg.vlan_fliter_cap == HCLGE_VLAN_FLTR_CAN_MDF)
|
||||
set_bit(HNAE3_DEV_SUPPORT_VLAN_FLTR_MDF_B, ae_dev->caps);
|
||||
|
||||
@ -1618,7 +1619,7 @@ static int hclge_config_tso(struct hclge_dev *hdev, u16 tso_mss_min,
|
||||
return hclge_cmd_send(&hdev->hw, &desc, 1);
|
||||
}
|
||||
|
||||
static int hclge_config_gro(struct hclge_dev *hdev, bool en)
|
||||
static int hclge_config_gro(struct hclge_dev *hdev)
|
||||
{
|
||||
struct hclge_cfg_gro_status_cmd *req;
|
||||
struct hclge_desc desc;
|
||||
@ -1630,7 +1631,7 @@ static int hclge_config_gro(struct hclge_dev *hdev, bool en)
|
||||
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_GRO_GENERIC_CONFIG, false);
|
||||
req = (struct hclge_cfg_gro_status_cmd *)desc.data;
|
||||
|
||||
req->gro_en = en ? 1 : 0;
|
||||
req->gro_en = hdev->gro_en ? 1 : 0;
|
||||
|
||||
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
|
||||
if (ret)
|
||||
@ -2952,12 +2953,12 @@ static void hclge_update_link_status(struct hclge_dev *hdev)
|
||||
}
|
||||
|
||||
if (state != hdev->hw.mac.link) {
|
||||
hdev->hw.mac.link = state;
|
||||
client->ops->link_status_change(handle, state);
|
||||
hclge_config_mac_tnl_int(hdev, state);
|
||||
if (rclient && rclient->ops->link_status_change)
|
||||
rclient->ops->link_status_change(rhandle, state);
|
||||
|
||||
hdev->hw.mac.link = state;
|
||||
hclge_push_link_status(hdev);
|
||||
}
|
||||
|
||||
@ -10073,7 +10074,11 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
|
||||
static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
|
||||
bool writen_to_tbl)
|
||||
{
|
||||
struct hclge_vport_vlan_cfg *vlan;
|
||||
struct hclge_vport_vlan_cfg *vlan, *tmp;
|
||||
|
||||
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node)
|
||||
if (vlan->vlan_id == vlan_id)
|
||||
return;
|
||||
|
||||
vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
|
||||
if (!vlan)
|
||||
@ -11443,6 +11448,28 @@ static void hclge_clear_resetting_state(struct hclge_dev *hdev)
|
||||
}
|
||||
}
|
||||
|
||||
static int hclge_clear_hw_resource(struct hclge_dev *hdev)
|
||||
{
|
||||
struct hclge_desc desc;
|
||||
int ret;
|
||||
|
||||
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CLEAR_HW_RESOURCE, false);
|
||||
|
||||
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
|
||||
/* This new command is only supported by new firmware, it will
|
||||
* fail with older firmware. Error value -EOPNOSUPP can only be
|
||||
* returned by older firmware running this command, to keep code
|
||||
* backward compatible we will override this value and return
|
||||
* success.
|
||||
*/
|
||||
if (ret && ret != -EOPNOTSUPP) {
|
||||
dev_err(&hdev->pdev->dev,
|
||||
"failed to clear hw resource, ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hclge_init_rxd_adv_layout(struct hclge_dev *hdev)
|
||||
{
|
||||
if (hnae3_ae_dev_rxd_adv_layout_supported(hdev->ae_dev))
|
||||
@ -11492,6 +11519,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
|
||||
if (ret)
|
||||
goto err_cmd_uninit;
|
||||
|
||||
ret = hclge_clear_hw_resource(hdev);
|
||||
if (ret)
|
||||
goto err_cmd_uninit;
|
||||
|
||||
ret = hclge_get_cap(hdev);
|
||||
if (ret)
|
||||
goto err_cmd_uninit;
|
||||
@ -11556,7 +11587,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
|
||||
goto err_mdiobus_unreg;
|
||||
}
|
||||
|
||||
ret = hclge_config_gro(hdev, true);
|
||||
ret = hclge_config_gro(hdev);
|
||||
if (ret)
|
||||
goto err_mdiobus_unreg;
|
||||
|
||||
@ -11937,7 +11968,7 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = hclge_config_gro(hdev, true);
|
||||
ret = hclge_config_gro(hdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -12671,8 +12702,15 @@ static int hclge_gro_en(struct hnae3_handle *handle, bool enable)
|
||||
{
|
||||
struct hclge_vport *vport = hclge_get_vport(handle);
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
bool gro_en_old = hdev->gro_en;
|
||||
int ret;
|
||||
|
||||
return hclge_config_gro(hdev, enable);
|
||||
hdev->gro_en = enable;
|
||||
ret = hclge_config_gro(hdev);
|
||||
if (ret)
|
||||
hdev->gro_en = gro_en_old;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void hclge_sync_promisc_mode(struct hclge_dev *hdev)
|
||||
|
@ -927,6 +927,7 @@ struct hclge_dev {
|
||||
unsigned long fd_bmap[BITS_TO_LONGS(MAX_FD_FILTER_NUM)];
|
||||
enum HCLGE_FD_ACTIVE_RULE_TYPE fd_active_type;
|
||||
u8 fd_en;
|
||||
bool gro_en;
|
||||
|
||||
u16 wanted_umv_size;
|
||||
/* max available unicast mac vlan space */
|
||||
|
@ -507,12 +507,17 @@ static void hclgevf_cmd_uninit_regs(struct hclgevf_hw *hw)
|
||||
|
||||
void hclgevf_cmd_uninit(struct hclgevf_dev *hdev)
|
||||
{
|
||||
set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state);
|
||||
/* wait to ensure that the firmware completes the possible left
|
||||
* over commands.
|
||||
*/
|
||||
msleep(HCLGEVF_CMDQ_CLEAR_WAIT_TIME);
|
||||
spin_lock_bh(&hdev->hw.cmq.csq.lock);
|
||||
spin_lock(&hdev->hw.cmq.crq.lock);
|
||||
set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state);
|
||||
hclgevf_cmd_uninit_regs(&hdev->hw);
|
||||
spin_unlock(&hdev->hw.cmq.crq.lock);
|
||||
spin_unlock_bh(&hdev->hw.cmq.csq.lock);
|
||||
|
||||
hclgevf_free_cmd_desc(&hdev->hw.cmq.csq);
|
||||
hclgevf_free_cmd_desc(&hdev->hw.cmq.crq);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "hnae3.h"
|
||||
|
||||
#define HCLGEVF_CMDQ_TX_TIMEOUT 30000
|
||||
#define HCLGEVF_CMDQ_CLEAR_WAIT_TIME 200
|
||||
#define HCLGEVF_CMDQ_RX_INVLD_B 0
|
||||
#define HCLGEVF_CMDQ_RX_OUTVLD_B 1
|
||||
|
||||
|
@ -506,10 +506,10 @@ void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state)
|
||||
link_state =
|
||||
test_bit(HCLGEVF_STATE_DOWN, &hdev->state) ? 0 : link_state;
|
||||
if (link_state != hdev->hw.mac.link) {
|
||||
hdev->hw.mac.link = link_state;
|
||||
client->ops->link_status_change(handle, !!link_state);
|
||||
if (rclient && rclient->ops->link_status_change)
|
||||
rclient->ops->link_status_change(rhandle, !!link_state);
|
||||
hdev->hw.mac.link = link_state;
|
||||
}
|
||||
|
||||
clear_bit(HCLGEVF_STATE_LINK_UPDATING, &hdev->state);
|
||||
@ -2487,6 +2487,8 @@ static int hclgevf_configure(struct hclgevf_dev *hdev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
hdev->gro_en = true;
|
||||
|
||||
ret = hclgevf_get_basic_info(hdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
@ -2549,7 +2551,7 @@ static int hclgevf_init_roce_base_info(struct hclgevf_dev *hdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hclgevf_config_gro(struct hclgevf_dev *hdev, bool en)
|
||||
static int hclgevf_config_gro(struct hclgevf_dev *hdev)
|
||||
{
|
||||
struct hclgevf_cfg_gro_status_cmd *req;
|
||||
struct hclgevf_desc desc;
|
||||
@ -2562,7 +2564,7 @@ static int hclgevf_config_gro(struct hclgevf_dev *hdev, bool en)
|
||||
false);
|
||||
req = (struct hclgevf_cfg_gro_status_cmd *)desc.data;
|
||||
|
||||
req->gro_en = en ? 1 : 0;
|
||||
req->gro_en = hdev->gro_en ? 1 : 0;
|
||||
|
||||
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
|
||||
if (ret)
|
||||
@ -3308,7 +3310,7 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = hclgevf_config_gro(hdev, true);
|
||||
ret = hclgevf_config_gro(hdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -3389,7 +3391,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
|
||||
if (ret)
|
||||
goto err_config;
|
||||
|
||||
ret = hclgevf_config_gro(hdev, true);
|
||||
ret = hclgevf_config_gro(hdev);
|
||||
if (ret)
|
||||
goto err_config;
|
||||
|
||||
@ -3638,8 +3640,15 @@ void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed,
|
||||
static int hclgevf_gro_en(struct hnae3_handle *handle, bool enable)
|
||||
{
|
||||
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
||||
bool gro_en_old = hdev->gro_en;
|
||||
int ret;
|
||||
|
||||
return hclgevf_config_gro(hdev, enable);
|
||||
hdev->gro_en = enable;
|
||||
ret = hclgevf_config_gro(hdev);
|
||||
if (ret)
|
||||
hdev->gro_en = gro_en_old;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void hclgevf_get_media_type(struct hnae3_handle *handle, u8 *media_type,
|
||||
|
@ -310,6 +310,8 @@ struct hclgevf_dev {
|
||||
u16 *vector_status;
|
||||
int *vector_irq;
|
||||
|
||||
bool gro_en;
|
||||
|
||||
unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)];
|
||||
|
||||
struct hclgevf_mac_table_cfg mac_table;
|
||||
|
@ -323,8 +323,8 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev)
|
||||
flag = (u8)msg_q[5];
|
||||
|
||||
/* update upper layer with new link link status */
|
||||
hclgevf_update_link_status(hdev, link_status);
|
||||
hclgevf_update_speed_duplex(hdev, speed, duplex);
|
||||
hclgevf_update_link_status(hdev, link_status);
|
||||
|
||||
if (flag & HCLGE_MBX_PUSH_LINK_STATUS_EN)
|
||||
set_bit(HCLGEVF_STATE_PF_PUSH_LINK_STATUS,
|
||||
|
Loading…
Reference in New Issue
Block a user