Skip to content

Commit 597b8af

Browse files
praczynsanguy11
authored andcommitted
ice: add new VSI type for subfunctions
Add required plumbing for new VSI type dedicated to devlink subfunctions. Make sure that the vsi is properly configured and destroyed. Also allow loading XDP and AF_XDP sockets. The first implementation of devlink subfunctions supports only one Tx/Rx queue pair per given subfunction. Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Signed-off-by: Piotr Raczynski <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 52fc70a commit 597b8af

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ ice_setup_tx_ctx(struct ice_tx_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf
325325
tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf->vf_id;
326326
tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF;
327327
break;
328+
case ICE_VSI_SF:
329+
tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ;
330+
break;
328331
default:
329332
return;
330333
}
@@ -540,7 +543,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
540543

541544
ring->rx_buf_len = ring->vsi->rx_buf_len;
542545

543-
if (ring->vsi->type == ICE_VSI_PF) {
546+
if (ring->vsi->type == ICE_VSI_PF || ring->vsi->type == ICE_VSI_SF) {
544547
if (!xdp_rxq_info_is_reg(&ring->xdp_rxq)) {
545548
err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
546549
ring->q_index,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi)
187187
vsi->tc_cfg.numtc = ice_dcb_get_num_tc(cfg);
188188
break;
189189
case ICE_VSI_CHNL:
190+
case ICE_VSI_SF:
190191
vsi->tc_cfg.ena_tc = BIT(ice_get_first_droptc(vsi));
191192
vsi->tc_cfg.numtc = 1;
192193
break;

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const char *ice_vsi_type_str(enum ice_vsi_type vsi_type)
2020
return "ICE_VSI_PF";
2121
case ICE_VSI_VF:
2222
return "ICE_VSI_VF";
23+
case ICE_VSI_SF:
24+
return "ICE_VSI_SF";
2325
case ICE_VSI_CTRL:
2426
return "ICE_VSI_CTRL";
2527
case ICE_VSI_CHNL:
@@ -135,6 +137,7 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi)
135137
{
136138
switch (vsi->type) {
137139
case ICE_VSI_PF:
140+
case ICE_VSI_SF:
138141
case ICE_VSI_CTRL:
139142
case ICE_VSI_LB:
140143
/* a user could change the values of num_[tr]x_desc using
@@ -201,6 +204,12 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)
201204
max_t(int, vsi->alloc_rxq,
202205
vsi->alloc_txq));
203206
break;
207+
case ICE_VSI_SF:
208+
vsi->alloc_txq = 1;
209+
vsi->alloc_rxq = 1;
210+
vsi->num_q_vectors = 1;
211+
vsi->irq_dyn_alloc = true;
212+
break;
204213
case ICE_VSI_VF:
205214
if (vf->num_req_qs)
206215
vf->num_vf_qs = vf->num_req_qs;
@@ -559,6 +568,7 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)
559568

560569
switch (vsi->type) {
561570
case ICE_VSI_PF:
571+
case ICE_VSI_SF:
562572
/* Setup default MSIX irq handler for VSI */
563573
vsi->irq_handler = ice_msix_clean_rings;
564574
break;
@@ -889,6 +899,11 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi)
889899
max_rss_size);
890900
vsi->rss_lut_type = ICE_LUT_PF;
891901
break;
902+
case ICE_VSI_SF:
903+
vsi->rss_table_size = ICE_LUT_VSI_SIZE;
904+
vsi->rss_size = min_t(u16, num_online_cpus(), max_rss_size);
905+
vsi->rss_lut_type = ICE_LUT_VSI;
906+
break;
892907
case ICE_VSI_VF:
893908
/* VF VSI will get a small RSS table.
894909
* For VSI_LUT, LUT size should be set to 64 bytes.
@@ -1136,6 +1151,7 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
11361151
lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_PF;
11371152
break;
11381153
case ICE_VSI_VF:
1154+
case ICE_VSI_SF:
11391155
/* VF VSI will gets a small RSS table which is a VSI LUT type */
11401156
lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI;
11411157
break;
@@ -1214,6 +1230,7 @@ static int ice_vsi_init(struct ice_vsi *vsi, u32 vsi_flags)
12141230
case ICE_VSI_PF:
12151231
ctxt->flags = ICE_AQ_VSI_TYPE_PF;
12161232
break;
1233+
case ICE_VSI_SF:
12171234
case ICE_VSI_CHNL:
12181235
ctxt->flags = ICE_AQ_VSI_TYPE_VMDQ2;
12191236
break;
@@ -2095,6 +2112,7 @@ static void ice_set_agg_vsi(struct ice_vsi *vsi)
20952112
case ICE_VSI_CHNL:
20962113
case ICE_VSI_LB:
20972114
case ICE_VSI_PF:
2115+
case ICE_VSI_SF:
20982116
max_agg_nodes = ICE_MAX_PF_AGG_NODES;
20992117
agg_node_id_start = ICE_PF_AGG_NODE_ID_START;
21002118
agg_node_iter = &pf->pf_agg_node[0];
@@ -2264,6 +2282,7 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
22642282

22652283
switch (vsi->type) {
22662284
case ICE_VSI_CTRL:
2285+
case ICE_VSI_SF:
22672286
case ICE_VSI_PF:
22682287
ret = ice_vsi_alloc_q_vectors(vsi);
22692288
if (ret)
@@ -2648,7 +2667,8 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked)
26482667

26492668
clear_bit(ICE_VSI_NEEDS_RESTART, vsi->state);
26502669

2651-
if (vsi->netdev && vsi->type == ICE_VSI_PF) {
2670+
if (vsi->netdev && (vsi->type == ICE_VSI_PF ||
2671+
vsi->type == ICE_VSI_SF)) {
26522672
if (netif_running(vsi->netdev)) {
26532673
if (!locked)
26542674
rtnl_lock();
@@ -2676,7 +2696,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked)
26762696

26772697
set_bit(ICE_VSI_NEEDS_RESTART, vsi->state);
26782698

2679-
if (vsi->type == ICE_VSI_PF && vsi->netdev) {
2699+
if (vsi->netdev && (vsi->type == ICE_VSI_PF ||
2700+
vsi->type == ICE_VSI_SF)) {
26802701
if (netif_running(vsi->netdev)) {
26812702
if (!locked)
26822703
rtnl_lock();

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,6 +2974,9 @@ int ice_vsi_determine_xdp_res(struct ice_vsi *vsi)
29742974
if (avail < cpus / 2)
29752975
return -ENOMEM;
29762976

2977+
if (vsi->type == ICE_VSI_SF)
2978+
avail = vsi->alloc_txq;
2979+
29772980
vsi->num_xdp_txq = min_t(u16, avail, cpus);
29782981

29792982
if (vsi->num_xdp_txq < cpus)
@@ -3095,8 +3098,8 @@ static int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp)
30953098
struct ice_vsi *vsi = np->vsi;
30963099
int ret;
30973100

3098-
if (vsi->type != ICE_VSI_PF) {
3099-
NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF VSI");
3101+
if (vsi->type != ICE_VSI_PF && vsi->type != ICE_VSI_SF) {
3102+
NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF or SF VSI");
31003103
return -EINVAL;
31013104
}
31023105

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ enum ice_vsi_type {
159159
ICE_VSI_CTRL = 3, /* equates to ICE_VSI_PF with 1 queue pair */
160160
ICE_VSI_CHNL = 4,
161161
ICE_VSI_LB = 6,
162+
ICE_VSI_SF = 9,
162163
};
163164

164165
struct ice_link_status {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
289289
{
290290
int err;
291291

292-
if (vsi->type != ICE_VSI_PF)
292+
if (vsi->type != ICE_VSI_PF && vsi->type != ICE_VSI_SF)
293293
return -EINVAL;
294294

295295
if (qid >= vsi->netdev->real_num_rx_queues ||

0 commit comments

Comments
 (0)