Skip to content

Commit 260e938

Browse files
jbrandebJeff Kirsher
authored andcommitted
virtchnl: move some code to core driver
Before moving this function over to virtchnl.h, move some driver specific checks that had snuck into a fairly generic function, back into the caller of the function. Signed-off-by: Jesse Brandeburg <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 310a2ad commit 260e938

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,10 +2549,6 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
25492549
bool err_msg_format = false;
25502550
int valid_len = 0;
25512551

2552-
/* Check if VF is disabled. */
2553-
if (test_bit(I40E_VF_STATE_DISABLED, &vf->vf_states))
2554-
return I40E_ERR_PARAM;
2555-
25562552
/* Validate message length. */
25572553
switch (v_opcode) {
25582554
case VIRTCHNL_OP_VERSION:
@@ -2657,10 +2653,6 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
26572653
if (msglen >= valid_len) {
26582654
struct virtchnl_rss_key *vrk =
26592655
(struct virtchnl_rss_key *)msg;
2660-
if (vrk->key_len != I40E_HKEY_ARRAY_SIZE) {
2661-
err_msg_format = true;
2662-
break;
2663-
}
26642656
valid_len += vrk->key_len - 1;
26652657
}
26662658
break;
@@ -2669,10 +2661,6 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
26692661
if (msglen >= valid_len) {
26702662
struct virtchnl_rss_lut *vrl =
26712663
(struct virtchnl_rss_lut *)msg;
2672-
if (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE) {
2673-
err_msg_format = true;
2674-
break;
2675-
}
26762664
valid_len += vrl->lut_entries - 1;
26772665
}
26782666
break;
@@ -2719,9 +2707,27 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
27192707
if (local_vf_id >= pf->num_alloc_vfs)
27202708
return -EINVAL;
27212709
vf = &(pf->vf[local_vf_id]);
2710+
2711+
/* Check if VF is disabled. */
2712+
if (test_bit(I40E_VF_STATE_DISABLED, &vf->vf_states))
2713+
return I40E_ERR_PARAM;
2714+
27222715
/* perform basic checks on the msg */
27232716
ret = i40e_vc_validate_vf_msg(vf, v_opcode, v_retval, msg, msglen);
27242717

2718+
/* perform additional checks specific to this driver */
2719+
if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_KEY) {
2720+
struct virtchnl_rss_key *vrk = (struct virtchnl_rss_key *)msg;
2721+
2722+
if (vrk->key_len != I40E_HKEY_ARRAY_SIZE)
2723+
ret = -EINVAL;
2724+
} else if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_LUT) {
2725+
struct virtchnl_rss_lut *vrl = (struct virtchnl_rss_lut *)msg;
2726+
2727+
if (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)
2728+
ret = -EINVAL;
2729+
}
2730+
27252731
if (ret) {
27262732
dev_err(&pf->pdev->dev, "Invalid message from VF %d, opcode %d, len %d\n",
27272733
local_vf_id, v_opcode, msglen);

0 commit comments

Comments
 (0)