All of lore.kernel.org
 help / color / mirror / Atom feed
From: maxg@mellanox.com (Max Gurtovoy)
Subject: [PATCH rfc 2/4] nvmet: don't override treq upon modification.
Date: Sun, 7 Oct 2018 02:01:51 +0300	[thread overview]
Message-ID: <69faa49f-6ba6-41ee-7b88-4b0b14f3a26e@mellanox.com> (raw)
In-Reply-To: <20181002001422.9111-3-sagi@grimberg.me>



On 10/2/2018 3:14 AM, Sagi Grimberg wrote:
> Only override the allowed parts of it.
> 
> Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
> ---
>   drivers/nvme/target/configfs.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index b37a8e3e3f80..53b88858ee97 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -148,7 +148,7 @@ CONFIGFS_ATTR(nvmet_, addr_traddr);
>   static ssize_t nvmet_addr_treq_show(struct config_item *item,
>   		char *page)
>   {
> -	switch (to_nvmet_port(item)->disc_addr.treq) {
> +	switch (to_nvmet_port(item)->disc_addr.treq & 0x3) {

can you use some MACRO for 0x3 ? this will make the code more readable.

>   	case NVMF_TREQ_NOT_SPECIFIED:
>   		return sprintf(page, "not specified\n");
>   	case NVMF_TREQ_REQUIRED:
> @@ -164,6 +164,7 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item,
>   		const char *page, size_t count)
>   {
>   	struct nvmet_port *port = to_nvmet_port(item);
> +	u8 treq = port->disc_addr.treq & 0xfc;

also for 0xfc.

>   
>   	if (port->enabled) {
>   		pr_err("Cannot modify address while enabled\n");
> @@ -172,15 +173,16 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item,
>   	}
>   
>   	if (sysfs_streq(page, "not specified")) {
> -		port->disc_addr.treq = NVMF_TREQ_NOT_SPECIFIED;
> +		treq |= NVMF_TREQ_NOT_SPECIFIED;
>   	} else if (sysfs_streq(page, "required")) {
> -		port->disc_addr.treq = NVMF_TREQ_REQUIRED;
> +		treq |= NVMF_TREQ_REQUIRED;
>   	} else if (sysfs_streq(page, "not required")) {
> -		port->disc_addr.treq = NVMF_TREQ_NOT_REQUIRED;
> +		treq |= NVMF_TREQ_NOT_REQUIRED;
>   	} else {
>   		pr_err("Invalid value '%s' for treq\n", page);
>   		return -EINVAL;
>   	}
> +	port->disc_addr.treq = treq;
>   
>   	return count;
>   }
> 

  parent reply	other threads:[~2018-10-06 23:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02  0:14 [PATCH rfc 0/4] Support SQ flow control disabled mode (TP 8005) Sagi Grimberg
2018-10-02  0:14 ` [PATCH rfc 1/4] nvmet: support fabrics sq flow control Sagi Grimberg
2018-10-02 14:03   ` Hannes Reinecke
2018-10-02  0:14 ` [PATCH rfc 2/4] nvmet: don't override treq upon modification Sagi Grimberg
2018-10-02 14:04   ` Hannes Reinecke
2018-10-06 23:01   ` Max Gurtovoy [this message]
2018-10-02  0:14 ` [PATCH rfc 3/4] nvmet: expose support for fabrics SQ flow control disable in treq Sagi Grimberg
2018-10-02 14:04   ` Hannes Reinecke
2018-10-02  0:14 ` [PATCH rfc 4/4] nvme: Ask for fabrics SQ flow control disable by default Sagi Grimberg
2018-10-02 14:08   ` Hannes Reinecke
2018-10-02 16:17     ` Sagi Grimberg

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=69faa49f-6ba6-41ee-7b88-4b0b14f3a26e@mellanox.com \
    --to=maxg@mellanox.com \
    /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.