@@ -2536,15 +2536,16 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen)
2536
2536
2537
2537
/**
2538
2538
* i40e_vc_validate_vf_msg
2539
- * @vf: pointer to the VF info
2539
+ * @ver: Virtchnl version info
2540
+ * @v_opcode: Opcode for the message
2540
2541
* @msg: pointer to the msg buffer
2541
2542
* @msglen: msg length
2542
- * @msghndl: msg handle
2543
2543
*
2544
- * validate msg
2544
+ * validate msg format against struct for each opcode
2545
2545
**/
2546
- static int i40e_vc_validate_vf_msg (struct i40e_vf * vf , u32 v_opcode ,
2547
- u32 v_retval , u8 * msg , u16 msglen )
2546
+ static int
2547
+ i40e_vc_validate_vf_msg (struct virtchnl_version_info * ver , u32 v_opcode ,
2548
+ u8 * msg , u16 msglen )
2548
2549
{
2549
2550
bool err_msg_format = false;
2550
2551
int valid_len = 0 ;
@@ -2557,7 +2558,7 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
2557
2558
case VIRTCHNL_OP_RESET_VF :
2558
2559
break ;
2559
2560
case VIRTCHNL_OP_GET_VF_RESOURCES :
2560
- if (VF_IS_V11 (& vf -> vf_ver ))
2561
+ if (VF_IS_V11 (ver ))
2561
2562
valid_len = sizeof (u32 );
2562
2563
break ;
2563
2564
case VIRTCHNL_OP_CONFIG_TX_QUEUE :
@@ -2633,7 +2634,6 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
2633
2634
err_msg_format = true;
2634
2635
break ;
2635
2636
case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP :
2636
- valid_len = 0 ;
2637
2637
break ;
2638
2638
case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP :
2639
2639
valid_len = sizeof (struct virtchnl_iwarp_qvlist_info );
@@ -2673,15 +2673,13 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
2673
2673
case VIRTCHNL_OP_EVENT :
2674
2674
case VIRTCHNL_OP_UNKNOWN :
2675
2675
default :
2676
- return - EPERM ;
2676
+ return VIRTCHNL_ERR_PARAM ;
2677
2677
}
2678
2678
/* few more checks */
2679
- if ((valid_len != msglen ) || (err_msg_format )) {
2680
- i40e_vc_send_resp_to_vf (vf , v_opcode , I40E_ERR_PARAM );
2681
- return - EINVAL ;
2682
- } else {
2683
- return 0 ;
2684
- }
2679
+ if ((valid_len != msglen ) || (err_msg_format ))
2680
+ return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH ;
2681
+
2682
+ return 0 ;
2685
2683
}
2686
2684
2687
2685
/**
@@ -2713,7 +2711,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
2713
2711
return I40E_ERR_PARAM ;
2714
2712
2715
2713
/* perform basic checks on the msg */
2716
- ret = i40e_vc_validate_vf_msg (vf , v_opcode , v_retval , msg , msglen );
2714
+ ret = i40e_vc_validate_vf_msg (& vf -> vf_ver , v_opcode , msg , msglen );
2717
2715
2718
2716
/* perform additional checks specific to this driver */
2719
2717
if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_KEY ) {
@@ -2729,9 +2727,15 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
2729
2727
}
2730
2728
2731
2729
if (ret ) {
2730
+ i40e_vc_send_resp_to_vf (vf , v_opcode , I40E_ERR_PARAM );
2732
2731
dev_err (& pf -> pdev -> dev , "Invalid message from VF %d, opcode %d, len %d\n" ,
2733
2732
local_vf_id , v_opcode , msglen );
2734
- return ret ;
2733
+ switch (ret ) {
2734
+ case VIRTCHNL_ERR_PARAM :
2735
+ return - EPERM ;
2736
+ default :
2737
+ return - EINVAL ;
2738
+ }
2735
2739
}
2736
2740
2737
2741
switch (v_opcode ) {
0 commit comments