提交 fb6d05c2 编写于 作者: J Junxin Chen 提交者: Yang Yingliang

net: hns3: add protect for parameters and remove unused functions

driver inclusion
category: feature
bugzilla: NA
CVE: NA

----------------------------------

Add protect for hns3_cae and remove some functions, and change version
to 1.9.36.0.
Signed-off-by: NJunxin Chen <chenjunxin1@huawei.com>
Reviewed-by: NZhong Zhaohui <zhongzhaohui@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 c5e03556
...@@ -28,11 +28,10 @@ ccflags-y += -I$(PWD) \ ...@@ -28,11 +28,10 @@ ccflags-y += -I$(PWD) \
obj-$(CONFIG_HNS3) += hnae3.o obj-$(CONFIG_HNS3) += hnae3.o
#### compile hns3.ko #### compile hns3.ko
HNS3_OBJS = hns3_enet.o \ HNS3_OBJS = hns3_enet.o \
hns3_ethtool.o \ hns3_ethtool.o \
hns3_debugfs.o hns3_debugfs.o
HNS3_OBJS_IT = hns-customer/hns3_enet_it.o \ HNS3_OBJS_IT = hns-customer/hns3_enet_it.o
hns-customer/hns3_ext.o
obj-$(CONFIG_HNS3_ENET) += hns3.o obj-$(CONFIG_HNS3_ENET) += hns3.o
hns3-objs = $(HNS3_OBJS) $(HNS3_OBJS_IT) hns3-objs = $(HNS3_OBJS) $(HNS3_OBJS_IT)
...@@ -49,11 +48,8 @@ HCLGE_OBJ = hns3pf/hclge_main.o \ ...@@ -49,11 +48,8 @@ HCLGE_OBJ = hns3pf/hclge_main.o \
HCLGE_OBJ_IT_MAIN = hns-customer/hns3pf/hclge_main_it.o HCLGE_OBJ_IT_MAIN = hns-customer/hns3pf/hclge_main_it.o
HCLGE_OBJ_IT_EXPORT = hns-customer/hns3pf/hclge_ext.o
obj-$(CONFIG_HNS3_HCLGE) += hclge.o obj-$(CONFIG_HNS3_HCLGE) += hclge.o
hclge-objs := $(HCLGE_OBJ) $(HCLGE_OBJ_IT_MAIN) $(HCLGE_OBJ_IT_EXPORT) hclge-objs := $(HCLGE_OBJ) $(HCLGE_OBJ_IT_MAIN)
hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o
#### compile hclgevf.ko #### compile hclgevf.ko
obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o
...@@ -63,25 +59,20 @@ hclgevf-objs := hns3vf/hclgevf_main.o hns3vf/hclgevf_cmd.o hns3vf/hclgevf_mbx.o ...@@ -63,25 +59,20 @@ hclgevf-objs := hns3vf/hclgevf_main.o hns3vf/hclgevf_cmd.o hns3vf/hclgevf_mbx.o
#add rally code #add rally code
HNS3_CAE_OBJS_PRIM = hns3_cae/hns3_cae_init.o \ HNS3_CAE_OBJS_PRIM = hns3_cae/hns3_cae_init.o \
hns3_cae/hns3_cae_lib.o \ hns3_cae/hns3_cae_lib.o \
hns3_cae/hns3_cae_common.o \
hns3_cae/hns3_cae_dcb.o \ hns3_cae/hns3_cae_dcb.o \
hns3_cae/hns3_cae_lamp.o \ hns3_cae/hns3_cae_dcqcn.o \
hns3_cae/hns3_cae_dcqcn.o \ hns3_cae/hns3_cae_version.o \
hns3_cae/hns3_cae_mactbl.o \ hns3_cae/hns3_cae_reset.o \
hns3_cae/hns3_cae_version.o \ hns3_cae/hns3_cae_pfc_storm.o \
hns3_cae/hns3_cae_reset.o \ hns3_cae/hns3_cae_cmd.o
hns3_cae/hns3_cae_pfc_storm.o \
hns3_cae/hns3_cae_cmd.o
#add test code #add test code
HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \ HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \
hns3_cae/hns3_cae_ext.o \
hns3_cae/hns3_cae_fd.o \ hns3_cae/hns3_cae_fd.o \
hns3_cae/hns3_cae_hilink_param.o \ hns3_cae/hns3_cae_hilink_param.o \
hns3_cae/hns3_cae_checksum.o \ hns3_cae/hns3_cae_checksum.o \
hns3_cae/hns3_cae_irq.o \ hns3_cae/hns3_cae_irq.o \
hns3_cae/hns3_cae_gro.o \ hns3_cae/hns3_cae_gro.o \
hns3_cae/hns3_cae_mac.o \ hns3_cae/hns3_cae_mac.o \
hns3_cae/hns3_cae_pkt.o \
hns3_cae/hns3_cae_port.o \ hns3_cae/hns3_cae_port.o \
hns3_cae/hns3_cae_promisc.o \ hns3_cae/hns3_cae_promisc.o \
hns3_cae/hns3_cae_qinfo.o \ hns3_cae/hns3_cae_qinfo.o \
...@@ -92,6 +83,6 @@ HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \ ...@@ -92,6 +83,6 @@ HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \
hns3_cae/hns3_cae_tm.o \ hns3_cae/hns3_cae_tm.o \
hns3_cae/hns3_cae_vlan.o \ hns3_cae/hns3_cae_vlan.o \
hns3_cae/hns3_cae_xsfp.o \ hns3_cae/hns3_cae_xsfp.o \
hns3_cae/hns3_cae_led.o hns3_cae/hns3_cae_led.o
obj-$(CONFIG_HNS3_CAE) += hns3_cae.o obj-$(CONFIG_HNS3_CAE) += hns3_cae.o
hns3_cae-objs := $(HNS3_CAE_OBJS_PRIM) $(HNS3_CAE_OBJS_EXT) hns3_cae-objs := $(HNS3_CAE_OBJS_PRIM) $(HNS3_CAE_OBJS_EXT)
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/types.h> #include <linux/types.h>
#define HNAE3_MOD_VERSION "1.9.35.1" #define HNAE3_MOD_VERSION "1.9.36.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */ #define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
......
// SPDX-License-Identifier: GPL-2.0+
// Copyright (c) 2016-2017 Hisilicon Limited.
#ifdef CONFIG_HNS3_TEST
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/interrupt.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/skbuff.h>
#include <linux/sctp.h>
#include <linux/vermagic.h>
#include <net/gre.h>
#include <net/pkt_cls.h>
#include <net/vxlan.h>
#include "hns3_ext.h"
extern const char hns3_driver_name[];
int nic_netdev_match_check(struct net_device *netdev)
{
struct ethtool_drvinfo drv_info;
if (!netdev)
return -EINVAL;
if (netdev->ethtool_ops && netdev->ethtool_ops->get_drvinfo)
netdev->ethtool_ops->get_drvinfo(netdev, &drv_info);
if (!strncmp(drv_info.driver, hns3_driver_name,
strlen(hns3_driver_name)))
return 0;
return -EINVAL;
}
EXPORT_SYMBOL(nic_netdev_match_check);
void nic_chip_recover_handler(struct net_device *netdev,
enum hnae3_event_type_custom event_t)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(netdev))
return;
dev_info(&netdev->dev, "reset type is %d!!\n", event_t);
if (event_t == HNAE3_PPU_POISON_CUSTOM)
event_t = HNAE3_FUNC_RESET_CUSTOM;
if (event_t != HNAE3_FUNC_RESET_CUSTOM &&
event_t != HNAE3_GLOBAL_RESET_CUSTOM &&
event_t != HNAE3_IMP_RESET_CUSTOM) {
dev_err(&netdev->dev, "reset type err!!\n");
return;
}
h = hns3_get_handle(netdev);
if (h->ae_algo->ops->priv_ops)
h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_RESET, &event_t, 0);
}
EXPORT_SYMBOL(nic_chip_recover_handler);
int nic_clean_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats)
{
struct hns3_nic_priv *priv;
struct hnae3_handle *h;
struct hnae3_knic_private_info *kinfo;
struct hns3_enet_ring *ring;
int i;
if (nic_netdev_match_check(ndev))
return -ENODEV;
priv = netdev_priv(ndev);
h = hns3_get_handle(ndev);
kinfo = &h->kinfo;
if (h->ae_algo->ops->priv_ops)
h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_CLEAN_STATS64, stats,
0);
for (i = 0; i < kinfo->num_tqps; i++) {
ring = &priv->ring[i];
memset(&ring->stats, 0, sizeof(struct ring_stats));
ring = &priv->ring[i + kinfo->num_tqps];
memset(&ring->stats, 0, sizeof(struct ring_stats));
}
memset(&ndev->stats, 0, sizeof(struct net_device_stats));
return 0;
}
EXPORT_SYMBOL(nic_clean_stats64);
int nic_get_chipid(struct net_device *ndev, u32 *chip_id)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!chip_id)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_CHIPID,
chip_id, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_chipid);
int nic_get_mac_id(struct net_device *ndev, u32 *mac_id)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!mac_id)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_MAC_ID,
mac_id, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_mac_id);
int nic_get_sfpinfo(struct net_device *ndev, u8 *buff, u16 size, u16 *outlen)
{
struct hns3_sfp_info_para para;
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!buff || !outlen)
return -EINVAL;
para.buff = buff;
para.outlen = outlen;
para.offset = 0;
para.size = size;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops) {
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_SFPINFO,
&para, 0);
} else {
return -EOPNOTSUPP;
}
}
EXPORT_SYMBOL(nic_get_sfpinfo);
int nic_get_sfp_present(struct net_device *ndev, int *present)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!present)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_PRESENT,
present, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_sfp_present);
int nic_set_sfp_state(struct net_device *ndev, bool en)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_SFP_STATE,
&en, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_set_sfp_state);
int nic_get_chip_num(struct net_device *ndev, u32 *chip_num)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!chip_num)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_CHIP_NUM,
chip_num, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_chip_num);
int nic_get_port_num_per_chip(struct net_device *ndev, u32 *port_num)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!port_num)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_PORT_NUM,
port_num, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_port_num_per_chip);
int nic_set_led(struct net_device *ndev, int type, int status)
{
struct hns3_led_state_para para;
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
para.status = status;
para.type = type;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_LED, &para,
0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_set_led);
int nic_get_led_signal(struct net_device *ndev, struct hns3_lamp_signal *signal)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!signal)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_LED_SIGNAL,
signal, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_led_signal);
int nic_disable_net_lane(struct net_device *ndev)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_DISABLE_LANE,
NULL, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_disable_net_lane);
int nic_get_net_lane_status(struct net_device *ndev, u32 *status)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!status)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_GET_LANE_STATUS,
status, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_net_lane_status);
int nic_set_mac_state(struct net_device *ndev, int enable)
{
struct hnae3_handle *h;
bool en;
if (nic_netdev_match_check(ndev))
return -ENODEV;
h = hns3_get_handle(ndev);
en = !!enable;
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_MAC_STATE,
&en, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_set_mac_state);
int nic_set_cpu_affinity(struct net_device *netdev, cpumask_t *affinity_mask)
{
struct hns3_enet_tqp_vector *tqp_vector;
struct hns3_nic_priv *priv;
int ret;
u16 i;
if (!netdev || !affinity_mask) {
pr_err("Invalid input param when set ethernet cpu affinity\n");
return -EINVAL;
}
if (nic_netdev_match_check(netdev))
return -ENODEV;
priv = netdev_priv(netdev);
if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) {
dev_err(&netdev->dev,
"ethernet is down, not support cpu affinity set\n");
return -EOPNOTSUPP;
}
for (i = 0; i < priv->vector_num; i++) {
tqp_vector = &priv->tqp_vector[i];
if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED)
continue;
tqp_vector->affinity_mask = *affinity_mask;
ret = irq_set_affinity_hint(tqp_vector->vector_irq, NULL);
if (ret) {
dev_err(&netdev->dev,
"reset affinity hint fail, ret = %d\n", ret);
return ret;
}
ret = irq_set_affinity_hint(tqp_vector->vector_irq,
&tqp_vector->affinity_mask);
if (ret) {
dev_err(&netdev->dev,
"set affinity hint fail, ret = %d\n", ret);
return ret;
}
}
dev_info(&netdev->dev, "set nic cpu affinity %*pb succeed\n",
cpumask_pr_args(affinity_mask));
return 0;
}
EXPORT_SYMBOL(nic_set_cpu_affinity);
int nic_disable_clock(struct net_device *ndev)
{
struct hnae3_handle *h;
u32 en;
if (nic_netdev_match_check(ndev))
return -ENODEV;
en = 0;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_CONFIG_CLOCK,
&en, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_disable_clock);
int nic_set_pfc_storm_para(struct net_device *ndev, int dir, int enable,
int period_ms, int times, int recovery_period_ms)
{
struct hns3_pfc_storm_para para;
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
para.dir = dir;
para.enable = enable;
para.period_ms = period_ms;
para.times = times;
para.recovery_period_ms = recovery_period_ms;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_SET_PFC_STORM_PARA,
&para, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_set_pfc_storm_para);
int nic_get_pfc_storm_para(struct net_device *ndev, int dir, int *enable,
int *period_ms, int *times, int *recovery_period_ms)
{
struct hns3_pfc_storm_para para;
struct hnae3_handle *h;
int ret;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!enable || !period_ms || !times || !recovery_period_ms) {
pr_err("get pfc storm para failed because invalid input param.\n");
return -EINVAL;
}
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops) {
para.dir = dir;
ret = h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_GET_PFC_STORM_PARA,
&para, 0);
if (!ret) {
*enable = para.enable;
*period_ms = para.period_ms;
*times = para.times;
*recovery_period_ms = para.recovery_period_ms;
return 0;
} else {
return ret;
}
} else {
return -EOPNOTSUPP;
}
}
EXPORT_SYMBOL(nic_get_pfc_storm_para);
int nic_get_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 *data)
{
struct hns3_phy_para para;
struct hnae3_handle *h;
int ret;
if (nic_netdev_match_check(ndev))
return -ENODEV;
para.page_select_addr = page_select_addr;
para.page = page;
para.reg_addr = reg_addr;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops) {
ret = h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_PHY_REG,
&para, 0);
if (!ret) {
*data = para.data;
return 0;
} else {
return ret;
}
} else {
return -EOPNOTSUPP;
}
}
EXPORT_SYMBOL(nic_get_phy_reg);
int nic_set_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 data)
{
struct hns3_phy_para para;
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
para.page_select_addr = page_select_addr;
para.page = page;
para.reg_addr = reg_addr;
para.data = data;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_PHY_REG,
&para, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_set_phy_reg);
int nic_get_hilink_ref_los(struct net_device *ndev, u32 *status)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!status)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_GET_HILINK_REF_LOS,
status, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_hilink_ref_los);
int nic_get_8211_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 *data)
{
struct hns3_phy_para phy_para;
struct hnae3_handle *h;
int ret;
if (nic_netdev_match_check(ndev))
return -ENODEV;
phy_para.page_select_addr = page_select_addr;
phy_para.page = page;
phy_para.reg_addr = reg_addr;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops) {
ret = h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_GET_8211_PHY_REG,
&phy_para, 0);
if (!ret) {
*data = phy_para.data;
return 0;
} else {
return ret;
}
} else {
return -EOPNOTSUPP;
}
}
EXPORT_SYMBOL(nic_get_8211_phy_reg);
int nic_set_8211_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 data)
{
struct hns3_phy_para phy_para;
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
phy_para.page_select_addr = page_select_addr;
phy_para.page = page;
phy_para.reg_addr = reg_addr;
phy_para.data = data;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_SET_8211_PHY_REG,
&phy_para, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_set_8211_phy_reg);
int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type)
{
struct hnae3_handle *h;
if (nic_netdev_match_check(ndev))
return -ENODEV;
if (!wire_type)
return -EINVAL;
h = hns3_get_handle(ndev);
if (h->ae_algo->ops->priv_ops)
return h->ae_algo->ops->priv_ops(h,
HNS3_EXT_OPC_GET_PORT_TYPE,
wire_type, 0);
else
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(nic_get_port_wire_type);
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2017 Hisilicon Limited. */
#ifndef __HNS3_EXT_H
#define __HNS3_EXT_H
#include <linux/types.h>
#include "hns3_enet.h"
#include "hnae3.h"
#include "hclge_main_it.h"
enum hns3_ext_op_code {
HNS3_EXT_OPC_CLEAN_STATS64 = 0,
HNS3_EXT_OPC_GET_CHIPID,
HNS3_EXT_OPC_GET_SFPINFO,
HNS3_EXT_OPC_SET_SFP_STATE,
HNS3_EXT_OPC_GET_CHIP_NUM,
HNS3_EXT_OPC_GET_PORT_NUM,
HNS3_EXT_OPC_SET_LED,
HNS3_EXT_OPC_GET_PRESENT,
HNS3_EXT_OPC_DISABLE_LANE,
HNS3_EXT_OPC_GET_LANE_STATUS,
HNS3_EXT_OPC_GET_LED_SIGNAL,
HNS3_EXT_OPC_SET_MAC_STATE,
HNS3_EXT_OPC_CONFIG_CLOCK,
HNS3_EXT_OPC_GET_PFC_STORM_PARA,
HNS3_EXT_OPC_SET_PFC_STORM_PARA,
HNS3_EXT_OPC_GET_PHY_REG,
HNS3_EXT_OPC_SET_PHY_REG,
HNS3_EXT_OPC_GET_MAC_ID,
HNS3_EXT_OPC_OPT_MAC_TABLE,
HNS3_EXT_OPC_RESET,
HNS3_EXT_OPC_GET_HILINK_REF_LOS,
HNS3_EXT_OPC_GET_8211_PHY_REG,
HNS3_EXT_OPC_SET_8211_PHY_REG,
HNS3_EXT_OPC_GET_PORT_TYPE,
};
struct hns3_sfp_info_para {
u8 *buff;
u16 offset;
u16 size;
u16 *outlen;
};
struct hns3_led_state_para {
u32 type;
u32 status;
};
struct hns3_pfc_storm_para {
u32 dir;
u32 enable;
u32 period_ms;
u32 times;
u32 recovery_period_ms;
};
struct hns3_phy_para {
u32 page_select_addr;
u32 reg_addr;
u16 page;
u16 data;
};
struct hns3_lamp_signal {
u8 error;
u8 locate;
u8 activity;
};
int nic_get_chipid(struct net_device *ndev, u32 *chip_id);
int nic_netdev_match_check(struct net_device *netdev);
int nic_get_sfpinfo(struct net_device *ndev, u8 *buff, u16 size, u16 *outlen);
int nic_get_sfp_present(struct net_device *ndev, int *present);
int nic_set_sfp_state(struct net_device *ndev, bool en);
int nic_clean_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats);
int nic_get_chip_num(struct net_device *ndev, u32 *chip_num);
int nic_get_port_num_per_chip(struct net_device *ndev, u32 *port_num);
int nic_set_led(struct net_device *ndev, int type, int status);
int nic_disable_net_lane(struct net_device *ndev);
int nic_get_net_lane_status(struct net_device *ndev, u32 *status);
int nic_set_cpu_affinity(struct net_device *netdev, cpumask_t *affinity_mask);
int nic_set_mac_state(struct net_device *ndev, int enable);
int nic_disable_clock(struct net_device *ndev);
int nic_set_pfc_storm_para(struct net_device *ndev, int dir, int enable,
int period_ms, int times, int recovery_period_ms);
int nic_get_pfc_storm_para(struct net_device *ndev, int dir, int *enable,
int *period_ms, int *times, int *recovery_period_ms);
int nic_get_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 *data);
int nic_set_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 data);
int nic_get_mac_id(struct net_device *ndev, u32 *mac_id);
int nic_get_hilink_ref_los(struct net_device *ndev, u32 *status);
int nic_get_8211_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 *data);
int nic_set_8211_phy_reg(struct net_device *ndev, u32 page_select_addr,
u16 page, u32 reg_addr, u16 data);
int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type);
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2017 Hisilicon Limited. */
#ifndef __HCLGE_EXT_H
#define __HCLGE_EXT_H
#include <linux/types.h>
#include "hnae3.h"
#ifdef CONFIG_IT_VALIDATION
#define HCLGE_SFP_INFO_LEN 6
#define HCLGE_SFP_INFO_SIZE 140
#define HCLGE_8211_PHY_INDIRECT_PAGE 0xa43
#define HCLGE_8211_PHY_INDIRECT_REG 0x1b
#define HCLGE_8211_PHY_INDIRECT_DATA 0x1c
#define HCLGE_8211_PHY_INDIRECT_RANGE1_S 0xDC0
#define HCLGE_8211_PHY_INDIRECT_RANGE1_E 0xDCF
#define HCLGE_8211_PHY_INDIRECT_RANGE2_S 0xDE0
#define HCLGE_8211_PHY_INDIRECT_RANGE2_E 0xDF0
#define HCLGE_OPC_CONFIG_NIC_CLOCK 0x0060
#define PORT_QUERY_TYPE_SFP 1
struct hclge_chip_id_cmd {
u32 chip_id;
u32 rsv[5];
};
struct hclge_sfp_info_para {
u8 *buff;
u16 offset;
u16 size;
u16 *outlen;
};
struct hclge_sfp_info {
u32 sfpinfo[6];
};
struct hclge_led_state {
u32 type;
u32 status;
};
struct hclge_pfc_storm_para {
u32 dir;
u32 enable;
u32 period_ms;
u32 times;
u32 recovery_period_ms;
};
struct hclge_phy_para {
u32 page_select_addr;
u32 reg_addr;
u16 page;
u16 data;
};
struct hclge_sfp_enable_cmd {
u32 set_sfp_enable_flag;
u32 rsv[5];
};
struct hclge_sfp_present_cmd {
u32 sfp_present;
u32 rsv[5];
};
struct hclge_lamp_signal {
u8 error;
u8 locate;
u8 activity;
};
struct hclge_mac_table_para {
u8 op_cmd;
u8 mac_addr[ETH_ALEN];
};
enum hclge_ext_op_code {
HCLGE_EXT_OPC_CLEAN_STATS64 = 0,
HCLGE_EXT_OPC_GET_CHIPID,
HCLGE_EXT_OPC_GET_SFPINFO,
HCLGE_EXT_OPC_SET_SFP_STATE,
HCLGE_EXT_OPC_GET_CHIP_NUM,
HCLGE_EXT_OPC_GET_PORT_NUM,
HCLGE_EXT_OPC_SET_LED,
HCLGE_EXT_OPC_GET_PRESENT,
HCLGE_EXT_OPC_DISABLE_LANE,
HCLGE_EXT_OPC_GET_LANE_STATUS,
HCLGE_EXT_OPC_GET_LED_SIGNAL,
HCLGE_EXT_OPC_SET_MAC_STATE,
HCLGE_EXT_OPC_CONFIG_CLOCK,
HCLGE_EXT_OPC_GET_PFC_STORM_PARA,
HCLGE_EXT_OPC_SET_PFC_STORM_PARA,
HCLGE_EXT_OPC_GET_PHY_REG,
HCLGE_EXT_OPC_SET_PHY_REG,
HCLGE_EXT_OPC_GET_MAC_ID,
HCLGE_EXT_OPC_OPT_MAC_TABLE,
HCLGE_EXT_OPC_RESET,
HCLGE_EXT_OPC_GET_HILINK_REF_LOS,
HCLGE_EXT_OPC_GET_8211_PHY_REG,
HCLGE_EXT_OPC_SET_8211_PHY_REG,
HCLGE_EXT_OPC_GET_PORT_TYPE,
};
enum hclge_opt_table_code {
HCLGE_OPT_TABLE_LOOKUP,
HCLGE_OPT_TABLE_ADD,
HCLGE_OPT_TABLE_DEL,
};
struct hclge_ext_func {
int opcode;
int (*priv_ops)(struct hnae3_handle *handle, int opcode,
void *data, int length);
};
enum hclge_ext_opcode_type {
/* misc command */
HCLGE_OPC_CHIP_ID_GET = 0x7003,
HCLGE_OPC_IMP_COMMIT_ID_GET = 0x7004,
HCLGE_OPC_GET_CHIP_NUM = 0x7005,
HCLGE_OPC_GET_PORT_NUM = 0x7006,
HCLGE_OPC_SET_LED = 0x7007,
HCLGE_OPC_DISABLE_NET_LANE = 0x7008,
HCLGE_OPC_CFG_PAUSE_STORM_PARA = 0x7019,
HCLGE_OPC_CFG_GET_HILINK_REF_LOS = 0x701B,
/*SFP command */
HCLGE_OPC_SFP_GET_INFO = 0x7100,
HCLGE_OPC_SFP_GET_PRESENT = 0x7101,
HCLGE_OPC_SFP_SET_STATUS = 0x7102,
HCLGE_OPC_SFP_GET_PORT_INFO = 0x7104,
};
int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode,
void *data, int length);
void hclge_reset_task_schedule_it(struct hclge_dev *hdev);
#endif
#endif
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "hclge_cmd.h" #include "hclge_cmd.h"
#include "hclge_main.h" #include "hclge_main.h"
#include "hnae3.h" #include "hnae3.h"
#include "hclge_ext.h"
#include "hclge_main_it.h" #include "hclge_main_it.h"
#ifdef CONFIG_IT_VALIDATION #ifdef CONFIG_IT_VALIDATION
...@@ -46,17 +45,16 @@ int nic_unregister_event(void) ...@@ -46,17 +45,16 @@ int nic_unregister_event(void)
} }
EXPORT_SYMBOL(nic_unregister_event); EXPORT_SYMBOL(nic_unregister_event);
void nic_call_event(struct net_device *netdev, static void nic_call_event(struct net_device *netdev,
enum hnae3_event_type_custom event_t) enum hnae3_event_type_custom event_t)
{ {
if (nic_event_call) { if (nic_event_call) {
nic_event_call(netdev, event_t); nic_event_call(netdev, event_t);
netdev_info(netdev, "report event %d\n", event_t); netdev_info(netdev, "report event %d\n", event_t);
} }
} }
EXPORT_SYMBOL(nic_call_event);
void hclge_handle_imp_error_it(struct hnae3_handle *handle) static void hclge_handle_imp_error_it(struct hnae3_handle *handle)
{ {
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
...@@ -85,6 +83,14 @@ void hclge_handle_imp_error_it(struct hnae3_handle *handle) ...@@ -85,6 +83,14 @@ void hclge_handle_imp_error_it(struct hnae3_handle *handle)
} }
static void hclge_reset_task_schedule_it(struct hclge_dev *hdev)
{
if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) &&
!test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state))
mod_delayed_work_on(cpumask_first(&hdev->affinity_mask),
system_wq, &hdev->service_task, 0);
}
void hclge_reset_event_it(struct pci_dev *pdev, struct hnae3_handle *handle) void hclge_reset_event_it(struct pci_dev *pdev, struct hnae3_handle *handle)
{ {
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
...@@ -168,10 +174,6 @@ bool hclge_reset_done_it(struct hnae3_handle *handle, bool done) ...@@ -168,10 +174,6 @@ bool hclge_reset_done_it(struct hnae3_handle *handle, bool done)
int hclge_init_it(void) int hclge_init_it(void)
{ {
#ifdef CONFIG_HNS3_TEST
hclge_ops.priv_ops = hclge_ext_ops_handle;
#endif
hclge_ops.reset_event = hclge_reset_event_it; hclge_ops.reset_event = hclge_reset_event_it;
hclge_ops.reset_done = hclge_reset_done_it; hclge_ops.reset_done = hclge_reset_done_it;
hclge_ops.handle_imp_error = hclge_handle_imp_error_it; hclge_ops.handle_imp_error = hclge_handle_imp_error_it;
......
...@@ -48,7 +48,5 @@ int nic_register_event(nic_event_fn_t event_call); ...@@ -48,7 +48,5 @@ int nic_register_event(nic_event_fn_t event_call);
*/ */
int nic_unregister_event(void); int nic_unregister_event(void);
void nic_call_event(struct net_device *netdev,
enum hnae3_event_type_custom event_t);
int hclge_init(void); int hclge_init(void);
#endif #endif
// SPDX-License-Identifier: GPL-2.0+
// Copyright (c) 2016-2017 Hisilicon Limited.
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/phy_fixed.h>
#include <linux/platform_device.h>
#include "hclge_cmd.h"
#include "hclge_main.h"
#include "hnae3.h"
#include "hns3_enet.h"
#include "hns3_cae_cmd.h"
#include "hns3_cae_common.h"
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 = NULL;
struct hclge_dev *hdev = NULL;
struct hclge_desc desc;
int ret;
vport = hns3_cae_get_vport(net_priv->ae_handle);
hdev = vport->back;
if (in_buf->bits_width == 64) {
hns3_cae_cmd_setup_basic_desc(&desc, CMDQ_64_COM_CMD_OPCODE,
false);
desc.data[0] = in_buf->addr;
desc.data[1] = in_buf->data[0];
} else {
hns3_cae_cmd_setup_basic_desc(&desc, CMDQ_32_COM_CMD_OPCODE,
false);
desc.data[0] = in_buf->addr;
desc.data[2] = in_buf->data[0];
}
ret = hns3_cae_cmd_send(hdev, &desc, 1);
if (ret) {
dev_err(&hdev->pdev->dev, "%s fail, ret is %d.\n", __func__,
ret);
return ret;
}
return 0;
}
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)
{
struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle);
struct reg_ret_param *out_buf = (struct reg_ret_param *)buf_out;
struct reg_param *in_buf = (struct reg_param *)buf_in;
struct hclge_dev *hdev = vport->back;
struct hclge_desc desc;
bool check = !buf_out || out_size < sizeof(struct reg_param);
int ret;
if (check) {
pr_err("input param buf_out error in %s function\n", __func__);
return -EFAULT;
}
if (in_buf->bits_width == 64)
hns3_cae_cmd_setup_basic_desc(&desc,
CMDQ_64_COM_CMD_OPCODE, true);
else
hns3_cae_cmd_setup_basic_desc(&desc,
CMDQ_32_COM_CMD_OPCODE, true);
desc.data[0] = in_buf->addr;
ret = hns3_cae_cmd_send(hdev, &desc, 1);
if (ret) {
dev_err(&hdev->pdev->dev, "%s fail, ret is %d.\n", __func__,
ret);
return ret;
}
out_buf->value[0] = desc.data[0];
if (in_buf->bits_width == 64)
out_buf->value[1] = desc.data[1];
return 0;
}
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;
int ret;
if (check) {
pr_err("input param buf_in error in %s function\n", __func__);
return -EFAULT;
}
if (mode_param->is_read == 1)
ret = hns3_cae_read_reg_cfg(net_priv, buf_in, in_size,
buf_out, out_size);
else
ret = hns3_cae_write_reg_cfg(net_priv, buf_in, in_size,
buf_out, out_size);
return ret;
}
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2019 Hisilicon Limited. */
#ifndef __HNS3_CAE_COMMON_H
#define __HNS3_CAE_COMMON_H
#define REG_RDATA_NUM 2
#define CMDQ_32_COM_CMD_OPCODE 0xfffd
#define CMDQ_64_COM_CMD_OPCODE 0xffff
struct reg_param {
u32 addr;
u32 data[REG_RDATA_NUM];
u8 bits_width;
u8 is_read;
};
struct reg_ret_param {
u32 value[REG_RDATA_NUM];
};
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
...@@ -220,13 +220,7 @@ int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, ...@@ -220,13 +220,7 @@ int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv,
dcb_all_info[curr_dev_idx].pfc_cfg_info.prien = dcb_all_info[curr_dev_idx].pfc_cfg_info.prien =
in_info->prien; in_info->prien;
if (ndev->dcbnl_ops->ieee_setpfc) { if (ndev->dcbnl_ops->ieee_setpfc) {
#ifdef CONFIG_EXT_TEST
rtnl_lock();
#endif
ret = ndev->dcbnl_ops->ieee_setpfc(ndev, &pfc); ret = ndev->dcbnl_ops->ieee_setpfc(ndev, &pfc);
#ifdef CONFIG_EXT_TEST
rtnl_unlock();
#endif
if (ret) if (ret)
return ret; return ret;
} }
...@@ -397,13 +391,7 @@ int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, ...@@ -397,13 +391,7 @@ int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv,
curr_dev_idx); curr_dev_idx);
if (ndev->dcbnl_ops->ieee_setets) { if (ndev->dcbnl_ops->ieee_setets) {
#ifdef CONFIG_EXT_TEST
rtnl_lock();
#endif
ret = ndev->dcbnl_ops->ieee_setets(ndev, &ets); ret = ndev->dcbnl_ops->ieee_setets(ndev, &ets);
#ifdef CONFIG_EXT_TEST
rtnl_unlock();
#endif
if (ret) if (ret)
return ret; return ret;
} }
......
// SPDX-License-Identifier: GPL-2.0+
// Copyright (c) 2016-2017 Hisilicon Limited.
#if (defined CONFIG_EXT_TEST) && (defined CONFIG_IT_VALIDATION)
#include "hns3_cae_ext.h"
#include "hns3_ext.h"
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(const struct hns3_nic_priv *priv)
{
struct hns3_enet_tqp_vector *tqp_vector = NULL;
struct hnae3_handle *h = NULL;
int i;
if (!priv) {
pr_err("invalid input param when get cpu affinity\n");
return -EINVAL;
}
h = priv->ae_handle;
if (nic_netdev_match_check(priv->netdev))
return -ENODEV;
pr_info("%s : %d irq total.\n", h->pdev->driver->name,
priv->vector_num);
for (i = 0; i < priv->vector_num; i++) {
tqp_vector = &priv->tqp_vector[i];
if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED)
continue;
pr_err("irq %d ==> cpu affinity: %*pb\n",
tqp_vector->vector_irq,
cpumask_pr_args(&tqp_vector->affinity_mask));
}
return 0;
}
static int hns3_affi(const struct hns3_nic_priv *net_priv, void *in)
{
struct hns3_cpumask_param *cpumask_param = NULL;
cpumask_var_t cpumask_new;
int ret;
cpumask_param = (struct hns3_cpumask_param *)in;
if (cpumask_param->affi_exec_flag != HNS3_AFFI_GET_BIT) {
if (!alloc_cpumask_var(&cpumask_new, GFP_KERNEL))
return -ENOMEM;
ret = cpumask_parse(cpumask_param->mask, cpumask_new);
if (ret) {
pr_err("parse cpu affinity from user fail, ret = %d\n",
ret);
return ret;
}
ret = nic_set_cpu_affinity(net_priv->netdev, cpumask_new);
if (ret) {
pr_err("set cpu affinity fail, ret = %d\n", ret);
return ret;
}
} else {
ret = hns3_get_cpu_affinity(net_priv);
if (ret) {
pr_err("get cpu affinity fail, ret = %d\n", ret);
return ret;
}
}
return ret;
}
static int hns3_get_chipid(const struct hns3_nic_priv *net_priv, void *out)
{
u32 chip_id;
int ret;
ret = nic_get_chipid(net_priv->netdev, &chip_id);
if (!ret)
*(u32 *)out = chip_id;
return ret;
}
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_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;
return nic_set_led(netdev, para->type, para->status);
}
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;
struct hns3_priv_sfp_info_para *para_out =
(struct hns3_priv_sfp_info_para *)out;
struct net_device *netdev = net_priv->netdev;
int ret;
ret = nic_get_sfpinfo(netdev, para_out->buff, para_in->size,
&para_out->outlen);
return ret;
}
static int hns3_get_sfp_present(const struct hns3_nic_priv *net_priv,
void *out)
{
struct net_device *netdev = net_priv->netdev;
u32 present;
int ret;
ret = nic_get_sfp_present(netdev, &present);
if (!ret)
*(u32 *)out = present;
return ret;
}
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;
return nic_set_sfp_state(netdev, en);
}
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_get_chip_num(const struct hns3_nic_priv *net_priv, void *out)
{
u32 chip_num;
int ret;
ret = nic_get_chip_num(net_priv->netdev, &chip_num);
if (!ret)
*(u32 *)out = chip_num;
return ret;
}
static int hns3_get_port_num(const struct hns3_nic_priv *net_priv, void *out)
{
u32 port_num;
int ret;
ret = nic_get_port_num_per_chip(net_priv->netdev, &port_num);
if (!ret)
*(u32 *)out = port_num;
return ret;
}
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_get_lane_status(const struct hns3_nic_priv *net_priv,
void *out)
{
u32 lane_status;
int ret;
ret = nic_get_net_lane_status(net_priv->netdev, &lane_status);
if (!ret)
*(u32 *)out = lane_status;
return ret;
}
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;
return nic_set_mac_state(netdev, enable);
}
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;
return nic_set_pfc_storm_para(netdev, para->dir, para->enable,
para->period_ms, para->times,
para->recovery_period_ms);
}
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;
u32 recovery_period_ms;
u32 period_ms;
u32 enable;
u32 times;
u32 dir;
int ret;
dir = para_in->dir;
ret = nic_get_pfc_storm_para(netdev, dir, &enable, &period_ms,
&times, &recovery_period_ms);
if (!ret) {
para_out->dir = dir;
para_out->enable = enable;
para_out->period_ms = period_ms;
para_out->times = times;
para_out->recovery_period_ms = recovery_period_ms;
}
return ret;
}
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;
u32 page_select_addr = para_in->page_select_addr;
struct net_device *netdev = net_priv->netdev;
u32 reg_addr = para_in->reg_addr;
u16 page = para_in->page;
u16 data;
int ret;
if (phy_type == PHY_TYPE_8211)
ret = nic_get_8211_phy_reg(netdev, page_select_addr, page,
reg_addr, &data);
else
ret = nic_get_phy_reg(netdev, page_select_addr, page, reg_addr,
&data);
if (!ret) {
para_out->page = page;
para_out->reg_addr = reg_addr;
para_out->data = data;
}
return ret;
}
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;
if (phy_type == PHY_TYPE_8211)
return nic_set_8211_phy_reg(netdev, para->page_select_addr,
para->page, para->reg_addr,
para->data);
else
return nic_set_phy_reg(netdev, para->page_select_addr,
para->page, para->reg_addr,
para->data);
}
static int hns3_get_macid(const struct hns3_nic_priv *net_priv, void *out)
{
u32 mac_id;
int ret;
ret = nic_get_mac_id(net_priv->netdev, &mac_id);
if (!ret)
*(u32 *)out = mac_id;
return ret;
}
static int hns3_get_hilink_ref_los(const struct hns3_nic_priv *net_priv,
void *out)
{
u32 status;
int ret;
ret = nic_get_hilink_ref_los(net_priv->netdev, &status);
if (!ret)
*(u32 *)out = status;
return ret;
}
static int hns3_get_port_type(const struct hns3_nic_priv *net_priv, void *out)
{
u32 wire_type;
int ret;
ret = nic_get_port_wire_type(net_priv->netdev, &wire_type);
if (!ret)
*(u32 *)out = wire_type;
return ret;
}
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 *)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;
if (check) {
pr_err("input parameter error in %s function\n", __func__);
return -EFAULT;
}
in = ext_param_in->buf;
out = ext_param_out->buf;
switch (ext_param_in->op_code) {
case EXT_AFFI_MASK:
ret = hns3_affi(net_priv, in);
break;
case EXT_DISABLE_NET_CLK:
ret = hns3_disable_netclk(net_priv);
break;
case EXT_GET_CHIP_ID:
ret = hns3_get_chipid(net_priv, out);
break;
case EXT_NET_MATCH_CHECK:
ret = hns3_match_check(net_priv);
break;
case EXT_SET_LED:
ret = hns3_set_led(net_priv, in);
break;
case EXT_GET_SFP_INFO:
ret = hns3_get_sfp_info(net_priv, in, out);
break;
case EXT_GET_SFP_PRESENT:
ret = hns3_get_sfp_present(net_priv, out);
break;
case EXT_SET_SFP_STATE:
ret = hns3_set_sfp_state(net_priv, in);
break;
case EXT_CLEAN_STATS64:
ret = hns3_clean_stats64(net_priv);
break;
case EXT_GET_CHIP_NUM:
ret = hns3_get_chip_num(net_priv, out);
break;
case EXT_GET_PORT_NUM:
ret = hns3_get_port_num(net_priv, out);
break;
case EXT_DISABLE_NET_LANE:
ret = hns3_disable_net_lane(net_priv);
break;
case EXT_GET_LANE_STATUS:
ret = hns3_get_lane_status(net_priv, out);
break;
case EXT_SET_MAC_STATE:
ret = hns3_set_mac_state(net_priv, in);
break;
case EXT_SET_PFC_STORM_PARA:
ret = hns3_set_pfc_storm_para(net_priv, in);
break;
case EXT_GET_PFC_STORM_PARA:
ret = hns3_get_pfc_storm_para(net_priv, in, out);
break;
case EXT_GET_PHY_REG:
ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_1512);
break;
case EXT_SET_PHY_REG:
ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_1512);
break;
case EXT_GET_MAC_ID:
ret = hns3_get_macid(net_priv, out);
break;
case EXT_GET_HILINK_REF_LOS:
ret = hns3_get_hilink_ref_los(net_priv, out);
break;
case EXT_GET_8211_PHY_REG:
ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_8211);
break;
case EXT_SET_8211_PHY_REG:
ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_8211);
break;
case EXT_GET_PORT_TYPE:
ret = hns3_get_port_type(net_priv, out);
break;
default:
ret = -EFAULT;
}
return ret;
}
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2019 Hisilicon Limited. */
#ifndef __HNS3_CAE_EXT_H
#define __HNS3_CAE_EXT_H
#include "hnae3.h"
#include "hns3_enet.h"
#define HNS3_AFFI_SET_BIT BIT(0)
#define HNS3_AFFI_GET_BIT BIT(1)
#define HNS3_AFFI_MAX_LEN 34
enum ext_op_code {
EXT_AFFI_MASK = 0,
EXT_DISABLE_NET_CLK,
EXT_GET_CHIP_ID,
EXT_NET_MATCH_CHECK,
EXT_SET_LED,
EXT_GET_SFP_INFO,
EXT_GET_SFP_PRESENT,
EXT_SET_SFP_STATE,
EXT_CLEAN_STATS64,
EXT_GET_CHIP_NUM,
EXT_GET_PORT_NUM,
EXT_DISABLE_NET_LANE,
EXT_GET_LANE_STATUS,
EXT_SET_MAC_STATE,
EXT_SET_PFC_STORM_PARA,
EXT_GET_PFC_STORM_PARA,
EXT_GET_PHY_REG,
EXT_SET_PHY_REG,
EXT_GET_MAC_ID,
EXT_GET_HILINK_REF_LOS,
EXT_GET_8211_PHY_REG,
EXT_SET_8211_PHY_REG,
EXT_GET_PORT_TYPE,
};
enum phy_type {
PHY_TYPE_8211 = 0,
PHY_TYPE_1512,
};
struct hns3_cpumask_param {
u32 affi_exec_flag;
char mask[HNS3_AFFI_MAX_LEN];
};
struct hns3_priv_sfp_info_para {
u8 buff[768];
u16 offset;
u16 size;
u16 outlen;
};
struct cmd_ext_driver_param {
u32 op_code;
u32 judge_class;
u8 buf[1024];
};
int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv,
void *buf_in, u32 in_size,
void *buf_out, u32 out_size);
#endif
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "hns3_cae_cmd.h" #include "hns3_cae_cmd.h"
#include "hns3_cae_tm.h" #include "hns3_cae_tm.h"
#include "hns3_cae_dcb.h" #include "hns3_cae_dcb.h"
#include "hns3_cae_pkt.h"
#include "hns3_cae_mac.h" #include "hns3_cae_mac.h"
#include "hns3_cae_dfx.h" #include "hns3_cae_dfx.h"
#include "hns3_cae_vlan.h" #include "hns3_cae_vlan.h"
...@@ -29,12 +28,9 @@ ...@@ -29,12 +28,9 @@
#include "hns3_cae_promisc.h" #include "hns3_cae_promisc.h"
#include "hns3_cae_fd.h" #include "hns3_cae_fd.h"
#include "hns3_cae_rss.h" #include "hns3_cae_rss.h"
#include "hns3_cae_common.h"
#include "hns3_cae_qres.h" #include "hns3_cae_qres.h"
#include "hns3_cae_stat.h" #include "hns3_cae_stat.h"
#include "hns3_cae_irq.h" #include "hns3_cae_irq.h"
#include "hns3_cae_lamp.h"
#include "hns3_cae_ext.h"
#include "hns3_cae_pfc_storm.h" #include "hns3_cae_pfc_storm.h"
#include "hns3_cae_xsfp.h" #include "hns3_cae_xsfp.h"
#include "hns3_cae_port.h" #include "hns3_cae_port.h"
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
#include "hns3_cae_dcqcn.h" #include "hns3_cae_dcqcn.h"
#include "hns3_cae_reset.h" #include "hns3_cae_reset.h"
#include "hns3_cae_gro.h" #include "hns3_cae_gro.h"
#include "hns3_cae_mactbl.h"
#include "hns3_cae_led.h" #include "hns3_cae_led.h"
#define MAX_MSG_OUT_SIZE (1024U * 2048U) #define MAX_MSG_OUT_SIZE (1024U * 2048U)
...@@ -153,7 +148,7 @@ static int hns3_cae_netdev_match_check(struct net_device *netdev) ...@@ -153,7 +148,7 @@ static int hns3_cae_netdev_match_check(struct net_device *netdev)
netdev->ethtool_ops->get_drvinfo(netdev, &drv_info); netdev->ethtool_ops->get_drvinfo(netdev, &drv_info);
if (!strncmp(drv_info.driver, hns3_driver_name, if (!strncmp(drv_info.driver, hns3_driver_name,
strlen(hns3_driver_name))) strlen(hns3_driver_name) + 1))
return 0; return 0;
netdev_err(netdev, "match hns3 driver name(%s) failed\n", netdev_err(netdev, "match hns3 driver name(%s) failed\n",
...@@ -243,7 +238,6 @@ struct drv_module_handle driv_module_cmd_handle[] = { ...@@ -243,7 +238,6 @@ struct drv_module_handle driv_module_cmd_handle[] = {
{DFX_INFO_CMD, hns3_cae_get_dfx_info}, {DFX_INFO_CMD, hns3_cae_get_dfx_info},
{DFX_READ_CMD, hns3_cae_read_dfx_info}, {DFX_READ_CMD, hns3_cae_read_dfx_info},
{EVENT_INJECTION_CMD, hns3_cae_event_injection}, {EVENT_INJECTION_CMD, hns3_cae_event_injection},
{SEND_PKT, hns3_cae_send_pkt},
{RX_PRIV_BUFF_WL_CFG, hns3_cae_rx_priv_buff_wl_cfg}, {RX_PRIV_BUFF_WL_CFG, hns3_cae_rx_priv_buff_wl_cfg},
{RX_COMMON_THRD_CFG, hns3_cae_common_thrd_cfg}, {RX_COMMON_THRD_CFG, hns3_cae_common_thrd_cfg},
{RX_COMMON_WL_CFG, hns3_cae_common_wl_cfg}, {RX_COMMON_WL_CFG, hns3_cae_common_wl_cfg},
...@@ -257,26 +251,16 @@ struct drv_module_handle driv_module_cmd_handle[] = { ...@@ -257,26 +251,16 @@ struct drv_module_handle driv_module_cmd_handle[] = {
{GET_BD_BUFF_SIZE, hns3_gro_dump_bd_buff_size}, {GET_BD_BUFF_SIZE, hns3_gro_dump_bd_buff_size},
{PROMISC_MODE_CFG, hns3_promisc_mode_cfg}, {PROMISC_MODE_CFG, hns3_promisc_mode_cfg},
{QINFO_CFG, hns3_cae_qinfo_cfg}, {QINFO_CFG, hns3_cae_qinfo_cfg},
#ifdef CONFIG_IT_VALIDATION
{MACTABLE_CFG, hns3_cae_opt_mactbl},
#endif
{CLEAN_STATS, hns3_cae_clean_stats}, {CLEAN_STATS, hns3_cae_clean_stats},
{FD_CFG, hns3_cae_fd_cfg}, {FD_CFG, hns3_cae_fd_cfg},
{RSS_GENERIC_CFG, hns3_cae_rss_cfg}, {RSS_GENERIC_CFG, hns3_cae_rss_cfg},
{REG_CFG, hns3_cae_reg_cfg},
{COM_REG_CFG, hns3_cae_common_cmd_send}, {COM_REG_CFG, hns3_cae_common_cmd_send},
{GRO_CFG, hns3_gro_age_handle}, {GRO_CFG, hns3_gro_age_handle},
{M7_CMD_MODE_CFG, hns3_m7_cmd_handle},
{QRES_CFG, hns3_cae_qres_cfg}, {QRES_CFG, hns3_cae_qres_cfg},
{STAT_CFG, hns3_stat_mode_cfg}, {STAT_CFG, hns3_stat_mode_cfg},
{IRQ_CFG, hns3_irq_lli_cfg}, {IRQ_CFG, hns3_irq_lli_cfg},
{VLAN_UPMAPPING, hns3_cae_upmapping_cfg}, {VLAN_UPMAPPING, hns3_cae_upmapping_cfg},
#ifdef CONFIG_EXT_TEST
{LAMP_CFG, hns3_lamp_cfg},
{EXTERN_INTERFACE_CFG, hns3_ext_interface_test},
#else
{EXTERN_INTERFACE_CFG, hns3_cae_pfc_storm_cfg}, {EXTERN_INTERFACE_CFG, hns3_cae_pfc_storm_cfg},
#endif
{XSFP_CFG, hns3_xsfp_cfg}, {XSFP_CFG, hns3_xsfp_cfg},
{SHOW_PORT_INFO, hns3_get_port_info}, {SHOW_PORT_INFO, hns3_get_port_info},
{SHOW_HILINK_PARAM, hns3_get_hilink_param}, {SHOW_HILINK_PARAM, hns3_get_hilink_param},
...@@ -342,7 +326,6 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd, ...@@ -342,7 +326,6 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd,
pr_err("alloc out buffer failed\n"); pr_err("alloc out buffer failed\n");
goto out_free_buf_in; goto out_free_buf_in;
} }
#ifndef CONFIG_EXT_TEST
/** /**
* After decoupling with driver, the scenario of hns driver unregister * After decoupling with driver, the scenario of hns driver unregister
* must be considered. In this scenario, driver unregister may happened * must be considered. In this scenario, driver unregister may happened
...@@ -352,7 +335,6 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd, ...@@ -352,7 +335,6 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd,
* code yet, so we don't need lock. * code yet, so we don't need lock.
*/ */
rtnl_lock(); rtnl_lock();
#endif
ret = hns3_cae_k_get_netdev_by_ifname(nt_msg.device_name, &nic_dev); ret = hns3_cae_k_get_netdev_by_ifname(nt_msg.device_name, &nic_dev);
if (ret) { if (ret) {
pr_err("can not get the netdevice correctly\n"); pr_err("can not get the netdevice correctly\n");
...@@ -380,18 +362,14 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd, ...@@ -380,18 +362,14 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd,
ret = -EINVAL; ret = -EINVAL;
goto out_invalid; goto out_invalid;
} }
#ifndef CONFIG_EXT_TEST
rtnl_unlock(); rtnl_unlock();
#endif
ret = copy_buf_out_to_user(&nt_msg, out_size, buf_out); ret = copy_buf_out_to_user(&nt_msg, out_size, buf_out);
if (ret) if (ret)
pr_err("copy buf to user failed\n"); pr_err("copy buf to user failed\n");
goto out_free_buf_out; goto out_free_buf_out;
out_invalid: out_invalid:
#ifndef CONFIG_EXT_TEST
rtnl_unlock(); rtnl_unlock();
#endif
out_free_buf_out: out_free_buf_out:
free_buff_out(buf_out); free_buff_out(buf_out);
out_free_buf_in: out_free_buf_in:
......
// SPDX-License-Identifier: GPL-2.0+
// Copyright (c) 2016-2017 Hisilicon Limited.
#ifdef CONFIG_EXT_TEST
#include "hclge_cmd.h"
#include "hnae3.h"
#include "hclge_main.h"
#include "hns3_enet.h"
#include "hns3_cae_lamp.h"
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;
struct hns3_lamp_signal *signal = NULL;
struct hns3_lamp_param *param = NULL;
int ret = -1;
if (!buf_in || in_size < sizeof(struct hns3_lamp_param))
return -ENODEV;
param = (struct hns3_lamp_param *)buf_in;
signal = (struct hns3_lamp_signal *)buf_out;
if (param->op_type == LAMP_OP_GET_SGPIO) {
if (!buf_out || out_size < sizeof(struct hns3_lamp_signal))
return -ENODEV;
ret = nic_get_led_signal(netdev, signal);
} else if (param->op_type == LAMP_OP_SET_TYPE) {
ret = nic_set_led(netdev, param->type, param->status);
}
return ret;
}
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2019 Hisilicon Limited. */
#ifndef __HNS3_CAE_LAMP_H__
#define __HNS3_CAE_LAMP_H__
#include "hclge_cmd.h"
#include "hnae3.h"
#include "hclge_main.h"
#include "hns3_enet.h"
enum hns3_lamp_spgio_e {
LAMP_OP_GET_SGPIO = 0,
LAMP_OP_SET_TYPE,
LAMP_OP_UNKNOWN
};
struct hns3_lamp_param {
u32 op_type;
u32 type;
u32 status;
};
struct hns3_lamp_signal {
u8 error;
u8 locate;
u8 activity;
};
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,
struct hns3_lamp_signal *signal);
int nic_set_led(struct net_device *ndev, int type, int status);
#endif
...@@ -63,53 +63,3 @@ int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, ...@@ -63,53 +63,3 @@ int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv,
return 0; return 0;
} }
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 = !buf_in || in_size < sizeof(struct m7_cmd_para);
int ret;
if (check) {
pr_err("input param buf_in error in %s function\n", __func__);
return -EFAULT;
}
bd_size = sizeof(struct hclge_desc) * cmd_para->bd_count;
desc = kzalloc(bd_size, GFP_KERNEL);
if (ZERO_OR_NULL_PTR(desc)) {
pr_err("desc kzalloc failed in m7_cmd_handle function\n");
return -ENOMEM;
}
if (copy_from_user((void *)desc, cmd_para->bd_data, bd_size)) {
pr_err("copy from user failed in m7_cmd_handle function\n");
kfree(desc);
return -EFAULT;
}
ret = hns3_cae_cmd_send(hdev, desc, cmd_para->bd_count);
if (ret) {
dev_err(&hdev->pdev->dev,
"generic cmd send fail, ret is %d.\n", ret);
kfree(desc);
return ret;
}
if (desc->flag & HCLGE_CMD_FLAG_WR) {
if (!buf_out || out_size < bd_size) {
pr_err("input param buf_out error in %s function\n",
__func__);
kfree(desc);
return -EFAULT;
}
memcpy(buf_out, desc, bd_size);
}
kfree(desc);
return 0;
}
...@@ -138,6 +138,4 @@ int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, ...@@ -138,6 +138,4 @@ int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv,
void *buf_in, u32 in_size, void *buf_out, void *buf_in, u32 in_size, void *buf_out,
u32 out_size); 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 #endif
// SPDX-License-Identifier: GPL-2.0+
// Copyright (c) 2016-2017 Hisilicon Limited.
#ifdef CONFIG_IT_VALIDATION
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/phy_fixed.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include "hclge_cmd.h"
#include "hnae3.h"
#include "hclge_main.h"
#include "hns3_enet.h"
#include "hns3_ext.h"
#include "hns3_cae_mactbl.h"
int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv,
void *buf_in, u32 in_size,
void *buf_out, u32 out_size)
{
#ifndef CONFIG_HNS3_TEST
return -EOPNOTSUPP;
#else
struct hns3_mac_tbl_para *out = (struct hns3_mac_tbl_para *)buf_out;
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 = !buf_in || in_size < sizeof(struct hns3_mac_tbl_para) ||
!buf_out || out_size < sizeof(struct hns3_mac_tbl_para);
int ret;
if (check) {
pr_err("input parameter error in %s function\n", __func__);
return -EFAULT;
}
h = hns3_get_handle(netdev);
if (!h->ae_algo->ops->priv_ops)
return -EOPNOTSUPP;
out->op_cmd = in->op_cmd;
memcpy(out->mac_addr, in->mac_addr, sizeof(in->mac_addr));
ret = h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_OPT_MAC_TABLE, in, 0);
if (!ret) {
out->result = HNS3_MACTBL_RESULT_SUCCESS;
return 0;
} else if (ret == -ENOENT) {
out->result = HNS3_MACTBL_RESULT_NOEXIST;
return 0;
}
out->result = HNS3_MACTBL_RESULT_FAIL;
return ret;
#endif
}
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2019 Hisilicon Limited. */
#ifndef __HNS3_CAE_MACTBL_H__
#define __HNS3_CAE_MACTBL_H__
enum hns3_mac_table_code {
HNS3_MACTBL_OPT_TABLE_LOOKUP,
HNS3_MACTBL_OPT_TABLE_ADD,
HNS3_MACTBL_OPT_TABLE_DEL,
};
enum hns3_mac_result_code {
HNS3_MACTBL_RESULT_SUCCESS,
HNS3_MACTBL_RESULT_FAIL,
HNS3_MACTBL_RESULT_NOEXIST,
HNS3_MACTBL_RESULT_NOSPACE
};
struct hns3_mac_tbl_para {
u8 op_cmd;
u8 mac_addr[6];
u8 result;
};
int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv,
void *buf_in, u32 in_size,
void *buf_out, u32 out_size);
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2019 Hisilicon Limited. */
#ifndef __HNS3_CAE_PKT_H__
#define __HNS3_CAE_PKT_H__
#include <linux/types.h>
#define IP_ADDR_LEN 4
#define IP6_ADDR_LEN 10
#define MIN_PKT_LEN 64
#define IPV4_TRACEROUTE_PKT_LEN 66
#define IPV6_EXTENSION_PKT_LEN 114
enum PKT_TYPE {
HNS3_CAE_PKT_TYPE_ARP = 0,
HNS3_CAE_PKT_TYPE_TCP,
HNS3_CAE_PKT_TYPE_TCP_DSCP,
HNS3_CAE_PKT_TYPE_PAUSE,
HNS3_CAE_PKT_TYPE_PAUSE_ERR,
HNS3_CAE_PKT_TYPE_PFC,
HNS3_CAE_PKT_TYPE_PFC_ERR,
HNS3_CAE_PKT_TYPE_IPV4,
HNS3_CAE_PKT_TYPE_IPV4_LOOSESRCROUTE_OPTION,
HNS3_CAE_PKT_TYPE_IPV4_TRACEROUTE_OPTION,
HNS3_CAE_PKT_TYPE_IPV6,
HNS3_CAE_PKT_TYPE_IPV6_EXTENSION_ROUTING,
HNS3_CAE_PKT_TYPE_SCTP4,
HNS3_CAE_PKT_TYPE_SCTP6,
HNS3_CAE_PKT_TYPE_MAX,
};
struct hns3_cae_pkt_cfg_info {
int queue_id;
int type;
int pkt_len;
int num;
int mss;
int new_thread;
int stop_thread;
int wait_all_finish;
u32 vlan_tag;
u16 pause_time;
u16 eth_type;
u16 pause_code;
u8 priority;
u8 dscp;
u8 dst_mac[ETH_ALEN];
u8 dst_ip[IP_ADDR_LEN];
int multi_queue;
int pkt_payload_flag;
u16 pkt_checksum;
u32 pkt_checksum_sctp;
u16 pkt_inet6_addr[IP6_ADDR_LEN];
};
struct hns3_cae_pkt_result_info {
int total_len;
int num;
};
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);
#endif
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#define BD_NUM_6 6 #define BD_NUM_6 6
#define BD_NUM_7 7 #define BD_NUM_7 7
void fill_port_info(struct hclge_port_info *get_port_info_out, static void fill_port_info(struct hclge_port_info *get_port_info_out,
struct hclge_desc *port_desc, u32 bd_num) struct hclge_desc *port_desc, u32 bd_num)
{ {
u8 *dest_data = NULL; u8 *dest_data = NULL;
u8 *tmp_buff = NULL; u8 *tmp_buff = NULL;
......
...@@ -45,6 +45,7 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, ...@@ -45,6 +45,7 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev,
void *buf_in, u32 in_size, void *buf_in, u32 in_size,
void *buf_out, u32 out_size) void *buf_out, u32 out_size)
{ {
#define PROMISC_EN_MAX_VAL 0x1
bool check = !buf_in || in_size < sizeof(struct promisc_mode_param); bool check = !buf_in || in_size < sizeof(struct promisc_mode_param);
struct promisc_mode_param *mode_param = NULL; struct promisc_mode_param *mode_param = NULL;
struct hclge_promisc_cfg_cmd *req = NULL; struct hclge_promisc_cfg_cmd *req = NULL;
...@@ -76,16 +77,22 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, ...@@ -76,16 +77,22 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev,
switch (mode_param->type) { switch (mode_param->type) {
case HNS3_UNICAST: case HNS3_UNICAST:
req->flag &= ~BIT(HNS3_CAE_UC_PROMISC_EN_B); req->flag &= ~BIT(HNS3_CAE_UC_PROMISC_EN_B);
if (mode_param->uc > PROMISC_EN_MAX_VAL)
return -EINVAL;
req->flag |= (mode_param->uc << HNS3_CAE_UC_PROMISC_EN_B) | req->flag |= (mode_param->uc << HNS3_CAE_UC_PROMISC_EN_B) |
HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B;
break; break;
case HNS3_MULTICAST: case HNS3_MULTICAST:
req->flag &= ~BIT(HNS3_CAE_MC_PROMISC_EN_B); req->flag &= ~BIT(HNS3_CAE_MC_PROMISC_EN_B);
if (mode_param->mc > PROMISC_EN_MAX_VAL)
return -EINVAL;
req->flag |= (mode_param->mc << HNS3_CAE_MC_PROMISC_EN_B) | req->flag |= (mode_param->mc << HNS3_CAE_MC_PROMISC_EN_B) |
HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B;
break; break;
case HNS3_BROADCAST: case HNS3_BROADCAST:
req->flag &= ~BIT(HNS3_CAE_BC_PROMISC_EN_B); req->flag &= ~BIT(HNS3_CAE_BC_PROMISC_EN_B);
if (mode_param->bc > PROMISC_EN_MAX_VAL)
return -EINVAL;
req->flag |= (mode_param->bc << HNS3_CAE_BC_PROMISC_EN_B) | req->flag |= (mode_param->bc << HNS3_CAE_BC_PROMISC_EN_B) |
HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B;
break; break;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "hns3_cae_qinfo.h" #include "hns3_cae_qinfo.h"
int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -16,7 +16,7 @@ int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -16,7 +16,7 @@ int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -29,7 +29,7 @@ int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -29,7 +29,7 @@ int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -40,7 +40,7 @@ int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -40,7 +40,7 @@ int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -51,7 +51,7 @@ int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -51,7 +51,7 @@ int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -64,7 +64,7 @@ int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -64,7 +64,7 @@ int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -77,7 +77,7 @@ int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -77,7 +77,7 @@ int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -88,7 +88,7 @@ int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) ...@@ -88,7 +88,7 @@ int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id)
return num; return num;
} }
int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id) static int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -146,5 +146,6 @@ int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, ...@@ -146,5 +146,6 @@ int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv,
out_info->tx_tail = tx_tail; out_info->tx_tail = tx_tail;
out_info->tx_ebd = tx_ebd; out_info->tx_ebd = tx_ebd;
out_info->tx_fbd = tx_fbd; out_info->tx_fbd = tx_fbd;
return 0; return 0;
} }
...@@ -25,14 +25,6 @@ struct qinfo_param { ...@@ -25,14 +25,6 @@ struct qinfo_param {
int rx_fbd; int rx_fbd;
}; };
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, int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv,
void *buf_in, u32 in_size, void *buf_in, u32 in_size,
void *buf_out, u32 out_size); void *buf_out, u32 out_size);
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#include "hns3_cae_qres.h" #include "hns3_cae_qres.h"
int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id, static int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv,
enum param_type type) int ring_id, enum param_type type)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int tqps_num; int tqps_num;
...@@ -51,8 +51,8 @@ int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id, ...@@ -51,8 +51,8 @@ int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id,
return num; return num;
} }
int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id, static int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv,
enum param_type type) int ring_id, enum param_type type)
{ {
struct hns3_enet_ring *ring = NULL; struct hns3_enet_ring *ring = NULL;
int num; int num;
...@@ -97,8 +97,8 @@ int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id, ...@@ -97,8 +97,8 @@ int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id,
return num; return num;
} }
void fill_queue_info(const struct hns3_nic_priv *net_priv, static void fill_queue_info(const struct hns3_nic_priv *net_priv,
struct qres_param *out_info, int ring_id) struct qres_param *out_info, int ring_id)
{ {
/* rx info */ /* rx info */
out_info->qid = ring_id; out_info->qid = ring_id;
......
...@@ -64,8 +64,7 @@ int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv, ...@@ -64,8 +64,7 @@ int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv,
void *buf_in, u32 in_size, void *buf_in, u32 in_size,
void *buf_out, u32 out_size) void *buf_out, u32 out_size)
{ {
struct tx_timeout_param *out_info = struct tx_timeout_param *out_info = (struct tx_timeout_param *)buf_out;
(struct tx_timeout_param *)buf_out;
struct tx_timeout_param *in_info = (struct tx_timeout_param *)buf_in; struct tx_timeout_param *in_info = (struct tx_timeout_param *)buf_in;
bool check = !buf_in || in_size < sizeof(struct tx_timeout_param); bool check = !buf_in || in_size < sizeof(struct tx_timeout_param);
struct net_device *netdev = net_priv->netdev; struct net_device *netdev = net_priv->netdev;
......
...@@ -20,8 +20,9 @@ static int hns3_cae_tm_schd_mode_set(struct hclge_dev *hdev, ...@@ -20,8 +20,9 @@ static int hns3_cae_tm_schd_mode_set(struct hclge_dev *hdev,
{ {
struct hclge_desc desc; struct hclge_desc desc;
if (mode > HCLGE_SCH_MODE_DWRR)
return -EINVAL;
hns3_cae_cmd_setup_basic_desc(&desc, opcode, false); hns3_cae_cmd_setup_basic_desc(&desc, opcode, false);
if (mode == HCLGE_SCH_MODE_DWRR) if (mode == HCLGE_SCH_MODE_DWRR)
desc.data[1] = 1; desc.data[1] = 1;
else else
...@@ -48,7 +49,7 @@ static int hns3_cae_tm_schd_mode_get(struct hclge_dev *hdev, ...@@ -48,7 +49,7 @@ static int hns3_cae_tm_schd_mode_get(struct hclge_dev *hdev,
return ret; return ret;
} }
int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id) static int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id)
{ {
struct hclge_nq_to_qs_link_cmd *map = NULL; struct hclge_nq_to_qs_link_cmd *map = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -61,7 +62,7 @@ int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id) ...@@ -61,7 +62,7 @@ int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id) static int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id)
{ {
struct hclge_nq_to_qs_link_cmd *map = NULL; struct hclge_nq_to_qs_link_cmd *map = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -78,7 +79,7 @@ int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id) ...@@ -78,7 +79,7 @@ int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id)
return ret; return ret;
} }
int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri) static int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri)
{ {
struct hclge_qs_to_pri_link_cmd *map = NULL; struct hclge_qs_to_pri_link_cmd *map = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -93,7 +94,7 @@ int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri) ...@@ -93,7 +94,7 @@ int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri) static int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri)
{ {
struct hclge_qs_to_pri_link_cmd *map = NULL; struct hclge_qs_to_pri_link_cmd *map = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -109,7 +110,7 @@ int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri) ...@@ -109,7 +110,7 @@ int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri)
return ret; return ret;
} }
int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr) static int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr)
{ {
struct hclge_qs_weight_cmd *weight = NULL; struct hclge_qs_weight_cmd *weight = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -122,7 +123,8 @@ int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr) ...@@ -122,7 +123,8 @@ int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev, u16 qs_id, u8 *dwrr) static int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev,
u16 qs_id, u8 *dwrr)
{ {
struct hclge_qs_weight_cmd *weight = NULL; struct hclge_qs_weight_cmd *weight = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -138,7 +140,8 @@ int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev, u16 qs_id, u8 *dwrr) ...@@ -138,7 +140,8 @@ int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev, u16 qs_id, u8 *dwrr)
return ret; return ret;
} }
int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev, u8 pri_id, u8 dwrr) static int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev,
u8 pri_id, u8 dwrr)
{ {
struct hclge_priority_weight_cmd *weight = NULL; struct hclge_priority_weight_cmd *weight = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -151,7 +154,8 @@ int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev, u8 pri_id, u8 dwrr) ...@@ -151,7 +154,8 @@ int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev, u8 pri_id, u8 dwrr)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev, u8 pri_id, u8 *dwrr) static int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev,
u8 pri_id, u8 *dwrr)
{ {
struct hclge_priority_weight_cmd *weight = NULL; struct hclge_priority_weight_cmd *weight = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -167,7 +171,8 @@ int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev, u8 pri_id, u8 *dwrr) ...@@ -167,7 +171,8 @@ int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev, u8 pri_id, u8 *dwrr)
return ret; return ret;
} }
int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev, u8 pg_id, u8 bitmap) static int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev,
u8 pg_id, u8 bitmap)
{ {
struct hclge_pg_to_pri_link_cmd *map = NULL; struct hclge_pg_to_pri_link_cmd *map = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -181,8 +186,8 @@ int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev, u8 pg_id, u8 bitmap) ...@@ -181,8 +186,8 @@ int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev, u8 pg_id, u8 bitmap)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id, static int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id,
u8 *bitmap) u8 *bitmap)
{ {
struct hclge_pg_to_pri_link_cmd *map = NULL; struct hclge_pg_to_pri_link_cmd *map = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -200,8 +205,8 @@ int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id, ...@@ -200,8 +205,8 @@ int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id,
return 0; return 0;
} }
int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id, static int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id,
u32 map) u32 map)
{ {
struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd = NULL; struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -217,8 +222,8 @@ int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id, ...@@ -217,8 +222,8 @@ int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id,
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id, static int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id,
u32 *map) u32 *map)
{ {
struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd = NULL; struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -237,9 +242,9 @@ int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id, ...@@ -237,9 +242,9 @@ int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id,
return 0; return 0;
} }
int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev, static int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev,
enum hclge_shap_bucket bucket, u8 pri_id, enum hclge_shap_bucket bucket,
u32 shaper) u8 pri_id, u32 shaper)
{ {
struct hclge_pri_shapping_cmd *shap_cfg_cmd = NULL; struct hclge_pri_shapping_cmd *shap_cfg_cmd = NULL;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
...@@ -255,9 +260,9 @@ int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev, ...@@ -255,9 +260,9 @@ int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev,
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev, static int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev,
enum hclge_shap_bucket bucket, u8 pri_id, enum hclge_shap_bucket bucket,
u32 *shaper) u8 pri_id, u32 *shaper)
{ {
struct hclge_pri_shapping_cmd *shap_cfg_cmd = NULL; struct hclge_pri_shapping_cmd *shap_cfg_cmd = NULL;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
...@@ -275,7 +280,7 @@ int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev, ...@@ -275,7 +280,7 @@ int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev,
return ret; return ret;
} }
int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr) static int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr)
{ {
struct hclge_pg_weight_cmd *weight = NULL; struct hclge_pg_weight_cmd *weight = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -288,7 +293,7 @@ int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr) ...@@ -288,7 +293,7 @@ int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr) static int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr)
{ {
struct hclge_pg_weight_cmd *weight = NULL; struct hclge_pg_weight_cmd *weight = NULL;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -304,9 +309,9 @@ int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr) ...@@ -304,9 +309,9 @@ int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr)
return ret; return ret;
} }
int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev, static int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev,
enum hclge_shap_bucket bucket, u8 pg_id, enum hclge_shap_bucket bucket,
u32 shaper) u8 pg_id, u32 shaper)
{ {
struct hclge_pg_shapping_cmd *shap_cfg_cmd = NULL; struct hclge_pg_shapping_cmd *shap_cfg_cmd = NULL;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
...@@ -322,9 +327,9 @@ int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev, ...@@ -322,9 +327,9 @@ int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev,
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev, static int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev,
enum hclge_shap_bucket bucket, u8 pg_id, enum hclge_shap_bucket bucket,
u32 *shaper) u8 pg_id, u32 *shaper)
{ {
struct hclge_pg_shapping_cmd *shap_cfg_cmd = NULL; struct hclge_pg_shapping_cmd *shap_cfg_cmd = NULL;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
...@@ -343,7 +348,7 @@ int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev, ...@@ -343,7 +348,7 @@ int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev,
return ret; return ret;
} }
int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper) static int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper)
{ {
struct hclge_port_shapping_cmd *shap_cfg_cmd = NULL; struct hclge_port_shapping_cmd *shap_cfg_cmd = NULL;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
...@@ -357,7 +362,7 @@ int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper) ...@@ -357,7 +362,7 @@ int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper)
return hns3_cae_cmd_send(hdev, &desc, 1); return hns3_cae_cmd_send(hdev, &desc, 1);
} }
int hns3_cae_tm_port_shapping_get(struct hclge_dev *hdev, u32 *shaper) static int hns3_cae_tm_port_shapping_get(struct hclge_dev *hdev, u32 *shaper)
{ {
struct hclge_port_shapping_cmd *shap_cfg_cmd = NULL; struct hclge_port_shapping_cmd *shap_cfg_cmd = NULL;
enum hclge_opcode_type opcode; enum hclge_opcode_type opcode;
...@@ -474,8 +479,9 @@ int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, ...@@ -474,8 +479,9 @@ int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv,
return -EFAULT; return -EFAULT;
} }
if (in_info->queue_id >= MAX_QUEUE_ID)
return -EINVAL;
is_read = in_info->is_read; is_read = in_info->is_read;
if (is_read) { if (is_read) {
check = !buf_out || check = !buf_out ||
out_size < sizeof(struct hns3_cae_queue_cfg_info); out_size < sizeof(struct hns3_cae_queue_cfg_info);
...@@ -492,6 +498,8 @@ int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, ...@@ -492,6 +498,8 @@ int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv,
return -1; return -1;
} }
} else { } else {
if (in_info->qs >= MAX_QSET_ID)
return -EINVAL;
if (hns3_cae_tm_q_to_qs_set(hdev, in_info->queue_id, if (hns3_cae_tm_q_to_qs_set(hdev, in_info->queue_id,
in_info->qs)) { in_info->qs)) {
pr_err("%s,%d:set queue(%d) to qs(%d) failed!\n", pr_err("%s,%d:set queue(%d) to qs(%d) failed!\n",
...@@ -571,6 +579,8 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, ...@@ -571,6 +579,8 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv,
is_read = in_info->is_read; is_read = in_info->is_read;
qs_id = in_info->qs_id; qs_id = in_info->qs_id;
if (qs_id >= MAX_QSET_ID)
return -EINVAL;
gp_id = qs_id / 32; gp_id = qs_id / 32;
offset = qs_id % 32; offset = qs_id % 32;
...@@ -618,7 +628,6 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, ...@@ -618,7 +628,6 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv,
__func__, __LINE__, qs_id, ret); __func__, __LINE__, qs_id, ret);
return -1; return -1;
} }
} else { } else {
if ((in_info->flag & HNS3_TM_QSET_MAPPING_FLAG) && if ((in_info->flag & HNS3_TM_QSET_MAPPING_FLAG) &&
hns3_cae_tm_qs_to_pri_set(hdev, qs_id, in_info->pri)) { hns3_cae_tm_qs_to_pri_set(hdev, qs_id, in_info->pri)) {
...@@ -661,6 +670,10 @@ static int hns3_cae_pri_pg_set_map(struct hclge_dev *hdev, ...@@ -661,6 +670,10 @@ static int hns3_cae_pri_pg_set_map(struct hclge_dev *hdev,
u8 bitmap = map; u8 bitmap = map;
u16 pri_id = in_info->pri_id; u16 pri_id = in_info->pri_id;
if (pri_id >= MAX_TC_NUM)
return -EINVAL;
if (in_info->pg >= MAX_PG_NUM)
return -EINVAL;
/* clear old map */ /* clear old map */
if (in_info->pg != cur_pg) { if (in_info->pg != cur_pg) {
bitmap &= ~BIT(pri_id); bitmap &= ~BIT(pri_id);
...@@ -712,8 +725,9 @@ int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv, ...@@ -712,8 +725,9 @@ int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv,
} }
is_read = in_info->is_read; is_read = in_info->is_read;
pri_id = in_info->pri_id; pri_id = in_info->pri_id;
if (pri_id >= MAX_TC_NUM)
return -EINVAL;
for (cur_pg = 0; cur_pg < MAX_PG_NUM; cur_pg++) { for (cur_pg = 0; cur_pg < MAX_PG_NUM; cur_pg++) {
bitmap = 0; bitmap = 0;
...@@ -838,6 +852,8 @@ int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, ...@@ -838,6 +852,8 @@ int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in,
is_read = in_info->is_read; is_read = in_info->is_read;
pg_id = in_info->pg_id; pg_id = in_info->pg_id;
if (pg_id >= MAX_PG_NUM)
return -EINVAL;
if (is_read) { if (is_read) {
check = !buf_out || check = !buf_out ||
...@@ -969,6 +985,7 @@ int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, ...@@ -969,6 +985,7 @@ int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv,
u32 out_size) u32 out_size)
{ {
#define HNS3_TM_ETS_PORT_SHAPING 0x10820850 #define HNS3_TM_ETS_PORT_SHAPING 0x10820850
#define HNS3_TM_MAC_ID_MASK 0x7
struct hns3_cae_ets_cfg_info *out_info = struct hns3_cae_ets_cfg_info *out_info =
(struct hns3_cae_ets_cfg_info *)buf_out; (struct hns3_cae_ets_cfg_info *)buf_out;
struct hns3_cae_ets_cfg_info *in_info = struct hns3_cae_ets_cfg_info *in_info =
...@@ -993,7 +1010,16 @@ int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, ...@@ -993,7 +1010,16 @@ int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv,
is_read = in_info->is_read; is_read = in_info->is_read;
tc_id = in_info->tc_id; tc_id = in_info->tc_id;
mac_id = in_info->mac_id; if (tc_id >= MAX_TC_NUM) {
pr_err("tc id(%d) is invalid in %s function\n", tc_id, __func__);
return -EFAULT;
}
mac_id = in_info->mac_id & HNS3_TM_MAC_ID_MASK;
if (mac_id & 0x1) {
pr_err("mac id(%d) is invalid in %s function\n", mac_id, __func__);
return -EFAULT;
}
addr = (u64)HNS3_TM_ETS_PORT_SHAPING + ((u64)mac_id << 20); addr = (u64)HNS3_TM_ETS_PORT_SHAPING + ((u64)mac_id << 20);
out_info->tc_id = tc_id; out_info->tc_id = tc_id;
out_info->mac_id = mac_id; out_info->mac_id = mac_id;
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#define MAX_QUEUE_NUM 16 #define MAX_QUEUE_NUM 16
#define MAX_PG_NUM 4 #define MAX_PG_NUM 4
#define MAX_TC_NUM 8 #define MAX_TC_NUM 8
#define MAX_QUEUE_ID 1024
#define MAX_QSET_ID 1024
#define HNS3_CAE_QS_ID_MSK (BIT(10) - 1) #define HNS3_CAE_QS_ID_MSK (BIT(10) - 1)
#define HCLGE_OPC_TM_PORT_SCH_MODE_CFG 0x0811 #define HCLGE_OPC_TM_PORT_SCH_MODE_CFG 0x0811
......
...@@ -52,7 +52,6 @@ int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, ...@@ -52,7 +52,6 @@ int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in,
struct hclge_vport *vport = struct hclge_vport *vport =
container_of(handle, struct hclge_vport, nic); container_of(handle, struct hclge_vport, nic);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
u32 fw_ver; u32 fw_ver;
if (check) { if (check) {
...@@ -65,10 +64,9 @@ int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, ...@@ -65,10 +64,9 @@ int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in,
return -EFAULT; return -EFAULT;
fw_ver = hdev->fw_version; fw_ver = hdev->fw_version;
out_buf->imp_ver = fw_ver;
if (!fw_ver) if (!fw_ver)
return -EFAULT; return -EFAULT;
out_buf->imp_ver = fw_ver;
return 0; return 0;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#ifndef __HNS3_CAE_VERSION_H__ #ifndef __HNS3_CAE_VERSION_H__
#define __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
#define HNS3_CAE_MOD_VERSION "1.9.35.1" #define HNS3_CAE_MOD_VERSION "1.9.36.0"
#define CMT_ID_LEN 8 #define CMT_ID_LEN 8
#define RESV_LEN 3 #define RESV_LEN 3
......
...@@ -124,7 +124,7 @@ static int hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, u16 offset, ...@@ -124,7 +124,7 @@ static int hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, u16 offset,
return 0; return 0;
} }
int hns3_set_sfp_state(struct hnae3_handle *handle, bool en) static int hns3_set_sfp_state(struct hnae3_handle *handle, bool en)
{ {
struct hclge_vport *vport = hns3_cae_get_vport(handle); struct hclge_vport *vport = hns3_cae_get_vport(handle);
struct hclge_sfp_enable_cmd *req = NULL; struct hclge_sfp_enable_cmd *req = NULL;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "hnae3.h" #include "hnae3.h"
#define HNS3_MOD_VERSION "1.9.35.1" #define HNS3_MOD_VERSION "1.9.36.0"
extern char hns3_driver_version[]; extern char hns3_driver_version[];
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "hclge_cmd.h" #include "hclge_cmd.h"
#include "hnae3.h" #include "hnae3.h"
#define HCLGE_MOD_VERSION "1.9.35.1" #define HCLGE_MOD_VERSION "1.9.36.0"
#define HCLGE_DRIVER_NAME "hclge" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 #define HCLGE_MAX_PF_NUM 8
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "hclgevf_cmd.h" #include "hclgevf_cmd.h"
#include "hnae3.h" #include "hnae3.h"
#define HCLGEVF_MOD_VERSION "1.9.35.1" #define HCLGEVF_MOD_VERSION "1.9.36.0"
#define HCLGEVF_DRIVER_NAME "hclgevf" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095 #define HCLGEVF_MAX_VLAN_ID 4095
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册