Commit f66756e0 authored by Grzegorz Nitka's avatar Grzegorz Nitka Committed by Tony Nguyen

ice: introduce new type of VSI for switchdev

New type of VSI has to be defined for switchdev control plane
VSI. Number of allocated Tx and Rx queue has to be equal to
amount of VFs, because each port representor should have one
Tx and Rx queue.

Also to not increase number of used irqs too much, control plane
VSI uses only one q_vector and handle all queues in one irq.
To allow handling all queues in one irq , new function to clean
msix for eswitch was introduced. This function will schedule napi
for each representor instead of scheduling it only for one like in
normal clean irq function.

Only one additional msix has to be requested. Always try to request
it in ice_ena_msix_range function.
Signed-off-by: default avatarGrzegorz Nitka <grzegorz.nitka@intel.com>
Tested-by: default avatarSandeep Penigalapati <sandeep.penigalapati@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 1a1c40df
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
#define ICE_FDIR_MSIX 2 #define ICE_FDIR_MSIX 2
#define ICE_RDMA_NUM_AEQ_MSIX 4 #define ICE_RDMA_NUM_AEQ_MSIX 4
#define ICE_MIN_RDMA_MSIX 2 #define ICE_MIN_RDMA_MSIX 2
#define ICE_ESWITCH_MSIX 1
#define ICE_NO_VSI 0xffff #define ICE_NO_VSI 0xffff
#define ICE_VSI_MAP_CONTIG 0 #define ICE_VSI_MAP_CONTIG 0
#define ICE_VSI_MAP_SCATTER 1 #define ICE_VSI_MAP_SCATTER 1
......
...@@ -217,6 +217,30 @@ static u16 ice_calc_q_handle(struct ice_vsi *vsi, struct ice_ring *ring, u8 tc) ...@@ -217,6 +217,30 @@ static u16 ice_calc_q_handle(struct ice_vsi *vsi, struct ice_ring *ring, u8 tc)
return ring->q_index - vsi->tc_cfg.tc_info[tc].qoffset; return ring->q_index - vsi->tc_cfg.tc_info[tc].qoffset;
} }
/**
* ice_eswitch_calc_q_handle
* @ring: pointer to ring which unique index is needed
*
* To correctly work with many netdevs ring->q_index of Tx rings on switchdev
* VSI can repeat. Hardware ring setup requires unique q_index. Calculate it
* here by finding index in vsi->tx_rings of this ring.
*
* Return ICE_INVAL_Q_INDEX when index wasn't found. Should never happen,
* because VSI is get from ring->vsi, so it has to be present in this VSI.
*/
static u16 ice_eswitch_calc_q_handle(struct ice_ring *ring)
{
struct ice_vsi *vsi = ring->vsi;
int i;
ice_for_each_txq(vsi, i) {
if (vsi->tx_rings[i] == ring)
return i;
}
return ICE_INVAL_Q_INDEX;
}
/** /**
* ice_cfg_xps_tx_ring - Configure XPS for a Tx ring * ice_cfg_xps_tx_ring - Configure XPS for a Tx ring
* @ring: The Tx ring to configure * @ring: The Tx ring to configure
...@@ -280,6 +304,9 @@ ice_setup_tx_ctx(struct ice_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf_q) ...@@ -280,6 +304,9 @@ ice_setup_tx_ctx(struct ice_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf_q)
tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf_id; tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf_id;
tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF; tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF;
break; break;
case ICE_VSI_SWITCHDEV_CTRL:
tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ;
break;
default: default:
return; return;
} }
...@@ -746,7 +773,14 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, ...@@ -746,7 +773,14 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,
/* Add unique software queue handle of the Tx queue per /* Add unique software queue handle of the Tx queue per
* TC into the VSI Tx ring * TC into the VSI Tx ring
*/ */
ring->q_handle = ice_calc_q_handle(vsi, ring, tc); if (vsi->type == ICE_VSI_SWITCHDEV_CTRL) {
ring->q_handle = ice_eswitch_calc_q_handle(ring);
if (ring->q_handle == ICE_INVAL_Q_INDEX)
return -ENODEV;
} else {
ring->q_handle = ice_calc_q_handle(vsi, ring, tc);
}
status = ice_ena_vsi_txq(vsi->port_info, vsi->idx, tc, ring->q_handle, status = ice_ena_vsi_txq(vsi->port_info, vsi->idx, tc, ring->q_handle,
1, qg_buf, buf_len, NULL); 1, qg_buf, buf_len, NULL);
......
...@@ -261,7 +261,7 @@ static void ice_eswitch_release_env(struct ice_pf *pf) ...@@ -261,7 +261,7 @@ static void ice_eswitch_release_env(struct ice_pf *pf)
static struct ice_vsi * static struct ice_vsi *
ice_eswitch_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi) ice_eswitch_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)
{ {
return NULL; return ice_vsi_setup(pf, pi, ICE_VSI_SWITCHDEV_CTRL, ICE_INVAL_VFID);
} }
/** /**
......
...@@ -24,6 +24,8 @@ const char *ice_vsi_type_str(enum ice_vsi_type vsi_type) ...@@ -24,6 +24,8 @@ const char *ice_vsi_type_str(enum ice_vsi_type vsi_type)
return "ICE_VSI_CTRL"; return "ICE_VSI_CTRL";
case ICE_VSI_LB: case ICE_VSI_LB:
return "ICE_VSI_LB"; return "ICE_VSI_LB";
case ICE_VSI_SWITCHDEV_CTRL:
return "ICE_VSI_SWITCHDEV_CTRL";
default: default:
return "unknown"; return "unknown";
} }
...@@ -132,6 +134,7 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi) ...@@ -132,6 +134,7 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi)
{ {
switch (vsi->type) { switch (vsi->type) {
case ICE_VSI_PF: case ICE_VSI_PF:
case ICE_VSI_SWITCHDEV_CTRL:
case ICE_VSI_CTRL: case ICE_VSI_CTRL:
case ICE_VSI_LB: case ICE_VSI_LB:
/* a user could change the values of num_[tr]x_desc using /* a user could change the values of num_[tr]x_desc using
...@@ -200,6 +203,14 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) ...@@ -200,6 +203,14 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
max_t(int, vsi->alloc_rxq, max_t(int, vsi->alloc_rxq,
vsi->alloc_txq)); vsi->alloc_txq));
break; break;
case ICE_VSI_SWITCHDEV_CTRL:
/* The number of queues for ctrl VSI is equal to number of VFs.
* Each ring is associated to the corresponding VF_PR netdev.
*/
vsi->alloc_txq = pf->num_alloc_vfs;
vsi->alloc_rxq = pf->num_alloc_vfs;
vsi->num_q_vectors = 1;
break;
case ICE_VSI_VF: case ICE_VSI_VF:
vf = &pf->vf[vsi->vf_id]; vf = &pf->vf[vsi->vf_id];
if (vf->num_req_qs) if (vf->num_req_qs)
...@@ -408,6 +419,21 @@ static irqreturn_t ice_msix_clean_rings(int __always_unused irq, void *data) ...@@ -408,6 +419,21 @@ static irqreturn_t ice_msix_clean_rings(int __always_unused irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static irqreturn_t ice_eswitch_msix_clean_rings(int __always_unused irq, void *data)
{
struct ice_q_vector *q_vector = (struct ice_q_vector *)data;
struct ice_pf *pf = q_vector->vsi->back;
int i;
if (!q_vector->tx.ring && !q_vector->rx.ring)
return IRQ_HANDLED;
ice_for_each_vf(pf, i)
napi_schedule(&pf->vf[i].repr->q_vector->napi);
return IRQ_HANDLED;
}
/** /**
* ice_vsi_alloc - Allocates the next available struct VSI in the PF * ice_vsi_alloc - Allocates the next available struct VSI in the PF
* @pf: board private structure * @pf: board private structure
...@@ -448,6 +474,13 @@ ice_vsi_alloc(struct ice_pf *pf, enum ice_vsi_type vsi_type, u16 vf_id) ...@@ -448,6 +474,13 @@ ice_vsi_alloc(struct ice_pf *pf, enum ice_vsi_type vsi_type, u16 vf_id)
ice_vsi_set_num_qs(vsi, ICE_INVAL_VFID); ice_vsi_set_num_qs(vsi, ICE_INVAL_VFID);
switch (vsi->type) { switch (vsi->type) {
case ICE_VSI_SWITCHDEV_CTRL:
if (ice_vsi_alloc_arrays(vsi))
goto err_rings;
/* Setup eswitch MSIX irq handler for VSI */
vsi->irq_handler = ice_eswitch_msix_clean_rings;
break;
case ICE_VSI_PF: case ICE_VSI_PF:
if (ice_vsi_alloc_arrays(vsi)) if (ice_vsi_alloc_arrays(vsi))
goto err_rings; goto err_rings;
...@@ -707,6 +740,12 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi) ...@@ -707,6 +740,12 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi)
BIT(cap->rss_table_entry_width)); BIT(cap->rss_table_entry_width));
vsi->rss_lut_type = ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF; vsi->rss_lut_type = ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF;
break; break;
case ICE_VSI_SWITCHDEV_CTRL:
vsi->rss_table_size = ICE_VSIQF_HLUT_ARRAY_SIZE;
vsi->rss_size = min_t(u16, num_online_cpus(),
BIT(cap->rss_table_entry_width));
vsi->rss_lut_type = ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_VSI;
break;
case ICE_VSI_VF: case ICE_VSI_VF:
/* VF VSI will get a small RSS table. /* VF VSI will get a small RSS table.
* For VSI_LUT, LUT size should be set to 64 bytes. * For VSI_LUT, LUT size should be set to 64 bytes.
...@@ -980,6 +1019,9 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi) ...@@ -980,6 +1019,9 @@ static int ice_vsi_init(struct ice_vsi *vsi, bool init_vsi)
case ICE_VSI_PF: case ICE_VSI_PF:
ctxt->flags = ICE_AQ_VSI_TYPE_PF; ctxt->flags = ICE_AQ_VSI_TYPE_PF;
break; break;
case ICE_VSI_SWITCHDEV_CTRL:
ctxt->flags = ICE_AQ_VSI_TYPE_VMDQ2;
break;
case ICE_VSI_VF: case ICE_VSI_VF:
ctxt->flags = ICE_AQ_VSI_TYPE_VF; ctxt->flags = ICE_AQ_VSI_TYPE_VF;
/* VF number here is the absolute VF number (0-255) */ /* VF number here is the absolute VF number (0-255) */
...@@ -2297,6 +2339,7 @@ static void ice_set_agg_vsi(struct ice_vsi *vsi) ...@@ -2297,6 +2339,7 @@ static void ice_set_agg_vsi(struct ice_vsi *vsi)
case ICE_VSI_CTRL: case ICE_VSI_CTRL:
case ICE_VSI_LB: case ICE_VSI_LB:
case ICE_VSI_PF: case ICE_VSI_PF:
case ICE_VSI_SWITCHDEV_CTRL:
max_agg_nodes = ICE_MAX_PF_AGG_NODES; max_agg_nodes = ICE_MAX_PF_AGG_NODES;
agg_node_id_start = ICE_PF_AGG_NODE_ID_START; agg_node_id_start = ICE_PF_AGG_NODE_ID_START;
agg_node_iter = &pf->pf_agg_node[0]; agg_node_iter = &pf->pf_agg_node[0];
...@@ -2448,6 +2491,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi, ...@@ -2448,6 +2491,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
switch (vsi->type) { switch (vsi->type) {
case ICE_VSI_CTRL: case ICE_VSI_CTRL:
case ICE_VSI_SWITCHDEV_CTRL:
case ICE_VSI_PF: case ICE_VSI_PF:
ret = ice_vsi_alloc_q_vectors(vsi); ret = ice_vsi_alloc_q_vectors(vsi);
if (ret) if (ret)
...@@ -2757,7 +2801,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) ...@@ -2757,7 +2801,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked)
} else { } else {
ice_vsi_close(vsi); ice_vsi_close(vsi);
} }
} else if (vsi->type == ICE_VSI_CTRL) { } else if (vsi->type == ICE_VSI_CTRL ||
vsi->type == ICE_VSI_SWITCHDEV_CTRL) {
ice_vsi_close(vsi); ice_vsi_close(vsi);
} }
} }
...@@ -3136,6 +3181,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi) ...@@ -3136,6 +3181,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
switch (vtype) { switch (vtype) {
case ICE_VSI_CTRL: case ICE_VSI_CTRL:
case ICE_VSI_SWITCHDEV_CTRL:
case ICE_VSI_PF: case ICE_VSI_PF:
ret = ice_vsi_alloc_q_vectors(vsi); ret = ice_vsi_alloc_q_vectors(vsi);
if (ret) if (ret)
......
...@@ -3541,6 +3541,13 @@ static int ice_ena_msix_range(struct ice_pf *pf) ...@@ -3541,6 +3541,13 @@ static int ice_ena_msix_range(struct ice_pf *pf)
v_left -= needed; v_left -= needed;
} }
/* reserve for switchdev */
needed = ICE_ESWITCH_MSIX;
if (v_left < needed)
goto no_hw_vecs_left_err;
v_budget += needed;
v_left -= needed;
/* total used for non-traffic vectors */ /* total used for non-traffic vectors */
v_other = v_budget; v_other = v_budget;
......
...@@ -139,6 +139,7 @@ enum ice_vsi_type { ...@@ -139,6 +139,7 @@ enum ice_vsi_type {
ICE_VSI_VF = 1, ICE_VSI_VF = 1,
ICE_VSI_CTRL = 3, /* equates to ICE_VSI_PF with 1 queue pair */ ICE_VSI_CTRL = 3, /* equates to ICE_VSI_PF with 1 queue pair */
ICE_VSI_LB = 6, ICE_VSI_LB = 6,
ICE_VSI_SWITCHDEV_CTRL = 7,
}; };
struct ice_link_status { struct ice_link_status {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment