aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/i40e/i40e_main.c
diff options
context:
space:
mode:
authorGreg Rose <gregory.v.rose@intel.com>2015-02-06 03:52:12 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2015-02-25 00:28:11 -0500
commitf4492db16df8a027cebc209c3905cbe421b53d3a (patch)
treea7d7e9cb5f066d6cc1961187f0ed610d96aa1d6a /drivers/net/ethernet/intel/i40e/i40e_main.c
parent2bc7ee8ac5439efec66fa20a8dc01c0a2b5af739 (diff)
i40e: Add NPAR BW get and set functions
We need to be able to get, set and commit permanently the NPAR partition BW configuration through configfs. These are necessary precursor functions for that feature. Also update the copyright year. Change-ID: I9d5ca160a9288145f1dd2042994028679fff55f3 Signed-off-by: Greg Rose <gregory.v.rose@intel.com> Tested-by: Jim Young <james.m.young@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_main.c')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index a8824c785b5a..e3e48c3ae24a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7254,6 +7254,128 @@ int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count)
7254} 7254}
7255 7255
7256/** 7256/**
7257 * i40e_get_npar_bw_setting - Retrieve BW settings for this PF partition
7258 * @pf: board private structure
7259 **/
7260i40e_status i40e_get_npar_bw_setting(struct i40e_pf *pf)
7261{
7262 i40e_status status;
7263 bool min_valid, max_valid;
7264 u32 max_bw, min_bw;
7265
7266 status = i40e_read_bw_from_alt_ram(&pf->hw, &max_bw, &min_bw,
7267 &min_valid, &max_valid);
7268
7269 if (!status) {
7270 if (min_valid)
7271 pf->npar_min_bw = min_bw;
7272 if (max_valid)
7273 pf->npar_max_bw = max_bw;
7274 }
7275
7276 return status;
7277}
7278
7279/**
7280 * i40e_set_npar_bw_setting - Set BW settings for this PF partition
7281 * @pf: board private structure
7282 **/
7283i40e_status i40e_set_npar_bw_setting(struct i40e_pf *pf)
7284{
7285 struct i40e_aqc_configure_partition_bw_data bw_data;
7286 i40e_status status;
7287
7288 /* Set the valid bit for this pf */
7289 bw_data.pf_valid_bits = cpu_to_le16(1 << pf->hw.pf_id);
7290 bw_data.max_bw[pf->hw.pf_id] = pf->npar_max_bw & I40E_ALT_BW_VALUE_MASK;
7291 bw_data.min_bw[pf->hw.pf_id] = pf->npar_min_bw & I40E_ALT_BW_VALUE_MASK;
7292
7293 /* Set the new bandwidths */
7294 status = i40e_aq_configure_partition_bw(&pf->hw, &bw_data, NULL);
7295
7296 return status;
7297}
7298
7299/**
7300 * i40e_commit_npar_bw_setting - Commit BW settings for this PF partition
7301 * @pf: board private structure
7302 **/
7303i40e_status i40e_commit_npar_bw_setting(struct i40e_pf *pf)
7304{
7305 /* Commit temporary BW setting to permanent NVM image */
7306 enum i40e_admin_queue_err last_aq_status;
7307 i40e_status ret;
7308 u16 nvm_word;
7309
7310 if (pf->hw.partition_id != 1) {
7311 dev_info(&pf->pdev->dev,
7312 "Commit BW only works on partition 1! This is partition %d",
7313 pf->hw.partition_id);
7314 ret = I40E_NOT_SUPPORTED;
7315 goto bw_commit_out;
7316 }
7317
7318 /* Acquire NVM for read access */
7319 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ);
7320 last_aq_status = pf->hw.aq.asq_last_status;
7321 if (ret) {
7322 dev_info(&pf->pdev->dev,
7323 "Cannot acquire NVM for read access, err %d: aq_err %d\n",
7324 ret, last_aq_status);
7325 goto bw_commit_out;
7326 }
7327
7328 /* Read word 0x10 of NVM - SW compatibility word 1 */
7329 ret = i40e_aq_read_nvm(&pf->hw,
7330 I40E_SR_NVM_CONTROL_WORD,
7331 0x10, sizeof(nvm_word), &nvm_word,
7332 false, NULL);
7333 /* Save off last admin queue command status before releasing
7334 * the NVM
7335 */
7336 last_aq_status = pf->hw.aq.asq_last_status;
7337 i40e_release_nvm(&pf->hw);
7338 if (ret) {
7339 dev_info(&pf->pdev->dev, "NVM read error, err %d aq_err %d\n",
7340 ret, last_aq_status);
7341 goto bw_commit_out;
7342 }
7343
7344 /* Wait a bit for NVM release to complete */
7345 msleep(50);
7346
7347 /* Acquire NVM for write access */
7348 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_WRITE);
7349 last_aq_status = pf->hw.aq.asq_last_status;
7350 if (ret) {
7351 dev_info(&pf->pdev->dev,
7352 "Cannot acquire NVM for write access, err %d: aq_err %d\n",
7353 ret, last_aq_status);
7354 goto bw_commit_out;
7355 }
7356 /* Write it back out unchanged to initiate update NVM,
7357 * which will force a write of the shadow (alt) RAM to
7358 * the NVM - thus storing the bandwidth values permanently.
7359 */
7360 ret = i40e_aq_update_nvm(&pf->hw,
7361 I40E_SR_NVM_CONTROL_WORD,
7362 0x10, sizeof(nvm_word),
7363 &nvm_word, true, NULL);
7364 /* Save off last admin queue command status before releasing
7365 * the NVM
7366 */
7367 last_aq_status = pf->hw.aq.asq_last_status;
7368 i40e_release_nvm(&pf->hw);
7369 if (ret)
7370 dev_info(&pf->pdev->dev,
7371 "BW settings NOT SAVED, err %d aq_err %d\n",
7372 ret, last_aq_status);
7373bw_commit_out:
7374
7375 return ret;
7376}
7377
7378/**
7257 * i40e_sw_init - Initialize general software structures (struct i40e_pf) 7379 * i40e_sw_init - Initialize general software structures (struct i40e_pf)
7258 * @pf: board private structure to initialize 7380 * @pf: board private structure to initialize
7259 * 7381 *
@@ -7306,6 +7428,13 @@ static int i40e_sw_init(struct i40e_pf *pf)
7306 if (pf->hw.func_caps.npar_enable || pf->hw.func_caps.mfp_mode_1) { 7428 if (pf->hw.func_caps.npar_enable || pf->hw.func_caps.mfp_mode_1) {
7307 pf->flags |= I40E_FLAG_MFP_ENABLED; 7429 pf->flags |= I40E_FLAG_MFP_ENABLED;
7308 dev_info(&pf->pdev->dev, "MFP mode Enabled\n"); 7430 dev_info(&pf->pdev->dev, "MFP mode Enabled\n");
7431 if (i40e_get_npar_bw_setting(pf))
7432 dev_warn(&pf->pdev->dev,
7433 "Could not get NPAR bw settings\n");
7434 else
7435 dev_info(&pf->pdev->dev,
7436 "Min BW = %8.8x, Max BW = %8.8x\n",
7437 pf->npar_min_bw, pf->npar_max_bw);
7309 } 7438 }
7310 7439
7311 /* FW/NVM is not yet fixed in this regard */ 7440 /* FW/NVM is not yet fixed in this regard */