From: gaoxun gaoxun3@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA ---------------------------------------------------------- This patch is dedicated to solve some review issues: 1.bool type variables are initialized at declaration; 2.Pointer variables are properly initialized at declaration 3.Certain prevailing input paraemeters, 'priv' in specific, of pointer type whose associated memory is not expected to be modified in principle, is specified as a pointer to const data type; 4.Handle functions in cae_ext are renamed to present the code in a straightforward while informative manner;
Signed-off-by: gaoxun gaoxun3@huawei.com Reviewed-by: dengweiwei dengweiwei@huawei.com Reviewed-by:chenjunxin chenjunxin1@huawei.com Reviewed-by:youshengzui youshengzui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_checksum.c | 19 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_checksum.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_cmd.c | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_common.c | 19 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_common.h | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.c | 48 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.h | 11 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c | 17 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dfx.c | 32 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_dfx.h | 6 +- .../hisilicon/hns3/hns3_cae/hns3_cae_ext.c | 138 ++++++++++----------- .../hisilicon/hns3/hns3_cae/hns3_cae_ext.h | 2 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c | 56 ++++----- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_gro.c | 24 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_gro.h | 7 +- .../hns3/hns3_cae/hns3_cae_hilink_param.c | 16 ++- .../hns3/hns3_cae/hns3_cae_hilink_param.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_init.c | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_irq.c | 16 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_irq.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.c | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_led.c | 8 +- .../hisilicon/hns3/hns3_cae/hns3_cae_led.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.c | 27 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.h | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mac.c | 20 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_mac.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c | 45 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.c | 24 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_port.c | 18 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_port.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.c | 33 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c | 42 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h | 18 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_qos.c | 134 ++++++++++---------- .../hisilicon/hns3/hns3_cae/hns3_cae_qos.h | 19 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_qres.c | 29 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_qres.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.c | 28 ++--- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_rss.c | 47 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_rss.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_stat.c | 48 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_stat.h | 4 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c | 133 +++++++++----------- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h | 22 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_version.c | 32 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_version.h | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_vlan.c | 20 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_vlan.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c | 26 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 64 files changed, 628 insertions(+), 673 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index e153848..24a5846 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.30.0" +#define HNAE3_MOD_VERSION "1.9.32.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c index d29ea16..ef41194 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c @@ -15,7 +15,7 @@
static int hns3_cae_chs_set(struct hclge_dev *hdev, u8 chs_type, u8 enable) { - struct hns3_cae_chs_cmd_param *recv; + struct hns3_cae_chs_cmd_param *recv = NULL; struct hclge_desc desc; int ret;
@@ -58,7 +58,7 @@ static int hns3_cae_chs_set(struct hclge_dev *hdev, u8 chs_type, u8 enable)
static int hns3_cae_chs_get(struct hclge_dev *hdev, u8 chs_type, u8 *enable) { - struct hns3_cae_chs_cmd_param *recv; + struct hns3_cae_chs_cmd_param *recv = NULL; struct hclge_desc desc; u8 inner_sctp_en; u8 inner_tcp_en; @@ -109,17 +109,17 @@ static int hns3_cae_chs_get(struct hclge_dev *hdev, u8 chs_type, u8 *enable) return ret; }
-int hns3_cae_chs_cfg(struct hns3_nic_priv *net_priv, void *buf_in, +int hns3_cae_chs_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_chs_param *in_info; - struct hclge_vport *vport; - struct hclge_dev *hdev; - u8 *out_info; - bool check; + struct hns3_cae_chs_param *in_info = + (struct hns3_cae_chs_param *)buf_in; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; + u8 *out_info = NULL; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_chs_param); u8 is_set;
- check = !buf_in || in_size < sizeof(struct hns3_cae_chs_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -127,7 +127,6 @@ int hns3_cae_chs_cfg(struct hns3_nic_priv *net_priv, void *buf_in,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - in_info = (struct hns3_cae_chs_param *)buf_in; out_info = (u8 *)buf_out; is_set = in_info->is_set;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h index b890d755..7a4c230 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h @@ -43,6 +43,7 @@ struct hns3_cae_chs_param { u8 is_enable; };
-int hns3_cae_chs_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_chs_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c index 4c93fac..345d351 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c @@ -166,8 +166,8 @@ void hns3_cae_cmd_setup_basic_desc(struct hclge_desc *desc, **/ int hns3_cae_cmd_send(struct hclge_dev *hdev, struct hclge_desc *desc, int num) { - struct hclge_desc *desc_to_use; - struct hclge_cmq_ring *csq; + struct hclge_desc *desc_to_use = NULL; + struct hclge_cmq_ring *csq = NULL; bool complete = false; u32 timeout = 0; int handle = 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c index 34abfec..1c49f93 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c @@ -18,13 +18,13 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_common.h"
-static int hns3_cae_write_reg_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_write_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct reg_param *in_buf = (struct reg_param *)buf_in; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int ret;
@@ -52,7 +52,7 @@ static int hns3_cae_write_reg_cfg(struct hns3_nic_priv *net_priv, return 0; }
-static int hns3_cae_read_reg_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_read_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { @@ -61,10 +61,9 @@ static int hns3_cae_read_reg_cfg(struct hns3_nic_priv *net_priv, struct reg_param *in_buf = (struct reg_param *)buf_in; struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; + bool check = !buf_out || out_size < sizeof(struct reg_param); int ret;
- check = !buf_out || out_size < sizeof(struct reg_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -92,14 +91,14 @@ static int hns3_cae_read_reg_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_reg_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_reg_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { + bool check = !buf_in || in_size < sizeof(struct reg_param); struct reg_param *mode_param = (struct reg_param *)buf_in; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct reg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h index deb0de9..c9af908 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h @@ -20,6 +20,6 @@ struct reg_ret_param { u32 value[REG_RDATA_NUM]; };
-int hns3_cae_reg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size); +int hns3_cae_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c index 7abd5ff..fa6c6b4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c @@ -19,7 +19,7 @@
struct hns3_cae_dcb_info dcb_all_info[MAX_DEV_LISTED];
-static int check_and_set_curr_dev(struct hns3_nic_priv *net_priv) +static int check_and_set_curr_dev(const struct hns3_nic_priv *net_priv) { int i;
@@ -36,22 +36,22 @@ static int check_and_set_curr_dev(struct hns3_nic_priv *net_priv) return i; }
-int hns3_cae_dcb_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_dcb_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_dcb_cfg_param *out_info = NULL; - struct hns3_cae_dcb_cfg_param *in_info = NULL; + struct hns3_cae_dcb_cfg_param *out_info = + (struct hns3_cae_dcb_cfg_param *)buf_out; + struct hns3_cae_dcb_cfg_param *in_info = + (struct hns3_cae_dcb_cfg_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_dcb_cfg_param); int curr_dev_idx; - bool check;
- check = !buf_in || in_size < sizeof(struct hns3_cae_dcb_cfg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- in_info = (struct hns3_cae_dcb_cfg_param *)buf_in; - out_info = (struct hns3_cae_dcb_cfg_param *)buf_out; curr_dev_idx = check_and_set_curr_dev(net_priv); if (curr_dev_idx < 0) { pr_err("Exceed MAX_DEV_LISTED: %d\n", MAX_DEV_LISTED); @@ -155,21 +155,22 @@ static int hns3_cae_cfg_pause_param(struct hclge_dev *hdev, return 0; }
-int hns3_cae_dcb_pfc_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_pfc_cfg_param *out_info = NULL; - struct hns3_cae_pfc_cfg_param *in_info = NULL; + struct hns3_cae_pfc_cfg_param *out_info = + (struct hns3_cae_pfc_cfg_param *)buf_out; + struct hns3_cae_pfc_cfg_param *in_info = + (struct hns3_cae_pfc_cfg_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_pfc_cfg_param); struct hclge_vport *vport = NULL; struct net_device *ndev = NULL; struct hnae3_handle *h = NULL; struct hclge_dev *hdev = NULL; int curr_dev_idx; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_pfc_cfg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -184,8 +185,6 @@ int hns3_cae_dcb_pfc_cfg(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(h); ndev = h->netdev; hdev = vport->back; - in_info = (struct hns3_cae_pfc_cfg_param *)buf_in; - out_info = (struct hns3_cae_pfc_cfg_param *)buf_out;
if (!in_info->is_read && !dcb_all_info[curr_dev_idx].dcb_cfg_info.dcb_en) { @@ -311,25 +310,28 @@ static void hns3_cae_enable_ets_cfg(struct hclge_dev *hdev, } }
-int hns3_cae_dcb_ets_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define BYTELEN 4 - struct hns3_cae_ets_cfg_param *out_info = NULL; - struct hns3_cae_ets_cfg_param *in_info = NULL; + struct hns3_cae_ets_cfg_param *out_info = + (struct hns3_cae_ets_cfg_param *)buf_out; + struct hns3_cae_ets_cfg_param *in_info = + (struct hns3_cae_ets_cfg_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_cae_ets_cfg_param) || + !buf_out || + out_size < sizeof(struct hns3_cae_ets_cfg_param); struct hclge_vport *vport = NULL; struct net_device *ndev = NULL; struct hclge_dev *hdev = NULL; struct hnae3_handle *h = NULL; struct hclge_desc desc; int curr_dev_idx; - bool check; int ret; int i;
- check = !buf_in || in_size < sizeof(struct hns3_cae_ets_cfg_param) || - !buf_out || out_size < sizeof(struct hns3_cae_ets_cfg_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; @@ -344,8 +346,6 @@ int hns3_cae_dcb_ets_cfg(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(h); ndev = h->netdev; hdev = vport->back; - in_info = (struct hns3_cae_ets_cfg_param *)buf_in; - out_info = (struct hns3_cae_ets_cfg_param *)buf_out;
if (!in_info->is_read && !dcb_all_info[curr_dev_idx].dcb_cfg_info.dcb_en) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h index 86154c5..c9437f5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h @@ -51,18 +51,19 @@ struct hns3_cae_ets_cfg_param { };
struct hns3_cae_dcb_info { - struct hns3_nic_priv *net_priv; + const struct hns3_nic_priv *net_priv; struct hns3_cae_pfc_cfg_param pfc_cfg_info; struct hns3_cae_dcb_cfg_param dcb_cfg_info; struct hns3_cae_ets_cfg_param ets_cfg_info; };
-int hns3_cae_dcb_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_dcb_ets_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_dcb_pfc_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c index 2cf633a..fb7aafc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c @@ -13,12 +13,12 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_dcqcn.h"
-static int hns3_dcqcn_rw(struct hns3_nic_priv *net_priv, +static int hns3_dcqcn_rw(const struct hns3_nic_priv *net_priv, u32 offset, u32 *data, u32 rw_type) { struct hnae3_handle *h = net_priv->ae_handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int ret;
@@ -55,7 +55,7 @@ static int hns3_dcqcn_rw(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, +int hns3_nic_dcqcn(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define SCC_TEMP_CFG0 0x6000 @@ -64,16 +64,15 @@ int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, #define SCC_TEMP_CFG3 0x600c struct hnae3_handle *h = net_priv->ae_handle; struct hclge_vport *vport = container_of(h, struct hclge_vport, nic); + bool check = !buf_in || in_size < sizeof(struct cfg_dcqcn_param); struct cfg_dcqcn_param *parm_out = buf_out; struct cfg_dcqcn_param *parm_in = buf_in; struct cfg_dcqcn_param tempbuffer = {0}; struct hclge_dev *hdev = vport->back; u32 tempoutbuff; u32 offset; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct cfg_dcqcn_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -226,7 +225,7 @@ int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_dcqcn_get_msg_cnt(struct hns3_nic_priv *net_priv, +int hns3_dcqcn_get_msg_cnt(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { @@ -235,10 +234,10 @@ int hns3_dcqcn_get_msg_cnt(struct hns3_nic_priv *net_priv, struct dcqcn_statistic_param *statistic_parm_out = buf_out; struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; + bool check = !buf_out || + out_size < sizeof(struct dcqcn_statistic_param); int ret;
- check = !buf_out || out_size < sizeof(struct dcqcn_statistic_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h index 3ec9336..435f222 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h @@ -51,9 +51,10 @@ struct dcqcn_statistic_param { #define HIARM_DCQCN_READ_CFG_MODE 30 #define HIARM_DCQCN_WRITE_CFG_MODE 31
-int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_dcqcn_get_msg_cnt(struct hns3_nic_priv *net_priv, +int hns3_nic_dcqcn(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_dcqcn_get_msg_cnt(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c index c901243..6346c9a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c @@ -80,24 +80,24 @@ static int hns3_cae_get_chip_and_mac_id(struct hnae3_handle *handle, return 0; }
-int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HNS3_CAE_MAC_MODE_ADDR 0x10000000U #define HNS3_CAE_MAC_MAP_ADDR 0x10000008U - struct hns3_cae_dfx_param *out_info = NULL; + struct hns3_cae_dfx_param *out_info = + (struct hns3_cae_dfx_param *)buf_out; struct hns3_cae_reg_param reg_info; struct hnae3_handle *handle = NULL; struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; u32 chip_id; u32 mac_id; - bool check; + bool check = !buf_out || out_size < sizeof(struct hns3_cae_dfx_param); int ret; int i;
- check = !buf_out || out_size < sizeof(struct hns3_cae_dfx_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -106,7 +106,6 @@ int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, handle = net_priv->ae_handle; vport = hns3_cae_get_vport(handle); hdev = vport->back; - out_info = (struct hns3_cae_dfx_param *)buf_out;
ret = hns3_cae_get_chip_and_mac_id(handle, &chip_id, &mac_id); if (ret) @@ -139,18 +138,19 @@ int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_read_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_reg_param *out_info = NULL; - struct hns3_cae_reg_param *in_info = NULL; + struct hns3_cae_reg_param *out_info = + (struct hns3_cae_reg_param *)buf_out; + struct hns3_cae_reg_param *in_info = + (struct hns3_cae_reg_param *)buf_in; struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_reg_param); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_reg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -159,9 +159,6 @@ int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
- in_info = (struct hns3_cae_reg_param *)buf_in; - out_info = (struct hns3_cae_reg_param *)buf_out; - if (in_info->is_read) { check = !buf_out || out_size < sizeof(struct hns3_cae_reg_param); @@ -186,18 +183,18 @@ int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_event_injection(struct hns3_nic_priv *net_priv, +int hns3_cae_event_injection(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_event_param *in_info = NULL; + struct hns3_cae_event_param *in_info = + (struct hns3_cae_event_param *)buf_in; struct hns3_cae_reg_param reg_info; struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_event_param); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_event_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -206,7 +203,6 @@ int hns3_cae_event_injection(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
- in_info = (struct hns3_cae_event_param *)buf_in; reg_info.addr = in_info->addr; reg_info.bit_width = 32; reg_info.is_read = false; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h index 27f9d5c..8d8edb8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h @@ -35,13 +35,13 @@ struct hns3_cae_event_param {
#define HNS3_CAE_MAX_MAC_NUMBER 0x8
-int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_read_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_event_injection(struct hns3_nic_priv *net_priv, +int hns3_cae_event_injection(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c index 5afb3ea..c3b963c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c @@ -5,17 +5,17 @@ #include "hns3_cae_ext.h" #include "hns3_ext.h"
-static int hns3_ext_test_disable_netclk(struct hns3_nic_priv *net_priv) +static int hns3_disable_netclk(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_disable_clock(netdev); }
-static int hns3_get_cpu_affinity(struct hns3_nic_priv *priv) +static int hns3_get_cpu_affinity(const struct hns3_nic_priv *priv) { - struct hns3_enet_tqp_vector *tqp_vector; - struct hnae3_handle *h; + struct hns3_enet_tqp_vector *tqp_vector = NULL; + struct hnae3_handle *h = NULL; int i;
if (!priv) { @@ -42,9 +42,9 @@ static int hns3_get_cpu_affinity(struct hns3_nic_priv *priv) return 0; }
-static int hns3_ext_test_affi(struct hns3_nic_priv *net_priv, void *in) +static int hns3_affi(const struct hns3_nic_priv *net_priv, void *in) { - struct hns3_cpumask_param *cpumask_param; + struct hns3_cpumask_param *cpumask_param = NULL; cpumask_var_t cpumask_new; int ret;
@@ -77,7 +77,7 @@ static int hns3_ext_test_affi(struct hns3_nic_priv *net_priv, void *in) return ret; }
-static int hns3_ext_test_get_chipid(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_chipid(const struct hns3_nic_priv *net_priv, void *out) { u32 chip_id; int ret; @@ -89,14 +89,14 @@ static int hns3_ext_test_get_chipid(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_match_check(struct hns3_nic_priv *net_priv) +static int hns3_match_check(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_netdev_match_check(netdev); }
-static int hns3_ext_test_set_led(struct hns3_nic_priv *net_priv, void *in) +static int hns3_set_led(const struct hns3_nic_priv *net_priv, void *in) { struct hns3_led_state_para *para = (struct hns3_led_state_para *)in; struct net_device *netdev = net_priv->netdev; @@ -104,8 +104,8 @@ static int hns3_ext_test_set_led(struct hns3_nic_priv *net_priv, void *in) return nic_set_led(netdev, para->type, para->status); }
-static int hns3_ext_test_get_sfp_info(struct hns3_nic_priv *net_priv, void *in, - void *out) +static int hns3_get_sfp_info(const struct hns3_nic_priv *net_priv, void *in, + void *out) { struct hns3_priv_sfp_info_para *para_in = (struct hns3_priv_sfp_info_para *)in; @@ -120,8 +120,8 @@ static int hns3_ext_test_get_sfp_info(struct hns3_nic_priv *net_priv, void *in, return ret; }
-static int hns3_ext_test_get_sfp_present(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_sfp_present(const struct hns3_nic_priv *net_priv, + void *out) { struct net_device *netdev = net_priv->netdev; u32 present; @@ -134,7 +134,7 @@ static int hns3_ext_test_get_sfp_present(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_set_sfp_state(struct hns3_nic_priv *net_priv, void *in) +static int hns3_set_sfp_state(const struct hns3_nic_priv *net_priv, void *in) { struct net_device *netdev = net_priv->netdev; bool en = *(bool *)in; @@ -142,14 +142,14 @@ static int hns3_ext_test_set_sfp_state(struct hns3_nic_priv *net_priv, void *in) return nic_set_sfp_state(netdev, en); }
-static int hns3_ext_test_clean_stats64(struct hns3_nic_priv *net_priv) +static int hns3_clean_stats64(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_clean_stats64(netdev, NULL); }
-static int hns3_ext_test_get_chip_num(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_chip_num(const struct hns3_nic_priv *net_priv, void *out) { u32 chip_num; int ret; @@ -161,7 +161,7 @@ static int hns3_ext_test_get_chip_num(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_get_port_num(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_port_num(const struct hns3_nic_priv *net_priv, void *out) { u32 port_num; int ret; @@ -173,15 +173,15 @@ static int hns3_ext_test_get_port_num(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_disable_net_lane(struct hns3_nic_priv *net_priv) +static int hns3_disable_net_lane(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_disable_net_lane(netdev); }
-static int hns3_ext_test_get_lane_status(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_lane_status(const struct hns3_nic_priv *net_priv, + void *out) { u32 lane_status; int ret; @@ -193,7 +193,7 @@ static int hns3_ext_test_get_lane_status(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_set_mac_state(struct hns3_nic_priv *net_priv, void *in) +static int hns3_set_mac_state(const struct hns3_nic_priv *net_priv, void *in) { struct net_device *netdev = net_priv->netdev; int enable = *(int *)in; @@ -201,8 +201,8 @@ static int hns3_ext_test_set_mac_state(struct hns3_nic_priv *net_priv, void *in) return nic_set_mac_state(netdev, enable); }
-static int hns3_ext_test_set_pfc_storm_para(struct hns3_nic_priv *net_priv, - void *in) +static int hns3_set_pfc_storm_para(const struct hns3_nic_priv *net_priv, + void *in) { struct hns3_pfc_storm_para *para = (struct hns3_pfc_storm_para *)in; struct net_device *netdev = net_priv->netdev; @@ -212,13 +212,13 @@ static int hns3_ext_test_set_pfc_storm_para(struct hns3_nic_priv *net_priv, para->recovery_period_ms); }
-static int hns3_ext_test_get_pfc_storm_para(struct hns3_nic_priv *net_priv, - void *in, void *out) +static int hns3_get_pfc_storm_para(const struct hns3_nic_priv *net_priv, + void *in, void *out) { struct hns3_pfc_storm_para *para_in = (struct hns3_pfc_storm_para *)in; struct net_device *netdev = net_priv->netdev; struct hns3_pfc_storm_para *para_out = - (struct hns3_pfc_storm_para *)out; + (struct hns3_pfc_storm_para *)out; u32 recovery_period_ms; u32 period_ms; u32 enable; @@ -240,9 +240,9 @@ static int hns3_ext_test_get_pfc_storm_para(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_get_phy_reg(struct hns3_nic_priv *net_priv, - void *in, void *out, - enum phy_type phy_type) +static int hns3_get_phy_reg(const struct hns3_nic_priv *net_priv, + void *in, void *out, + enum phy_type phy_type) { struct hns3_phy_para *para_out = (struct hns3_phy_para *)out; struct hns3_phy_para *para_in = (struct hns3_phy_para *)in; @@ -268,8 +268,8 @@ static int hns3_ext_test_get_phy_reg(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_set_phy_reg(struct hns3_nic_priv *net_priv, - void *in, enum phy_type phy_type) +static int hns3_set_phy_reg(const struct hns3_nic_priv *net_priv, void *in, + enum phy_type phy_type) { struct hns3_phy_para *para = (struct hns3_phy_para *)in; struct net_device *netdev = net_priv->netdev; @@ -284,7 +284,7 @@ static int hns3_ext_test_set_phy_reg(struct hns3_nic_priv *net_priv, para->data); }
-static int hns3_ext_test_get_macid(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_macid(const struct hns3_nic_priv *net_priv, void *out) { u32 mac_id; int ret; @@ -296,8 +296,8 @@ static int hns3_ext_test_get_macid(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_get_hilink_ref_los(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_hilink_ref_los(const struct hns3_nic_priv *net_priv, + void *out) { u32 status; int ret; @@ -309,8 +309,7 @@ static int hns3_ext_test_get_hilink_ref_los(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_get_port_type(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_port_type(const struct hns3_nic_priv *net_priv, void *out) { u32 wire_type; int ret; @@ -322,100 +321,97 @@ static int hns3_ext_test_get_port_type(struct hns3_nic_priv *net_priv, return ret; }
-int hns3_ext_interface_test(struct hns3_nic_priv *net_priv, +int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct cmd_ext_driver_param *ext_param_out; - struct cmd_ext_driver_param *ext_param_in; - bool check; - void *out; - void *in; + struct cmd_ext_driver_param *ext_param_out = + (struct cmd_ext_driver_param *)buf_out; + struct cmd_ext_driver_param *ext_param_in = + (struct cmd_ext_driver_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct cmd_ext_driver_param) || + !buf_out || out_size < sizeof(struct cmd_ext_driver_param); + void *out = NULL; + void *in = NULL; int ret;
- check = !buf_in || in_size < sizeof(struct cmd_ext_driver_param) || - !buf_out || out_size < sizeof(struct cmd_ext_driver_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- ext_param_in = (struct cmd_ext_driver_param *)buf_in; - ext_param_out = (struct cmd_ext_driver_param *)buf_out; in = ext_param_in->buf; out = ext_param_out->buf;
switch (ext_param_in->op_code) { case EXT_AFFI_MASK: - ret = hns3_ext_test_affi(net_priv, in); + ret = hns3_affi(net_priv, in); break; case EXT_DISABLE_NET_CLK: - ret = hns3_ext_test_disable_netclk(net_priv); + ret = hns3_disable_netclk(net_priv); break; case EXT_GET_CHIP_ID: - ret = hns3_ext_test_get_chipid(net_priv, out); + ret = hns3_get_chipid(net_priv, out); break; case EXT_NET_MATCH_CHECK: - ret = hns3_ext_test_match_check(net_priv); + ret = hns3_match_check(net_priv); break; case EXT_SET_LED: - ret = hns3_ext_test_set_led(net_priv, in); + ret = hns3_set_led(net_priv, in); break; case EXT_GET_SFP_INFO: - ret = hns3_ext_test_get_sfp_info(net_priv, in, out); + ret = hns3_get_sfp_info(net_priv, in, out); break; case EXT_GET_SFP_PRESENT: - ret = hns3_ext_test_get_sfp_present(net_priv, out); + ret = hns3_get_sfp_present(net_priv, out); break; case EXT_SET_SFP_STATE: - ret = hns3_ext_test_set_sfp_state(net_priv, in); + ret = hns3_set_sfp_state(net_priv, in); break; case EXT_CLEAN_STATS64: - ret = hns3_ext_test_clean_stats64(net_priv); + ret = hns3_clean_stats64(net_priv); break; case EXT_GET_CHIP_NUM: - ret = hns3_ext_test_get_chip_num(net_priv, out); + ret = hns3_get_chip_num(net_priv, out); break; case EXT_GET_PORT_NUM: - ret = hns3_ext_test_get_port_num(net_priv, out); + ret = hns3_get_port_num(net_priv, out); break; case EXT_DISABLE_NET_LANE: - ret = hns3_ext_test_disable_net_lane(net_priv); + ret = hns3_disable_net_lane(net_priv); break; case EXT_GET_LANE_STATUS: - ret = hns3_ext_test_get_lane_status(net_priv, out); + ret = hns3_get_lane_status(net_priv, out); break; case EXT_SET_MAC_STATE: - ret = hns3_ext_test_set_mac_state(net_priv, in); + ret = hns3_set_mac_state(net_priv, in); break; case EXT_SET_PFC_STORM_PARA: - ret = hns3_ext_test_set_pfc_storm_para(net_priv, in); + ret = hns3_set_pfc_storm_para(net_priv, in); break; case EXT_GET_PFC_STORM_PARA: - ret = hns3_ext_test_get_pfc_storm_para(net_priv, in, out); + ret = hns3_get_pfc_storm_para(net_priv, in, out); break; case EXT_GET_PHY_REG: - ret = hns3_ext_test_get_phy_reg(net_priv, in, out, - PHY_TYPE_1512); + ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_1512); break; case EXT_SET_PHY_REG: - ret = hns3_ext_test_set_phy_reg(net_priv, in, PHY_TYPE_1512); + ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_1512); break; case EXT_GET_MAC_ID: - ret = hns3_ext_test_get_macid(net_priv, out); + ret = hns3_get_macid(net_priv, out); break; case EXT_GET_HILINK_REF_LOS: - ret = hns3_ext_test_get_hilink_ref_los(net_priv, out); + ret = hns3_get_hilink_ref_los(net_priv, out); break; case EXT_GET_8211_PHY_REG: - ret = hns3_ext_test_get_phy_reg(net_priv, in, out, - PHY_TYPE_8211); + ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_8211); break; case EXT_SET_8211_PHY_REG: - ret = hns3_ext_test_set_phy_reg(net_priv, in, PHY_TYPE_8211); + ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_8211); break; case EXT_GET_PORT_TYPE: - ret = hns3_ext_test_get_port_type(net_priv, out); + ret = hns3_get_port_type(net_priv, out); break; default: ret = -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h index 28df48a..aca4988 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h @@ -61,7 +61,7 @@ struct cmd_ext_driver_param { u8 buf[1024]; };
-int hns3_ext_interface_test(struct hns3_nic_priv *net_priv, +int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c index 516dc2e..21e0341 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c @@ -22,10 +22,10 @@ static int hns3_cae_send_generic_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_get_fd_mode_cmd *mode_cfg; - struct hclge_get_fd_mode_cmd *req; + struct hclge_get_fd_mode_cmd *mode_cfg = NULL; + struct hclge_get_fd_mode_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = false; int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_MODE_CTRL, @@ -63,14 +63,13 @@ static int hns3_cae_send_generic_cmd(struct hclge_dev *hdev, u8 *buf_in, static int hns3_cae_send_allocate_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { - struct hclge_get_fd_allocation_cmd *allocation_cfg; - struct hclge_get_fd_allocation_cmd *req; + struct hclge_get_fd_allocation_cmd *allocation_cfg = NULL; + struct hclge_get_fd_allocation_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_out || + out_size < sizeof(struct hclge_get_fd_allocation_cmd); int ret;
- check = !buf_out || - out_size < sizeof(struct hclge_get_fd_allocation_cmd); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -102,10 +101,10 @@ static int hns3_cae_send_key_cfg_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_set_fd_key_config_cmd *key_cfg_data; - struct hclge_set_fd_key_config_cmd *req; + struct hclge_set_fd_key_config_cmd *key_cfg_data = NULL; + struct hclge_set_fd_key_config_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = false; int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_KEY_CONFIG, @@ -157,13 +156,13 @@ static int hns3_cae_send_tcam_op_cmd(struct hclge_dev *hdev, u8 *buf_in, #define HNS3_CAE_FD_TCAM_BD_NUM 3 struct fd_param *param = (struct fd_param *)buf_in; struct hclge_desc desc[HNS3_CAE_FD_TCAM_BD_NUM]; - struct hclge_fd_tcam_config_1_cmd *req1; - struct hclge_fd_tcam_config_2_cmd *req2; - struct hclge_fd_tcam_config_3_cmd *req3; - struct hclge_fd_tcam_data *tcam_data; - struct hclge_desc *pdesc; - bool check; - u8 *buf; + struct hclge_fd_tcam_config_1_cmd *req1 = NULL; + struct hclge_fd_tcam_config_2_cmd *req2 = NULL; + struct hclge_fd_tcam_config_3_cmd *req3 = NULL; + struct hclge_fd_tcam_data *tcam_data = NULL; + struct hclge_desc *pdesc = NULL; + bool check = false; + u8 *buf = NULL; int ret; int i;
@@ -228,10 +227,10 @@ static int hns3_cae_send_ad_op_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_fd_ad_config_cmd *ad_data; - struct hclge_fd_ad_config_cmd *req; + struct hclge_fd_ad_config_cmd *ad_data = NULL; + struct hclge_fd_ad_config_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = false; int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_AD_OP, @@ -271,10 +270,10 @@ static int hns3_cae_send_cnt_op_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_fd_cnt_op_cmd *cnt_data; - struct hclge_fd_cnt_op_cmd *req; + struct hclge_fd_cnt_op_cmd *cnt_data = NULL; + struct hclge_fd_cnt_op_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_out || out_size < sizeof(struct hclge_fd_cnt_op_cmd); int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_CNT_OP, true); @@ -282,7 +281,6 @@ static int hns3_cae_send_cnt_op_cmd(struct hclge_dev *hdev, u8 *buf_in, req->stage = param->stage; req->cnt_idx = param->idx;
- check = !buf_out || out_size < sizeof(struct hclge_fd_cnt_op_cmd); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -300,17 +298,17 @@ static int hns3_cae_send_cnt_op_cmd(struct hclge_dev *hdev, u8 *buf_in, return 0; }
-int hns3_cae_fd_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_fd_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { + bool check = !buf_in || in_size < sizeof(struct fd_param); struct hnae3_handle *handle = net_priv->ae_handle; struct hclge_vport *vport = hns3_cae_get_vport(handle); struct fd_param *param = (struct fd_param *)buf_in; struct hclge_dev *hdev = vport->back; int ret = -1; - bool check;
- check = !buf_in || in_size < sizeof(struct fd_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h index 1d69139..9e2053b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h @@ -31,7 +31,8 @@ struct hclge_fd_tcam_data { u8 tcam_data[52]; };
-int hns3_cae_fd_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_fd_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c index 6395078..afda7fe 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c @@ -11,20 +11,19 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_gro.h"
-int hns3_gro_age_handle(struct hns3_nic_priv *net_priv, +int hns3_gro_age_handle(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hnae3_handle *h = net_priv->ae_handle; - struct hns3_cae_gro_age_config_cmd *req; - struct hclge_vport *vport; - struct gro_param *param; + struct hns3_cae_gro_age_config_cmd *req = NULL; + struct hclge_vport *vport = NULL; + struct gro_param *param = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - struct hclge_dev *hdev; - bool check; + bool check = !buf_in || in_size < sizeof(struct gro_param); int ret;
- check = !buf_in || in_size < sizeof(struct gro_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -61,12 +60,13 @@ int hns3_gro_age_handle(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_gro_dump_bd_buff_size(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_gro_dump_bd_buff_size(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hclge_vport *vport; - struct hnae3_handle *h; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hnae3_handle *h = NULL; + struct hclge_dev *hdev = NULL;
if (!buf_out || out_size < sizeof(u16)) { pr_err("input param buf_out error in %s function\n", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h index 9427c7e..49a9548 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h @@ -16,9 +16,10 @@ struct gro_param { u32 age_cnt; };
-int hns3_gro_age_handle(struct hns3_nic_priv *net_priv, +int hns3_gro_age_handle(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_gro_dump_bd_buff_size(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_gro_dump_bd_buff_size(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c index bc99c20..6aa003f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c @@ -168,28 +168,26 @@ static int hns3_get_hilink_ffe(struct hclge_dev *hdev, return ret; }
-int hns3_get_hilink_param(struct hns3_nic_priv *net_priv, +int hns3_get_hilink_param(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); struct hclge_vport *vport = hns3_cae_get_vport(handle); - struct hns3_hilink_param *hns3_param_out = NULL; - struct hns3_hilink_param *hns3_param_in = NULL; + struct hns3_hilink_param *hns3_param_out = + (struct hns3_hilink_param *)buf_out; + struct hns3_hilink_param *hns3_param_in = + (struct hns3_hilink_param *)buf_in; struct hclge_dev *hdev = vport->back; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_hilink_param) || + !buf_out || out_size < sizeof(struct hns3_hilink_param); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_hilink_param) || - !buf_out || out_size < sizeof(struct hns3_hilink_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- hns3_param_in = (struct hns3_hilink_param *)buf_in; - hns3_param_out = (struct hns3_hilink_param *)buf_out; - memset(hns3_param_out->ctle_param, 0x0, sizeof(hns3_param_out->ctle_param)); memset(hns3_param_out->dfe_param, 0x0, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h index 81acfa7..507311c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h @@ -45,7 +45,7 @@ struct hns3_hilink_param { struct hns3_ffe_data ffe_param[HILINK_LANE_MAX_NUM]; };
-int hns3_get_hilink_param(struct hns3_nic_priv *net_priv, +int hns3_get_hilink_param(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c index cc18001..96f0bb0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c @@ -59,8 +59,9 @@ int g_hns3_cae_init_flag; int g_hns3_cae_ref_cnt;
-typedef int (*driv_module) (struct hns3_nic_priv *nic_dev, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +typedef int (*driv_module) (const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
struct drv_module_handle { enum driver_cmd_type driv_cmd_name; @@ -77,7 +78,7 @@ static void free_buff_in(void *buf_in)
static int alloc_buff_in(struct msg_module *nt_msg, u32 in_size, void **buf_in) { - void *msg_buf; + void *msg_buf = NULL;
if (!in_size) return 0; @@ -469,7 +470,7 @@ static int if_hns3_cae_exist(void) static int hns3_cae_k_init(void) { int ret; - struct device *pdevice; + struct device *pdevice = NULL;
if (g_hns3_cae_init_flag) { g_hns3_cae_ref_cnt++; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c index c939136..27a37ef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c @@ -20,24 +20,24 @@ struct hns3_irq_lli_param { u16 tqp_nums; };
-int hns3_irq_lli_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_irq_lli_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_irq_lli_param *in_info = NULL; - struct hns3_irq_lli_param *out_info = NULL; + struct hns3_irq_lli_param *in_info = + (struct hns3_irq_lli_param *)buf_in; + struct hns3_irq_lli_param *out_info = + (struct hns3_irq_lli_param *)buf_out; struct hnae3_handle *handle = NULL; int is_get; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_irq_lli_param);
- check = !buf_in || in_size < sizeof(struct hns3_irq_lli_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
handle = net_priv->ae_handle; - in_info = (struct hns3_irq_lli_param *)buf_in; - out_info = (struct hns3_irq_lli_param *)buf_out; is_get = in_info->is_get;
if (is_get) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h index a58db86..30b9806 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h @@ -4,6 +4,7 @@ #ifndef __HNS3_CAE_IRQ_H__ #define __HNS3_CAE_IRQ_H__
-int hns3_irq_lli_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_irq_lli_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c index 1d675f8..57f25e0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c @@ -8,7 +8,7 @@ #include "hns3_enet.h" #include "hns3_cae_lamp.h"
-int hns3_lamp_cfg(struct hns3_nic_priv *net_priv, +int hns3_lamp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct net_device *netdev = net_priv->netdev; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h index 78eeb8a..2d8069f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h @@ -26,7 +26,7 @@ struct hns3_lamp_signal { u8 activity; };
-int hns3_lamp_cfg(struct hns3_nic_priv *net_priv, +int hns3_lamp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); int nic_get_led_signal(struct net_device *ndev, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c index 863b27f..75edb14 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c @@ -8,19 +8,19 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_led.h"
-int hns3_led_cfg_ncl_info(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_led_cfg_ncl_info(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); struct hclge_vport *vport = hns3_cae_get_vport(handle); struct led_statistic_param *parm_out = buf_out; struct hclge_dev *hdev = vport->back; struct hclge_desc desc = {0}; - bool check; + bool check = !buf_out || out_size < sizeof(struct led_statistic_param); int index; int ret;
- check = !buf_out || out_size < sizeof(struct led_statistic_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h index 0b2b735..4a6a50b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h @@ -10,6 +10,7 @@ struct led_statistic_param { u32 data[6]; };
-int hns3_led_cfg_ncl_info(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_led_cfg_ncl_info(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c index df0b8ff..fd923ae 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c @@ -15,23 +15,27 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_lib.h"
-int hns3_cae_common_cmd_send(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define MAX_DESC_DATA_LEN 6 - struct cmd_desc_param *param_in; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct cmd_desc_param *param_in = (struct cmd_desc_param *)buf_in; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_in || in_size < sizeof(struct cmd_desc_param); int ret; int i;
- check = !buf_in || in_size < sizeof(struct cmd_desc_param); + if (check) { + pr_err("input param buf_in error in %s function\n", __func__); + return -EFAULT; + } + vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
- param_in = (struct cmd_desc_param *)buf_in; hns3_cae_cmd_setup_basic_desc(&desc, param_in->fw_dw_opcode, param_in->is_read); for (i = 0; i < MAX_DESC_DATA_LEN; i++) @@ -59,18 +63,17 @@ int hns3_cae_common_cmd_send(struct hns3_nic_priv *net_priv, void *buf_in, return 0; }
-int hns3_m7_cmd_handle(struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_m7_cmd_handle(const struct hns3_nic_priv *nic_dev, void *buf_in, + u32 in_size, void *buf_out, u32 out_size) { struct hclge_vport *vport = hns3_cae_get_vport(nic_dev->ae_handle); struct m7_cmd_para *cmd_para = (struct m7_cmd_para *)buf_in; struct hclge_dev *hdev = vport->back; struct hclge_desc *desc = NULL; u32 bd_size; - bool check; + bool check = !buf_in || in_size < sizeof(struct m7_cmd_para); int ret;
- check = !buf_in || in_size < sizeof(struct m7_cmd_para); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h index 61ae1af6..236b5a8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h @@ -134,9 +134,10 @@ struct m7_cmd_para { void *bd_data; };
-int hns3_cae_common_cmd_send(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
-int hns3_m7_cmd_handle(struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, - void *buf_out, u32 out_size); +int hns3_m7_cmd_handle(const struct hns3_nic_priv *nic_dev, void *buf_in, + u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c index 09dacf0db..acbb684 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c @@ -14,31 +14,27 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_mac.h"
-int hns3_cae_mac_loop_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_mac_loop_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hns3_cae_cfg_serdes_mode_cmd *req1 = NULL; struct hns3_cae_cfg_mac_mode_cmd *req2 = NULL; - struct hns3_cae_loop_param *out_info = NULL; - struct hns3_cae_loop_param *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_loop_param *out_info = + (struct hns3_cae_loop_param *)buf_out; + struct hns3_cae_loop_param *in_info = + (struct hns3_cae_loop_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_loop_param); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_loop_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_loop_param *)buf_in; - out_info = (struct hns3_cae_loop_param *)buf_out; - req1 = (struct hns3_cae_cfg_serdes_mode_cmd *)&desc.data[0]; req2 = (struct hns3_cae_cfg_mac_mode_cmd *)&desc.data[0];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h index a5faf4c..3ab73ca 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h @@ -31,7 +31,7 @@ struct hns3_cae_cfg_serdes_mode_cmd { u8 rsv[21]; };
-int hns3_cae_mac_loop_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_mac_loop_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c index a7b2e23..5b9c86a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c @@ -19,7 +19,7 @@ #include "hns3_ext.h" #include "hns3_cae_mactbl.h"
-int hns3_cae_opt_mactbl(struct hns3_nic_priv *net_priv, +int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { @@ -30,11 +30,10 @@ int hns3_cae_opt_mactbl(struct hns3_nic_priv *net_priv, struct hns3_mac_tbl_para *in = (struct hns3_mac_tbl_para *)buf_in; struct net_device *netdev = net_priv->netdev; struct hnae3_handle *h = NULL; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_mac_tbl_para) || + !buf_out || out_size < sizeof(struct hns3_mac_tbl_para); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_mac_tbl_para) || - !buf_out || out_size < sizeof(struct hns3_mac_tbl_para); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h index 16570b4..a96c380 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h @@ -23,7 +23,7 @@ struct hns3_mac_tbl_para { u8 result; };
-int hns3_cae_opt_mactbl(struct hns3_nic_priv *net_priv, +int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c index 4bb55c6..cda7164 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c @@ -6,18 +6,18 @@ #include "hns3_cae_pfc_storm.h" #include "hns3_enet.h"
-static int hns3_cae_set_pfc_storm_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_set_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size) { - struct cmd_pfc_storm_param *prelude_in; - struct net_device *netdev; - struct hclge_vport *vport; - struct hnae3_handle *h; - struct hclge_dev *hdev; + struct cmd_pfc_storm_param *prelude_in = + (struct cmd_pfc_storm_param *)buf_in; + struct net_device *netdev = NULL; + struct hclge_vport *vport = NULL; + struct hnae3_handle *h = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int ret;
- prelude_in = (struct cmd_pfc_storm_param *)buf_in; netdev = net_priv->netdev; h = hns3_get_handle(netdev); vport = hns3_cae_get_vport(h); @@ -41,16 +41,18 @@ static int hns3_cae_set_pfc_storm_cfg(struct hns3_nic_priv *net_priv, return 0; }
-static int hns3_cae_get_pfc_storm_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, - u32 out_size) +static int hns3_cae_get_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, + void *buf_out, u32 out_size) { - struct cmd_pfc_storm_param *prelude_in; - struct cmd_pfc_storm_param *info_dstn; - struct net_device *netdev; - struct hclge_vport *vport; - struct hnae3_handle *h; - struct hclge_dev *hdev; + struct cmd_pfc_storm_param *prelude_in = + (struct cmd_pfc_storm_param *)buf_in; + struct cmd_pfc_storm_param *info_dstn = + (struct cmd_pfc_storm_param *)buf_out; + struct net_device *netdev = NULL; + struct hclge_vport *vport = NULL; + struct hnae3_handle *h = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int check; int ret; @@ -61,8 +63,6 @@ static int hns3_cae_get_pfc_storm_cfg(struct hns3_nic_priv *net_priv, return -EFAULT; }
- prelude_in = (struct cmd_pfc_storm_param *)buf_in; - info_dstn = (struct cmd_pfc_storm_param *)buf_out; netdev = net_priv->netdev; h = hns3_get_handle(netdev); vport = hns3_cae_get_vport(h); @@ -89,10 +89,12 @@ static int hns3_cae_get_pfc_storm_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_pfc_storm_cfg(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct cmd_pfc_storm_param *para_in; + struct cmd_pfc_storm_param *para_in = + (struct cmd_pfc_storm_param *)buf_in; int check; int ret;
@@ -102,7 +104,6 @@ int hns3_cae_pfc_storm_cfg(struct hns3_nic_priv *net_priv, void *buf_in, return -EFAULT; }
- para_in = (struct cmd_pfc_storm_param *)buf_in; if (para_in->op_code == SET_PFC_STORM_PARA) { ret = hns3_cae_set_pfc_storm_cfg(net_priv, buf_in, in_size); } else if (para_in->op_code == GET_PFC_STORM_PARA) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h index ea6d0e918..ff0cc35 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h @@ -24,5 +24,6 @@ struct cmd_pfc_storm_param { }; };
-int hns3_cae_pfc_storm_cfg(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c index dffc58e..3d04966 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c @@ -182,7 +182,7 @@ struct kthread_info { int tid; struct task_struct *task; int stop; - struct hns3_nic_priv *net_priv; + const struct hns3_nic_priv *net_priv; struct hns3_cae_pkt_cfg_info *in_info; struct hns3_cae_pkt_result_info *out_info; }; @@ -332,7 +332,7 @@ void __fill_the_pkt_head(struct net_device *netdev, u8 *payload, struct hns3_cae_pkt_cfg_info *in_info) { struct in_ifaddr *ifa_list = NULL; - u8 *pkt_payload; + u8 *pkt_payload = NULL; u32 vlan_tag; size_t count; int i; @@ -493,11 +493,11 @@ static int __hns3_cae_change_send_queue(int cur_queue, return queue_id; }
-int __hns3_cae_send_pkt(struct hns3_nic_priv *net_priv, +int __hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, struct hns3_cae_pkt_cfg_info *in_info, struct hns3_cae_pkt_result_info *out_info) { - struct hnae3_handle *handle; + struct hnae3_handle *handle = NULL; struct sk_buff *skb = NULL; u8 *payload = NULL; int pkt_len; @@ -626,7 +626,7 @@ int __hns3_cae_new_task(void *arg) }
int hns3_cae_create_new_thread(int tid, - struct hns3_nic_priv *net_priv, + const struct hns3_nic_priv *net_priv, struct hns3_cae_pkt_cfg_info *in_info, struct hns3_cae_pkt_result_info *out_info) { @@ -700,18 +700,18 @@ void hns3_cae_stop_new_thread(int tid) mutex_unlock(&pkt_mutex[tid]); }
-int hns3_cae_send_pkt(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_pkt_result_info *out_info; - struct hns3_cae_pkt_cfg_info *in_info; + struct hns3_cae_pkt_result_info *out_info = + (struct hns3_cae_pkt_result_info *)buf_out; + struct hns3_cae_pkt_cfg_info *in_info = + (struct hns3_cae_pkt_cfg_info *)buf_in; struct hnae3_handle *handle = NULL; int queue_id; int tid;
- in_info = (struct hns3_cae_pkt_cfg_info *)buf_in; - out_info = (struct hns3_cae_pkt_result_info *)buf_out; - if (!in_info || in_size < sizeof(struct hns3_cae_pkt_cfg_info) || !out_info || out_size < sizeof(struct hns3_cae_pkt_result_info)) { pr_err("input parameter error in %s function\n", __func__); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h index 4d3eff3..ea68c18 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h @@ -59,7 +59,7 @@ struct hns3_cae_pkt_result_info { int num; };
-int hns3_cae_send_pkt(struct hns3_nic_priv *net_priv, void *buf_in, +int hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); void hns3_cae_pkt_init(void); void hns3_cae_pkt_destroy(void); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c index a55e827..78d270e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c @@ -20,8 +20,8 @@ void fill_port_info(struct hclge_port_info *get_port_info_out, struct hclge_desc *port_desc, u32 bd_num) { - u8 *dest_data; - u8 *tmp_buff; + u8 *dest_data = NULL; + u8 *tmp_buff = NULL; u32 i;
dest_data = (u8 *)get_port_info_out; @@ -55,16 +55,18 @@ void fill_port_info(struct hclge_port_info *get_port_info_out, } }
-int hns3_get_port_info(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_get_port_info(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); struct hclge_vport *vport = hns3_cae_get_vport(handle); - struct hclge_port_info *get_port_info_out; + struct hclge_port_info *get_port_info_out = + (struct hclge_port_info *)buf_out; struct hclge_dev *hdev = vport->back; - struct hclge_desc *port_desc; + struct hclge_desc *port_desc = NULL; struct hclge_desc desc = {0}; - __le32 *desc_data; + __le32 *desc_data = NULL; u32 bd_num; int ret; u32 i; @@ -72,8 +74,6 @@ int hns3_get_port_info(struct hns3_nic_priv *net_priv, if (!buf_out || out_size < sizeof(struct hclge_port_info)) return -ENODEV;
- get_port_info_out = (struct hclge_port_info *)buf_out; - get_port_info_out->gpio_insert = 0;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_PORTINFO_BD_NUM, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h index 66c7bb9..37cfdae 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h @@ -87,7 +87,7 @@ struct hclge_lsport_info { u32 portinfo[6]; };
-int hns3_get_port_info(struct hns3_nic_priv *net_priv, +int hns3_get_port_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c index f641ba4..b9e8d1f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c @@ -4,20 +4,19 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_promisc.h"
-int hns3_read_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_read_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_promisc_cfg_cmd *req; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_promisc_cfg_cmd *req = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - u8 *out_buf; - bool check; + u8 *out_buf = NULL; + bool check = !buf_out || out_size < sizeof(u8); u8 enable; int ret;
- check = !buf_out || out_size < sizeof(u8); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -42,19 +41,18 @@ int hns3_read_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, return 0; }
-int hns3_set_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct promisc_mode_param *mode_param; - struct hclge_promisc_cfg_cmd *req; - struct hclge_vport *vport; - struct hclge_dev *hdev; + bool check = !buf_in || in_size < sizeof(struct promisc_mode_param); + struct promisc_mode_param *mode_param = NULL; + struct hclge_promisc_cfg_cmd *req = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct promisc_mode_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -103,15 +101,14 @@ int hns3_set_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, return ret; }
-int hns3_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct promisc_mode_param *mode_param; - bool check; + bool check = !buf_in || in_size < sizeof(struct promisc_mode_param); + struct promisc_mode_param *mode_param = NULL; int ret;
- check = !buf_in || in_size < sizeof(struct promisc_mode_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h index 1328fe1..51d4743 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h @@ -26,7 +26,7 @@ struct promisc_mode_param { u8 type; };
-int hns3_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c index ffbd51d..a984107 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c @@ -3,9 +3,9 @@
#include "hns3_cae_qinfo.h"
-int hns3_get_q_rx_fbd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -16,9 +16,9 @@ int hns3_get_q_rx_fbd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_ebd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -29,9 +29,9 @@ int hns3_get_q_rx_ebd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_fbd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -40,9 +40,9 @@ int hns3_get_q_tx_fbd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_ebd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -51,9 +51,9 @@ int hns3_get_q_tx_ebd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_tail(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -64,9 +64,9 @@ int hns3_get_q_rx_tail(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_head(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -77,9 +77,9 @@ int hns3_get_q_rx_head(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_tail(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -88,9 +88,9 @@ int hns3_get_q_tx_tail(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_head(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -99,11 +99,13 @@ int hns3_get_q_tx_head(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_cae_qinfo_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct qinfo_param *out_info; + struct qinfo_param *out_info = (struct qinfo_param *)buf_out; + bool check = !buf_in || in_size < sizeof(int) || !buf_out || + out_size < sizeof(struct qinfo_param); int tqps_num; int ring_id; int rx_head; @@ -114,17 +116,13 @@ int hns3_cae_qinfo_cfg(struct hns3_nic_priv *net_priv, int tx_tail; int tx_ebd; int tx_fbd; - bool check;
- check = !buf_in || in_size < sizeof(int) || - !buf_out || out_size < sizeof(struct qinfo_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
tqps_num = net_priv->ae_handle->kinfo.num_tqps; - out_info = (struct qinfo_param *)buf_out; ring_id = *((int *)buf_in);
if (ring_id >= tqps_num || ring_id < 0) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h index 3bce38ef..46ab594 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h @@ -25,15 +25,15 @@ struct qinfo_param { int rx_fbd; };
-int hns3_get_q_rx_fbd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_ebd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_fbd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_ebd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_tail(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_head(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_tail(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_head(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_cae_qinfo_cfg(struct hns3_nic_priv *net_priv, +int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c index 7f7c4f9..ffd9e3f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c @@ -7,10 +7,10 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_qos.h"
-struct hclge_dev *get_val_hdev(struct hns3_nic_priv *net_priv) +struct hclge_dev *get_val_hdev(const struct hns3_nic_priv *net_priv) { - struct hnae3_handle *handle; - struct hclge_vport *vport; + struct hnae3_handle *handle = NULL; + struct hclge_vport *vport = NULL;
handle = net_priv->ae_handle; vport = hns3_cae_get_vport(handle); @@ -20,7 +20,7 @@ struct hclge_dev *get_val_hdev(struct hns3_nic_priv *net_priv) int hns3_cmd_rx_priv_wl_config(struct hclge_dev *hdev, u16 tc, u32 high, u32 low, u32 en) { - struct hclge_rx_priv_wl_buf *req; + struct hclge_rx_priv_wl_buf *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; int idx; @@ -61,15 +61,16 @@ int hns3_cmd_rx_priv_wl_config(struct hclge_dev *hdev, u16 tc, return 0; }
-int hns3_cae_rx_priv_buff_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_priv_buff_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_rx_priv_buff_wl_param *in_info; - bool check; + struct hns3_rx_priv_buff_wl_param *in_info = + (struct hns3_rx_priv_buff_wl_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_rx_priv_buff_wl_param);
- check = !buf_in || in_size < sizeof(struct hns3_rx_priv_buff_wl_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -80,7 +81,7 @@ int hns3_cae_rx_priv_buff_wl_cfg(struct hns3_nic_priv *net_priv, "This device is not support this cmd!\n"); return -EPERM; } - in_info = (struct hns3_rx_priv_buff_wl_param *)buf_in; + pr_err("wl is_set param, tc_no = 0x%x, hight = 0x%x, low = 0x%x\n", in_info->tc_no, in_info->high_wl, in_info->low_wl);
@@ -92,7 +93,7 @@ int hns3_cmd_common_thrd_config(struct hclge_dev *hdev, u16 tc, u32 high, u32 low, u32 en) { #define HNS3_CAE_THRD_ALLOC_BD_NUM 2 - struct hclge_rx_com_thrd *req; + struct hclge_rx_com_thrd *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; int idx; @@ -134,15 +135,16 @@ int hns3_cmd_common_thrd_config(struct hclge_dev *hdev, u16 tc, return 0; }
-int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_thrd_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_rx_priv_buff_wl_param *in_info; - bool check; + struct hns3_rx_priv_buff_wl_param *in_info = + (struct hns3_rx_priv_buff_wl_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_rx_priv_buff_wl_param);
- check = !buf_in || in_size < sizeof(struct hns3_rx_priv_buff_wl_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -153,7 +155,7 @@ int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, "This device is not support this cmd!\n"); return -EPERM; } - in_info = (struct hns3_rx_priv_buff_wl_param *)buf_in; + pr_info("common thrd is_set param, tc_no = 0x%x, hight = 0x%x, low = 0x%x\n", in_info->tc_no, in_info->high_wl, in_info->low_wl);
@@ -165,7 +167,7 @@ int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, int hns3_cmd_common_wl_config(struct hclge_dev *hdev, u32 high, u32 low, u32 en) { enum hclge_cmd_status status; - struct hclge_rx_com_wl *req; + struct hclge_rx_com_wl *req = NULL; struct hclge_desc desc;
req = (struct hclge_rx_com_wl *)desc.data; @@ -184,20 +186,22 @@ int hns3_cmd_common_wl_config(struct hclge_dev *hdev, u32 high, u32 low, u32 en) return 0; }
-int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_rx_priv_buff_wl_param *out_info; - struct hns3_rx_priv_buff_wl_param *in_info; + struct hns3_rx_priv_buff_wl_param *out_info = + (struct hns3_rx_priv_buff_wl_param *)buf_out; + struct hns3_rx_priv_buff_wl_param *in_info = + (struct hns3_rx_priv_buff_wl_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_rx_priv_buff_wl_param); enum hclge_cmd_status status; - struct hclge_rx_com_wl *req; - struct hclge_vport *vport; + struct hclge_rx_com_wl *req = NULL; + struct hclge_vport *vport = NULL; struct hclge_desc desc; - struct hclge_dev *hdev; - bool check; + struct hclge_dev *hdev = NULL;
- check = !buf_in || in_size < sizeof(struct hns3_rx_priv_buff_wl_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -205,8 +209,6 @@ int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - out_info = (struct hns3_rx_priv_buff_wl_param *)buf_out; - in_info = (struct hns3_rx_priv_buff_wl_param *)buf_in;
if (in_info->is_read == IS_WRITE) { status = hns3_cmd_common_wl_config(hdev, in_info->high_wl, @@ -237,22 +239,23 @@ int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv, return status; }
-int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_rx_priv_buff_cmd *recv; - struct hns3_rx_buff_param *out_info; - struct hns3_rx_buff_param *in_info; + struct hclge_rx_priv_buff_cmd *recv = NULL; + struct hns3_rx_buff_param *out_info = + (struct hns3_rx_buff_param *)buf_out; + struct hns3_rx_buff_param *in_info = + (struct hns3_rx_buff_param *)buf_in; enum hclge_cmd_status status; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_rx_buff_param) || + !buf_out || out_size < sizeof(struct hns3_rx_buff_param); int i;
- check = !buf_in || in_size < sizeof(struct hns3_rx_buff_param) || - !buf_out || out_size < sizeof(struct hns3_rx_buff_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; @@ -260,8 +263,6 @@ int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - out_info = (struct hns3_rx_buff_param *)buf_out; - in_info = (struct hns3_rx_buff_param *)buf_in;
if (in_info->is_read == IS_READ) { hns3_cae_cmd_setup_basic_desc(&desc, @@ -283,22 +284,23 @@ int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_tx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_tx_buff_alloc_cmd *recv; - struct hns3_tx_buff_param *out_info; - struct hns3_tx_buff_param *in_info; + struct hclge_tx_buff_alloc_cmd *recv = NULL; + struct hns3_tx_buff_param *out_info = + (struct hns3_tx_buff_param *)buf_out; + struct hns3_tx_buff_param *in_info = + (struct hns3_tx_buff_param *)buf_in; enum hclge_cmd_status status; - struct hclge_vport *vport; + struct hclge_vport *vport = NULL; struct hclge_desc desc; - struct hclge_dev *hdev; - bool check; + struct hclge_dev *hdev = NULL; + bool check = !buf_in || in_size < sizeof(struct hns3_tx_buff_param) || + !buf_out || out_size < sizeof(struct hns3_tx_buff_param); int i;
- check = !buf_in || in_size < sizeof(struct hns3_tx_buff_param) || - !buf_out || out_size < sizeof(struct hns3_tx_buff_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; @@ -306,8 +308,6 @@ int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - out_info = (struct hns3_tx_buff_param *)buf_out; - in_info = (struct hns3_tx_buff_param *)buf_in;
if (in_info->is_read == IS_READ) { hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_TX_BUFF_ALLOC, @@ -326,29 +326,28 @@ int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_show_comm_thres(struct hns3_nic_priv *net_priv, +int hns3_cae_show_comm_thres(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HNS3_CAE_THRD_ALLOC_BD_NUM 2 struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_total_priv_wl_param *out_info; - struct hclge_rx_com_thrd *req; + struct hns3_total_priv_wl_param *out_info = + (struct hns3_total_priv_wl_param *)buf_out; + struct hclge_rx_com_thrd *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; - bool check; + bool check = !buf_out || + out_size < sizeof(struct hns3_total_priv_wl_param); int idx; int i; int j;
- check = !buf_out || out_size < sizeof(struct hns3_total_priv_wl_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- out_info = (struct hns3_total_priv_wl_param *)buf_out; - for (i = 0; i < HNS3_CAE_THRD_ALLOC_BD_NUM; i++) { hns3_cae_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_RX_COM_THRD_ALLOC, @@ -378,29 +377,28 @@ int hns3_cae_show_comm_thres(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_show_rx_priv_wl(struct hns3_nic_priv *net_priv, +int hns3_cae_show_rx_priv_wl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HNS3_CAE_WL_ALLOC_BD_NUM 2 struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_total_priv_wl_param *out_info; - struct hclge_rx_priv_wl_buf *req; + struct hns3_total_priv_wl_param *out_info = + (struct hns3_total_priv_wl_param *)buf_out; + struct hclge_rx_priv_wl_buf *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; - bool check; + bool check = !buf_out || + out_size < sizeof(struct hns3_total_priv_wl_param); int idx; int i; int j;
- check = !buf_out || out_size < sizeof(struct hns3_total_priv_wl_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- out_info = (struct hns3_total_priv_wl_param *)buf_out; - for (i = 0; i < HNS3_CAE_WL_ALLOC_BD_NUM; i++) { hns3_cae_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_RX_PRIV_WL_ALLOC, @@ -430,19 +428,19 @@ int hns3_cae_show_rx_priv_wl(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_qcn_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define HCLGE_OPC_QCN_CFG 0x1A01 - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int qcn_bypass; u32 qcn_cfg; - bool check; + bool check = !buf_in || in_size < sizeof(int); int ret;
- check = !buf_in || in_size < sizeof(int); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h index 074ec29..125ca69 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h @@ -43,28 +43,29 @@ enum opt_type { #define HNS3_QOS_QCN_BYPASS_MASK 0x20000 #define HNS3_QCN_SHAP_BYPASS_OFF 17
-int hns3_cae_rx_priv_buff_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_priv_buff_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_thrd_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_tx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_show_rx_priv_wl(struct hns3_nic_priv *net_priv, +int hns3_cae_show_rx_priv_wl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_show_comm_thres(struct hns3_nic_priv *net_priv, +int hns3_cae_show_comm_thres(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_qcn_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c index a3ed7eaa..fb37c73 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c @@ -3,10 +3,10 @@
#include "hns3_cae_qres.h"
-int hns3_get_qres_rx_value(struct hns3_nic_priv *net_priv, int ring_id, +int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id, enum param_type type) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int tqps_num; int num;
@@ -51,10 +51,10 @@ int hns3_get_qres_rx_value(struct hns3_nic_priv *net_priv, int ring_id, return num; }
-int hns3_get_qres_tx_value(struct hns3_nic_priv *net_priv, int ring_id, +int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id, enum param_type type) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -97,7 +97,7 @@ int hns3_get_qres_tx_value(struct hns3_nic_priv *net_priv, int ring_id, return num; }
-void fill_queue_info(struct hns3_nic_priv *net_priv, +void fill_queue_info(const struct hns3_nic_priv *net_priv, struct qres_param *out_info, int ring_id) { /* rx info */ @@ -133,27 +133,26 @@ void fill_queue_info(struct hns3_nic_priv *net_priv, TX_SOFTWARE_TAIL_TYPE); }
-int hns3_cae_qres_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_qres_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct qres_bufin_param *qres_in_param; - struct hns3_enet_ring *ring; - struct qres_param *out_info; + struct qres_bufin_param *qres_in_param = + (struct qres_bufin_param *)buf_in; + struct qres_param *out_info = (struct qres_param *)buf_out; + struct hns3_enet_ring *ring = NULL; + bool check = !buf_in || in_size < sizeof(struct qres_bufin_param) || + !buf_out || out_size < sizeof(struct qres_param); int bd_index; int tqps_num; int ring_id; - bool check;
- check = !buf_in || in_size < sizeof(struct qres_bufin_param) || - !buf_out || out_size < sizeof(struct qres_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
tqps_num = net_priv->ae_handle->kinfo.num_tqps; - out_info = (struct qres_param *)buf_out; - qres_in_param = (struct qres_bufin_param *)buf_in; ring_id = qres_in_param->queue_id; bd_index = qres_in_param->BD_id;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h index 4920bd3..08b11ad 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h @@ -64,7 +64,7 @@ enum qres_queue_type { TYPE_TX, };
-int hns3_cae_qres_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_qres_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c index 44dbb0b..1c95f65 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c @@ -12,18 +12,18 @@ #include "hclge_main.h" #include "hns3_cae_reset.h"
-int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_nic_reset(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define MIN_DOG_INTVAL 12 struct hnae3_handle *h = net_priv->ae_handle; - struct reset_param *reset_info; + struct reset_param *reset_info = (struct reset_param *)buf_in; enum hnae3_reset_type rst_type; - struct hclge_vport *vport; - struct hclge_dev *hdev; - bool check; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; + bool check = !buf_in || in_size < sizeof(struct reset_param);
- check = !buf_in || in_size < sizeof(struct reset_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -31,7 +31,6 @@ int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv,
vport = container_of(h, struct hclge_vport, nic); hdev = vport->back; - reset_info = (struct reset_param *)buf_in; rst_type = HNAE3_NONE_RESET;
if (test_bit(HCLGE_STATE_REMOVING, &hdev->state)) { @@ -61,24 +60,21 @@ int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_nic_timeout_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { + struct tx_timeout_param *out_info = + (struct tx_timeout_param *)buf_out; + struct tx_timeout_param *in_info = (struct tx_timeout_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct tx_timeout_param); struct net_device *netdev = net_priv->netdev; - struct tx_timeout_param *in_info; - struct tx_timeout_param *out_info; - bool check;
- check = !buf_in || in_size < sizeof(struct tx_timeout_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- in_info = (struct tx_timeout_param *)buf_in; - out_info = (struct tx_timeout_param *)buf_out; - if (in_info->wr_flag) { netdev->watchdog_timeo = (in_info->tx_timeout_size) * HZ; } else { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h index 68487b1..3439dd3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h @@ -13,9 +13,10 @@ struct tx_timeout_param { u16 tx_timeout_size; };
-int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_nic_timeout_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_nic_reset(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c index 3c0db59..f263156 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c @@ -22,7 +22,7 @@ static int hclge_set_rss_algo_key(struct hclge_dev *hdev, const u8 hfunc, const u8 *key) { - struct hclge_rss_config_cmd *req; + struct hclge_rss_config_cmd *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc; int key_offset; @@ -54,31 +54,26 @@ static int hclge_set_rss_algo_key(struct hclge_dev *hdev, return 0; }
-static int hns3_cae_set_rss_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_set_rss_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_rss_config_cmd *in_info; + struct hclge_rss_config_cmd *in_info = + (struct hclge_rss_config_cmd *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hclge_rss_config_cmd); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; + u8 *key = vport->rss_hash_key; enum hclge_cmd_status status; - struct hclge_vport *vport; - struct hclge_dev *hdev; u8 hash_config; - bool check; - u8 *key;
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - key = vport->rss_hash_key; - - check = !buf_in || in_size < sizeof(struct hclge_rss_config_cmd); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- in_info = (struct hclge_rss_config_cmd *)buf_in; hash_config = - ((u8)(vport->rss_algo) & (HASH_ALG_MASK)) | in_info->hash_config; + ((u8)(vport->rss_algo) & (HASH_ALG_MASK)) | in_info->hash_config; status = hclge_set_rss_algo_key(hdev, hash_config, key); if (status) { dev_err(&hdev->pdev->dev, @@ -90,27 +85,23 @@ static int hns3_cae_set_rss_cfg(struct hns3_nic_priv *net_priv, return 0; }
-static int hns3_cae_get_rss_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_get_rss_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_rss_config_cmd *req; + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + bool check = !buf_out || out_size < sizeof(u8); + struct hclge_rss_config_cmd *req = NULL; + struct hclge_dev *hdev = vport->back; enum hclge_cmd_status status; u8 *out_buf = (u8 *)buf_out; - struct hclge_vport *vport; - struct hclge_dev *hdev; struct hclge_desc desc; - bool check;
- check = !buf_out || out_size < sizeof(u8); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_RSS_GENERIC_CONFIG, true); status = hns3_cae_cmd_send(hdev, &desc, 1); @@ -125,14 +116,14 @@ static int hns3_cae_get_rss_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_rss_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_rss_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct rss_config *mode_param; - bool check; + bool check = !buf_in || in_size < sizeof(struct rss_config); + struct rss_config *mode_param = NULL; int ret;
- check = !buf_in || in_size < sizeof(struct rss_config); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h index 67c0242..584970b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h @@ -13,7 +13,7 @@ struct rss_config { u8 is_read; };
-int hns3_cae_rss_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rss_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c index a6dba8d..ea69639 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c @@ -102,16 +102,16 @@ static int hns3_get_stat_val(struct ring_stats *r_stats, char *val_name, return HCLGE_STATUS_SUCCESS; }
-static int hns3_read_stat_mode_cfg(struct hns3_nic_priv *nic_dev, +static int hns3_read_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct stat_sw_mode_param *stat_sw_param; - struct hnae3_knic_private_info *kinfo; + struct stat_sw_mode_param *stat_sw_param = NULL; + struct hnae3_knic_private_info *kinfo = NULL; u64 *ret_data = (u64 *)buf_out; - struct hnae3_handle *handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hnae3_handle *handle = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; u64 *val = NULL; u32 ring_idx; int ret; @@ -151,15 +151,15 @@ static int hns3_read_stat_mode_cfg(struct hns3_nic_priv *nic_dev, return HCLGE_STATUS_SUCCESS; }
-static int hns3_set_stat_mode_cfg(struct hns3_nic_priv *nic_dev, +static int hns3_set_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct stat_sw_mode_param *stat_sw_param; - struct hnae3_knic_private_info *kinfo; - struct hnae3_handle *handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct stat_sw_mode_param *stat_sw_param = NULL; + struct hnae3_knic_private_info *kinfo = NULL; + struct hnae3_handle *handle = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; u64 *val = NULL; u32 ring_idx; int ret; @@ -194,14 +194,14 @@ static int hns3_set_stat_mode_cfg(struct hns3_nic_priv *nic_dev, return HCLGE_STATUS_SUCCESS; }
-int hns3_stat_mode_cfg(struct hns3_nic_priv *nic_dev, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct stat_sw_mode_param *mode_param; - bool check; + struct stat_sw_mode_param *mode_param = NULL; + bool check = !buf_in || in_size < sizeof(struct stat_sw_mode_param); int ret;
- check = !buf_in || in_size < sizeof(struct stat_sw_mode_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -218,17 +218,17 @@ int hns3_stat_mode_cfg(struct hns3_nic_priv *nic_dev, return ret; }
-int hns3_cae_clean_stats(struct hns3_nic_priv *net_priv, +int hns3_cae_clean_stats(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct net_device *netdev = net_priv->netdev; - struct hnae3_knic_private_info *kinfo; - struct hnae3_handle *handle; - struct hns3_enet_ring *ring; - struct hclge_vport *vport; - struct hclge_dev *hdev; - struct hclge_tqp *tqp; + struct hnae3_knic_private_info *kinfo = NULL; + struct hnae3_handle *handle = NULL; + struct hns3_enet_ring *ring = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; + struct hclge_tqp *tqp = NULL; int i;
handle = net_priv->ae_handle; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h index f8c19c5..a54ef8e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h @@ -43,10 +43,10 @@ struct ring_stats_name { u32 stats_namd_id; };
-int hns3_stat_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_clean_stats(struct hns3_nic_priv *net_priv, +int hns3_cae_clean_stats(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c index c5ec226..b3a89e2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c @@ -455,27 +455,25 @@ static int hns3_cae_tm_operate_nic_regs(struct hclge_dev *hdev, return 0; }
-int hns3_cae_queue_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_queue_cfg_info *out_info = NULL; - struct hns3_cae_queue_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_queue_cfg_info *out_info = + (struct hns3_cae_queue_cfg_info *)buf_out; + struct hns3_cae_queue_cfg_info *in_info = + (struct hns3_cae_queue_cfg_info *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_cae_queue_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; - bool check;
- check = !buf_in || in_size < sizeof(struct hns3_cae_queue_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_queue_cfg_info *)buf_in; - out_info = (struct hns3_cae_queue_cfg_info *)buf_out; is_read = in_info->is_read;
if (is_read) { @@ -547,32 +545,30 @@ static int hns3_cae_qs_set_new_map(int tc, u32 map, return 0; }
-int hns3_cae_qs_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_qs_cfg_info *out_info = NULL; - struct hns3_cae_qs_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_qs_cfg_info *out_info = + (struct hns3_cae_qs_cfg_info *)buf_out; + struct hns3_cae_qs_cfg_info *in_info = + (struct hns3_cae_qs_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_qs_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; int offset; u32 bp_map; - bool check; u16 qs_id; int gp_id; int ret; int tc;
- check = !buf_in || in_size < sizeof(struct hns3_cae_qs_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_qs_cfg_info *)buf_in; - out_info = (struct hns3_cae_qs_cfg_info *)buf_out; is_read = in_info->is_read; qs_id = in_info->qs_id; gp_id = qs_id / 32; @@ -694,29 +690,27 @@ static int hns3_cae_pri_pg_set_map(struct hclge_dev *hdev, return 0; }
-int hns3_cae_pri_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_pri_cfg_info *out_info = NULL; - struct hns3_cae_pri_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_pri_cfg_info *out_info = + (struct hns3_cae_pri_cfg_info *)buf_out; + struct hns3_cae_pri_cfg_info *in_info = + (struct hns3_cae_pri_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_pri_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; u16 pri_id; int cur_pg; - bool check; u8 bitmap;
- check = !buf_in || in_size < sizeof(struct hns3_cae_pri_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_pri_cfg_info *)buf_in; - out_info = (struct hns3_cae_pri_cfg_info *)buf_out; is_read = in_info->is_read;
pri_id = in_info->pri_id; @@ -824,27 +818,24 @@ int hns3_cae_pri_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_pg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_pg_cfg_info *out_info = NULL; - struct hns3_cae_pg_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_pg_cfg_info *out_info = + (struct hns3_cae_pg_cfg_info *)buf_out; + struct hns3_cae_pg_cfg_info *in_info = + (struct hns3_cae_pg_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_pg_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; - bool check; u16 pg_id;
- check = !buf_in || in_size < sizeof(struct hns3_cae_pg_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_pg_cfg_info *)buf_in; - out_info = (struct hns3_cae_pg_cfg_info *)buf_out; is_read = in_info->is_read; pg_id = in_info->pg_id;
@@ -925,27 +916,25 @@ int hns3_cae_pg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, return 0; }
-int hns3_cae_port_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_port_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_port_cfg_info *out_info = NULL; - struct hns3_cae_port_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_port_cfg_info *out_info = + (struct hns3_cae_port_cfg_info *)buf_out; + struct hns3_cae_port_cfg_info *in_info = + (struct hns3_cae_port_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_port_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; u16 port_id; int is_read; - bool check;
- check = !buf_in || in_size < sizeof(struct hns3_cae_port_cfg_info); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_port_cfg_info *)buf_in; - out_info = (struct hns3_cae_port_cfg_info *)buf_out; is_read = in_info->is_read; port_id = in_info->port_id;
@@ -975,33 +964,33 @@ int hns3_cae_port_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_ets_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define HNS3_TM_ETS_PORT_SHAPING 0x10820850 - struct hns3_cae_ets_cfg_info *out_info = NULL; - struct hns3_cae_ets_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_ets_cfg_info *out_info = + (struct hns3_cae_ets_cfg_info *)buf_out; + struct hns3_cae_ets_cfg_info *in_info = + (struct hns3_cae_ets_cfg_info *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_cae_ets_cfg_info) || + !buf_out || + out_size < sizeof(struct hns3_cae_ets_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; u8 weight[MAX_TC_NUM]; int is_read; - bool check; u16 tc_id; u8 mac_id; u64 value; u64 addr;
- check = !buf_in || in_size < sizeof(struct hns3_cae_ets_cfg_info) || - !buf_out || out_size < sizeof(struct hns3_cae_ets_cfg_info); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_ets_cfg_info *)buf_in; - out_info = (struct hns3_cae_ets_cfg_info *)buf_out; is_read = in_info->is_read; tc_id = in_info->tc_id; mac_id = in_info->mac_id; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h index 6a533d0..43627c6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h @@ -96,19 +96,21 @@ struct hns3_cae_ets_cfg_info { u8 flag; };
-int hns3_cae_queue_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_qs_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_pri_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_pg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size); -int hns3_cae_port_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_port_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_ets_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c index 53e1354..42809f1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c @@ -18,7 +18,7 @@ static int hns3_cae_get_commit_id(struct hnae3_handle *handle, u8 *commit_id, { #define COMMIT_ID_LEN 8 struct hclge_vport *vport = hns3_cae_get_vport(handle); - struct hns3_cae_commit_id_param *resp; + struct hns3_cae_commit_id_param *resp = NULL; struct hclge_dev *hdev = vport->back; struct hclge_desc desc; int ret, i; @@ -40,28 +40,26 @@ static int hns3_cae_get_commit_id(struct hnae3_handle *handle, u8 *commit_id, return 0; }
-int hns3_cae_get_fw_ver(struct hns3_nic_priv *nic_dev, void *buf_in, +int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_firmware_ver_param *out_buf; - struct hnae3_handle *handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; - bool check; + struct hns3_cae_firmware_ver_param *out_buf = + (struct hns3_cae_firmware_ver_param *)buf_out; + bool check = !buf_out || + out_size < sizeof(struct hns3_cae_firmware_ver_param); + + struct hnae3_handle *handle = nic_dev->ae_handle; + struct hclge_vport *vport = + container_of(handle, struct hclge_vport, nic); + struct hclge_dev *hdev = vport->back; + u32 fw_ver;
- check = !buf_out || - out_size < sizeof(struct hns3_cae_firmware_ver_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- handle = nic_dev->ae_handle; - vport = container_of(handle, struct hclge_vport, nic); - hdev = vport->back; - out_buf = (struct hns3_cae_firmware_ver_param *)buf_out; - if (hns3_cae_get_commit_id(handle, out_buf->commit_id, &out_buf->ncl_version)) return -EFAULT; @@ -75,9 +73,9 @@ int hns3_cae_get_fw_ver(struct hns3_nic_priv *nic_dev, void *buf_in, return 0; }
-int hns3_cae_get_driver_ver(struct hns3_nic_priv *nic_dev, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_cae_get_driver_ver(const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, + void *buf_out, u32 out_size) { if (!buf_out || out_size < strlen(HNS3_CAE_MOD_VERSION)) return -ENOMEM; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index b1e04e9..a6a07c7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.30.0" +#define HNS3_CAE_MOD_VERSION "1.9.32.0"
#define CMT_ID_LEN 8 #define RESV_LEN 3 @@ -24,9 +24,10 @@ struct hns3_cae_firmware_ver_param { u32 ncl_version; };
-int hns3_cae_get_fw_ver(struct hns3_nic_priv *nic_dev, void *buf_in, +int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_get_driver_ver(struct hns3_nic_priv *nic_dev, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_get_driver_ver(const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c index 53186f8..c626a51 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c @@ -14,31 +14,27 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_vlan.h"
-int hns3_cae_upmapping_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_upmapping_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HCLGE_OPC_VLANUP_MAPPING_VF_TX_CFG 0x0F10 #define HCLGE_OPC_VLANUP_MAPPING_PORT_TX_CFG 0x0F11 - struct hns3_cae_vlanup_param *out_info; - struct hns3_cae_vlanup_param *in_info; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hns3_cae_vlanup_param *out_info = + (struct hns3_cae_vlanup_param *)buf_out; + struct hns3_cae_vlanup_param *in_info = + (struct hns3_cae_vlanup_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_vlanup_param); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_vlanup_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_vlanup_param *)buf_in; - out_info = (struct hns3_cae_vlanup_param *)buf_out; - if (in_info->is_read) { check = !buf_out || out_size < sizeof(struct hns3_cae_vlanup_param); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h index f983dbf..54739fb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h @@ -34,7 +34,7 @@ struct hns3_cae_vlanup_param { u8 module; };
-int hns3_cae_upmapping_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_upmapping_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c index ef26cb9..9862e4a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c @@ -18,7 +18,7 @@ static int hns3_get_sfp_present(struct hnae3_handle *handle, u32 *present) { struct hclge_vport *vport = hns3_cae_get_vport(handle); struct hclge_dev *hdev = vport->back; - struct hclge_sfp_present_cmd *resp; + struct hclge_sfp_present_cmd *resp = NULL; struct hclge_desc desc; int ret;
@@ -42,7 +42,7 @@ static int _hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, struct hclge_dev *hdev = vport->back; struct hclge_sfp_info *resp = NULL; u32 data_length; - u8 *temp_data; + u8 *temp_data = NULL; u32 temp_len; int ret; u32 i; @@ -98,7 +98,7 @@ static int hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, u16 offset, u16 size, u16 *outlen) { u16 tmp_size; - u8 *tmp_buff; + u8 *tmp_buff = NULL; u16 tmp_outlen; int ret;
@@ -144,26 +144,20 @@ int hns3_set_sfp_state(struct hnae3_handle *handle, bool en) return ret; }
-int hns3_xsfp_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_xsfp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size) { - struct hns3_xsfp_info *xsfp_info_out; - struct hnae3_handle *handle; - struct hns3_cfg_xsfp *param; + struct hns3_xsfp_info *xsfp_info_out = (struct hns3_xsfp_info *)buf_out; + bool check = !buf_in || in_size < sizeof(struct hns3_cfg_xsfp) || + !buf_out || out_size < sizeof(struct hns3_xsfp_info); + struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); + struct hns3_cfg_xsfp *param = (struct hns3_cfg_xsfp *)buf_in; u32 sfp_present = 0; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cfg_xsfp) || - !buf_out || out_size < sizeof(struct hns3_xsfp_info); if (check) return -ENODEV;
- handle = hns3_get_handle(net_priv->netdev); - - param = (struct hns3_cfg_xsfp *)buf_in; - xsfp_info_out = (struct hns3_xsfp_info *)buf_out; - ret = hns3_get_sfp_present(handle, &sfp_present); if (ret) { pr_err("nic_get_sfp_present error.\n"); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h index 9789327..afcf21b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h @@ -45,7 +45,7 @@ struct hns3_xsfp_info { u8 sfp_info[STD_XSFP_INFO_MAX_SIZE]; };
-int hns3_xsfp_cfg(struct hns3_nic_priv *net_priv, void *buf_in, +int hns3_xsfp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 152571d..17d7c09 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.30.0" +#define HNS3_MOD_VERSION "1.9.32.0"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 04b15f4..20729a2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.30.0" +#define HCLGE_MOD_VERSION "1.9.32.0" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 5986540..47c9f16 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.30.0" +#define HCLGEVF_MOD_VERSION "1.9.32.0" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095