Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'hns3-fixes'

Guangbin Huang says:

====================
net: hns3: add some fixes for -net

This series adds some fixes for the HNS3 ethernet driver.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+149 -134
+7
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 4210 4210 } 4211 4211 4212 4212 out: 4213 + /* sync head pointer before exiting, since hardware will calculate 4214 + * FBD number with head pointer 4215 + */ 4216 + if (unused_count > 0) 4217 + failure = failure || 4218 + hns3_nic_alloc_rx_buffers(ring, unused_count); 4219 + 4213 4220 return failure ? budget : recv_pkts; 4214 4221 } 4215 4222
+1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
··· 483 483 if (hnae3_dev_phy_imp_supported(hdev)) 484 484 hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1); 485 485 hnae3_set_bit(compat, HCLGE_MAC_STATS_EXT_EN_B, 1); 486 + hnae3_set_bit(compat, HCLGE_SYNC_RX_RING_HEAD_EN_B, 1); 486 487 487 488 req->compat = cpu_to_le32(compat); 488 489 }
+1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
··· 1151 1151 #define HCLGE_NCSI_ERROR_REPORT_EN_B 1 1152 1152 #define HCLGE_PHY_IMP_EN_B 2 1153 1153 #define HCLGE_MAC_STATS_EXT_EN_B 3 1154 + #define HCLGE_SYNC_RX_RING_HEAD_EN_B 4 1154 1155 struct hclge_firmware_compat_cmd { 1155 1156 __le32 compat; 1156 1157 u8 rsv[20];
+9 -13
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
··· 129 129 u32 total_ets_bw = 0; 130 130 u8 i; 131 131 132 - for (i = 0; i < hdev->tc_max; i++) { 132 + for (i = 0; i < HNAE3_MAX_TC; i++) { 133 133 switch (ets->tc_tsa[i]) { 134 134 case IEEE_8021QAZ_TSA_STRICT: 135 135 if (hdev->tm_info.tc_info[i].tc_sch_mode != ··· 286 286 287 287 static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc) 288 288 { 289 - u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC]; 290 289 struct hclge_vport *vport = hclge_get_vport(h); 291 290 struct hclge_dev *hdev = vport->back; 292 291 int ret; 293 - u8 i; 294 292 295 293 memset(pfc, 0, sizeof(*pfc)); 296 294 pfc->pfc_cap = hdev->pfc_max; 297 295 pfc->pfc_en = hdev->tm_info.pfc_en; 298 296 299 - ret = hclge_pfc_tx_stats_get(hdev, requests); 300 - if (ret) 297 + ret = hclge_mac_update_stats(hdev); 298 + if (ret) { 299 + dev_err(&hdev->pdev->dev, 300 + "failed to update MAC stats, ret = %d.\n", ret); 301 301 return ret; 302 - 303 - ret = hclge_pfc_rx_stats_get(hdev, indications); 304 - if (ret) 305 - return ret; 306 - 307 - for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { 308 - pfc->requests[i] = requests[i]; 309 - pfc->indications[i] = indications[i]; 310 302 } 303 + 304 + hclge_pfc_tx_stats_get(hdev, pfc->requests); 305 + hclge_pfc_rx_stats_get(hdev, pfc->indications); 306 + 311 307 return 0; 312 308 } 313 309
+39 -67
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 26 26 #include "hclge_devlink.h" 27 27 28 28 #define HCLGE_NAME "hclge" 29 - #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset))) 30 - #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f)) 31 29 32 30 #define HCLGE_BUF_SIZE_UNIT 256U 33 31 #define HCLGE_BUF_MUL_BY 2 ··· 566 568 struct hclge_desc desc; 567 569 int ret; 568 570 571 + /* Driver needs total register number of both valid registers and 572 + * reserved registers, but the old firmware only returns number 573 + * of valid registers in device V2. To be compatible with these 574 + * devices, driver uses a fixed value. 575 + */ 576 + if (hdev->ae_dev->dev_version == HNAE3_DEVICE_VERSION_V2) { 577 + *reg_num = HCLGE_MAC_STATS_MAX_NUM_V1; 578 + return 0; 579 + } 580 + 569 581 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_MAC_REG_NUM, true); 570 582 ret = hclge_cmd_send(&hdev->hw, &desc, 1); 571 583 if (ret) { ··· 595 587 return 0; 596 588 } 597 589 598 - static int hclge_mac_update_stats(struct hclge_dev *hdev) 590 + int hclge_mac_update_stats(struct hclge_dev *hdev) 599 591 { 600 592 /* The firmware supports the new statistics acquisition method */ 601 593 if (hdev->ae_dev->dev_specs.mac_stats_num) ··· 2589 2581 if (hdev->num_msi < hdev->num_nic_msi + hdev->num_roce_msi) 2590 2582 return -EINVAL; 2591 2583 2592 - roce->rinfo.base_vector = hdev->roce_base_vector; 2584 + roce->rinfo.base_vector = hdev->num_nic_msi; 2593 2585 2594 2586 roce->rinfo.netdev = nic->kinfo.netdev; 2595 2587 roce->rinfo.roce_io_base = hdev->hw.io_base; ··· 2624 2616 2625 2617 hdev->num_msi = vectors; 2626 2618 hdev->num_msi_left = vectors; 2627 - 2628 - hdev->base_msi_vector = pdev->irq; 2629 - hdev->roce_base_vector = hdev->base_msi_vector + 2630 - hdev->num_nic_msi; 2631 2619 2632 2620 hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, 2633 2621 sizeof(u16), GFP_KERNEL); ··· 8953 8949 8954 8950 err_no_space: 8955 8951 /* if already overflow, not to print each time */ 8956 - if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE)) 8952 + if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE)) { 8953 + vport->overflow_promisc_flags |= HNAE3_OVERFLOW_MPE; 8957 8954 dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n"); 8955 + } 8956 + 8958 8957 return -ENOSPC; 8959 8958 } 8960 8959 ··· 9013 9006 9014 9007 static void hclge_sync_vport_mac_list(struct hclge_vport *vport, 9015 9008 struct list_head *list, 9016 - int (*sync)(struct hclge_vport *, 9017 - const unsigned char *)) 9009 + enum HCLGE_MAC_ADDR_TYPE mac_type) 9018 9010 { 9011 + int (*sync)(struct hclge_vport *vport, const unsigned char *addr); 9019 9012 struct hclge_mac_node *mac_node, *tmp; 9020 9013 int ret; 9014 + 9015 + if (mac_type == HCLGE_MAC_ADDR_UC) 9016 + sync = hclge_add_uc_addr_common; 9017 + else 9018 + sync = hclge_add_mc_addr_common; 9021 9019 9022 9020 list_for_each_entry_safe(mac_node, tmp, list, node) { 9023 9021 ret = sync(vport, mac_node->mac_addr); ··· 9035 9023 /* If one unicast mac address is existing in hardware, 9036 9024 * we need to try whether other unicast mac addresses 9037 9025 * are new addresses that can be added. 9026 + * Multicast mac address can be reusable, even though 9027 + * there is no space to add new multicast mac address, 9028 + * we should check whether other mac addresses are 9029 + * existing in hardware for reuse. 9038 9030 */ 9039 - if (ret != -EEXIST) 9031 + if ((mac_type == HCLGE_MAC_ADDR_UC && ret != -EEXIST) || 9032 + (mac_type == HCLGE_MAC_ADDR_MC && ret != -ENOSPC)) 9040 9033 break; 9041 9034 } 9042 9035 } ··· 9049 9032 9050 9033 static void hclge_unsync_vport_mac_list(struct hclge_vport *vport, 9051 9034 struct list_head *list, 9052 - int (*unsync)(struct hclge_vport *, 9053 - const unsigned char *)) 9035 + enum HCLGE_MAC_ADDR_TYPE mac_type) 9054 9036 { 9037 + int (*unsync)(struct hclge_vport *vport, const unsigned char *addr); 9055 9038 struct hclge_mac_node *mac_node, *tmp; 9056 9039 int ret; 9040 + 9041 + if (mac_type == HCLGE_MAC_ADDR_UC) 9042 + unsync = hclge_rm_uc_addr_common; 9043 + else 9044 + unsync = hclge_rm_mc_addr_common; 9057 9045 9058 9046 list_for_each_entry_safe(mac_node, tmp, list, node) { 9059 9047 ret = unsync(vport, mac_node->mac_addr); ··· 9190 9168 spin_unlock_bh(&vport->mac_list_lock); 9191 9169 9192 9170 /* delete first, in order to get max mac table space for adding */ 9193 - if (mac_type == HCLGE_MAC_ADDR_UC) { 9194 - hclge_unsync_vport_mac_list(vport, &tmp_del_list, 9195 - hclge_rm_uc_addr_common); 9196 - hclge_sync_vport_mac_list(vport, &tmp_add_list, 9197 - hclge_add_uc_addr_common); 9198 - } else { 9199 - hclge_unsync_vport_mac_list(vport, &tmp_del_list, 9200 - hclge_rm_mc_addr_common); 9201 - hclge_sync_vport_mac_list(vport, &tmp_add_list, 9202 - hclge_add_mc_addr_common); 9203 - } 9171 + hclge_unsync_vport_mac_list(vport, &tmp_del_list, mac_type); 9172 + hclge_sync_vport_mac_list(vport, &tmp_add_list, mac_type); 9204 9173 9205 9174 /* if some mac addresses were added/deleted fail, move back to the 9206 9175 * mac_list, and retry at next time. ··· 9350 9337 9351 9338 spin_unlock_bh(&vport->mac_list_lock); 9352 9339 9353 - if (mac_type == HCLGE_MAC_ADDR_UC) 9354 - hclge_unsync_vport_mac_list(vport, &tmp_del_list, 9355 - hclge_rm_uc_addr_common); 9356 - else 9357 - hclge_unsync_vport_mac_list(vport, &tmp_del_list, 9358 - hclge_rm_mc_addr_common); 9340 + hclge_unsync_vport_mac_list(vport, &tmp_del_list, mac_type); 9359 9341 9360 9342 if (!list_empty(&tmp_del_list)) 9361 9343 dev_warn(&hdev->pdev->dev, ··· 9418 9410 return return_status; 9419 9411 } 9420 9412 9421 - static bool hclge_check_vf_mac_exist(struct hclge_vport *vport, int vf_idx, 9422 - u8 *mac_addr) 9423 - { 9424 - struct hclge_mac_vlan_tbl_entry_cmd req; 9425 - struct hclge_dev *hdev = vport->back; 9426 - struct hclge_desc desc; 9427 - u16 egress_port = 0; 9428 - int i; 9429 - 9430 - if (is_zero_ether_addr(mac_addr)) 9431 - return false; 9432 - 9433 - memset(&req, 0, sizeof(req)); 9434 - hnae3_set_field(egress_port, HCLGE_MAC_EPORT_VFID_M, 9435 - HCLGE_MAC_EPORT_VFID_S, vport->vport_id); 9436 - req.egress_port = cpu_to_le16(egress_port); 9437 - hclge_prepare_mac_addr(&req, mac_addr, false); 9438 - 9439 - if (hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false) != -ENOENT) 9440 - return true; 9441 - 9442 - vf_idx += HCLGE_VF_VPORT_START_NUM; 9443 - for (i = HCLGE_VF_VPORT_START_NUM; i < hdev->num_alloc_vport; i++) 9444 - if (i != vf_idx && 9445 - ether_addr_equal(mac_addr, hdev->vport[i].vf_info.mac)) 9446 - return true; 9447 - 9448 - return false; 9449 - } 9450 - 9451 9413 static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, 9452 9414 u8 *mac_addr) 9453 9415 { ··· 9433 9455 "Specified MAC(=%pM) is same as before, no change committed!\n", 9434 9456 mac_addr); 9435 9457 return 0; 9436 - } 9437 - 9438 - if (hclge_check_vf_mac_exist(vport, vf, mac_addr)) { 9439 - dev_err(&hdev->pdev->dev, "Specified MAC(=%pM) exists!\n", 9440 - mac_addr); 9441 - return -EEXIST; 9442 9458 } 9443 9459 9444 9460 ether_addr_copy(vport->vf_info.mac, mac_addr);
+5 -3
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
··· 404 404 }; 405 405 406 406 /* max number of mac statistics on each version */ 407 - #define HCLGE_MAC_STATS_MAX_NUM_V1 84 407 + #define HCLGE_MAC_STATS_MAX_NUM_V1 87 408 408 #define HCLGE_MAC_STATS_MAX_NUM_V2 105 409 409 410 410 struct hclge_comm_stats_str { ··· 852 852 (y) = (_k_ ^ ~_v_) & (_k_); \ 853 853 } while (0) 854 854 855 + #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f)) 856 + #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset))) 857 + 855 858 #define HCLGE_MAC_TNL_LOG_SIZE 8 856 859 #define HCLGE_VPORT_NUM 256 857 860 struct hclge_dev { ··· 907 904 u16 num_msi; 908 905 u16 num_msi_left; 909 906 u16 num_msi_used; 910 - u32 base_msi_vector; 911 907 u16 *vector_status; 912 908 int *vector_irq; 913 909 u16 num_nic_msi; /* Num of nic vectors for this PF */ 914 910 u16 num_roce_msi; /* Num of roce vectors for this PF */ 915 - int roce_base_vector; 916 911 917 912 unsigned long service_timer_period; 918 913 unsigned long service_timer_previous; ··· 1169 1168 int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len); 1170 1169 int hclge_push_vf_link_status(struct hclge_vport *vport); 1171 1170 int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en); 1171 + int hclge_mac_update_stats(struct hclge_dev *hdev); 1172 1172 #endif
+36 -43
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
··· 113 113 return 0; 114 114 } 115 115 116 - static int hclge_pfc_stats_get(struct hclge_dev *hdev, 117 - enum hclge_opcode_type opcode, u64 *stats) 116 + static const u16 hclge_pfc_tx_stats_offset[] = { 117 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri0_pkt_num), 118 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri1_pkt_num), 119 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri2_pkt_num), 120 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri3_pkt_num), 121 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri4_pkt_num), 122 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri5_pkt_num), 123 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri6_pkt_num), 124 + HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri7_pkt_num) 125 + }; 126 + 127 + static const u16 hclge_pfc_rx_stats_offset[] = { 128 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri0_pkt_num), 129 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri1_pkt_num), 130 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri2_pkt_num), 131 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri3_pkt_num), 132 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri4_pkt_num), 133 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri5_pkt_num), 134 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri6_pkt_num), 135 + HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri7_pkt_num) 136 + }; 137 + 138 + static void hclge_pfc_stats_get(struct hclge_dev *hdev, bool tx, u64 *stats) 118 139 { 119 - struct hclge_desc desc[HCLGE_TM_PFC_PKT_GET_CMD_NUM]; 120 - int ret, i, j; 140 + const u16 *offset; 141 + int i; 121 142 122 - if (!(opcode == HCLGE_OPC_QUERY_PFC_RX_PKT_CNT || 123 - opcode == HCLGE_OPC_QUERY_PFC_TX_PKT_CNT)) 124 - return -EINVAL; 143 + if (tx) 144 + offset = hclge_pfc_tx_stats_offset; 145 + else 146 + offset = hclge_pfc_rx_stats_offset; 125 147 126 - for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM - 1; i++) { 127 - hclge_cmd_setup_basic_desc(&desc[i], opcode, true); 128 - desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); 129 - } 130 - 131 - hclge_cmd_setup_basic_desc(&desc[i], opcode, true); 132 - 133 - ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM); 134 - if (ret) 135 - return ret; 136 - 137 - for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) { 138 - struct hclge_pfc_stats_cmd *pfc_stats = 139 - (struct hclge_pfc_stats_cmd *)desc[i].data; 140 - 141 - for (j = 0; j < HCLGE_TM_PFC_NUM_GET_PER_CMD; j++) { 142 - u32 index = i * HCLGE_TM_PFC_PKT_GET_CMD_NUM + j; 143 - 144 - if (index < HCLGE_MAX_TC_NUM) 145 - stats[index] = 146 - le64_to_cpu(pfc_stats->pkt_num[j]); 147 - } 148 - } 149 - return 0; 148 + for (i = 0; i < HCLGE_MAX_TC_NUM; i++) 149 + stats[i] = HCLGE_STATS_READ(&hdev->mac_stats, offset[i]); 150 150 } 151 151 152 - int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats) 152 + void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats) 153 153 { 154 - return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_RX_PKT_CNT, stats); 154 + hclge_pfc_stats_get(hdev, false, stats); 155 155 } 156 156 157 - int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats) 157 + void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats) 158 158 { 159 - return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_TX_PKT_CNT, stats); 159 + hclge_pfc_stats_get(hdev, true, stats); 160 160 } 161 161 162 162 int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx) ··· 1123 1123 1124 1124 static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev) 1125 1125 { 1126 - #define DEFAULT_TC_WEIGHT 1 1127 1126 #define DEFAULT_TC_OFFSET 14 1128 1127 1129 1128 struct hclge_ets_tc_weight_cmd *ets_weight; ··· 1135 1136 for (i = 0; i < HNAE3_MAX_TC; i++) { 1136 1137 struct hclge_pg_info *pg_info; 1137 1138 1138 - ets_weight->tc_weight[i] = DEFAULT_TC_WEIGHT; 1139 - 1140 - if (!(hdev->hw_tc_map & BIT(i))) 1141 - continue; 1142 - 1143 - pg_info = 1144 - &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; 1139 + pg_info = &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; 1145 1140 ets_weight->tc_weight[i] = pg_info->tc_dwrr[i]; 1146 1141 } 1147 1142
+2 -2
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
··· 228 228 int hclge_tm_init_hw(struct hclge_dev *hdev, bool init); 229 229 int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx); 230 230 int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); 231 - int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); 232 - int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); 231 + void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); 232 + void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); 233 233 int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate); 234 234 int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num); 235 235 int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num);
+32
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c
··· 434 434 return ret; 435 435 } 436 436 437 + static int hclgevf_firmware_compat_config(struct hclgevf_dev *hdev, bool en) 438 + { 439 + struct hclgevf_firmware_compat_cmd *req; 440 + struct hclgevf_desc desc; 441 + u32 compat = 0; 442 + 443 + hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_IMP_COMPAT_CFG, false); 444 + 445 + if (en) { 446 + req = (struct hclgevf_firmware_compat_cmd *)desc.data; 447 + 448 + hnae3_set_bit(compat, HCLGEVF_SYNC_RX_RING_HEAD_EN_B, 1); 449 + 450 + req->compat = cpu_to_le32(compat); 451 + } 452 + 453 + return hclgevf_cmd_send(&hdev->hw, &desc, 1); 454 + } 455 + 437 456 int hclgevf_cmd_init(struct hclgevf_dev *hdev) 438 457 { 458 + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); 439 459 int ret; 440 460 441 461 spin_lock_bh(&hdev->hw.cmq.csq.lock); ··· 504 484 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK, 505 485 HNAE3_FW_VERSION_BYTE0_SHIFT)); 506 486 487 + if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) { 488 + /* ask the firmware to enable some features, driver can work 489 + * without it. 490 + */ 491 + ret = hclgevf_firmware_compat_config(hdev, true); 492 + if (ret) 493 + dev_warn(&hdev->pdev->dev, 494 + "Firmware compatible features not enabled(%d).\n", 495 + ret); 496 + } 497 + 507 498 return 0; 508 499 509 500 err_cmd_init: ··· 539 508 540 509 void hclgevf_cmd_uninit(struct hclgevf_dev *hdev) 541 510 { 511 + hclgevf_firmware_compat_config(hdev, false); 542 512 set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state); 543 513 /* wait to ensure that the firmware completes the possible left 544 514 * over commands.
+9
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h
··· 15 15 struct hclgevf_hw; 16 16 struct hclgevf_dev; 17 17 18 + #define HCLGEVF_SYNC_RX_RING_HEAD_EN_B 4 19 + struct hclgevf_firmware_compat_cmd { 20 + __le32 compat; 21 + u8 rsv[20]; 22 + }; 23 + 18 24 struct hclgevf_desc { 19 25 __le16 opcode; 20 26 __le16 flag; ··· 113 107 HCLGEVF_OPC_RSS_TC_MODE = 0x0D08, 114 108 /* Mailbox cmd */ 115 109 HCLGEVF_OPC_MBX_VF_TO_PF = 0x2001, 110 + 111 + /* IMP stats command */ 112 + HCLGEVF_OPC_IMP_COMPAT_CFG = 0x701A, 116 113 }; 117 114 118 115 #define HCLGEVF_TQP_REG_OFFSET 0x80000
+6 -4
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 2557 2557 hdev->num_msi_left == 0) 2558 2558 return -EINVAL; 2559 2559 2560 - roce->rinfo.base_vector = hdev->roce_base_vector; 2560 + roce->rinfo.base_vector = hdev->roce_base_msix_offset; 2561 2561 2562 2562 roce->rinfo.netdev = nic->kinfo.netdev; 2563 2563 roce->rinfo.roce_io_base = hdev->hw.io_base; ··· 2823 2823 hdev->num_msi = vectors; 2824 2824 hdev->num_msi_left = vectors; 2825 2825 2826 - hdev->base_msi_vector = pdev->irq; 2827 - hdev->roce_base_vector = pdev->irq + hdev->roce_base_msix_offset; 2828 - 2829 2826 hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, 2830 2827 sizeof(u16), GFP_KERNEL); 2831 2828 if (!hdev->vector_status) { ··· 3010 3013 3011 3014 /* un-init roce, if it exists */ 3012 3015 if (hdev->roce_client) { 3016 + while (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) 3017 + msleep(HCLGEVF_WAIT_RESET_DONE); 3013 3018 clear_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state); 3019 + 3014 3020 hdev->roce_client->ops->uninit_instance(&hdev->roce, 0); 3015 3021 hdev->roce_client = NULL; 3016 3022 hdev->roce.client = NULL; ··· 3022 3022 /* un-init nic/unic, if this was not called by roce client */ 3023 3023 if (client->ops->uninit_instance && hdev->nic_client && 3024 3024 client->type != HNAE3_CLIENT_ROCE) { 3025 + while (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) 3026 + msleep(HCLGEVF_WAIT_RESET_DONE); 3025 3027 clear_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state); 3026 3028 3027 3029 client->ops->uninit_instance(&hdev->nic, 0);
+2 -2
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
··· 109 109 #define HCLGEVF_VF_RST_ING 0x07008 110 110 #define HCLGEVF_VF_RST_ING_BIT BIT(16) 111 111 112 + #define HCLGEVF_WAIT_RESET_DONE 100 113 + 112 114 #define HCLGEVF_RSS_IND_TBL_SIZE 512 113 115 #define HCLGEVF_RSS_SET_BITMAP_MSK 0xffff 114 116 #define HCLGEVF_RSS_KEY_SIZE 40 ··· 310 308 u16 num_nic_msix; /* Num of nic vectors for this VF */ 311 309 u16 num_roce_msix; /* Num of roce vectors for this VF */ 312 310 u16 roce_base_msix_offset; 313 - int roce_base_vector; 314 - u32 base_msi_vector; 315 311 u16 *vector_status; 316 312 int *vector_irq; 317 313