Skip to content

Commit 5513b92

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Update Tx scheduler tree for VSI multi-Tx queue support
This patch adds the ability for a VSI to use multiple Tx queues. More specifically, the patch 1) Provides the ability to update the Tx scheduler tree in the firmware. The driver can configure the Tx scheduler tree by adding/removing multiple Tx queues per TC per VSI. 2) Allows a VSI to reconfigure its Tx queues during runtime. 3) Synchronizes the Tx scheduler update operations using locks. Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent fcea6f3 commit 5513b92

File tree

8 files changed

+1006
-3
lines changed

8 files changed

+1006
-3
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ extern const char ice_drv_ver[];
4242
#define ICE_MIN_NUM_DESC 8
4343
#define ICE_MAX_NUM_DESC 8160
4444
#define ICE_REQ_DESC_MULTIPLE 32
45+
#define ICE_DFLT_TRAFFIC_CLASS BIT(0)
4546
#define ICE_INT_NAME_STR_LEN (IFNAMSIZ + 16)
4647
#define ICE_ETHTOOL_FWVER_LEN 32
4748
#define ICE_AQ_LEN 64
@@ -261,6 +262,12 @@ static inline void ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi,
261262
wr32(hw, GLINT_DYN_CTL(vector), val);
262263
}
263264

265+
static inline void ice_vsi_set_tc_cfg(struct ice_vsi *vsi)
266+
{
267+
vsi->tc_cfg.ena_tc = ICE_DFLT_TRAFFIC_CLASS;
268+
vsi->tc_cfg.numtc = 1;
269+
}
270+
264271
void ice_set_ethtool_ops(struct net_device *netdev);
265272
int ice_up(struct ice_vsi *vsi);
266273
int ice_down(struct ice_vsi *vsi);

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,25 @@ struct ice_aqc_get_topo {
631631
__le32 addr_low;
632632
};
633633

634+
/* Update TSE (indirect 0x0403)
635+
* Get TSE (indirect 0x0404)
636+
*/
637+
struct ice_aqc_get_cfg_elem {
638+
__le16 num_elem_req; /* Used by commands */
639+
__le16 num_elem_resp; /* Used by responses */
640+
__le32 reserved;
641+
__le32 addr_high;
642+
__le32 addr_low;
643+
};
644+
645+
/* This is the buffer for:
646+
* Suspend Nodes (indirect 0x0409)
647+
* Resume Nodes (indirect 0x040A)
648+
*/
649+
struct ice_aqc_suspend_resume_elem {
650+
__le32 teid[1];
651+
};
652+
634653
/* Add TSE (indirect 0x0401)
635654
* Delete TSE (indirect 0x040F)
636655
* Move TSE (indirect 0x0408)
@@ -691,6 +710,11 @@ struct ice_aqc_txsched_topo_grp_info_hdr {
691710
__le16 reserved2;
692711
};
693712

713+
struct ice_aqc_add_elem {
714+
struct ice_aqc_txsched_topo_grp_info_hdr hdr;
715+
struct ice_aqc_txsched_elem_data generic[1];
716+
};
717+
694718
struct ice_aqc_get_topo_elem {
695719
struct ice_aqc_txsched_topo_grp_info_hdr hdr;
696720
struct ice_aqc_txsched_elem_data
@@ -1181,6 +1205,7 @@ struct ice_aq_desc {
11811205
struct ice_aqc_get_sw_cfg get_sw_conf;
11821206
struct ice_aqc_sw_rules sw_rules;
11831207
struct ice_aqc_get_topo get_topo;
1208+
struct ice_aqc_get_cfg_elem get_update_elem;
11841209
struct ice_aqc_query_txsched_res query_sched_res;
11851210
struct ice_aqc_add_move_delete_elem add_move_delete_elem;
11861211
struct ice_aqc_nvm nvm;
@@ -1258,6 +1283,9 @@ enum ice_adminq_opc {
12581283

12591284
/* transmit scheduler commands */
12601285
ice_aqc_opc_get_dflt_topo = 0x0400,
1286+
ice_aqc_opc_add_sched_elems = 0x0401,
1287+
ice_aqc_opc_suspend_sched_elems = 0x0409,
1288+
ice_aqc_opc_resume_sched_elems = 0x040A,
12611289
ice_aqc_opc_delete_sched_elems = 0x040F,
12621290
ice_aqc_opc_query_sched_res = 0x0412,
12631291

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,3 +2089,57 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
20892089
mutex_unlock(&pi->sched_lock);
20902090
return status;
20912091
}
2092+
2093+
/**
2094+
* ice_cfg_vsi_qs - configure the new/exisiting VSI queues
2095+
* @pi: port information structure
2096+
* @vsi_id: VSI Id
2097+
* @tc_bitmap: TC bitmap
2098+
* @maxqs: max queues array per TC
2099+
* @owner: lan or rdma
2100+
*
2101+
* This function adds/updates the VSI queues per TC.
2102+
*/
2103+
static enum ice_status
2104+
ice_cfg_vsi_qs(struct ice_port_info *pi, u16 vsi_id, u8 tc_bitmap,
2105+
u16 *maxqs, u8 owner)
2106+
{
2107+
enum ice_status status = 0;
2108+
u8 i;
2109+
2110+
if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
2111+
return ICE_ERR_CFG;
2112+
2113+
mutex_lock(&pi->sched_lock);
2114+
2115+
for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
2116+
/* configuration is possible only if TC node is present */
2117+
if (!ice_sched_get_tc_node(pi, i))
2118+
continue;
2119+
2120+
status = ice_sched_cfg_vsi(pi, vsi_id, i, maxqs[i], owner,
2121+
ice_is_tc_ena(tc_bitmap, i));
2122+
if (status)
2123+
break;
2124+
}
2125+
2126+
mutex_unlock(&pi->sched_lock);
2127+
return status;
2128+
}
2129+
2130+
/**
2131+
* ice_cfg_vsi_lan - configure VSI lan queues
2132+
* @pi: port information structure
2133+
* @vsi_id: VSI Id
2134+
* @tc_bitmap: TC bitmap
2135+
* @max_lanqs: max lan queues array per TC
2136+
*
2137+
* This function adds/updates the VSI lan queues per TC.
2138+
*/
2139+
enum ice_status
2140+
ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_id, u8 tc_bitmap,
2141+
u16 *max_lanqs)
2142+
{
2143+
return ice_cfg_vsi_qs(pi, vsi_id, tc_bitmap, max_lanqs,
2144+
ICE_SCHED_NODE_OWNER_LAN);
2145+
}

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ enum ice_status
6969
ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
7070
u32 *q_teids, struct ice_sq_cd *cmd_details);
7171
enum ice_status
72+
ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_id, u8 tc_bitmap,
73+
u16 *max_lanqs);
74+
enum ice_status
7275
ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_id, u8 tc, u8 num_qgrps,
7376
struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
7477
struct ice_sq_cd *cd);

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,10 +2085,11 @@ static struct ice_vsi *
20852085
ice_vsi_setup(struct ice_pf *pf, enum ice_vsi_type type,
20862086
struct ice_port_info *pi)
20872087
{
2088+
u16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };
20882089
struct device *dev = &pf->pdev->dev;
20892090
struct ice_vsi_ctx ctxt = { 0 };
20902091
struct ice_vsi *vsi;
2091-
int ret;
2092+
int ret, i;
20922093

20932094
vsi = ice_vsi_alloc(pf, type);
20942095
if (!vsi) {
@@ -2156,6 +2157,20 @@ ice_vsi_setup(struct ice_pf *pf, enum ice_vsi_type type,
21562157
*/
21572158
goto err_rings;
21582159
}
2160+
2161+
ice_vsi_set_tc_cfg(vsi);
2162+
2163+
/* configure VSI nodes based on number of queues and TC's */
2164+
for (i = 0; i < vsi->tc_cfg.numtc; i++)
2165+
max_txqs[i] = vsi->num_txq;
2166+
2167+
ret = ice_cfg_vsi_lan(vsi->port_info, vsi->vsi_num,
2168+
vsi->tc_cfg.ena_tc, max_txqs);
2169+
if (ret) {
2170+
dev_info(&pf->pdev->dev, "Failed VSI lan queue config\n");
2171+
goto err_rings;
2172+
}
2173+
21592174
return vsi;
21602175

21612176
err_rings:
@@ -2398,8 +2413,7 @@ static void ice_determine_q_usage(struct ice_pf *pf)
23982413
q_left_tx = pf->hw.func_caps.common_cap.num_txq;
23992414
q_left_rx = pf->hw.func_caps.common_cap.num_rxq;
24002415

2401-
/* initial support for only 1 tx queue */
2402-
pf->num_lan_tx = 1;
2416+
pf->num_lan_tx = min_t(int, q_left_tx, num_online_cpus());
24032417

24042418
/* only 1 rx queue unless RSS is enabled */
24052419
if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags))

0 commit comments

Comments
 (0)