| From: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com> |
| Date: Wed, 8 Jun 2022 13:52:48 +0200 |
| Subject: i40e: Refactor tc mqprio checks |
| Patch-mainline: v6.0-rc1 |
| Git-commit: 2313e69c84c024a85d017a60ae925085de47530a |
| References: jsc#SLE-18378 |
| |
| Refactor bitwise checks for whether TC MQPRIO is enabled |
| into one single method for improved readability. |
| |
| Signed-off-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com> |
| Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com> |
| Tested-by: Bharathi Sreenivas <bharathi.sreenivas@intel.com> |
| Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> |
| Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de> |
| |
| drivers/net/ethernet/intel/i40e/i40e.h | 14 ++++++++++++++ |
| drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 2 +- |
| drivers/net/ethernet/intel/i40e/i40e_main.c | 20 ++++++++++---------- |
| 3 files changed, 25 insertions(+), 11 deletions(-) |
| |
| |
| |
| @@ -1286,4 +1286,18 @@ int i40e_add_del_cloud_filter(struct i40 |
| int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi, |
| struct i40e_cloud_filter *filter, |
| bool add); |
| + |
| +/** |
| + * i40e_is_tc_mqprio_enabled - check if TC MQPRIO is enabled on PF |
| + * @pf: pointer to a pf. |
| + * |
| + * Check and return value of flag I40E_FLAG_TC_MQPRIO. |
| + * |
| + * Return: I40E_FLAG_TC_MQPRIO set state. |
| + **/ |
| +static inline u32 i40e_is_tc_mqprio_enabled(struct i40e_pf *pf) |
| +{ |
| + return pf->flags & I40E_FLAG_TC_MQPRIO; |
| +} |
| + |
| #endif /* _I40E_H_ */ |
| |
| |
| @@ -4921,7 +4921,7 @@ static int i40e_set_channels(struct net_ |
| /* We do not support setting channels via ethtool when TCs are |
| * configured through mqprio |
| */ |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) |
| + if (i40e_is_tc_mqprio_enabled(pf)) |
| return -EINVAL; |
| |
| /* verify they are not requesting separate vectors */ |
| |
| |
| @@ -5318,7 +5318,7 @@ static u8 i40e_pf_get_num_tc(struct i40e |
| u8 num_tc = 0; |
| struct i40e_dcbx_config *dcbcfg = &hw->local_dcbx_config; |
| |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) |
| + if (i40e_is_tc_mqprio_enabled(pf)) |
| return pf->vsi[pf->lan_vsi]->mqprio_qopt.qopt.num_tc; |
| |
| /* If neither MQPRIO nor DCB is enabled, then always use single TC */ |
| @@ -5350,7 +5350,7 @@ static u8 i40e_pf_get_num_tc(struct i40e |
| **/ |
| static u8 i40e_pf_get_tc_map(struct i40e_pf *pf) |
| { |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) |
| + if (i40e_is_tc_mqprio_enabled(pf)) |
| return i40e_mqprio_get_enabled_tc(pf); |
| |
| /* If neither MQPRIO nor DCB is enabled for this PF then just return |
| @@ -5447,7 +5447,7 @@ static int i40e_vsi_configure_bw_alloc(s |
| int i; |
| |
| /* There is no need to reset BW when mqprio mode is on. */ |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) |
| + if (i40e_is_tc_mqprio_enabled(pf)) |
| return 0; |
| if (!vsi->mqprio_qopt.qopt.hw && !(pf->flags & I40E_FLAG_DCB_ENABLED)) { |
| ret = i40e_set_bw_limit(vsi, vsi->seid, 0); |
| @@ -5519,7 +5519,7 @@ static void i40e_vsi_config_netdev_tc(st |
| vsi->tc_config.tc_info[i].qoffset); |
| } |
| |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) |
| + if (i40e_is_tc_mqprio_enabled(pf)) |
| return; |
| |
| /* Assign UP2TC map for the VSI */ |
| @@ -5680,7 +5680,7 @@ static int i40e_vsi_config_tc(struct i40 |
| ctxt.vf_num = 0; |
| ctxt.uplink_seid = vsi->uplink_seid; |
| ctxt.info = vsi->info; |
| - if (vsi->back->flags & I40E_FLAG_TC_MQPRIO) { |
| + if (i40e_is_tc_mqprio_enabled(pf)) { |
| ret = i40e_vsi_setup_queue_map_mqprio(vsi, &ctxt, enabled_tc); |
| if (ret) |
| goto out; |
| @@ -6404,7 +6404,7 @@ int i40e_create_queue_channel(struct i40 |
| pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; |
| |
| if (vsi->type == I40E_VSI_MAIN) { |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) |
| + if (i40e_is_tc_mqprio_enabled(pf)) |
| i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); |
| else |
| i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG); |
| @@ -7798,7 +7798,7 @@ static void *i40e_fwd_add(struct net_dev |
| netdev_info(netdev, "Macvlans are not supported when DCB is enabled\n"); |
| return ERR_PTR(-EINVAL); |
| } |
| - if ((pf->flags & I40E_FLAG_TC_MQPRIO)) { |
| + if (i40e_is_tc_mqprio_enabled(pf)) { |
| netdev_info(netdev, "Macvlans are not supported when HW TC offload is on\n"); |
| return ERR_PTR(-EINVAL); |
| } |
| @@ -8051,7 +8051,7 @@ config_tc: |
| /* Quiesce VSI queues */ |
| i40e_quiesce_vsi(vsi); |
| |
| - if (!hw && !(pf->flags & I40E_FLAG_TC_MQPRIO)) |
| + if (!hw && !i40e_is_tc_mqprio_enabled(pf)) |
| i40e_remove_queue_channels(vsi); |
| |
| /* Configure VSI for enabled TCs */ |
| @@ -8075,7 +8075,7 @@ config_tc: |
| "Setup channel (id:%u) utilizing num_queues %d\n", |
| vsi->seid, vsi->tc_config.tc_info[0].qcount); |
| |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) { |
| + if (i40e_is_tc_mqprio_enabled(pf)) { |
| if (vsi->mqprio_qopt.max_rate[0]) { |
| u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0]; |
| |
| @@ -10729,7 +10729,7 @@ static void i40e_rebuild(struct i40e_pf |
| * unless I40E_FLAG_TC_MQPRIO was enabled or DCB |
| * is not supported with new link speed |
| */ |
| - if (pf->flags & I40E_FLAG_TC_MQPRIO) { |
| + if (i40e_is_tc_mqprio_enabled(pf)) { |
| i40e_aq_set_dcb_parameters(hw, false, NULL); |
| } else { |
| if (I40E_IS_X710TL_DEVICE(hw->device_id) && |