@@ -73,7 +73,7 @@ void hclge_comm_cmd_setup_basic_desc(struct hclge_desc *desc,
7373 desc -> flag |= cpu_to_le16 (HCLGE_COMM_CMD_FLAG_WR );
7474}
7575
76- int hclge_comm_firmware_compat_config (struct hnae3_ae_dev * ae_dev , bool is_pf ,
76+ int hclge_comm_firmware_compat_config (struct hnae3_ae_dev * ae_dev ,
7777 struct hclge_comm_hw * hw , bool en )
7878{
7979 struct hclge_comm_firmware_compat_cmd * req ;
@@ -96,7 +96,7 @@ int hclge_comm_firmware_compat_config(struct hnae3_ae_dev *ae_dev, bool is_pf,
9696 req -> compat = cpu_to_le32 (compat );
9797 }
9898
99- return hclge_comm_cmd_send (hw , & desc , 1 , is_pf );
99+ return hclge_comm_cmd_send (hw , & desc , 1 );
100100}
101101
102102void hclge_comm_free_cmd_desc (struct hclge_comm_cmq_ring * ring )
@@ -209,7 +209,7 @@ int hclge_comm_cmd_query_version_and_capability(struct hnae3_ae_dev *ae_dev,
209209 resp = (struct hclge_comm_query_version_cmd * )desc .data ;
210210 resp -> api_caps = hclge_comm_build_api_caps ();
211211
212- ret = hclge_comm_cmd_send (hw , & desc , 1 , is_pf );
212+ ret = hclge_comm_cmd_send (hw , & desc , 1 );
213213 if (ret )
214214 return ret ;
215215
@@ -227,46 +227,32 @@ int hclge_comm_cmd_query_version_and_capability(struct hnae3_ae_dev *ae_dev,
227227 return ret ;
228228}
229229
230- static bool hclge_is_elem_in_array (const u16 * spec_opcode , u32 size , u16 opcode )
230+ static const u16 spec_opcode [] = { HCLGE_COMM_OPC_STATS_64_BIT ,
231+ HCLGE_COMM_OPC_STATS_32_BIT ,
232+ HCLGE_COMM_OPC_STATS_MAC ,
233+ HCLGE_COMM_OPC_STATS_MAC_ALL ,
234+ HCLGE_COMM_OPC_QUERY_32_BIT_REG ,
235+ HCLGE_COMM_OPC_QUERY_64_BIT_REG ,
236+ HCLGE_COMM_QUERY_CLEAR_MPF_RAS_INT ,
237+ HCLGE_COMM_QUERY_CLEAR_PF_RAS_INT ,
238+ HCLGE_COMM_QUERY_CLEAR_ALL_MPF_MSIX_INT ,
239+ HCLGE_COMM_QUERY_CLEAR_ALL_PF_MSIX_INT ,
240+ HCLGE_COMM_QUERY_ALL_ERR_INFO };
241+
242+ static bool hclge_comm_is_special_opcode (u16 opcode )
231243{
244+ /* these commands have several descriptors,
245+ * and use the first one to save opcode and return value
246+ */
232247 u32 i ;
233248
234- for (i = 0 ; i < size ; i ++ ) {
249+ for (i = 0 ; i < ARRAY_SIZE ( spec_opcode ) ; i ++ )
235250 if (spec_opcode [i ] == opcode )
236251 return true;
237- }
238252
239253 return false;
240254}
241255
242- static const u16 pf_spec_opcode [] = { HCLGE_COMM_OPC_STATS_64_BIT ,
243- HCLGE_COMM_OPC_STATS_32_BIT ,
244- HCLGE_COMM_OPC_STATS_MAC ,
245- HCLGE_COMM_OPC_STATS_MAC_ALL ,
246- HCLGE_COMM_OPC_QUERY_32_BIT_REG ,
247- HCLGE_COMM_OPC_QUERY_64_BIT_REG ,
248- HCLGE_COMM_QUERY_CLEAR_MPF_RAS_INT ,
249- HCLGE_COMM_QUERY_CLEAR_PF_RAS_INT ,
250- HCLGE_COMM_QUERY_CLEAR_ALL_MPF_MSIX_INT ,
251- HCLGE_COMM_QUERY_CLEAR_ALL_PF_MSIX_INT ,
252- HCLGE_COMM_QUERY_ALL_ERR_INFO };
253-
254- static const u16 vf_spec_opcode [] = { HCLGE_COMM_OPC_STATS_64_BIT ,
255- HCLGE_COMM_OPC_STATS_32_BIT ,
256- HCLGE_COMM_OPC_STATS_MAC };
257-
258- static bool hclge_comm_is_special_opcode (u16 opcode , bool is_pf )
259- {
260- /* these commands have several descriptors,
261- * and use the first one to save opcode and return value
262- */
263- const u16 * spec_opcode = is_pf ? pf_spec_opcode : vf_spec_opcode ;
264- u32 size = is_pf ? ARRAY_SIZE (pf_spec_opcode ) :
265- ARRAY_SIZE (vf_spec_opcode );
266-
267- return hclge_is_elem_in_array (spec_opcode , size , opcode );
268- }
269-
270256static int hclge_comm_ring_space (struct hclge_comm_cmq_ring * ring )
271257{
272258 int ntc = ring -> next_to_clean ;
@@ -378,7 +364,7 @@ static int hclge_comm_cmd_convert_err_code(u16 desc_ret)
378364
379365static int hclge_comm_cmd_check_retval (struct hclge_comm_hw * hw ,
380366 struct hclge_desc * desc , int num ,
381- int ntc , bool is_pf )
367+ int ntc )
382368{
383369 u16 opcode , desc_ret ;
384370 int handle ;
@@ -390,7 +376,7 @@ static int hclge_comm_cmd_check_retval(struct hclge_comm_hw *hw,
390376 if (ntc >= hw -> cmq .csq .desc_num )
391377 ntc = 0 ;
392378 }
393- if (likely (!hclge_comm_is_special_opcode (opcode , is_pf )))
379+ if (likely (!hclge_comm_is_special_opcode (opcode )))
394380 desc_ret = le16_to_cpu (desc [num - 1 ].retval );
395381 else
396382 desc_ret = le16_to_cpu (desc [0 ].retval );
@@ -402,7 +388,7 @@ static int hclge_comm_cmd_check_retval(struct hclge_comm_hw *hw,
402388
403389static int hclge_comm_cmd_check_result (struct hclge_comm_hw * hw ,
404390 struct hclge_desc * desc ,
405- int num , int ntc , bool is_pf )
391+ int num , int ntc )
406392{
407393 bool is_completed = false;
408394 int handle , ret ;
@@ -416,7 +402,7 @@ static int hclge_comm_cmd_check_result(struct hclge_comm_hw *hw,
416402 if (!is_completed )
417403 ret = - EBADE ;
418404 else
419- ret = hclge_comm_cmd_check_retval (hw , desc , num , ntc , is_pf );
405+ ret = hclge_comm_cmd_check_retval (hw , desc , num , ntc );
420406
421407 /* Clean the command send queue */
422408 handle = hclge_comm_cmd_csq_clean (hw );
@@ -433,13 +419,12 @@ static int hclge_comm_cmd_check_result(struct hclge_comm_hw *hw,
433419 * @hw: pointer to the hw struct
434420 * @desc: prefilled descriptor for describing the command
435421 * @num : the number of descriptors to be sent
436- * @is_pf: bool to judge pf/vf module
437422 *
438423 * This is the main send command for command queue, it
439424 * sends the queue, cleans the queue, etc
440425 **/
441426int hclge_comm_cmd_send (struct hclge_comm_hw * hw , struct hclge_desc * desc ,
442- int num , bool is_pf )
427+ int num )
443428{
444429 struct hclge_comm_cmq_ring * csq = & hw -> cmq .csq ;
445430 int ret ;
@@ -474,7 +459,7 @@ int hclge_comm_cmd_send(struct hclge_comm_hw *hw, struct hclge_desc *desc,
474459 hclge_comm_write_dev (hw , HCLGE_COMM_NIC_CSQ_TAIL_REG ,
475460 hw -> cmq .csq .next_to_use );
476461
477- ret = hclge_comm_cmd_check_result (hw , desc , num , ntc , is_pf );
462+ ret = hclge_comm_cmd_check_result (hw , desc , num , ntc );
478463
479464 spin_unlock_bh (& hw -> cmq .csq .lock );
480465
@@ -495,12 +480,12 @@ static void hclge_comm_cmd_uninit_regs(struct hclge_comm_hw *hw)
495480 hclge_comm_write_dev (hw , HCLGE_COMM_NIC_CRQ_TAIL_REG , 0 );
496481}
497482
498- void hclge_comm_cmd_uninit (struct hnae3_ae_dev * ae_dev , bool is_pf ,
483+ void hclge_comm_cmd_uninit (struct hnae3_ae_dev * ae_dev ,
499484 struct hclge_comm_hw * hw )
500485{
501486 struct hclge_comm_cmq * cmdq = & hw -> cmq ;
502487
503- hclge_comm_firmware_compat_config (ae_dev , is_pf , hw , false);
488+ hclge_comm_firmware_compat_config (ae_dev , hw , false);
504489 set_bit (HCLGE_COMM_STATE_CMD_DISABLE , & hw -> comm_state );
505490
506491 /* wait to ensure that the firmware completes the possible left
@@ -612,7 +597,7 @@ int hclge_comm_cmd_init(struct hnae3_ae_dev *ae_dev, struct hclge_comm_hw *hw,
612597 /* ask the firmware to enable some features, driver can work without
613598 * it.
614599 */
615- ret = hclge_comm_firmware_compat_config (ae_dev , is_pf , hw , true);
600+ ret = hclge_comm_firmware_compat_config (ae_dev , hw , true);
616601 if (ret )
617602 dev_warn (& ae_dev -> pdev -> dev ,
618603 "Firmware compatible features not enabled(%d).\n" ,
0 commit comments