aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_common.c
diff options
context:
space:
mode:
authorAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>2019-02-28 18:25:48 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2019-05-02 03:57:44 -0400
commitbb87ee0efb7396d79ba5f37ff8e8721d01c87d4a (patch)
treef4cbd3f588e0409d949f865d44d5cc990bf535d1 /drivers/net/ethernet/intel/ice/ice_common.c
parentf76c4b571feea8eb03184d8ba0ee45f98fff47ff (diff)
ice: Create framework for VSI queue context
This patch introduces a framework to store queue specific information in VSI queue contexts. Currently VSI queue context (represented by struct ice_q_ctx) only has q_handle as a member. In future patches, this structure will be updated to hold queue specific information. 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_common.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_common.c62
1 files changed, 57 insertions, 5 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 2937c6be1aee..dce07882f7e1 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -2791,10 +2791,35 @@ ice_set_ctx(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info)
2791} 2791}
2792 2792
2793/** 2793/**
2794 * ice_get_lan_q_ctx - get the LAN queue context for the given VSI and TC
2795 * @hw: pointer to the HW struct
2796 * @vsi_handle: software VSI handle
2797 * @tc: TC number
2798 * @q_handle: software queue handle
2799 */
2800static struct ice_q_ctx *
2801ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle)
2802{
2803 struct ice_vsi_ctx *vsi;
2804 struct ice_q_ctx *q_ctx;
2805
2806 vsi = ice_get_vsi_ctx(hw, vsi_handle);
2807 if (!vsi)
2808 return NULL;
2809 if (q_handle >= vsi->num_lan_q_entries[tc])
2810 return NULL;
2811 if (!vsi->lan_q_ctx[tc])
2812 return NULL;
2813 q_ctx = vsi->lan_q_ctx[tc];
2814 return &q_ctx[q_handle];
2815}
2816
2817/**
2794 * ice_ena_vsi_txq 2818 * ice_ena_vsi_txq
2795 * @pi: port information structure 2819 * @pi: port information structure
2796 * @vsi_handle: software VSI handle 2820 * @vsi_handle: software VSI handle
2797 * @tc: TC number 2821 * @tc: TC number
2822 * @q_handle: software queue handle
2798 * @num_qgrps: Number of added queue groups 2823 * @num_qgrps: Number of added queue groups
2799 * @buf: list of queue groups to be added 2824 * @buf: list of queue groups to be added
2800 * @buf_size: size of buffer for indirect command 2825 * @buf_size: size of buffer for indirect command
@@ -2803,12 +2828,13 @@ ice_set_ctx(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info)
2803 * This function adds one LAN queue 2828 * This function adds one LAN queue
2804 */ 2829 */
2805enum ice_status 2830enum ice_status
2806ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps, 2831ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
2807 struct ice_aqc_add_tx_qgrp *buf, u16 buf_size, 2832 u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
2808 struct ice_sq_cd *cd) 2833 struct ice_sq_cd *cd)
2809{ 2834{
2810 struct ice_aqc_txsched_elem_data node = { 0 }; 2835 struct ice_aqc_txsched_elem_data node = { 0 };
2811 struct ice_sched_node *parent; 2836 struct ice_sched_node *parent;
2837 struct ice_q_ctx *q_ctx;
2812 enum ice_status status; 2838 enum ice_status status;
2813 struct ice_hw *hw; 2839 struct ice_hw *hw;
2814 2840
@@ -2825,6 +2851,14 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
2825 2851
2826 mutex_lock(&pi->sched_lock); 2852 mutex_lock(&pi->sched_lock);
2827 2853
2854 q_ctx = ice_get_lan_q_ctx(hw, vsi_handle, tc, q_handle);
2855 if (!q_ctx) {
2856 ice_debug(hw, ICE_DBG_SCHED, "Enaq: invalid queue handle %d\n",
2857 q_handle);
2858 status = ICE_ERR_PARAM;
2859 goto ena_txq_exit;
2860 }
2861
2828 /* find a parent node */ 2862 /* find a parent node */
2829 parent = ice_sched_get_free_qparent(pi, vsi_handle, tc, 2863 parent = ice_sched_get_free_qparent(pi, vsi_handle, tc,
2830 ICE_SCHED_NODE_OWNER_LAN); 2864 ICE_SCHED_NODE_OWNER_LAN);
@@ -2851,7 +2885,7 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
2851 /* add the LAN queue */ 2885 /* add the LAN queue */
2852 status = ice_aq_add_lan_txq(hw, num_qgrps, buf, buf_size, cd); 2886 status = ice_aq_add_lan_txq(hw, num_qgrps, buf, buf_size, cd);
2853 if (status) { 2887 if (status) {
2854 ice_debug(hw, ICE_DBG_SCHED, "enable Q %d failed %d\n", 2888 ice_debug(hw, ICE_DBG_SCHED, "enable queue %d failed %d\n",
2855 le16_to_cpu(buf->txqs[0].txq_id), 2889 le16_to_cpu(buf->txqs[0].txq_id),
2856 hw->adminq.sq_last_status); 2890 hw->adminq.sq_last_status);
2857 goto ena_txq_exit; 2891 goto ena_txq_exit;
@@ -2859,6 +2893,7 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
2859 2893
2860 node.node_teid = buf->txqs[0].q_teid; 2894 node.node_teid = buf->txqs[0].q_teid;
2861 node.data.elem_type = ICE_AQC_ELEM_TYPE_LEAF; 2895 node.data.elem_type = ICE_AQC_ELEM_TYPE_LEAF;
2896 q_ctx->q_handle = q_handle;
2862 2897
2863 /* add a leaf node into schduler tree queue layer */ 2898 /* add a leaf node into schduler tree queue layer */
2864 status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node); 2899 status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node);
@@ -2871,7 +2906,10 @@ ena_txq_exit:
2871/** 2906/**
2872 * ice_dis_vsi_txq 2907 * ice_dis_vsi_txq
2873 * @pi: port information structure 2908 * @pi: port information structure
2909 * @vsi_handle: software VSI handle
2910 * @tc: TC number
2874 * @num_queues: number of queues 2911 * @num_queues: number of queues
2912 * @q_handles: pointer to software queue handle array
2875 * @q_ids: pointer to the q_id array 2913 * @q_ids: pointer to the q_id array
2876 * @q_teids: pointer to queue node teids 2914 * @q_teids: pointer to queue node teids
2877 * @rst_src: if called due to reset, specifies the reset source 2915 * @rst_src: if called due to reset, specifies the reset source
@@ -2881,12 +2919,14 @@ ena_txq_exit:
2881 * This function removes queues and their corresponding nodes in SW DB 2919 * This function removes queues and their corresponding nodes in SW DB
2882 */ 2920 */
2883enum ice_status 2921enum ice_status
2884ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids, 2922ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
2885 u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num, 2923 u16 *q_handles, u16 *q_ids, u32 *q_teids,
2924 enum ice_disq_rst_src rst_src, u16 vmvf_num,
2886 struct ice_sq_cd *cd) 2925 struct ice_sq_cd *cd)
2887{ 2926{
2888 enum ice_status status = ICE_ERR_DOES_NOT_EXIST; 2927 enum ice_status status = ICE_ERR_DOES_NOT_EXIST;
2889 struct ice_aqc_dis_txq_item qg_list; 2928 struct ice_aqc_dis_txq_item qg_list;
2929 struct ice_q_ctx *q_ctx;
2890 u16 i; 2930 u16 i;
2891 2931
2892 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) 2932 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
@@ -2909,6 +2949,17 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
2909 node = ice_sched_find_node_by_teid(pi->root, q_teids[i]); 2949 node = ice_sched_find_node_by_teid(pi->root, q_teids[i]);
2910 if (!node) 2950 if (!node)
2911 continue; 2951 continue;
2952 q_ctx = ice_get_lan_q_ctx(pi->hw, vsi_handle, tc, q_handles[i]);
2953 if (!q_ctx) {
2954 ice_debug(pi->hw, ICE_DBG_SCHED, "invalid queue handle%d\n",
2955 q_handles[i]);
2956 continue;
2957 }
2958 if (q_ctx->q_handle != q_handles[i]) {
2959 ice_debug(pi->hw, ICE_DBG_SCHED, "Err:handles %d %d\n",
2960 q_ctx->q_handle, q_handles[i]);
2961 continue;
2962 }
2912 qg_list.parent_teid = node->info.parent_teid; 2963 qg_list.parent_teid = node->info.parent_teid;
2913 qg_list.num_qs = 1; 2964 qg_list.num_qs = 1;
2914 qg_list.q_id[0] = cpu_to_le16(q_ids[i]); 2965 qg_list.q_id[0] = cpu_to_le16(q_ids[i]);
@@ -2919,6 +2970,7 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
2919 if (status) 2970 if (status)
2920 break; 2971 break;
2921 ice_free_sched_node(pi, node); 2972 ice_free_sched_node(pi, node);
2973 q_ctx->q_handle = ICE_INVAL_Q_HANDLE;
2922 } 2974 }
2923 mutex_unlock(&pi->sched_lock); 2975 mutex_unlock(&pi->sched_lock);
2924 return status; 2976 return status;