Skip to content

Commit e523af4

Browse files
shirazsaleemanguy11
authored andcommitted
net/ice: Add support for enable_iwarp and enable_roce devlink param
Allow support for 'enable_iwarp' and 'enable_roce' devlink params to turn on/off iWARP or RoCE protocol support for E800 devices. For example, a user can turn on iWARP functionality with, devlink dev param set pci/0000:07:00.0 name enable_iwarp value true cmode runtime This add an iWARP auxiliary rdma device, ice.iwarp.<>, under this PF. A user request to enable both iWARP and RoCE under the same PF is rejected since this device does not support both protocols simultaneously on the same port. Signed-off-by: Shiraz Saleem <[email protected]> Tested-by: Leszek Kaliszczuk <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 325e0d0 commit e523af4

File tree

6 files changed

+166
-5
lines changed

6 files changed

+166
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ struct ice_pf {
576576
struct ice_hw_port_stats stats_prev;
577577
struct ice_hw hw;
578578
u8 stat_prev_loaded:1; /* has previous stats been loaded */
579+
u8 rdma_mode;
579580
u16 dcbx_cap;
580581
u32 tx_timeout_count;
581582
unsigned long tx_timeout_last_recovery;

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

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,120 @@ static const struct devlink_ops ice_devlink_ops = {
430430
.flash_update = ice_devlink_flash_update,
431431
};
432432

433+
static int
434+
ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
435+
struct devlink_param_gset_ctx *ctx)
436+
{
437+
struct ice_pf *pf = devlink_priv(devlink);
438+
439+
ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2;
440+
441+
return 0;
442+
}
443+
444+
static int
445+
ice_devlink_enable_roce_set(struct devlink *devlink, u32 id,
446+
struct devlink_param_gset_ctx *ctx)
447+
{
448+
struct ice_pf *pf = devlink_priv(devlink);
449+
bool roce_ena = ctx->val.vbool;
450+
int ret;
451+
452+
if (!roce_ena) {
453+
ice_unplug_aux_dev(pf);
454+
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_ROCEV2;
455+
return 0;
456+
}
457+
458+
pf->rdma_mode |= IIDC_RDMA_PROTOCOL_ROCEV2;
459+
ret = ice_plug_aux_dev(pf);
460+
if (ret)
461+
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_ROCEV2;
462+
463+
return ret;
464+
}
465+
466+
static int
467+
ice_devlink_enable_roce_validate(struct devlink *devlink, u32 id,
468+
union devlink_param_value val,
469+
struct netlink_ext_ack *extack)
470+
{
471+
struct ice_pf *pf = devlink_priv(devlink);
472+
473+
if (!test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
474+
return -EOPNOTSUPP;
475+
476+
if (pf->rdma_mode & IIDC_RDMA_PROTOCOL_IWARP) {
477+
NL_SET_ERR_MSG_MOD(extack, "iWARP is currently enabled. This device cannot enable iWARP and RoCEv2 simultaneously");
478+
return -EOPNOTSUPP;
479+
}
480+
481+
return 0;
482+
}
483+
484+
static int
485+
ice_devlink_enable_iw_get(struct devlink *devlink, u32 id,
486+
struct devlink_param_gset_ctx *ctx)
487+
{
488+
struct ice_pf *pf = devlink_priv(devlink);
489+
490+
ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_IWARP;
491+
492+
return 0;
493+
}
494+
495+
static int
496+
ice_devlink_enable_iw_set(struct devlink *devlink, u32 id,
497+
struct devlink_param_gset_ctx *ctx)
498+
{
499+
struct ice_pf *pf = devlink_priv(devlink);
500+
bool iw_ena = ctx->val.vbool;
501+
int ret;
502+
503+
if (!iw_ena) {
504+
ice_unplug_aux_dev(pf);
505+
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_IWARP;
506+
return 0;
507+
}
508+
509+
pf->rdma_mode |= IIDC_RDMA_PROTOCOL_IWARP;
510+
ret = ice_plug_aux_dev(pf);
511+
if (ret)
512+
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_IWARP;
513+
514+
return ret;
515+
}
516+
517+
static int
518+
ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,
519+
union devlink_param_value val,
520+
struct netlink_ext_ack *extack)
521+
{
522+
struct ice_pf *pf = devlink_priv(devlink);
523+
524+
if (!test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
525+
return -EOPNOTSUPP;
526+
527+
if (pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2) {
528+
NL_SET_ERR_MSG_MOD(extack, "RoCEv2 is currently enabled. This device cannot enable iWARP and RoCEv2 simultaneously");
529+
return -EOPNOTSUPP;
530+
}
531+
532+
return 0;
533+
}
534+
535+
static const struct devlink_param ice_devlink_params[] = {
536+
DEVLINK_PARAM_GENERIC(ENABLE_ROCE, BIT(DEVLINK_PARAM_CMODE_RUNTIME),
537+
ice_devlink_enable_roce_get,
538+
ice_devlink_enable_roce_set,
539+
ice_devlink_enable_roce_validate),
540+
DEVLINK_PARAM_GENERIC(ENABLE_IWARP, BIT(DEVLINK_PARAM_CMODE_RUNTIME),
541+
ice_devlink_enable_iw_get,
542+
ice_devlink_enable_iw_set,
543+
ice_devlink_enable_iw_validate),
544+
545+
};
546+
433547
static void ice_devlink_free(void *devlink_ptr)
434548
{
435549
devlink_free((struct devlink *)devlink_ptr);
@@ -484,6 +598,36 @@ void ice_devlink_unregister(struct ice_pf *pf)
484598
devlink_unregister(priv_to_devlink(pf));
485599
}
486600

601+
int ice_devlink_register_params(struct ice_pf *pf)
602+
{
603+
struct devlink *devlink = priv_to_devlink(pf);
604+
union devlink_param_value value;
605+
int err;
606+
607+
err = devlink_params_register(devlink, ice_devlink_params,
608+
ARRAY_SIZE(ice_devlink_params));
609+
if (err)
610+
return err;
611+
612+
value.vbool = false;
613+
devlink_param_driverinit_value_set(devlink,
614+
DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP,
615+
value);
616+
617+
value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags) ? true : false;
618+
devlink_param_driverinit_value_set(devlink,
619+
DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE,
620+
value);
621+
622+
return 0;
623+
}
624+
625+
void ice_devlink_unregister_params(struct ice_pf *pf)
626+
{
627+
devlink_params_unregister(priv_to_devlink(pf), ice_devlink_params,
628+
ARRAY_SIZE(ice_devlink_params));
629+
}
630+
487631
/**
488632
* ice_devlink_create_pf_port - Create a devlink port for this PF
489633
* @pf: the PF to create a devlink port for

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
#ifndef _ICE_DEVLINK_H_
55
#define _ICE_DEVLINK_H_
66

7+
enum ice_devlink_param_id {
8+
ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
9+
};
10+
711
struct ice_pf *ice_allocate_pf(struct device *dev);
812

913
void ice_devlink_register(struct ice_pf *pf);
1014
void ice_devlink_unregister(struct ice_pf *pf);
15+
int ice_devlink_register_params(struct ice_pf *pf);
16+
void ice_devlink_unregister_params(struct ice_pf *pf);
1117
int ice_devlink_create_pf_port(struct ice_pf *pf);
1218
void ice_devlink_destroy_pf_port(struct ice_pf *pf);
1319
int ice_devlink_create_vf_port(struct ice_vf *vf);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ int ice_plug_aux_dev(struct ice_pf *pf)
288288
adev->id = pf->aux_idx;
289289
adev->dev.release = ice_adev_release;
290290
adev->dev.parent = &pf->pdev->dev;
291-
adev->name = IIDC_RDMA_ROCE_NAME;
291+
adev->name = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? "roce" : "iwarp";
292292

293293
ret = auxiliary_device_init(adev);
294294
if (ret) {
@@ -335,6 +335,6 @@ int ice_init_rdma(struct ice_pf *pf)
335335
dev_err(dev, "failed to reserve vectors for RDMA\n");
336336
return ret;
337337
}
338-
338+
pf->rdma_mode |= IIDC_RDMA_PROTOCOL_ROCEV2;
339339
return ice_plug_aux_dev(pf);
340340
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4705,14 +4705,18 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
47054705
if (err)
47064706
goto err_netdev_reg;
47074707

4708+
err = ice_devlink_register_params(pf);
4709+
if (err)
4710+
goto err_netdev_reg;
4711+
47084712
/* ready to go, so clear down state bit */
47094713
clear_bit(ICE_DOWN, pf->state);
47104714
if (ice_is_aux_ena(pf)) {
47114715
pf->aux_idx = ida_alloc(&ice_aux_ida, GFP_KERNEL);
47124716
if (pf->aux_idx < 0) {
47134717
dev_err(dev, "Failed to allocate device ID for AUX driver\n");
47144718
err = -ENOMEM;
4715-
goto err_netdev_reg;
4719+
goto err_devlink_reg_param;
47164720
}
47174721

47184722
err = ice_init_rdma(pf);
@@ -4731,6 +4735,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
47314735
err_init_aux_unroll:
47324736
pf->adev = NULL;
47334737
ida_free(&ice_aux_ida, pf->aux_idx);
4738+
err_devlink_reg_param:
4739+
ice_devlink_unregister_params(pf);
47344740
err_netdev_reg:
47354741
err_send_version_unroll:
47364742
ice_vsi_release_all(pf);
@@ -4845,6 +4851,7 @@ static void ice_remove(struct pci_dev *pdev)
48454851
ice_unplug_aux_dev(pf);
48464852
if (pf->aux_idx >= 0)
48474853
ida_free(&ice_aux_ida, pf->aux_idx);
4854+
ice_devlink_unregister_params(pf);
48484855
set_bit(ICE_DOWN, pf->state);
48494856

48504857
mutex_destroy(&(&pf->hw)->fdir_fltr_lock);

include/linux/net/intel/iidc.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ enum iidc_reset_type {
2626
IIDC_GLOBR,
2727
};
2828

29+
enum iidc_rdma_protocol {
30+
IIDC_RDMA_PROTOCOL_IWARP = BIT(0),
31+
IIDC_RDMA_PROTOCOL_ROCEV2 = BIT(1),
32+
};
33+
2934
#define IIDC_MAX_USER_PRIORITY 8
3035

3136
/* Struct to hold per RDMA Qset info */
@@ -70,8 +75,6 @@ int ice_rdma_request_reset(struct ice_pf *pf, enum iidc_reset_type reset_type);
7075
int ice_rdma_update_vsi_filter(struct ice_pf *pf, u16 vsi_id, bool enable);
7176
void ice_get_qos_params(struct ice_pf *pf, struct iidc_qos_params *qos);
7277

73-
#define IIDC_RDMA_ROCE_NAME "roce"
74-
7578
/* Structure representing auxiliary driver tailored information about the core
7679
* PCI dev, each auxiliary driver using the IIDC interface will have an
7780
* instance of this struct dedicated to it.

0 commit comments

Comments
 (0)