]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.8/ice-use-relative-vsi-index-for-vfs-instead-of-pf-vsi.patch
Fixes for 6.8
[thirdparty/kernel/stable-queue.git] / queue-6.8 / ice-use-relative-vsi-index-for-vfs-instead-of-pf-vsi.patch
1 From 2b15cdc9bdb1dfc2cc0fca5d8662e7699cac8e02 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Fri, 16 Feb 2024 14:06:37 -0800
4 Subject: ice: use relative VSI index for VFs instead of PF VSI number
5
6 From: Jacob Keller <jacob.e.keller@intel.com>
7
8 [ Upstream commit 11fbb1bfb5bc8c98b2d7db9da332b5e568f4aaab ]
9
10 When initializing over virtchnl, the PF is required to pass a VSI ID to the
11 VF as part of its capabilities exchange. The VF driver reports this value
12 back to the PF in a variety of commands. The PF driver validates that this
13 value matches the value it sent to the VF.
14
15 Some hardware families such as the E700 series could use this value when
16 reading RSS registers or communicating directly with firmware over the
17 Admin Queue.
18
19 However, E800 series hardware does not support any of these interfaces and
20 the VF's only use for this value is to report it back to the PF. Thus,
21 there is no requirement that this value be an actual VSI ID value of any
22 kind.
23
24 The PF driver already does not trust that the VF sends it a real VSI ID.
25 The VSI structure is always looked up from the VF structure. The PF does
26 validate that the VSI ID provided matches a VSI associated with the VF, but
27 otherwise does not use the VSI ID for any purpose.
28
29 Instead of reporting the VSI number relative to the PF space, report a
30 fixed value of 1. When communicating with the VF over virtchnl, validate
31 that the VSI number is returned appropriately.
32
33 This avoids leaking information about the firmware of the PF state.
34 Currently the ice driver only supplies a VF with a single VSI. However, it
35 appears that virtchnl has some support for allowing multiple VSIs. I did
36 not attempt to implement this. However, space is left open to allow further
37 relative indexes if additional VSIs are provided in future feature
38 development. For this reason, keep the ice_vc_isvalid_vsi_id function in
39 place to allow extending it for multiple VSIs in the future.
40
41 This change will also simplify handling of live migration in a future
42 series. Since we no longer will provide a real VSI number to the VF, there
43 will be no need to keep track of this number when migrating to a new host.
44
45 Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
46 Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
47 Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
48 Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
49 Signed-off-by: Sasha Levin <sashal@kernel.org>
50 ---
51 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 9 ++-------
52 drivers/net/ethernet/intel/ice/ice_virtchnl.h | 9 +++++++++
53 2 files changed, 11 insertions(+), 7 deletions(-)
54
55 diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
56 index 6f2328a049bf1..7b550d7d96b68 100644
57 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
58 +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
59 @@ -499,7 +499,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
60 vfres->rss_lut_size = ICE_LUT_VSI_SIZE;
61 vfres->max_mtu = ice_vc_get_max_frame_size(vf);
62
63 - vfres->vsi_res[0].vsi_id = vf->lan_vsi_num;
64 + vfres->vsi_res[0].vsi_id = ICE_VF_VSI_ID;
65 vfres->vsi_res[0].vsi_type = VIRTCHNL_VSI_SRIOV;
66 vfres->vsi_res[0].num_queue_pairs = vsi->num_txq;
67 ether_addr_copy(vfres->vsi_res[0].default_mac_addr,
68 @@ -545,12 +545,7 @@ static void ice_vc_reset_vf_msg(struct ice_vf *vf)
69 */
70 bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)
71 {
72 - struct ice_pf *pf = vf->pf;
73 - struct ice_vsi *vsi;
74 -
75 - vsi = ice_find_vsi(pf, vsi_id);
76 -
77 - return (vsi && (vsi->vf == vf));
78 + return vsi_id == ICE_VF_VSI_ID;
79 }
80
81 /**
82 diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.h b/drivers/net/ethernet/intel/ice/ice_virtchnl.h
83 index 60dfbe05980aa..3a41158691532 100644
84 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.h
85 +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.h
86 @@ -19,6 +19,15 @@
87 #define ICE_MAX_MACADDR_PER_VF 18
88 #define ICE_FLEX_DESC_RXDID_MAX_NUM 64
89
90 +/* VFs only get a single VSI. For ice hardware, the VF does not need to know
91 + * its VSI index. However, the virtchnl interface requires a VSI number,
92 + * mainly due to legacy hardware.
93 + *
94 + * Since the VF doesn't need this information, report a static value to the VF
95 + * instead of leaking any information about the PF or hardware setup.
96 + */
97 +#define ICE_VF_VSI_ID 1
98 +
99 struct ice_virtchnl_ops {
100 int (*get_ver_msg)(struct ice_vf *vf, u8 *msg);
101 int (*get_vf_res_msg)(struct ice_vf *vf, u8 *msg);
102 --
103 2.43.0
104