Re: [RFC 1/3] devlink: Add config parameter get/set operations

2017-10-13 Thread Jiri Pirko
Thu, Oct 12, 2017 at 08:12:48PM CEST, andrew.gospoda...@broadcom.com wrote:
>On Thu, Oct 12, 2017 at 04:03:17PM +0200, Jiri Pirko wrote:
>> Thu, Oct 12, 2017 at 03:34:20PM CEST, steven.l...@broadcom.com wrote:
>> >Add support for config parameter get/set commands. Initially used by
>> >bnxt driver, but other drivers can use the same, or new, attributes.
>> >The config_get() and config_set() operations operate as expected, but
>> >note that the driver implementation of the config_set() operation can
>> >indicate whether a restart is necessary for the setting to take
>> >effect.
>> >
>> 
>> First of all, I like this approach.
>> 
>> I would like to see this patch split into:
>> 1) config-options infrastructure introduction
>> 2) specific config options introductions - would be best to have it
>>per-option. We need to make sure every option is very well described
>>and explained usecases. This is needed in order vendors to share
>>attributes among drivers.
>> 
>> More nits inlined.
>> 
>> 
>> >Signed-off-by: Steve Lin 
>> >Acked-by: Andy Gospodarek 
>> >---
>> > include/net/devlink.h|   4 +
>> > include/uapi/linux/devlink.h | 108 ++
>> > net/core/devlink.c   | 207 
>> > +++
>> > 3 files changed, 319 insertions(+)
>> >
>> > static inline void *devlink_priv(struct devlink *devlink)
>> >diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>> >index 0cbca96..e959716 100644
>> >--- a/include/uapi/linux/devlink.h
>> >+++ b/include/uapi/linux/devlink.h
>[...]
>> >@@ -202,6 +267,49 @@ enum devlink_attr {
>> > 
>> >DEVLINK_ATTR_ESWITCH_ENCAP_MODE,/* u8 */
>> > 
>> >+   /* Configuration Parameters */
>> >+   DEVLINK_ATTR_SRIOV_ENABLED, /* u8 */
>> >+   DEVLINK_ATTR_NUM_VF_PER_PF, /* u32 */
>> >+   DEVLINK_ATTR_MAX_NUM_PF_MSIX_VECT,  /* u32 */
>> >+   DEVLINK_ATTR_MSIX_VECTORS_PER_VF,   /* u32 */
>> >+   DEVLINK_ATTR_NPAR_NUM_PARTITIONS_PER_PORT,  /* u32 */
>> >+   DEVLINK_ATTR_NPAR_BW_IN_PERCENT,/* u8 */
>> >+   DEVLINK_ATTR_NPAR_BW_RESERVATION,   /* u8 */
>> >+   DEVLINK_ATTR_NPAR_BW_RESERVATION_VALID, /* u8 */
>> >+   DEVLINK_ATTR_NPAR_BW_LIMIT, /* u8 */
>> >+   DEVLINK_ATTR_NPAR_BW_LIMIT_VALID,   /* u8 */
>> >+   DEVLINK_ATTR_DCBX_MODE, /* u8 */
>> >+   DEVLINK_ATTR_RDMA_ENABLED,  /* u8 */
>> >+   DEVLINK_ATTR_MULTIFUNC_MODE,/* u8 */
>> >+   DEVLINK_ATTR_SECURE_NIC_ENABLED,/* u8 */
>> >+   DEVLINK_ATTR_IGNORE_ARI_CAPABILITY, /* u8 */
>> >+   DEVLINK_ATTR_LLDP_NEAREST_BRIDGE_ENABLED,   /* u8 */
>> >+   DEVLINK_ATTR_LLDP_NEAREST_NONTPMR_BRIDGE_ENABLED,   /* u8 */
>> >+   DEVLINK_ATTR_PME_CAPABILITY_ENABLED,/* u8 */
>> >+   DEVLINK_ATTR_MAGIC_PACKET_WOL_ENABLED,  /* u8 */
>> >+   DEVLINK_ATTR_EEE_PWR_SAVE_ENABLED,  /* u8 */
>> >+   DEVLINK_ATTR_AUTONEG_PROTOCOL,  /* u8 */
>> >+   DEVLINK_ATTR_MEDIA_AUTO_DETECT, /* u8 */
>> >+   DEVLINK_ATTR_PHY_SELECT,/* u8 */
>> >+   DEVLINK_ATTR_PRE_OS_LINK_SPEED_D0,  /* u8 */
>> >+   DEVLINK_ATTR_PRE_OS_LINK_SPEED_D3,  /* u8 */
>> >+   DEVLINK_ATTR_MBA_ENABLED,   /* u8 */
>> >+   DEVLINK_ATTR_MBA_BOOT_TYPE, /* u8 */
>> >+   DEVLINK_ATTR_MBA_DELAY_TIME,/* u32 */
>> >+   DEVLINK_ATTR_MBA_SETUP_HOT_KEY, /* u8 */
>> >+   DEVLINK_ATTR_MBA_HIDE_SETUP_PROMPT, /* u8 */
>> >+   DEVLINK_ATTR_MBA_BOOT_RETRY_COUNT,  /* u32 */
>> >+   DEVLINK_ATTR_MBA_VLAN_ENABLED,  /* u8 */
>> >+   DEVLINK_ATTR_MBA_VLAN_TAG,  /* u16 */
>> >+   DEVLINK_ATTR_MBA_BOOT_PROTOCOL, /* u8 */
>> >+   DEVLINK_ATTR_MBA_LINK_SPEED,/* u8 */
>> 
>> Okay, I think it is about the time we should start thinking about
>> putting this new config attributes under nester attribute. What do you
>> think?
>> 
>
>Steve and I actually had a similar discussion yesterday when I was doing
>a final review of the patches.
>
>My only objection to nesting was coming up with a way to describe these
>functions that made them seem different than existing configuration
>options.  In this case of the hardware we are trying to support these
>are all permanent config options, so we would call them
>DEVLINK_ATTR_NVRAM or DEVLINK_ATTR_PERM.  Does that seem reasonable to
>others?

The name should go hand-in-hand with the names of the cmds.



Re: [RFC 1/3] devlink: Add config parameter get/set operations

2017-10-12 Thread Andy Gospodarek
On Thu, Oct 12, 2017 at 04:03:17PM +0200, Jiri Pirko wrote:
> Thu, Oct 12, 2017 at 03:34:20PM CEST, steven.l...@broadcom.com wrote:
> >Add support for config parameter get/set commands. Initially used by
> >bnxt driver, but other drivers can use the same, or new, attributes.
> >The config_get() and config_set() operations operate as expected, but
> >note that the driver implementation of the config_set() operation can
> >indicate whether a restart is necessary for the setting to take
> >effect.
> >
> 
> First of all, I like this approach.
> 
> I would like to see this patch split into:
> 1) config-options infrastructure introduction
> 2) specific config options introductions - would be best to have it
>per-option. We need to make sure every option is very well described
>and explained usecases. This is needed in order vendors to share
>attributes among drivers.
> 
> More nits inlined.
> 
> 
> >Signed-off-by: Steve Lin 
> >Acked-by: Andy Gospodarek 
> >---
> > include/net/devlink.h|   4 +
> > include/uapi/linux/devlink.h | 108 ++
> > net/core/devlink.c   | 207 
> > +++
> > 3 files changed, 319 insertions(+)
> >
> > static inline void *devlink_priv(struct devlink *devlink)
> >diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
> >index 0cbca96..e959716 100644
> >--- a/include/uapi/linux/devlink.h
> >+++ b/include/uapi/linux/devlink.h
[...]
> >@@ -202,6 +267,49 @@ enum devlink_attr {
> > 
> > DEVLINK_ATTR_ESWITCH_ENCAP_MODE,/* u8 */
> > 
> >+/* Configuration Parameters */
> >+DEVLINK_ATTR_SRIOV_ENABLED, /* u8 */
> >+DEVLINK_ATTR_NUM_VF_PER_PF, /* u32 */
> >+DEVLINK_ATTR_MAX_NUM_PF_MSIX_VECT,  /* u32 */
> >+DEVLINK_ATTR_MSIX_VECTORS_PER_VF,   /* u32 */
> >+DEVLINK_ATTR_NPAR_NUM_PARTITIONS_PER_PORT,  /* u32 */
> >+DEVLINK_ATTR_NPAR_BW_IN_PERCENT,/* u8 */
> >+DEVLINK_ATTR_NPAR_BW_RESERVATION,   /* u8 */
> >+DEVLINK_ATTR_NPAR_BW_RESERVATION_VALID, /* u8 */
> >+DEVLINK_ATTR_NPAR_BW_LIMIT, /* u8 */
> >+DEVLINK_ATTR_NPAR_BW_LIMIT_VALID,   /* u8 */
> >+DEVLINK_ATTR_DCBX_MODE, /* u8 */
> >+DEVLINK_ATTR_RDMA_ENABLED,  /* u8 */
> >+DEVLINK_ATTR_MULTIFUNC_MODE,/* u8 */
> >+DEVLINK_ATTR_SECURE_NIC_ENABLED,/* u8 */
> >+DEVLINK_ATTR_IGNORE_ARI_CAPABILITY, /* u8 */
> >+DEVLINK_ATTR_LLDP_NEAREST_BRIDGE_ENABLED,   /* u8 */
> >+DEVLINK_ATTR_LLDP_NEAREST_NONTPMR_BRIDGE_ENABLED,   /* u8 */
> >+DEVLINK_ATTR_PME_CAPABILITY_ENABLED,/* u8 */
> >+DEVLINK_ATTR_MAGIC_PACKET_WOL_ENABLED,  /* u8 */
> >+DEVLINK_ATTR_EEE_PWR_SAVE_ENABLED,  /* u8 */
> >+DEVLINK_ATTR_AUTONEG_PROTOCOL,  /* u8 */
> >+DEVLINK_ATTR_MEDIA_AUTO_DETECT, /* u8 */
> >+DEVLINK_ATTR_PHY_SELECT,/* u8 */
> >+DEVLINK_ATTR_PRE_OS_LINK_SPEED_D0,  /* u8 */
> >+DEVLINK_ATTR_PRE_OS_LINK_SPEED_D3,  /* u8 */
> >+DEVLINK_ATTR_MBA_ENABLED,   /* u8 */
> >+DEVLINK_ATTR_MBA_BOOT_TYPE, /* u8 */
> >+DEVLINK_ATTR_MBA_DELAY_TIME,/* u32 */
> >+DEVLINK_ATTR_MBA_SETUP_HOT_KEY, /* u8 */
> >+DEVLINK_ATTR_MBA_HIDE_SETUP_PROMPT, /* u8 */
> >+DEVLINK_ATTR_MBA_BOOT_RETRY_COUNT,  /* u32 */
> >+DEVLINK_ATTR_MBA_VLAN_ENABLED,  /* u8 */
> >+DEVLINK_ATTR_MBA_VLAN_TAG,  /* u16 */
> >+DEVLINK_ATTR_MBA_BOOT_PROTOCOL, /* u8 */
> >+DEVLINK_ATTR_MBA_LINK_SPEED,/* u8 */
> 
> Okay, I think it is about the time we should start thinking about
> putting this new config attributes under nester attribute. What do you
> think?
> 

Steve and I actually had a similar discussion yesterday when I was doing
a final review of the patches.

My only objection to nesting was coming up with a way to describe these
functions that made them seem different than existing configuration
options.  In this case of the hardware we are trying to support these
are all permanent config options, so we would call them
DEVLINK_ATTR_NVRAM or DEVLINK_ATTR_PERM.  Does that seem reasonable to
others?


Re: [RFC 1/3] devlink: Add config parameter get/set operations

2017-10-12 Thread Steve Lin
Jiri,

Thanks for your feedback below and in your other response.  I will
make some changes to address those issues and resubmit.

Thanks again!
Steve

On Thu, Oct 12, 2017 at 10:03 AM, Jiri Pirko  wrote:
> Thu, Oct 12, 2017 at 03:34:20PM CEST, steven.l...@broadcom.com wrote:
>>Add support for config parameter get/set commands. Initially used by
>>bnxt driver, but other drivers can use the same, or new, attributes.
>>The config_get() and config_set() operations operate as expected, but
>>note that the driver implementation of the config_set() operation can
>>indicate whether a restart is necessary for the setting to take
>>effect.
>>
>
> First of all, I like this approach.
>
> I would like to see this patch split into:
> 1) config-options infrastructure introduction
> 2) specific config options introductions - would be best to have it
>per-option. We need to make sure every option is very well described
>and explained usecases. This is needed in order vendors to share
>attributes among drivers.
>
> More nits inlined.
>
>
>>Signed-off-by: Steve Lin 
>>Acked-by: Andy Gospodarek 
>>---
>> include/net/devlink.h|   4 +
>> include/uapi/linux/devlink.h | 108 ++
>> net/core/devlink.c   | 207 
>> +++
>> 3 files changed, 319 insertions(+)
>>
>>diff --git a/include/net/devlink.h b/include/net/devlink.h
>>index b9654e1..952966c 100644
>>--- a/include/net/devlink.h
>>+++ b/include/net/devlink.h
>>@@ -270,6 +270,10 @@ struct devlink_ops {
>>   int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 
>> inline_mode);
>>   int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 
>> *p_encap_mode);
>>   int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode);
>>+  int (*config_get)(struct devlink *devlink, enum devlink_attr attr,
>>+u32 *value);
>>+  int (*config_set)(struct devlink *devlink, enum devlink_attr attr,
>>+u32 value, u8 *restart_reqd);
>> };
>>
>> static inline void *devlink_priv(struct devlink *devlink)
>>diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>>index 0cbca96..e959716 100644
>>--- a/include/uapi/linux/devlink.h
>>+++ b/include/uapi/linux/devlink.h
>>@@ -70,6 +70,9 @@ enum devlink_command {
>>   DEVLINK_CMD_DPIPE_HEADERS_GET,
>>   DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
>>
>>+  DEVLINK_CMD_CONFIG_GET,
>>+  DEVLINK_CMD_CONFIG_SET,
>>+
>>   /* add new commands above here */
>>   __DEVLINK_CMD_MAX,
>>   DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
>>@@ -124,6 +127,68 @@ enum devlink_eswitch_encap_mode {
>>   DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
>> };
>>
>>+enum devlink_dcbx_mode {
>>+  DEVLINK_DCBX_MODE_DISABLED,
>>+  DEVLINK_DCBX_MODE_IEEE,
>>+  DEVLINK_DCBX_MODE_CEE,
>>+  DEVLINK_DCBX_MODE_IEEE_CEE,
>>+};
>>+
>>+enum devlink_multifunc_mode {
>>+  DEVLINK_MULTIFUNC_MODE_ALLOWED, /* Ext switch activates MF */
>>+  DEVLINK_MULTIFUNC_MODE_FORCE_SINGFUNC,
>>+  DEVLINK_MULTIFUNC_MODE_NPAR10,  /* NPAR 1.0 */
>>+  DEVLINK_MULTIFUNC_MODE_NPAR15,  /* NPAR 1.5 */
>>+  DEVLINK_MULTIFUNC_MODE_NPAR20,  /* NPAR 2.0 */
>>+};
>>+
>>+enum devlink_autoneg_protocol {
>>+  DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY_BAM,
>>+  DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY_CONSORTIUM,
>>+  DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY,
>>+  DEVLINK_AUTONEG_PROTOCOL_BAM,   /* Broadcom Autoneg Mode */
>>+  DEVLINK_AUTONEG_PROTOCOL_CONSORTIUM,/* Consortium Autoneg Mode */
>>+};
>>+
>>+enum devlink_pre_os_link_speed {
>>+  DEVLINK_PRE_OS_LINK_SPEED_AUTONEG,
>>+  DEVLINK_PRE_OS_LINK_SPEED_1G,
>>+  DEVLINK_PRE_OS_LINK_SPEED_10G,
>>+  DEVLINK_PRE_OS_LINK_SPEED_25G,
>>+  DEVLINK_PRE_OS_LINK_SPEED_40G,
>>+  DEVLINK_PRE_OS_LINK_SPEED_50G,
>>+  DEVLINK_PRE_OS_LINK_SPEED_100G,
>>+  DEVLINK_PRE_OS_LINK_SPEED_5G = 0xe,
>>+  DEVLINK_PRE_OS_LINK_SPEED_100M = 0xf,
>>+};
>>+
>>+enum devlink_mba_boot_type {
>>+  DEVLINK_MBA_BOOT_TYPE_AUTO_DETECT,
>>+  DEVLINK_MBA_BOOT_TYPE_BBS,  /* BIOS Boot Specification */
>>+  DEVLINK_MBA_BOOT_TYPE_INTR18,   /* Hook interrupt 0x18 */
>>+  DEVLINK_MBA_BOOT_TYPE_INTR19,   /* Hook interrupt 0x19 */
>>+};
>>+
>>+enum devlink_mba_setup_hot_key {
>>+  DEVLINK_MBA_SETUP_HOT_KEY_CTRL_S,
>>+  DEVLINK_MBA_SETUP_HOT_KEY_CTRL_B,
>>+};
>>+
>>+enum devlink_mba_boot_protocol {
>>+  DEVLINK_MBA_BOOT_PROTOCOL_PXE,
>>+  DEVLINK_MBA_BOOT_PROTOCOL_ISCSI,
>>+  DEVLINK_MBA_BOOT_PROTOCOL_NONE = 0x7,
>>+};
>>+
>>+enum devlink_mba_link_speed {
>>+  DEVLINK_MBA_LINK_SPEED_AUTONEG,
>>+  DEVLINK_MBA_LINK_SPEED_1G,
>>+  DEVLINK_MBA_LINK_SPEED_10G,
>>+  DEVLINK_MBA_LINK_SPEED_25G,
>>+  DEVLINK_MBA_LINK_SPEED_40G,
>>+  DEVLINK_MBA_LINK_SPEED_50G,
>>+};
>>+
>> enum devlink_attr {
>>   /* don't change the order or add anythin

Re: [RFC 1/3] devlink: Add config parameter get/set operations

2017-10-12 Thread Jiri Pirko
Thu, Oct 12, 2017 at 03:34:20PM CEST, steven.l...@broadcom.com wrote:
>+
>+  /* When config doesn't take effect until next reboot (config
>+   * just changed NVM which isn't read until boot, for example),
>+   * this attribute should be set by the driver.
>+   */
>+  DEVLINK_ATTR_RESTART_REQUIRED,  /* u8 */
>+

I think it would be nice to return this information as a part of retply
to set message - extack

Also, we need to expose to the user the original value (currently being
used) and the new one (to be used after driver re-instatiation)



Re: [RFC 1/3] devlink: Add config parameter get/set operations

2017-10-12 Thread Jiri Pirko
Thu, Oct 12, 2017 at 03:34:20PM CEST, steven.l...@broadcom.com wrote:
>Add support for config parameter get/set commands. Initially used by
>bnxt driver, but other drivers can use the same, or new, attributes.
>The config_get() and config_set() operations operate as expected, but
>note that the driver implementation of the config_set() operation can
>indicate whether a restart is necessary for the setting to take
>effect.
>

First of all, I like this approach.

I would like to see this patch split into:
1) config-options infrastructure introduction
2) specific config options introductions - would be best to have it
   per-option. We need to make sure every option is very well described
   and explained usecases. This is needed in order vendors to share
   attributes among drivers.

More nits inlined.


>Signed-off-by: Steve Lin 
>Acked-by: Andy Gospodarek 
>---
> include/net/devlink.h|   4 +
> include/uapi/linux/devlink.h | 108 ++
> net/core/devlink.c   | 207 +++
> 3 files changed, 319 insertions(+)
>
>diff --git a/include/net/devlink.h b/include/net/devlink.h
>index b9654e1..952966c 100644
>--- a/include/net/devlink.h
>+++ b/include/net/devlink.h
>@@ -270,6 +270,10 @@ struct devlink_ops {
>   int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode);
>   int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 
> *p_encap_mode);
>   int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode);
>+  int (*config_get)(struct devlink *devlink, enum devlink_attr attr,
>+u32 *value);
>+  int (*config_set)(struct devlink *devlink, enum devlink_attr attr,
>+u32 value, u8 *restart_reqd);
> };
> 
> static inline void *devlink_priv(struct devlink *devlink)
>diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>index 0cbca96..e959716 100644
>--- a/include/uapi/linux/devlink.h
>+++ b/include/uapi/linux/devlink.h
>@@ -70,6 +70,9 @@ enum devlink_command {
>   DEVLINK_CMD_DPIPE_HEADERS_GET,
>   DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
> 
>+  DEVLINK_CMD_CONFIG_GET,
>+  DEVLINK_CMD_CONFIG_SET,
>+
>   /* add new commands above here */
>   __DEVLINK_CMD_MAX,
>   DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
>@@ -124,6 +127,68 @@ enum devlink_eswitch_encap_mode {
>   DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
> };
> 
>+enum devlink_dcbx_mode {
>+  DEVLINK_DCBX_MODE_DISABLED,
>+  DEVLINK_DCBX_MODE_IEEE,
>+  DEVLINK_DCBX_MODE_CEE,
>+  DEVLINK_DCBX_MODE_IEEE_CEE,
>+};
>+
>+enum devlink_multifunc_mode {
>+  DEVLINK_MULTIFUNC_MODE_ALLOWED, /* Ext switch activates MF */
>+  DEVLINK_MULTIFUNC_MODE_FORCE_SINGFUNC,
>+  DEVLINK_MULTIFUNC_MODE_NPAR10,  /* NPAR 1.0 */
>+  DEVLINK_MULTIFUNC_MODE_NPAR15,  /* NPAR 1.5 */
>+  DEVLINK_MULTIFUNC_MODE_NPAR20,  /* NPAR 2.0 */
>+};
>+
>+enum devlink_autoneg_protocol {
>+  DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY_BAM,
>+  DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY_CONSORTIUM,
>+  DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY,
>+  DEVLINK_AUTONEG_PROTOCOL_BAM,   /* Broadcom Autoneg Mode */
>+  DEVLINK_AUTONEG_PROTOCOL_CONSORTIUM,/* Consortium Autoneg Mode */
>+};
>+
>+enum devlink_pre_os_link_speed {
>+  DEVLINK_PRE_OS_LINK_SPEED_AUTONEG,
>+  DEVLINK_PRE_OS_LINK_SPEED_1G,
>+  DEVLINK_PRE_OS_LINK_SPEED_10G,
>+  DEVLINK_PRE_OS_LINK_SPEED_25G,
>+  DEVLINK_PRE_OS_LINK_SPEED_40G,
>+  DEVLINK_PRE_OS_LINK_SPEED_50G,
>+  DEVLINK_PRE_OS_LINK_SPEED_100G,
>+  DEVLINK_PRE_OS_LINK_SPEED_5G = 0xe,
>+  DEVLINK_PRE_OS_LINK_SPEED_100M = 0xf,
>+};
>+
>+enum devlink_mba_boot_type {
>+  DEVLINK_MBA_BOOT_TYPE_AUTO_DETECT,
>+  DEVLINK_MBA_BOOT_TYPE_BBS,  /* BIOS Boot Specification */
>+  DEVLINK_MBA_BOOT_TYPE_INTR18,   /* Hook interrupt 0x18 */
>+  DEVLINK_MBA_BOOT_TYPE_INTR19,   /* Hook interrupt 0x19 */
>+};
>+
>+enum devlink_mba_setup_hot_key {
>+  DEVLINK_MBA_SETUP_HOT_KEY_CTRL_S,
>+  DEVLINK_MBA_SETUP_HOT_KEY_CTRL_B,
>+};
>+
>+enum devlink_mba_boot_protocol {
>+  DEVLINK_MBA_BOOT_PROTOCOL_PXE,
>+  DEVLINK_MBA_BOOT_PROTOCOL_ISCSI,
>+  DEVLINK_MBA_BOOT_PROTOCOL_NONE = 0x7,
>+};
>+
>+enum devlink_mba_link_speed {
>+  DEVLINK_MBA_LINK_SPEED_AUTONEG,
>+  DEVLINK_MBA_LINK_SPEED_1G,
>+  DEVLINK_MBA_LINK_SPEED_10G,
>+  DEVLINK_MBA_LINK_SPEED_25G,
>+  DEVLINK_MBA_LINK_SPEED_40G,
>+  DEVLINK_MBA_LINK_SPEED_50G,
>+};
>+
> enum devlink_attr {
>   /* don't change the order or add anything between, this is ABI! */
>   DEVLINK_ATTR_UNSPEC,
>@@ -202,6 +267,49 @@ enum devlink_attr {
> 
>   DEVLINK_ATTR_ESWITCH_ENCAP_MODE,/* u8 */
> 
>+  /* Configuration Parameters */
>+  DEVLINK_ATTR_SRIOV_ENABLED, /* u8 */
>+  DEVLINK_ATTR_NUM_VF_PER_PF, /* u32 */
>+  DEVLINK_ATTR_MAX_NUM_PF

[RFC 1/3] devlink: Add config parameter get/set operations

2017-10-12 Thread Steve Lin
Add support for config parameter get/set commands. Initially used by
bnxt driver, but other drivers can use the same, or new, attributes.
The config_get() and config_set() operations operate as expected, but
note that the driver implementation of the config_set() operation can
indicate whether a restart is necessary for the setting to take
effect.

Signed-off-by: Steve Lin 
Acked-by: Andy Gospodarek 
---
 include/net/devlink.h|   4 +
 include/uapi/linux/devlink.h | 108 ++
 net/core/devlink.c   | 207 +++
 3 files changed, 319 insertions(+)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index b9654e1..952966c 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -270,6 +270,10 @@ struct devlink_ops {
int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode);
int (*eswitch_encap_mode_get)(struct devlink *devlink, u8 
*p_encap_mode);
int (*eswitch_encap_mode_set)(struct devlink *devlink, u8 encap_mode);
+   int (*config_get)(struct devlink *devlink, enum devlink_attr attr,
+ u32 *value);
+   int (*config_set)(struct devlink *devlink, enum devlink_attr attr,
+ u32 value, u8 *restart_reqd);
 };
 
 static inline void *devlink_priv(struct devlink *devlink)
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 0cbca96..e959716 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -70,6 +70,9 @@ enum devlink_command {
DEVLINK_CMD_DPIPE_HEADERS_GET,
DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
 
+   DEVLINK_CMD_CONFIG_GET,
+   DEVLINK_CMD_CONFIG_SET,
+
/* add new commands above here */
__DEVLINK_CMD_MAX,
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
@@ -124,6 +127,68 @@ enum devlink_eswitch_encap_mode {
DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
 };
 
+enum devlink_dcbx_mode {
+   DEVLINK_DCBX_MODE_DISABLED,
+   DEVLINK_DCBX_MODE_IEEE,
+   DEVLINK_DCBX_MODE_CEE,
+   DEVLINK_DCBX_MODE_IEEE_CEE,
+};
+
+enum devlink_multifunc_mode {
+   DEVLINK_MULTIFUNC_MODE_ALLOWED, /* Ext switch activates MF */
+   DEVLINK_MULTIFUNC_MODE_FORCE_SINGFUNC,
+   DEVLINK_MULTIFUNC_MODE_NPAR10,  /* NPAR 1.0 */
+   DEVLINK_MULTIFUNC_MODE_NPAR15,  /* NPAR 1.5 */
+   DEVLINK_MULTIFUNC_MODE_NPAR20,  /* NPAR 2.0 */
+};
+
+enum devlink_autoneg_protocol {
+   DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY_BAM,
+   DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY_CONSORTIUM,
+   DEVLINK_AUTONEG_PROTOCOL_IEEE8023BY,
+   DEVLINK_AUTONEG_PROTOCOL_BAM,   /* Broadcom Autoneg Mode */
+   DEVLINK_AUTONEG_PROTOCOL_CONSORTIUM,/* Consortium Autoneg Mode */
+};
+
+enum devlink_pre_os_link_speed {
+   DEVLINK_PRE_OS_LINK_SPEED_AUTONEG,
+   DEVLINK_PRE_OS_LINK_SPEED_1G,
+   DEVLINK_PRE_OS_LINK_SPEED_10G,
+   DEVLINK_PRE_OS_LINK_SPEED_25G,
+   DEVLINK_PRE_OS_LINK_SPEED_40G,
+   DEVLINK_PRE_OS_LINK_SPEED_50G,
+   DEVLINK_PRE_OS_LINK_SPEED_100G,
+   DEVLINK_PRE_OS_LINK_SPEED_5G = 0xe,
+   DEVLINK_PRE_OS_LINK_SPEED_100M = 0xf,
+};
+
+enum devlink_mba_boot_type {
+   DEVLINK_MBA_BOOT_TYPE_AUTO_DETECT,
+   DEVLINK_MBA_BOOT_TYPE_BBS,  /* BIOS Boot Specification */
+   DEVLINK_MBA_BOOT_TYPE_INTR18,   /* Hook interrupt 0x18 */
+   DEVLINK_MBA_BOOT_TYPE_INTR19,   /* Hook interrupt 0x19 */
+};
+
+enum devlink_mba_setup_hot_key {
+   DEVLINK_MBA_SETUP_HOT_KEY_CTRL_S,
+   DEVLINK_MBA_SETUP_HOT_KEY_CTRL_B,
+};
+
+enum devlink_mba_boot_protocol {
+   DEVLINK_MBA_BOOT_PROTOCOL_PXE,
+   DEVLINK_MBA_BOOT_PROTOCOL_ISCSI,
+   DEVLINK_MBA_BOOT_PROTOCOL_NONE = 0x7,
+};
+
+enum devlink_mba_link_speed {
+   DEVLINK_MBA_LINK_SPEED_AUTONEG,
+   DEVLINK_MBA_LINK_SPEED_1G,
+   DEVLINK_MBA_LINK_SPEED_10G,
+   DEVLINK_MBA_LINK_SPEED_25G,
+   DEVLINK_MBA_LINK_SPEED_40G,
+   DEVLINK_MBA_LINK_SPEED_50G,
+};
+
 enum devlink_attr {
/* don't change the order or add anything between, this is ABI! */
DEVLINK_ATTR_UNSPEC,
@@ -202,6 +267,49 @@ enum devlink_attr {
 
DEVLINK_ATTR_ESWITCH_ENCAP_MODE,/* u8 */
 
+   /* Configuration Parameters */
+   DEVLINK_ATTR_SRIOV_ENABLED, /* u8 */
+   DEVLINK_ATTR_NUM_VF_PER_PF, /* u32 */
+   DEVLINK_ATTR_MAX_NUM_PF_MSIX_VECT,  /* u32 */
+   DEVLINK_ATTR_MSIX_VECTORS_PER_VF,   /* u32 */
+   DEVLINK_ATTR_NPAR_NUM_PARTITIONS_PER_PORT,  /* u32 */
+   DEVLINK_ATTR_NPAR_BW_IN_PERCENT,/* u8 */
+   DEVLINK_ATTR_NPAR_BW_RESERVATION,   /* u8 */
+   DEVLINK_ATTR_NPAR_BW_RESERVATION_VALID, /* u8 */
+   DEVLINK_ATTR_NPAR_BW_LIMIT, /* u8 */
+   DEVLINK_ATTR_NPAR_BW_LIMIT_VALID,   /* u8 */
+   DEVLINK_ATTR_DCBX_MODE, /* u8 */
+   DEVLINK_ATTR_RDMA_