Commit b66a972a authored by Brett Creeley's avatar Brett Creeley Committed by Tony Nguyen

ice: Refactor ice_set/get_rss into LUT and key specific functions

Currently ice_set/get_rss are used to set/get the RSS LUT and/or RSS
key. However nearly everywhere these functions are called only the LUT
or key are set/get. Also, making this change reduces how many things
ice_set/get_rss are doing. Fix this by adding ice_set/get_rss_lut and
ice_set/get_rss_key functions.

Also, consolidate all calls for setting/getting the RSS LUT and RSS Key
to use ice_set/get_rss_lut() and ice_set/get_rss_key().
Signed-off-by: default avatarBrett Creeley <brett.creeley@intel.com>
Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent e3c53928
...@@ -621,8 +621,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi); ...@@ -621,8 +621,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi);
int int
ice_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, ice_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
u32 flags); u32 flags);
int ice_set_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size); int ice_set_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size);
int ice_get_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size); int ice_get_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size);
int ice_set_rss_key(struct ice_vsi *vsi, u8 *seed);
int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed);
void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size); void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size);
int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset); int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset);
void ice_print_link_msg(struct ice_vsi *vsi, bool isup); void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
......
...@@ -3140,7 +3140,7 @@ ice_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc) ...@@ -3140,7 +3140,7 @@ ice_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc)
struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi; struct ice_vsi *vsi = np->vsi;
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
int ret = 0, i; int err, i;
u8 *lut; u8 *lut;
if (hfunc) if (hfunc)
...@@ -3159,17 +3159,20 @@ ice_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc) ...@@ -3159,17 +3159,20 @@ ice_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc)
if (!lut) if (!lut)
return -ENOMEM; return -ENOMEM;
if (ice_get_rss(vsi, key, lut, vsi->rss_table_size)) { err = ice_get_rss_key(vsi, key);
ret = -EIO; if (err)
goto out;
err = ice_get_rss_lut(vsi, lut, vsi->rss_table_size);
if (err)
goto out; goto out;
}
for (i = 0; i < vsi->rss_table_size; i++) for (i = 0; i < vsi->rss_table_size; i++)
indir[i] = (u32)(lut[i]); indir[i] = (u32)(lut[i]);
out: out:
kfree(lut); kfree(lut);
return ret; return err;
} }
/** /**
...@@ -3190,7 +3193,7 @@ ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key, ...@@ -3190,7 +3193,7 @@ ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key,
struct ice_vsi *vsi = np->vsi; struct ice_vsi *vsi = np->vsi;
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
struct device *dev; struct device *dev;
u8 *seed = NULL; int err;
dev = ice_pf_to_dev(pf); dev = ice_pf_to_dev(pf);
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
...@@ -3211,7 +3214,10 @@ ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key, ...@@ -3211,7 +3214,10 @@ ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key,
return -ENOMEM; return -ENOMEM;
} }
memcpy(vsi->rss_hkey_user, key, ICE_VSIQF_HKEY_ARRAY_SIZE); memcpy(vsi->rss_hkey_user, key, ICE_VSIQF_HKEY_ARRAY_SIZE);
seed = vsi->rss_hkey_user;
err = ice_set_rss_key(vsi, vsi->rss_hkey_user);
if (err)
return err;
} }
if (!vsi->rss_lut_user) { if (!vsi->rss_lut_user) {
...@@ -3232,8 +3238,9 @@ ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key, ...@@ -3232,8 +3238,9 @@ ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key,
vsi->rss_size); vsi->rss_size);
} }
if (ice_set_rss(vsi, seed, vsi->rss_lut_user, vsi->rss_table_size)) err = ice_set_rss_lut(vsi, vsi->rss_lut_user, vsi->rss_table_size);
return -EIO; if (err)
return err;
return 0; return 0;
} }
...@@ -3328,12 +3335,10 @@ static int ice_get_valid_rss_size(struct ice_hw *hw, int new_size) ...@@ -3328,12 +3335,10 @@ static int ice_get_valid_rss_size(struct ice_hw *hw, int new_size)
*/ */
static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size) static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
{ {
struct ice_aq_get_set_rss_lut_params set_params = {};
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
enum ice_status status;
struct device *dev; struct device *dev;
struct ice_hw *hw; struct ice_hw *hw;
int err = 0; int err;
u8 *lut; u8 *lut;
dev = ice_pf_to_dev(pf); dev = ice_pf_to_dev(pf);
...@@ -3354,18 +3359,10 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size) ...@@ -3354,18 +3359,10 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
/* create/set RSS LUT */ /* create/set RSS LUT */
ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size); ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
set_params.vsi_handle = vsi->idx; err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
set_params.lut_size = vsi->rss_table_size; if (err)
set_params.lut_type = vsi->rss_lut_type; dev_err(dev, "Cannot set RSS lut, err %d aq_err %s\n", err,
set_params.lut = lut;
set_params.global_lut_id = 0;
status = ice_aq_set_rss_lut(hw, &set_params);
if (status) {
dev_err(dev, "Cannot set RSS lut, err %s aq_err %s\n",
ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status)); ice_aq_str(hw->adminq.sq_last_status));
err = -EIO;
}
kfree(lut); kfree(lut);
return err; return err;
......
...@@ -1326,7 +1326,7 @@ int ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena) ...@@ -1326,7 +1326,7 @@ int ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena)
vsi->rss_size); vsi->rss_size);
} }
err = ice_set_rss(vsi, NULL, lut, vsi->rss_table_size); err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
kfree(lut); kfree(lut);
return err; return err;
} }
...@@ -1337,13 +1337,10 @@ int ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena) ...@@ -1337,13 +1337,10 @@ int ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena)
*/ */
static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi) static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)
{ {
struct ice_aq_get_set_rss_lut_params set_params = {};
struct ice_aqc_get_set_rss_keys *key;
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
enum ice_status status;
struct device *dev; struct device *dev;
int err = 0; u8 *lut, *key;
u8 *lut; int err;
dev = ice_pf_to_dev(pf); dev = ice_pf_to_dev(pf);
vsi->rss_size = min_t(u16, vsi->rss_size, vsi->num_rxq); vsi->rss_size = min_t(u16, vsi->rss_size, vsi->num_rxq);
...@@ -1357,41 +1354,26 @@ static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi) ...@@ -1357,41 +1354,26 @@ static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)
else else
ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size); ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
set_params.vsi_handle = vsi->idx; err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
set_params.lut_size = vsi->rss_table_size; if (err) {
set_params.lut_type = vsi->rss_lut_type; dev_err(dev, "set_rss_lut failed, error %d\n", err);
set_params.lut = lut;
set_params.global_lut_id = 0;
status = ice_aq_set_rss_lut(&pf->hw, &set_params);
if (status) {
dev_err(dev, "set_rss_lut failed, error %s\n",
ice_stat_str(status));
err = -EIO;
goto ice_vsi_cfg_rss_exit; goto ice_vsi_cfg_rss_exit;
} }
key = kzalloc(sizeof(*key), GFP_KERNEL); key = kzalloc(ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE, GFP_KERNEL);
if (!key) { if (!key) {
err = -ENOMEM; err = -ENOMEM;
goto ice_vsi_cfg_rss_exit; goto ice_vsi_cfg_rss_exit;
} }
if (vsi->rss_hkey_user) if (vsi->rss_hkey_user)
memcpy(key, memcpy(key, vsi->rss_hkey_user, ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE);
(struct ice_aqc_get_set_rss_keys *)vsi->rss_hkey_user,
ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE);
else else
netdev_rss_key_fill((void *)key, netdev_rss_key_fill((void *)key, ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE);
ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE);
status = ice_aq_set_rss_key(&pf->hw, vsi->idx, key);
if (status) { err = ice_set_rss_key(vsi, key);
dev_err(dev, "set_rss_key failed, error %s\n", if (err)
ice_stat_str(status)); dev_err(dev, "set_rss_key failed, error %d\n", err);
err = -EIO;
}
kfree(key); kfree(key);
ice_vsi_cfg_rss_exit: ice_vsi_cfg_rss_exit:
......
...@@ -6317,100 +6317,119 @@ const char *ice_stat_str(enum ice_status stat_err) ...@@ -6317,100 +6317,119 @@ const char *ice_stat_str(enum ice_status stat_err)
} }
/** /**
* ice_set_rss - Set RSS keys and lut * ice_set_rss_lut - Set RSS LUT
* @vsi: Pointer to VSI structure * @vsi: Pointer to VSI structure
* @seed: RSS hash seed
* @lut: Lookup table * @lut: Lookup table
* @lut_size: Lookup table size * @lut_size: Lookup table size
* *
* Returns 0 on success, negative on failure * Returns 0 on success, negative on failure
*/ */
int ice_set_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size) int ice_set_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size)
{ {
struct ice_pf *pf = vsi->back; struct ice_aq_get_set_rss_lut_params params = {};
struct ice_hw *hw = &pf->hw; struct ice_hw *hw = &vsi->back->hw;
enum ice_status status; enum ice_status status;
struct device *dev;
dev = ice_pf_to_dev(pf); if (!lut)
if (seed) { return -EINVAL;
struct ice_aqc_get_set_rss_keys *buf =
(struct ice_aqc_get_set_rss_keys *)seed;
status = ice_aq_set_rss_key(hw, vsi->idx, buf); params.vsi_handle = vsi->idx;
params.lut_size = lut_size;
params.lut_type = vsi->rss_lut_type;
params.lut = lut;
status = ice_aq_set_rss_lut(hw, &params);
if (status) { if (status) {
dev_err(dev, "Cannot set RSS key, err %s aq_err %s\n", dev_err(ice_pf_to_dev(vsi->back), "Cannot set RSS lut, err %s aq_err %s\n",
ice_stat_str(status), ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status)); ice_aq_str(hw->adminq.sq_last_status));
return -EIO; return -EIO;
} }
}
if (lut) { return 0;
struct ice_aq_get_set_rss_lut_params set_params = { }
.vsi_handle = vsi->idx, .lut_size = lut_size,
.lut_type = vsi->rss_lut_type, .lut = lut,
.global_lut_id = 0
};
status = ice_aq_set_rss_lut(hw, &set_params); /**
* ice_set_rss_key - Set RSS key
* @vsi: Pointer to the VSI structure
* @seed: RSS hash seed
*
* Returns 0 on success, negative on failure
*/
int ice_set_rss_key(struct ice_vsi *vsi, u8 *seed)
{
struct ice_hw *hw = &vsi->back->hw;
enum ice_status status;
if (!seed)
return -EINVAL;
status = ice_aq_set_rss_key(hw, vsi->idx, (struct ice_aqc_get_set_rss_keys *)seed);
if (status) { if (status) {
dev_err(dev, "Cannot set RSS lut, err %s aq_err %s\n", dev_err(ice_pf_to_dev(vsi->back), "Cannot set RSS key, err %s aq_err %s\n",
ice_stat_str(status), ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status)); ice_aq_str(hw->adminq.sq_last_status));
return -EIO; return -EIO;
} }
}
return 0; return 0;
} }
/** /**
* ice_get_rss - Get RSS keys and lut * ice_get_rss_lut - Get RSS LUT
* @vsi: Pointer to VSI structure * @vsi: Pointer to VSI structure
* @seed: Buffer to store the keys
* @lut: Buffer to store the lookup table entries * @lut: Buffer to store the lookup table entries
* @lut_size: Size of buffer to store the lookup table entries * @lut_size: Size of buffer to store the lookup table entries
* *
* Returns 0 on success, negative on failure * Returns 0 on success, negative on failure
*/ */
int ice_get_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size) int ice_get_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size)
{ {
struct ice_pf *pf = vsi->back; struct ice_aq_get_set_rss_lut_params params = {};
struct ice_hw *hw = &pf->hw; struct ice_hw *hw = &vsi->back->hw;
enum ice_status status; enum ice_status status;
struct device *dev;
dev = ice_pf_to_dev(pf); if (!lut)
if (seed) { return -EINVAL;
struct ice_aqc_get_set_rss_keys *buf =
(struct ice_aqc_get_set_rss_keys *)seed;
status = ice_aq_get_rss_key(hw, vsi->idx, buf); params.vsi_handle = vsi->idx;
params.lut_size = lut_size;
params.lut_type = vsi->rss_lut_type;
params.lut = lut;
status = ice_aq_get_rss_lut(hw, &params);
if (status) { if (status) {
dev_err(dev, "Cannot get RSS key, err %s aq_err %s\n", dev_err(ice_pf_to_dev(vsi->back), "Cannot get RSS lut, err %s aq_err %s\n",
ice_stat_str(status), ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status)); ice_aq_str(hw->adminq.sq_last_status));
return -EIO; return -EIO;
} }
}
if (lut) { return 0;
struct ice_aq_get_set_rss_lut_params get_params = { }
.vsi_handle = vsi->idx, .lut_size = lut_size,
.lut_type = vsi->rss_lut_type, .lut = lut,
.global_lut_id = 0
};
status = ice_aq_get_rss_lut(hw, &get_params); /**
* ice_get_rss_key - Get RSS key
* @vsi: Pointer to VSI structure
* @seed: Buffer to store the key in
*
* Returns 0 on success, negative on failure
*/
int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed)
{
struct ice_hw *hw = &vsi->back->hw;
enum ice_status status;
if (!seed)
return -EINVAL;
status = ice_aq_get_rss_key(hw, vsi->idx, (struct ice_aqc_get_set_rss_keys *)seed);
if (status) { if (status) {
dev_err(dev, "Cannot get RSS lut, err %s aq_err %s\n", dev_err(ice_pf_to_dev(vsi->back), "Cannot get RSS key, err %s aq_err %s\n",
ice_stat_str(status), ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status)); ice_aq_str(hw->adminq.sq_last_status));
return -EIO; return -EIO;
} }
}
return 0; return 0;
} }
......
...@@ -2233,7 +2233,7 @@ static int ice_vc_config_rss_key(struct ice_vf *vf, u8 *msg) ...@@ -2233,7 +2233,7 @@ static int ice_vc_config_rss_key(struct ice_vf *vf, u8 *msg)
goto error_param; goto error_param;
} }
if (ice_set_rss(vsi, vrk->key, NULL, 0)) if (ice_set_rss_key(vsi, vrk->key))
v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR; v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR;
error_param: error_param:
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_KEY, v_ret, return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_KEY, v_ret,
...@@ -2280,7 +2280,7 @@ static int ice_vc_config_rss_lut(struct ice_vf *vf, u8 *msg) ...@@ -2280,7 +2280,7 @@ static int ice_vc_config_rss_lut(struct ice_vf *vf, u8 *msg)
goto error_param; goto error_param;
} }
if (ice_set_rss(vsi, NULL, vrl->lut, ICE_VSIQF_HLUT_ARRAY_SIZE)) if (ice_set_rss_lut(vsi, vrl->lut, ICE_VSIQF_HLUT_ARRAY_SIZE))
v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR; v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR;
error_param: error_param:
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_LUT, v_ret, return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_LUT, v_ret,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment