aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_lib.c
diff options
context:
space:
mode:
authorAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>2019-02-28 18:24:24 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2019-04-18 11:38:47 -0400
commit7b9ffc76bf5998aad8feaa26d9d3fcb65ec7a21b (patch)
tree9935f6c7b53786d7f9ce06d804aa4a42ce541ec4 /drivers/net/ethernet/intel/ice/ice_lib.c
parent0ebd3ff13ccad2940516ba522ca8d21cea4f56f6 (diff)
ice: Add code for DCB initialization part 3/4
This patch adds a new function ice_pf_dcb_cfg (and related helpers) which applies the DCB configuration obtained from the firmware. As part of this, VSIs/netdevs are updated with traffic class information. This patch requires a bit of a refactor of existing code. 1. For a MIB change event, the associated VSI is closed and brought up again. The gap between closing and opening the VSI can cause a race condition. Fix this by grabbing the rtnl_lock prior to closing the VSI and then only free it after re-opening the VSI during a MIB change event. 2. ice_sched_query_elem is used in ice_sched.c and with this patch, in ice_dcb.c as well. However, ice_dcb.c is not built when CONFIG_DCB is unset. This results in namespace warnings (ice_sched.o: Externally defined symbols with no external references) when CONFIG_DCB is unset. To avoid this move ice_sched_query_elem from ice_sched.c to ice_common.c. Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_lib.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_lib.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index d24da511b775..f3574daa147c 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -3,6 +3,7 @@
3 3
4#include "ice.h" 4#include "ice.h"
5#include "ice_lib.h" 5#include "ice_lib.h"
6#include "ice_dcb_lib.h"
6 7
7/** 8/**
8 * ice_setup_rx_ctx - Configure a receive ring context 9 * ice_setup_rx_ctx - Configure a receive ring context
@@ -1301,7 +1302,11 @@ err_out:
1301 * through the MSI-X enabling code. On a constrained vector budget, we map Tx 1302 * through the MSI-X enabling code. On a constrained vector budget, we map Tx
1302 * and Rx rings to the vector as "efficiently" as possible. 1303 * and Rx rings to the vector as "efficiently" as possible.
1303 */ 1304 */
1305#ifdef CONFIG_DCB
1306void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)
1307#else
1304static void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi) 1308static void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)
1309#endif /* CONFIG_DCB */
1305{ 1310{
1306 int q_vectors = vsi->num_q_vectors; 1311 int q_vectors = vsi->num_q_vectors;
1307 int tx_rings_rem, rx_rings_rem; 1312 int tx_rings_rem, rx_rings_rem;
@@ -2172,6 +2177,14 @@ err_out:
2172 return -EIO; 2177 return -EIO;
2173} 2178}
2174 2179
2180static void ice_vsi_set_tc_cfg(struct ice_vsi *vsi)
2181{
2182 struct ice_dcbx_cfg *cfg = &vsi->port_info->local_dcbx_cfg;
2183
2184 vsi->tc_cfg.ena_tc = ice_dcb_get_ena_tc(cfg);
2185 vsi->tc_cfg.numtc = ice_dcb_get_num_tc(cfg);
2186}
2187
2175/** 2188/**
2176 * ice_vsi_setup - Set up a VSI by a given type 2189 * ice_vsi_setup - Set up a VSI by a given type
2177 * @pf: board private structure 2190 * @pf: board private structure
@@ -2815,3 +2828,125 @@ bool ice_is_reset_in_progress(unsigned long *state)
2815 test_bit(__ICE_CORER_REQ, state) || 2828 test_bit(__ICE_CORER_REQ, state) ||
2816 test_bit(__ICE_GLOBR_REQ, state); 2829 test_bit(__ICE_GLOBR_REQ, state);
2817} 2830}
2831
2832#ifdef CONFIG_DCB
2833/**
2834 * ice_vsi_update_q_map - update our copy of the VSI info with new queue map
2835 * @vsi: VSI being configured
2836 * @ctx: the context buffer returned from AQ VSI update command
2837 */
2838static void ice_vsi_update_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctx)
2839{
2840 vsi->info.mapping_flags = ctx->info.mapping_flags;
2841 memcpy(&vsi->info.q_mapping, &ctx->info.q_mapping,
2842 sizeof(vsi->info.q_mapping));
2843 memcpy(&vsi->info.tc_mapping, ctx->info.tc_mapping,
2844 sizeof(vsi->info.tc_mapping));
2845}
2846
2847/**
2848 * ice_vsi_cfg_netdev_tc - Setup the netdev TC configuration
2849 * @vsi: the VSI being configured
2850 * @ena_tc: TC map to be enabled
2851 */
2852static void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc)
2853{
2854 struct net_device *netdev = vsi->netdev;
2855 struct ice_pf *pf = vsi->back;
2856 struct ice_dcbx_cfg *dcbcfg;
2857 u8 netdev_tc;
2858 int i;
2859
2860 if (!netdev)
2861 return;
2862
2863 if (!ena_tc) {
2864 netdev_reset_tc(netdev);
2865 return;
2866 }
2867
2868 if (netdev_set_num_tc(netdev, vsi->tc_cfg.numtc))
2869 return;
2870
2871 dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
2872
2873 ice_for_each_traffic_class(i)
2874 if (vsi->tc_cfg.ena_tc & BIT(i))
2875 netdev_set_tc_queue(netdev,
2876 vsi->tc_cfg.tc_info[i].netdev_tc,
2877 vsi->tc_cfg.tc_info[i].qcount_tx,
2878 vsi->tc_cfg.tc_info[i].qoffset);
2879
2880 for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
2881 u8 ets_tc = dcbcfg->etscfg.prio_table[i];
2882
2883 /* Get the mapped netdev TC# for the UP */
2884 netdev_tc = vsi->tc_cfg.tc_info[ets_tc].netdev_tc;
2885 netdev_set_prio_tc_map(netdev, i, netdev_tc);
2886 }
2887}
2888
2889/**
2890 * ice_vsi_cfg_tc - Configure VSI Tx Sched for given TC map
2891 * @vsi: VSI to be configured
2892 * @ena_tc: TC bitmap
2893 *
2894 * VSI queues expected to be quiesced before calling this function
2895 */
2896int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc)
2897{
2898 u16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };
2899 struct ice_vsi_ctx *ctx;
2900 struct ice_pf *pf = vsi->back;
2901 enum ice_status status;
2902 int i, ret = 0;
2903 u8 num_tc = 0;
2904
2905 ice_for_each_traffic_class(i) {
2906 /* build bitmap of enabled TCs */
2907 if (ena_tc & BIT(i))
2908 num_tc++;
2909 /* populate max_txqs per TC */
2910 max_txqs[i] = pf->num_lan_tx;
2911 }
2912
2913 vsi->tc_cfg.ena_tc = ena_tc;
2914 vsi->tc_cfg.numtc = num_tc;
2915
2916 ctx = devm_kzalloc(&pf->pdev->dev, sizeof(*ctx), GFP_KERNEL);
2917 if (!ctx)
2918 return -ENOMEM;
2919
2920 ctx->vf_num = 0;
2921 ctx->info = vsi->info;
2922
2923 ice_vsi_setup_q_map(vsi, ctx);
2924
2925 /* must to indicate which section of VSI context are being modified */
2926 ctx->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_RXQ_MAP_VALID);
2927 status = ice_update_vsi(&pf->hw, vsi->idx, ctx, NULL);
2928 if (status) {
2929 dev_info(&pf->pdev->dev, "Failed VSI Update\n");
2930 ret = -EIO;
2931 goto out;
2932 }
2933
2934 status = ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc,
2935 max_txqs);
2936
2937 if (status) {
2938 dev_err(&pf->pdev->dev,
2939 "VSI %d failed TC config, error %d\n",
2940 vsi->vsi_num, status);
2941 ret = -EIO;
2942 goto out;
2943 }
2944 ice_vsi_update_q_map(vsi, ctx);
2945 vsi->info.valid_sections = 0;
2946
2947 ice_vsi_cfg_netdev_tc(vsi, ena_tc);
2948out:
2949 devm_kfree(&pf->pdev->dev, ctx);
2950 return ret;
2951}
2952#endif /* CONFIG_DCB */