diff --git a/drivers/net/ethernet/hisilicon/hns3/Makefile b/drivers/net/ethernet/hisilicon/hns3/Makefile index bd5aea7dd4904faea75015f5b15a92fca8d44d8e..28068f9ea35bba2c01566c65e4a04e794a4677e8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/Makefile +++ b/drivers/net/ethernet/hisilicon/hns3/Makefile @@ -21,18 +21,18 @@ hns3-$(CONFIG_HNS3_UBL) += hns3_unic.o hns3_unic_debugfs.o obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o hclgevf-objs = hns3vf/hclgevf_main.o hns3vf/hclgevf_mbx.o hns3vf/hclgevf_devlink.o hns3vf/hclgevf_regs.o \ - hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o \ - hns3vf/hclgevf_udma.o + hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o hclgevf-$(CONFIG_HNS3_UBL) += hns3_common/hclge_comm_unic_addr.o hns3vf/hclgevf_unic_ip.o hns3vf/hclgevf_unic_guid.o \ hns3vf/hclgevf_unic_addr.o +hclgevf-$(CONFIG_UB_UDMA_HNS3) += hns3vf/hclgevf_udma.o obj-$(CONFIG_HNS3_HCLGE) += hclge.o hclge-objs = hns3pf/hclge_main.o hns3pf/hclge_mdio.o hns3pf/hclge_tm.o hns3pf/hclge_sysfs.o hns3pf/hclge_regs.o \ hns3pf/hclge_mbx.o hns3pf/hclge_err.o hns3pf/hclge_debugfs.o hns3pf/hclge_ptp.o hns3pf/hclge_devlink.o \ - hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o \ - hns3pf/hclge_udma.o + hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o hclge-objs += hns3pf/hclge_ext.o hclge-$(CONFIG_HNS3_UBL) += hns3_common/hclge_comm_unic_addr.o hns3pf/hclge_unic_ip.o hns3pf/hclge_unic_guid.o \ hns3pf/hclge_unic_addr.o +hclge-$(CONFIG_UB_UDMA_HNS3) += hns3pf/hclge_udma.o hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index e6f8a254d3298cea4b8a837602f6a13a4db4a50d..0bd3d361f48a0c72893ce8d81dae4d7afbc97aa5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -858,7 +858,7 @@ struct hnae3_ae_ops { const unsigned char *addr, enum hnae3_unic_addr_type addr_type); int (*get_func_guid)(struct hnae3_handle *handle, u8 *guid); - int (*set_func_guid)(struct hnae3_handle *handle, u8 *guid); + void (*set_func_guid)(struct hnae3_handle *handle, u8 *guid); }; struct hnae3_dcb_ops { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c index 136ec25d2c4540b95e735ec8476a5b482df85b48..5c11aaa806209b9c7b4325b539b95d7e899bd4ac 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c @@ -248,32 +248,38 @@ hclge_comm_unic_func_guid_cmd_prepare(u8 *guid, memcpy(req->guid, guid, UBL_ALEN); } -int hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 *guid) +void hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 **guid) { struct hclge_comm_func_guid_cmd *req; struct hclge_desc desc; int ret; + if (!*guid) + return; + req = (struct hclge_comm_func_guid_cmd *)desc.data; hclge_comm_cmd_setup_basic_desc(&desc, HCLGE_OPC_COMM_CFG_FUNC_GUID, false); - hclge_comm_unic_func_guid_cmd_prepare(guid, req); + hclge_comm_unic_func_guid_cmd_prepare(*guid, req); ret = hclge_comm_cmd_send(hw, &desc, 1); if (ret) - dev_err(&hw->cmq.csq.pdev->dev, - "failed to set guid for cmd_send, ret = %d\n", ret); - - return ret; + dev_warn(&hw->cmq.csq.pdev->dev, + "set guid failed for cmd_send, ret = %d.\n", ret); + else + *guid = NULL; } -void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw) +void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw, u8 **guid) { struct hclge_comm_func_guid_cmd *req; struct hclge_desc desc; int ret; + if (*guid) + return; + req = (struct hclge_comm_func_guid_cmd *)desc.data; hclge_comm_cmd_setup_basic_desc(&desc, HCLGE_OPC_COMM_CFG_FUNC_GUID, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h index 0db62ac8dbcbc8c5977b8c54f7e17a11f7b9f3af..398396099f8369480a121707e27e55af04539edc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h @@ -100,8 +100,8 @@ bool hclge_comm_unic_sync_addr_table(struct hnae3_handle *handle, struct list_head *)); int hclge_comm_unic_convert_ip_addr(const struct sockaddr *addr, struct in6_addr *ip_addr); -int hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 *guid); +void hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 **guid); int hclge_comm_unic_get_func_guid(struct hclge_comm_hw *hw, u8 *guid); -void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw); +void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw, u8 **guid); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 88efa8f9546fbc32544aed75360481305df7d857..e473d35907d682ea1010b3351702521867bc45e6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2584,7 +2584,9 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev) } #ifdef CONFIG_HNS3_UBL if (hns3_ubl_supported(hns3_get_handle(netdev))) { - ubl_rmv_sw_ctype(skb); + if (!ubl_rmv_sw_ctype(skb)) + goto out_err_tx_ok; + hns3_unic_set_default_cc(skb); } #endif @@ -5743,8 +5745,14 @@ static int hns3_client_init(struct hnae3_handle *handle) netdev->max_mtu = HNS3_MAX_MTU(ae_dev->dev_specs.max_frm_size); #ifdef CONFIG_HNS3_UBL - if (hns3_ubl_supported(handle)) - hns3_unic_init(netdev); + if (hns3_ubl_supported(handle)) { + ret = hns3_unic_init(netdev); + if (ret) { + dev_err(priv->dev, "failed to init unic, ret = %d\n", + ret); + goto out_dbg_init; + } + } #endif hns3_state_init(handle); @@ -5765,6 +5773,7 @@ static int hns3_client_init(struct hnae3_handle *handle) out_reg_netdev_fail: hns3_state_uninit(handle); +out_dbg_init: hns3_dbg_uninit(handle); hns3_client_stop(handle); out_client_start: @@ -6063,14 +6072,21 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) goto err_client_start_fail; } #ifdef CONFIG_HNS3_UBL - if (hns3_ubl_supported(handle)) - hns3_unic_init_guid(netdev); + if (hns3_ubl_supported(handle)) { + ret = hns3_unic_init_guid(netdev); + if (ret) { + dev_err(priv->dev, "init guid failed! ret=%d\n", ret); + goto err_init_guid_fail; + } + } #endif set_bit(HNS3_NIC_STATE_INITED, &priv->state); return ret; +err_init_guid_fail: + hns3_client_stop(handle); err_client_start_fail: hns3_free_rx_cpu_rmap(netdev); hns3_nic_uninit_irq(priv); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c index 3320d1ad5bd9bcdcebf2db61ab41a673fc0b9f75..7e904c23c8b7d65519631c643c1780b9937ff9c5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c @@ -36,7 +36,7 @@ void hns3_unic_set_default_cc(struct sk_buff *skb) ubl->h_cc = htons(UNIC_CC_DEFAULT_FECN_MODE); } -void hns3_unic_init(struct net_device *netdev) +int hns3_unic_init(struct net_device *netdev) { struct hnae3_handle *h = hns3_get_handle(netdev); struct pci_dev *pdev = h->pdev; @@ -53,7 +53,7 @@ void hns3_unic_init(struct net_device *netdev) netdev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); netdev->max_mtu = ae_dev->dev_specs.max_frm_size; - hns3_unic_init_guid(netdev); + return hns3_unic_init_guid(netdev); } /** @@ -324,7 +324,7 @@ void hns3_unic_set_rx_mode(struct net_device *netdev) hns3_request_update_promisc_mode(h); } -void hns3_unic_init_guid(struct net_device *netdev) +int hns3_unic_init_guid(struct net_device *netdev) { const u8 bc_guid[HNS3_SIMPLE_GUID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -336,23 +336,25 @@ void hns3_unic_init_guid(struct net_device *netdev) if (!h->ae_algo->ops->get_func_guid || !h->ae_algo->ops->set_func_guid) { netdev_err(netdev, "the guid handlers may not exist\n"); - return; + return -EOPNOTSUPP; } ret = h->ae_algo->ops->get_func_guid(h, temp_guid_addr); if (ret) { netdev_err(netdev, "get function guid fail, ret = %d!\n", ret); - return; + return ret; + } + + ret = hns3_unic_add_mc_guid(netdev, bc_guid); + if (ret) { + netdev_err(netdev, "add mc guid fail, ret = %d!\n", ret); + return ret; } memcpy(netdev->dev_addr, temp_guid_addr, netdev->addr_len); memcpy(netdev->perm_addr, temp_guid_addr, netdev->addr_len); - ret = h->ae_algo->ops->set_func_guid(h, netdev->dev_addr); - if (ret) { - netdev_err(netdev, "set function guid fail, ret = %d\n", ret); - return; - } + h->ae_algo->ops->set_func_guid(h, netdev->dev_addr); - hns3_unic_add_mc_guid(netdev, bc_guid); + return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h index d4071dd723766bc58d47d9fd24d6a7e53a05004c..028405e39da940fc2a470134e19ea9c5ae2db671 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h @@ -51,7 +51,7 @@ static inline void hns3_unic_format_sim_guid_addr(char *format_simple_guid_addr, } void hns3_unic_set_default_cc(struct sk_buff *skb); -void hns3_unic_init(struct net_device *netdev); +int hns3_unic_init(struct net_device *netdev); void hns3_unic_set_l3_type(struct sk_buff *skb, u32 *type_cs_vlan_tso); u8 hns3_unic_get_l3_type(struct net_device *netdev, u32 ol_info, u32 l234info); void hns3_unic_lp_setup_skb(struct sk_buff *skb); @@ -60,6 +60,6 @@ void hns3_unic_lb_check_skb_data(struct hns3_enet_ring *ring, void register_ipaddr_notifier(void); void unregister_ipaddr_notifier(void); void hns3_unic_set_rx_mode(struct net_device *netdev); -void hns3_unic_init_guid(struct net_device *netdev); +int hns3_unic_init_guid(struct net_device *netdev); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 54ce0cb8b05e40a244194d4f840e6df573e56eef..5d994e8c3f1a97c52832e680e42609ea66f46b3a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1821,7 +1821,9 @@ int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len) hclge_read_dev(&hdev->hw, offset)); } +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) hclge_dbg_dump_udma_rst_info(hdev, buf, len, &pos); +#endif pos += scnprintf(buf + pos, len - pos, "hdev state: 0x%lx\n", hdev->state); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index bd849e06c65859af92737d01c5c549f15620dd74..91f0a49a3403d4ca92a12cf83dca77b5c12eb5f0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -2758,7 +2758,10 @@ void hclge_handle_all_hns_hw_errors(struct hnae3_ae_dev *ae_dev) bool hclge_find_error_source(struct hclge_dev *hdev) { - u32 msix_src_flag, hw_err_src_flag, udma_err_src_flag; + u32 msix_src_flag, hw_err_src_flag; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) + u32 udma_err_src_flag; +#endif msix_src_flag = hclge_read_dev(&hdev->hw, HCLGE_MISC_VECTOR_INT_STS) & HCLGE_VECTOR0_REG_MSIX_MASK; @@ -2766,10 +2769,14 @@ bool hclge_find_error_source(struct hclge_dev *hdev) hw_err_src_flag = hclge_read_dev(&hdev->hw, HCLGE_RAS_PF_OTHER_INT_STS_REG) & HCLGE_RAS_REG_ERR_MASK; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) udma_err_src_flag = hclge_get_udma_error_reg(hdev) & HCLGE_RAS_REG_ERR_MASK_UB; return msix_src_flag || hw_err_src_flag || udma_err_src_flag; +#else + return msix_src_flag || hw_err_src_flag; +#endif } void hclge_handle_occurred_error(struct hclge_dev *hdev) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 5ac0d87eb9dae9b3b3823b8a29594d568e5cf584..9b7ddc9abf98d06ca7413697026023a1b1b4f989 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -796,7 +796,9 @@ static int hclge_query_function_status(struct hclge_dev *hdev) static int hclge_query_pf_resource(struct hclge_dev *hdev) { +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); +#endif struct hclge_pf_res_cmd *req; struct hclge_desc desc; int ret; @@ -849,11 +851,13 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) */ hdev->num_msi = hdev->num_nic_msi + hdev->num_roce_msi + hdev->num_roh_msi; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) } else if (hnae3_dev_udma_supported(ae_dev)) { hdev->num_udma_msi = le16_to_cpu(req->pf_intr_vector_number_roce); hdev->num_msi = hdev->num_nic_msi + hdev->num_udma_msi; +#endif } else { hdev->num_msi = hdev->num_nic_msi; } @@ -2982,11 +2986,13 @@ static void hclge_push_link_status(struct hclge_dev *hdev) static void hclge_update_link_status(struct hclge_dev *hdev) { struct hnae3_handle *rhandle = &hdev->vport[0].roce; - struct hnae3_handle *uhandle = &hdev->vport[0].udma; struct hnae3_handle *handle = &hdev->vport[0].nic; struct hnae3_client *rclient = hdev->roce_client; - struct hnae3_client *uclient = hdev->udma_client; struct hnae3_client *client = hdev->nic_client; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) + struct hnae3_handle *uhandle = &hdev->vport[0].udma; + struct hnae3_client *uclient = hdev->udma_client; +#endif int state; int ret; @@ -3008,8 +3014,10 @@ static void hclge_update_link_status(struct hclge_dev *hdev) hclge_config_mac_tnl_int(hdev, state); if (rclient && rclient->ops->link_status_change) rclient->ops->link_status_change(rhandle, state); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (uclient && uclient->ops->link_status_change) uclient->ops->link_status_change(uhandle, state); +#endif hclge_push_link_status(hdev); } @@ -3464,14 +3472,16 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf, static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) { - u32 cmdq_src_reg, msix_src_reg, hw_err_src_reg, udma_err_src_reg; + u32 cmdq_src_reg, msix_src_reg, hw_err_src_reg; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) + u32 udma_err_src_reg = hclge_get_udma_error_reg(hdev); +#endif /* fetch the events from their corresponding regs */ cmdq_src_reg = hclge_read_dev(&hdev->hw, HCLGE_VECTOR0_CMDQ_SRC_REG); msix_src_reg = hclge_read_dev(&hdev->hw, HCLGE_MISC_VECTOR_INT_STS); hw_err_src_reg = hclge_read_dev(&hdev->hw, HCLGE_RAS_PF_OTHER_INT_STS_REG); - udma_err_src_reg = hclge_get_udma_error_reg(hdev); /* Assumption: If by any chance reset and mailbox events are reported * together then we will only process reset event in this go and will @@ -3500,10 +3510,16 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) } /* check for vector0 msix event and hardware error event source */ +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (msix_src_reg & HCLGE_VECTOR0_REG_MSIX_MASK || hw_err_src_reg & HCLGE_RAS_REG_ERR_MASK || udma_err_src_reg & HCLGE_RAS_REG_ERR_MASK_UB) return HCLGE_VECTOR0_EVENT_ERR; +#else + if (msix_src_reg & HCLGE_VECTOR0_REG_MSIX_MASK || + hw_err_src_reg & HCLGE_RAS_REG_ERR_MASK) + return HCLGE_VECTOR0_EVENT_ERR; +#endif /* check for vector0 ptp event source */ if (BIT(HCLGE_VECTOR0_REG_PTP_INT_B) & msix_src_reg) { @@ -3519,10 +3535,16 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) } /* print other vector0 event source */ +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) dev_info(&hdev->pdev->dev, "INT status: CMDQ(%#x) HW errors(%#x, %#x) other(%#x)\n", cmdq_src_reg, hw_err_src_reg, udma_err_src_reg, msix_src_reg); +#else + dev_info(&hdev->pdev->dev, + "INT status: CMDQ(%#x) HW errors(%#x) other(%#x)\n", + cmdq_src_reg, hw_err_src_reg, msix_src_reg); +#endif return HCLGE_VECTOR0_EVENT_OTHER; } @@ -4262,9 +4284,11 @@ static int hclge_reset_prepare(struct hclge_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_DOWN_CLIENT); if (ret) return ret; +#endif rtnl_lock(); ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); @@ -4290,9 +4314,11 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_UNINIT_CLIENT); if (ret) return ret; +#endif rtnl_lock(); ret = hclge_reset_stack(hdev); @@ -4318,6 +4344,7 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_INIT_CLIENT); /* ignore udma notify error if it fails HCLGE_RESET_MAX_FAIL_CNT - 1 * times @@ -4325,6 +4352,7 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) if (ret && hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1) return ret; +#endif ret = hclge_reset_prepare_up(hdev); if (ret) @@ -4344,9 +4372,11 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_UP_CLIENT); if (ret) return ret; +#endif hdev->last_reset_time = jiffies; hdev->rst_stats.reset_fail_cnt = 0; @@ -4775,6 +4805,7 @@ static void hclge_periodic_service_task(struct hclge_dev *hdev) if (hnae3_dev_ubl_supported(hdev->ae_dev)) { hclge_unic_sync_mguid_table(hdev); hclge_unic_sync_ip_table(hdev); + hclge_comm_unic_set_func_guid(&hdev->hw.hw, &hdev->hw.func_guid); } #endif hclge_sync_promisc_mode(hdev); @@ -4863,8 +4894,10 @@ struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle) return container_of(handle, struct hclge_vport, roce); else if (handle->client->type == HNAE3_CLIENT_ROH) return container_of(handle, struct hclge_vport, roh); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) else if (handle->client->type == HNAE3_CLIENT_UDMA) return container_of(handle, struct hclge_vport, udma); +#endif else return container_of(handle, struct hclge_vport, nic); } @@ -11823,9 +11856,11 @@ static int hclge_init_client_instance(struct hnae3_client *client, if (ret) goto clear_roce; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_init_udma_client_instance(ae_dev, vport); if (ret) goto clear_udma; +#endif break; case HNAE3_CLIENT_ROCE: @@ -11850,6 +11885,7 @@ static int hclge_init_client_instance(struct hnae3_client *client, goto clear_roh; break; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) case HNAE3_CLIENT_UDMA: if (hnae3_dev_udma_supported(ae_dev)) { hdev->udma_client = client; @@ -11861,6 +11897,7 @@ static int hclge_init_client_instance(struct hnae3_client *client, goto clear_udma; break; +#endif default: return -EINVAL; } @@ -11879,10 +11916,12 @@ static int hclge_init_client_instance(struct hnae3_client *client, hdev->roh_client = NULL; vport->roh.client = NULL; return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) clear_udma: hdev->udma_client = NULL; vport->udma.client = NULL; return ret; +#endif } static void hclge_uninit_client_instance(struct hnae3_client *client, @@ -11891,6 +11930,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, struct hclge_dev *hdev = ae_dev->priv; struct hclge_vport *vport = &hdev->vport[0]; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (hdev->udma_client && (client->type == HNAE3_CLIENT_UDMA || client->type == HNAE3_CLIENT_KNIC)) { clear_bit(HCLGE_STATE_UDMA_REGISTERED, &hdev->state); @@ -11903,6 +11943,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, } if (client->type == HNAE3_CLIENT_UDMA) return; +#endif if (hdev->roh_client && (client->type == HNAE3_CLIENT_ROH || client->type == HNAE3_CLIENT_KNIC)) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index cc373064f198f0637c28a3cee0cd017bff86fb59..890fd92bededd4908b9068aa583db29b2c4fc31f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -297,6 +297,7 @@ struct hclge_hw { struct hclge_comm_hw hw; struct hclge_mac mac; int num_vec; + u8 *func_guid; }; enum hclge_fc_mode { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c index afbffa0aafc20f19ab8d99f08a1dce876327f43e..376c5dc1de747f884328dd2281881b08c9676a74 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c @@ -577,12 +577,12 @@ void hclge_unic_reset_mc_guid_space(struct hclge_dev *hdev) bitmap_zero(hdev->mc_guid_tbl_bmap, HCLGE_UNIC_MC_GUID_NUM); } -int hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) +void hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) { struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; - return hclge_comm_unic_set_func_guid(&hdev->hw.hw, guid); + hdev->hw.func_guid = guid; } int hclge_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid) @@ -595,5 +595,5 @@ int hclge_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid) void hclge_unic_rm_func_guid(struct hclge_dev *hdev) { - hclge_comm_unic_rm_func_guid(&hdev->hw.hw); + hclge_comm_unic_rm_func_guid(&hdev->hw.hw, &hdev->hw.func_guid); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h index c9b66400f51d6928f42d665d83c653f8b569cb45..56f11f43a5531809ea487731d629965706a76a2b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h @@ -37,7 +37,7 @@ void hclge_unic_del_vport_all_mc_guid_table(struct hclge_vport *vport, int hclge_unic_update_guid_list(struct hclge_vport *vport, enum HCLGE_COMM_ADDR_NODE_STATE state, const unsigned char *addr); -int hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); +void hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); int hclge_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid); void hclge_unic_rm_func_guid(struct hclge_dev *hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index c702df08127571ea61619b5fedc6a4593c3a19fd..b9be10cab8e053aa88bcd9b6fef9568cad376274 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -79,8 +79,10 @@ struct hclgevf_dev *hclgevf_ae_get_hdev(struct hnae3_handle *handle) return container_of(handle, struct hclgevf_dev, nic); else if (handle->client->type == HNAE3_CLIENT_ROCE) return container_of(handle, struct hclgevf_dev, roce); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) else if (handle->client->type == HNAE3_CLIENT_UDMA) return container_of(handle, struct hclgevf_dev, udma); +#endif else return container_of(handle, struct hclgevf_dev, nic); } @@ -452,7 +454,9 @@ static void hclgevf_request_link_info(struct hclgevf_dev *hdev) void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state) { struct hnae3_handle *rhandle = &hdev->roce; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) struct hnae3_handle *uhandle = &hdev->udma; +#endif struct hnae3_handle *handle = &hdev->nic; struct hnae3_client *rclient; struct hnae3_client *uclient; @@ -472,8 +476,10 @@ void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state) client->ops->link_status_change(handle, !!link_state); if (rclient && rclient->ops->link_status_change) rclient->ops->link_status_change(rhandle, !!link_state); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (uclient && uclient->ops->link_status_change) uclient->ops->link_status_change(uhandle, !!link_state); +#endif } clear_bit(HCLGEVF_STATE_LINK_UPDATING, &hdev->state); @@ -1609,9 +1615,11 @@ static int hclgevf_reset_prepare(struct hclgevf_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_notify_udma_client(hdev, HNAE3_DOWN_CLIENT); if (ret) return ret; +#endif rtnl_lock(); /* bring down the nic to stop any ongoing TX/RX */ @@ -1632,9 +1640,11 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_notify_udma_client(hdev, HNAE3_UNINIT_CLIENT); if (ret) return ret; +#endif rtnl_lock(); /* now, re-initialize the nic client and ae device */ @@ -1657,6 +1667,7 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_notify_udma_client(hdev, HNAE3_INIT_CLIENT); /* ignore UDMA notify error if it fails HCLGEVF_RESET_MAX_FAIL_CNT - 1 * times @@ -1668,6 +1679,7 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) ret = hclgevf_notify_udma_client(hdev, HNAE3_UP_CLIENT); if (ret) return ret; +#endif hdev->last_reset_time = jiffies; hdev->rst_stats.rst_done_cnt++; @@ -2004,6 +2016,7 @@ static void hclgevf_periodic_service_task(struct hclgevf_dev *hdev) if (hnae3_dev_ubl_supported(hdev->ae_dev)) { hclgevf_unic_sync_mc_guid_list(hdev); hclgevf_unic_sync_ip_list(hdev); + hclge_comm_unic_set_func_guid(&hdev->hw.hw, &hdev->hw.func_guid); } #endif hclgevf_sync_promisc_mode(hdev); @@ -2564,10 +2577,12 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, if (ret) goto clear_roce; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_init_udma_client_instance(ae_dev, hdev->udma_client); if (ret) goto clear_udma; +#endif break; case HNAE3_CLIENT_ROCE: @@ -2581,6 +2596,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, goto clear_roce; break; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) case HNAE3_CLIENT_UDMA: if (hnae3_dev_udma_supported(ae_dev)) { hdev->udma_client = client; @@ -2592,6 +2608,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, goto clear_udma; break; +#endif default: return -EINVAL; } @@ -2606,10 +2623,12 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, hdev->roce_client = NULL; hdev->roce.client = NULL; return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) clear_udma: hdev->udma_client = NULL; hdev->udma.client = NULL; return ret; +#endif } static void hclgevf_uninit_client_instance(struct hnae3_client *client, @@ -2617,6 +2636,7 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, { struct hclgevf_dev *hdev = ae_dev->priv; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) /* un-init udma, if it exists and called by nic or udma client */ if (hdev->udma_client && (client->type == HNAE3_CLIENT_UDMA || client->type == HNAE3_CLIENT_KNIC)) { @@ -2630,6 +2650,7 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, } if (client->type == HNAE3_CLIENT_UDMA) return; +#endif /* un-init roce, if it exists */ if (hdev->roce_client) { @@ -2741,7 +2762,9 @@ static void hclgevf_pci_uninit(struct hclgevf_dev *hdev) static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) { +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); +#endif struct hclgevf_query_res_cmd *req; struct hclge_desc desc; int ret; @@ -2773,6 +2796,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) */ hdev->num_msi = hdev->num_roce_msix + hdev->roce_base_msix_offset; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) } else if (hnae3_dev_udma_supported(ae_dev)) { hdev->roce_base_msix_offset = hnae3_get_field(le16_to_cpu(req->msixcap_localid_ba_rocee), @@ -2790,6 +2814,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) */ hdev->num_msi = hdev->num_udma_msix + hdev->roce_base_msix_offset; +#endif } else { hdev->num_msi = hnae3_get_field(le16_to_cpu(req->vf_intr_vector_number), diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 699a2afaef0ec646abc85907803c24ff60a5d1f7..77526a0a315b0c8610bed00791e055f2685f6b14 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -156,6 +156,7 @@ struct hclgevf_hw { struct hclge_comm_hw hw; int num_vec; struct hclgevf_mac mac; + u8 *func_guid; }; struct hclgevf_cfg { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c index 53b2b206e74566e97b8611f6134c8d01cb1d554b..8762690c5ac73644826e2360ca58c3bcab69eaa5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c @@ -103,11 +103,11 @@ void hclgevf_unic_uninit_mc_guid_list(struct hclgevf_dev *hdev) spin_unlock_bh(&hdev->mguid_list_lock); } -int hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) +void hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) { struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); - return hclge_comm_unic_set_func_guid(&hdev->hw.hw, guid); + hdev->hw.func_guid = guid; } int hclgevf_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h index faf9c90106d905a07116b5ad36688a50ecfb2a97..dd4e308c9e6a4c6f26f9eedd5758aaa58bcdcee1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h @@ -13,7 +13,7 @@ void hclgevf_unic_uninit_mc_guid_list(struct hclgevf_dev *hdev); int hclgevf_unic_update_guid_list(struct hnae3_handle *handle, enum HCLGE_COMM_ADDR_NODE_STATE state, const unsigned char *addr); -int hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); +void hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); int hclgevf_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid); #endif diff --git a/drivers/net/ub/dev/ubl.c b/drivers/net/ub/dev/ubl.c index 22132c067c1c77ef96ebfd0878a2817246d3411e..d94fcd1dab16d65e21c474ec7092906e7c50deba 100644 --- a/drivers/net/ub/dev/ubl.c +++ b/drivers/net/ub/dev/ubl.c @@ -44,6 +44,32 @@ static __be16 ubl_type_to_proto(u8 type) return proto; } +/** + * ubl_add_sw_ctype - add software packet type for skb->data + * @skb: buffer to alter + * @ctype: indicates the packet type + * + * The packet type cannot be known by parsing packe from user, + * which leads to restrictions on the use of socket. + * Add cs_type field to indicate the packet type. And sw_ctype + * exists only during software prcessing. + * +----------+----+-----+-----------+ + * | sw_ctype | CC | NPI | L3 Packet | + * +----------+----+-----+-----------+ + */ +int ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype) +{ + u8 *pkt_cfg; + + if (skb_cow_head(skb, sizeof(u8))) + return -ENOMEM; + + pkt_cfg = (u8 *)skb_push(skb, sizeof(u8)); + *pkt_cfg = ctype; + + return 0; +} + /** * ubl_create_header - create the ubl header * @skb: buffer to alter @@ -72,7 +98,9 @@ int ubl_create_header(struct sk_buff *skb, struct net_device *dev, /* if type is ETH_P_UB, then do nothing. */ ret = 0; } - ubl_add_sw_ctype(skb, ctype); + + if (ubl_add_sw_ctype(skb, ctype)) + ret = -ENOMEM; return ret; } diff --git a/drivers/net/ub/dev/ubl.h b/drivers/net/ub/dev/ubl.h index 02424918b01fc163479735c8582e6070606d5078..8e646158d07ce18584be49434092118145520ba2 100644 --- a/drivers/net/ub/dev/ubl.h +++ b/drivers/net/ub/dev/ubl.h @@ -59,26 +59,6 @@ struct ublhdr { __be32 h_npi; } __packed; -/** - * ubl_add_sw_ctype - add software packet type for skb->data - * @skb: buffer to alter - * @ctype: indicates the packet type - * - * The packet type cannot be known by parsing packe from user, - * which leads to restrictions on the use of socket. - * Add cs_type field to indicate the packet type. And sw_ctype - * exists only during software prcessing. - * +----------+----+-----+-----------+ - * | sw_ctype | CC | NPI | L3 Packet | - * +----------+----+-----+-----------+ - */ -static inline void ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype) -{ - u8 *pkt_cfg = (u8 *)skb_push(skb, sizeof(u8)); - - *pkt_cfg = ctype; -} - /** * ubl_rmv_sw_ctype - delete software packet type for skb->data * @skb: buffer to alter @@ -86,9 +66,9 @@ static inline void ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype) * Before the packet is sent to the hardware, remove sw_ctype field * and restore the original packet. */ -static inline void ubl_rmv_sw_ctype(struct sk_buff *skb) +static inline void *ubl_rmv_sw_ctype(struct sk_buff *skb) { - skb_pull_inline(skb, sizeof(u8)); + return pskb_pull(skb, sizeof(u8)); } int ubl_create_header(struct sk_buff *skb, struct net_device *dev, @@ -98,6 +78,7 @@ void ubl_setup(struct net_device *dev); __be16 ubl_type_trans(struct sk_buff *skb, struct net_device *dev, u8 type); struct net_device *alloc_ubndev_mqs(int sizeof_priv, unsigned int txqs, unsigned int rxqs); +int ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype); #define alloc_ubndev_mq(sizeof_priv, count) \ alloc_ubndev_mqs((sizeof_priv), (count), (count))