All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org
Subject: Re: [net-next v4 3/5] devlink: introduce flash update overwrite mask
Date: Thu, 10 Sep 2020 14:01:57 -0700	[thread overview]
Message-ID: <3faf14a5-e7da-2ad7-bdeb-0bbb6038c349@intel.com> (raw)
In-Reply-To: <20200909180310.27a19827@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>



On 9/9/2020 6:03 PM, Jakub Kicinski wrote:
> On Wed,  9 Sep 2020 15:26:51 -0700 Jacob Keller wrote:
>> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>> index 40d35145c879..19a573566359 100644
>> --- a/include/uapi/linux/devlink.h
>> +++ b/include/uapi/linux/devlink.h
>> @@ -228,6 +228,28 @@ enum {
>>  	DEVLINK_ATTR_STATS_MAX = __DEVLINK_ATTR_STATS_MAX - 1
>>  };
>>  
>> +/* Specify what sections of a flash component can be overwritten when
>> + * performing an update. Overwriting of firmware binary sections is always
>> + * implicitly assumed to be allowed.
>> + *
>> + * Each section must be documented in
>> + * Documentation/networking/devlink/devlink-flash.rst
>> + *
>> + */
>> +enum {
>> +	DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT,
>> +	DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT,
>> +
>> +	__DEVLINK_FLASH_OVERWRITE_MAX_BIT,
>> +	DEVLINK_FLASH_OVERWRITE_MAX_BIT = __DEVLINK_FLASH_OVERWRITE_MAX_BIT - 1
>> +};
>> +
>> +#define DEVLINK_FLASH_OVERWRITE_SETTINGS BIT(DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT)
>> +#define DEVLINK_FLASH_OVERWRITE_IDENTIFIERS BIT(DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT)
>> +
>> +#define DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS \
>> +	(BIT(__DEVLINK_FLASH_OVERWRITE_MAX_BIT) - 1)
> 
> I don't think you can use BIT() in uAPI headers :(
> 


Hmmm.. There are exactly 2 other uses I found by searching for 'BIT('
that already exists. We can chance this to just do the bit shift directly.

>>  /**
>>   * enum devlink_trap_action - Packet trap action.
>>   * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not
>> @@ -460,6 +482,9 @@ enum devlink_attr {
>>  
>>  	DEVLINK_ATTR_PORT_EXTERNAL,		/* u8 */
>>  	DEVLINK_ATTR_PORT_CONTROLLER_NUMBER,	/* u32 */
>> +
>> +	DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK,	/* bitfield32 */
>> +
>>  	/* add new attributes above here, update the policy in devlink.c */
>>  
>>  	__DEVLINK_ATTR_MAX,
>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index c61f9c8205f6..d0d38ca17ea8 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -3125,8 +3125,8 @@ static int devlink_nl_cmd_flash_update(struct sk_buff *skb,
>>  				       struct genl_info *info)
>>  {
>>  	struct devlink_flash_update_params params = {};
>> +	struct nlattr *nla_component, *nla_overwrite;
>>  	struct devlink *devlink = info->user_ptr[0];
>> -	struct nlattr *nla_component;
>>  	u32 supported_params;
>>  
>>  	if (!devlink->ops->flash_update)
>> @@ -3149,6 +3149,19 @@ static int devlink_nl_cmd_flash_update(struct sk_buff *skb,
>>  		params.component = nla_data(nla_component);
>>  	}
>>  
>> +	nla_overwrite = info->attrs[DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK];
>> +	if (nla_overwrite) {
>> +		struct nla_bitfield32 sections;
>> +
>> +		if (!(supported_params & DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK)) {
>> +			NL_SET_ERR_MSG_ATTR(info->extack, nla_overwrite,
>> +					    "overwrite is not supported");
> 
> settings ... by this device ?

Sure I can fix this along with the other location either as a follow up
or a respin if this still needs it.

Thanks,
Jake

> 
>> +			return -EOPNOTSUPP;
>> +		}
>> +		sections = nla_get_bitfield32(nla_overwrite);
>> +		params.overwrite_mask = sections.value & sections.selector;
>  
> 

  reply	other threads:[~2020-09-10 21:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 22:26 [net-next v4 0/5] devlink flash update overwrite mask Jacob Keller
2020-09-09 22:26 ` [net-next v4 1/5] devlink: check flash_update parameter support in net core Jacob Keller
2020-09-10  0:53   ` Jakub Kicinski
2020-09-09 22:26 ` [net-next v4 2/5] devlink: convert flash_update to use params structure Jacob Keller
2020-09-10  0:55   ` Jakub Kicinski
2020-09-10 20:59     ` Jacob Keller
2020-09-10 21:23       ` Jakub Kicinski
2020-09-10 21:33         ` Jacob Keller
2020-09-09 22:26 ` [net-next v4 3/5] devlink: introduce flash update overwrite mask Jacob Keller
2020-09-10  1:03   ` Jakub Kicinski
2020-09-10 21:01     ` Jacob Keller [this message]
2020-09-10 20:10   ` Jiri Pirko
2020-09-10 21:10     ` Jacob Keller
2020-09-09 22:26 ` [net-next v4 4/5] devlink: add support for overwrite mask to netdevsim Jacob Keller
2020-09-10  1:05   ` Jakub Kicinski
2020-09-10 21:02     ` Jacob Keller
2020-09-09 22:26 ` [net-next v4 5/5] ice: add support for flash update overwrite mask Jacob Keller
2020-09-10  1:06   ` Jakub Kicinski
2020-09-10 20:13 ` [net-next v4 0/5] devlink " David Miller
2020-09-10 21:03   ` Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3faf14a5-e7da-2ad7-bdeb-0bbb6038c349@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.