@@ -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+
433547static 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
0 commit comments