@@ -7253,6 +7253,128 @@ int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count)
72537253 return pf -> rss_size ;
72547254}
72557255
7256+ /**
7257+ * i40e_get_npar_bw_setting - Retrieve BW settings for this PF partition
7258+ * @pf: board private structure
7259+ **/
7260+ i40e_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+ **/
7283+ i40e_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+ **/
7303+ i40e_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 );
7373+ bw_commit_out :
7374+
7375+ return ret ;
7376+ }
7377+
72567378/**
72577379 * i40e_sw_init - Initialize general software structures (struct i40e_pf)
72587380 * @pf: board private structure to initialize
@@ -7306,6 +7428,13 @@ static int i40e_sw_init(struct i40e_pf *pf)
73067428 if (pf -> hw .func_caps .npar_enable || pf -> hw .func_caps .mfp_mode_1 ) {
73077429 pf -> flags |= I40E_FLAG_MFP_ENABLED ;
73087430 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 );
73097438 }
73107439
73117440 /* FW/NVM is not yet fixed in this regard */
0 commit comments