Re: svn commit: r325796 - head/sys/cam/nvme

2017-11-14 Thread Ravi Pokala
Well that's wonderfully ambiguous... :-p

Okay, thanks for clearing that up.

-Ravi (rpokala@)

-Original Message-
From: <wl...@bsdimp.com> on behalf of Warner Losh <i...@bsdimp.com>
Date: 2017-11-14, Tuesday at 12:38
To: Ravi Pokala <rpok...@mac.com>
Cc: Warner Losh <i...@freebsd.org>, src-committers 
<src-committ...@freebsd.org>, "svn-src-...@freebsd.org" 
<svn-src-...@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>
Subject: Re: svn commit: r325796 - head/sys/cam/nvme



On Mon, Nov 13, 2017 at 10:35 PM, Ravi Pokala <rpok...@mac.com> wrote:

In r325794, you set speed/max_speed to a KBps value; here, you're reporting 
those values as PCI Generation. That's... not right.



Two different CCBs. The PATH_INQ one returns a general KB/s number. The 
GET_TRANSPORT one returns the raw numbers.

Warner

 

-Ravi (rpokala@)

-Original Message-
From: <owner-src-committ...@freebsd.org> on behalf of Warner Losh 
<i...@freebsd.org>
Date: 2017-11-13, Monday at 21:05
To: <src-committ...@freebsd.org>, <svn-src-...@freebsd.org>, 
<svn-src-head@freebsd.org>
Subject: svn commit: r325796 - head/sys/cam/nvme

Author: imp
Date: Tue Nov 14 05:05:26 2017
New Revision: 325796
URL: https://svnweb.freebsd.org/changeset/base/325796

Log:
  Properly decode NVMe state of the drive and print out the information
  in the attach to more closely match what SCSI and ATA attached
  storage provides.

  Sponsored by: Netflix

Modified:
  head/sys/cam/nvme/nvme_all.c
  head/sys/cam/nvme/nvme_all.h
  head/sys/cam/nvme/nvme_xpt.c

Modified: head/sys/cam/nvme/nvme_all.c
==
--- head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:26 2017
(r325796)
@@ -87,9 +87,16 @@ nvme_identify_match(caddr_t identbuffer, caddr_t table

 void
 nvme_print_ident(const struct nvme_controller_data *cdata,
-const struct nvme_namespace_data *data)
+const struct nvme_namespace_data *data, struct sbuf *sb)
 {
-   printf("I'm a pretty NVME drive\n");
+
+   sbuf_printf(sb, "<");
+   cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn), 0);
+   sbuf_printf(sb, " ");
+   cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr), 0);
+   sbuf_printf(sb, " ");
+   cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn), 0);
+   sbuf_printf(sb, ">\n");
 }

 /* XXX need to do nvme admin opcodes too, but those aren't used yet by nda */

Modified: head/sys/cam/nvme/nvme_all.h
==
--- head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:26 2017
(r325796)
@@ -39,7 +39,8 @@ void  nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cm

 intnvme_identify_match(caddr_t identbuffer, caddr_t table_entry);

-void   nvme_print_ident(const struct nvme_controller_data *, const struct 
nvme_namespace_data *);
+struct sbuf;
+void   nvme_print_ident(const struct nvme_controller_data *, const struct 
nvme_namespace_data *, struct sbuf *);
 const char *nvme_op_string(const struct nvme_command *);
 const char *nvme_cmd_string(const struct nvme_command *, char *, size_t);
 const void *nvme_get_identify_cntrl(struct cam_periph *);

Modified: head/sys/cam/nvme/nvme_xpt.c
==
--- head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:26 2017
(r325796)
@@ -619,35 +619,49 @@ nvme_announce_periph(struct cam_periph *periph)
struct  ccb_pathinq cpi;
struct  ccb_trans_settings cts;
struct  cam_path *path = periph->path;
+   struct ccb_trans_settings_nvme  *nvmex;

cam_periph_assert(periph, MA_OWNED);

+   /* Ask the SIM for connection details */
xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cts.type = CTS_TYPE_CURRENT_SETTINGS;
xpt_action((union ccb*));
if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
return;
+   nvmex = _specific.nvme;
+
/* Ask the SIM for its base transfer speed */
xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *));
-   /* XXX NVME STUFF HERE */
+   printf("%s%d: nvme version %d.%d x%d (max x%d) lanes PCIe Gen%d (max 
Gen%d) link",
+   periph->periph_name, periph->unit_number,
+   NVME_MAJOR(nvmex->spec),
+   NVME_MINOR(nvmex->spec),
+   nvmex->lanes, nvmex-&

Re: svn commit: r325796 - head/sys/cam/nvme

2017-11-14 Thread Warner Losh
On Mon, Nov 13, 2017 at 10:35 PM, Ravi Pokala <rpok...@mac.com> wrote:

> In r325794, you set speed/max_speed to a KBps value; here, you're
> reporting those values as PCI Generation. That's... not right.
>

Two different CCBs. The PATH_INQ one returns a general KB/s number. The
GET_TRANSPORT one returns the raw numbers.

Warner



> -Ravi (rpokala@)
>
> -Original Message-
> From: <owner-src-committ...@freebsd.org> on behalf of Warner Losh
> <i...@freebsd.org>
> Date: 2017-11-13, Monday at 21:05
> To: <src-committ...@freebsd.org>, <svn-src-...@freebsd.org>, <
> svn-src-head@freebsd.org>
> Subject: svn commit: r325796 - head/sys/cam/nvme
>
> Author: imp
> Date: Tue Nov 14 05:05:26 2017
> New Revision: 325796
> URL: https://svnweb.freebsd.org/changeset/base/325796
>
> Log:
>   Properly decode NVMe state of the drive and print out the information
>   in the attach to more closely match what SCSI and ATA attached
>   storage provides.
>
>   Sponsored by: Netflix
>
> Modified:
>   head/sys/cam/nvme/nvme_all.c
>   head/sys/cam/nvme/nvme_all.h
>   head/sys/cam/nvme/nvme_xpt.c
>
> Modified: head/sys/cam/nvme/nvme_all.c
> 
> ==
> --- head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:21 2017
> (r325795)
> +++ head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:26 2017
> (r325796)
> @@ -87,9 +87,16 @@ nvme_identify_match(caddr_t identbuffer, caddr_t table
>
>  void
>  nvme_print_ident(const struct nvme_controller_data *cdata,
> -const struct nvme_namespace_data *data)
> +const struct nvme_namespace_data *data, struct sbuf *sb)
>  {
> -   printf("I'm a pretty NVME drive\n");
> +
> +   sbuf_printf(sb, "<");
> +   cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn), 0);
> +   sbuf_printf(sb, " ");
> +   cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr), 0);
> +   sbuf_printf(sb, " ");
> +   cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn), 0);
> +   sbuf_printf(sb, ">\n");
>  }
>
>  /* XXX need to do nvme admin opcodes too, but those aren't used yet by
> nda */
>
> Modified: head/sys/cam/nvme/nvme_all.h
> 
> ==
> --- head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:21 2017
> (r325795)
> +++ head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:26 2017
> (r325796)
> @@ -39,7 +39,8 @@ void  nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cm
>
>  intnvme_identify_match(caddr_t identbuffer, caddr_t table_entry);
>
> -void   nvme_print_ident(const struct nvme_controller_data *, const struct
> nvme_namespace_data *);
> +struct sbuf;
> +void   nvme_print_ident(const struct nvme_controller_data *, const struct
> nvme_namespace_data *, struct sbuf *);
>  const char *nvme_op_string(const struct nvme_command *);
>  const char *nvme_cmd_string(const struct nvme_command *, char *, size_t);
>  const void *nvme_get_identify_cntrl(struct cam_periph *);
>
> Modified: head/sys/cam/nvme/nvme_xpt.c
> 
> ==
> --- head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:21 2017
> (r325795)
> +++ head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:26 2017
> (r325796)
> @@ -619,35 +619,49 @@ nvme_announce_periph(struct cam_periph *periph)
> struct  ccb_pathinq cpi;
> struct  ccb_trans_settings cts;
> struct  cam_path *path = periph->path;
> +   struct ccb_trans_settings_nvme  *nvmex;
>
> cam_periph_assert(periph, MA_OWNED);
>
> +   /* Ask the SIM for connection details */
> xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
> cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
> cts.type = CTS_TYPE_CURRENT_SETTINGS;
> xpt_action((union ccb*));
> if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
> return;
> +   nvmex = _specific.nvme;
> +
> /* Ask the SIM for its base transfer speed */
> xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
> cpi.ccb_h.func_code = XPT_PATH_INQ;
> xpt_action((union ccb *));
> -   /* XXX NVME STUFF HERE */
> +   printf("%s%d: nvme version %d.%d x%d (max x%d) lanes PCIe Gen%d
> (max Gen%d) link",
> +   periph->periph_name, periph->unit_number,
> +   NVME_MAJOR(nvmex->spec),
> +   NVME_MINOR(nvmex->spec),
> +   nvmex->lanes, nvmex->max_lanes,
> +   nvmex->speed, nvmex->

Re: svn commit: r325796 - head/sys/cam/nvme

2017-11-13 Thread Ravi Pokala
In r325794, you set speed/max_speed to a KBps value; here, you're reporting 
those values as PCI Generation. That's... not right.

-Ravi (rpokala@)

-Original Message-
From: <owner-src-committ...@freebsd.org> on behalf of Warner Losh 
<i...@freebsd.org>
Date: 2017-11-13, Monday at 21:05
To: <src-committ...@freebsd.org>, <svn-src-...@freebsd.org>, 
<svn-src-head@freebsd.org>
Subject: svn commit: r325796 - head/sys/cam/nvme

Author: imp
Date: Tue Nov 14 05:05:26 2017
New Revision: 325796
URL: https://svnweb.freebsd.org/changeset/base/325796

Log:
  Properly decode NVMe state of the drive and print out the information
  in the attach to more closely match what SCSI and ATA attached
  storage provides.
  
  Sponsored by: Netflix

Modified:
  head/sys/cam/nvme/nvme_all.c
  head/sys/cam/nvme/nvme_all.h
  head/sys/cam/nvme/nvme_xpt.c

Modified: head/sys/cam/nvme/nvme_all.c
==
--- head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:26 2017
(r325796)
@@ -87,9 +87,16 @@ nvme_identify_match(caddr_t identbuffer, caddr_t table
 
 void
 nvme_print_ident(const struct nvme_controller_data *cdata,
-const struct nvme_namespace_data *data)
+const struct nvme_namespace_data *data, struct sbuf *sb)
 {
-   printf("I'm a pretty NVME drive\n");
+
+   sbuf_printf(sb, "<");
+   cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn), 0);
+   sbuf_printf(sb, " ");
+   cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr), 0);
+   sbuf_printf(sb, " ");
+   cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn), 0);
+   sbuf_printf(sb, ">\n");
 }
 
 /* XXX need to do nvme admin opcodes too, but those aren't used yet by nda */

Modified: head/sys/cam/nvme/nvme_all.h
==
--- head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:26 2017
(r325796)
@@ -39,7 +39,8 @@ void  nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cm
 
 intnvme_identify_match(caddr_t identbuffer, caddr_t table_entry);
 
-void   nvme_print_ident(const struct nvme_controller_data *, const struct 
nvme_namespace_data *);
+struct sbuf;
+void   nvme_print_ident(const struct nvme_controller_data *, const struct 
nvme_namespace_data *, struct sbuf *);
 const char *nvme_op_string(const struct nvme_command *);
 const char *nvme_cmd_string(const struct nvme_command *, char *, size_t);
 const void *nvme_get_identify_cntrl(struct cam_periph *);

Modified: head/sys/cam/nvme/nvme_xpt.c
==
--- head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:26 2017
(r325796)
@@ -619,35 +619,49 @@ nvme_announce_periph(struct cam_periph *periph)
struct  ccb_pathinq cpi;
struct  ccb_trans_settings cts;
struct  cam_path *path = periph->path;
+   struct ccb_trans_settings_nvme  *nvmex;
 
cam_periph_assert(periph, MA_OWNED);
 
+   /* Ask the SIM for connection details */
xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cts.type = CTS_TYPE_CURRENT_SETTINGS;
xpt_action((union ccb*));
if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
return;
+   nvmex = _specific.nvme;
+
/* Ask the SIM for its base transfer speed */
xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *));
-   /* XXX NVME STUFF HERE */
+   printf("%s%d: nvme version %d.%d x%d (max x%d) lanes PCIe Gen%d (max 
Gen%d) link",
+   periph->periph_name, periph->unit_number,
+   NVME_MAJOR(nvmex->spec),
+   NVME_MINOR(nvmex->spec),
+   nvmex->lanes, nvmex->max_lanes,
+   nvmex->speed, nvmex->max_speed);
printf("\n");
 }
 
 static void
 nvme_proto_announce(struct cam_ed *device)
 {
+   struct sbuf sb;
+   charbuffer[120];
 
-   nvme_print_ident(device->nvme_cdata, device->nvme_data);
+   sbuf_new(, buffer, sizeof(buffer), SBUF_FIXEDLEN);
+   nvme_print_ident(device->nvme_cdata, device->nvme_data, );
+   sbuf_finish();
+   sbuf_putbuf();
 }
 
 static void
 nvme_proto_denounce(struct cam_ed *device)
 {
 
-   nvme_print_ident(device->nvme_cdata, device->nvme_data);
+   nvme_proto_announce(device);
 }
 
 static void




___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325796 - head/sys/cam/nvme

2017-11-13 Thread Warner Losh
Author: imp
Date: Tue Nov 14 05:05:26 2017
New Revision: 325796
URL: https://svnweb.freebsd.org/changeset/base/325796

Log:
  Properly decode NVMe state of the drive and print out the information
  in the attach to more closely match what SCSI and ATA attached
  storage provides.
  
  Sponsored by: Netflix

Modified:
  head/sys/cam/nvme/nvme_all.c
  head/sys/cam/nvme/nvme_all.h
  head/sys/cam/nvme/nvme_xpt.c

Modified: head/sys/cam/nvme/nvme_all.c
==
--- head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_all.cTue Nov 14 05:05:26 2017
(r325796)
@@ -87,9 +87,16 @@ nvme_identify_match(caddr_t identbuffer, caddr_t table
 
 void
 nvme_print_ident(const struct nvme_controller_data *cdata,
-const struct nvme_namespace_data *data)
+const struct nvme_namespace_data *data, struct sbuf *sb)
 {
-   printf("I'm a pretty NVME drive\n");
+
+   sbuf_printf(sb, "<");
+   cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn), 0);
+   sbuf_printf(sb, " ");
+   cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr), 0);
+   sbuf_printf(sb, " ");
+   cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn), 0);
+   sbuf_printf(sb, ">\n");
 }
 
 /* XXX need to do nvme admin opcodes too, but those aren't used yet by nda */

Modified: head/sys/cam/nvme/nvme_all.h
==
--- head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_all.hTue Nov 14 05:05:26 2017
(r325796)
@@ -39,7 +39,8 @@ void  nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cm
 
 intnvme_identify_match(caddr_t identbuffer, caddr_t table_entry);
 
-void   nvme_print_ident(const struct nvme_controller_data *, const struct 
nvme_namespace_data *);
+struct sbuf;
+void   nvme_print_ident(const struct nvme_controller_data *, const struct 
nvme_namespace_data *, struct sbuf *);
 const char *nvme_op_string(const struct nvme_command *);
 const char *nvme_cmd_string(const struct nvme_command *, char *, size_t);
 const void *nvme_get_identify_cntrl(struct cam_periph *);

Modified: head/sys/cam/nvme/nvme_xpt.c
==
--- head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:21 2017
(r325795)
+++ head/sys/cam/nvme/nvme_xpt.cTue Nov 14 05:05:26 2017
(r325796)
@@ -619,35 +619,49 @@ nvme_announce_periph(struct cam_periph *periph)
struct  ccb_pathinq cpi;
struct  ccb_trans_settings cts;
struct  cam_path *path = periph->path;
+   struct ccb_trans_settings_nvme  *nvmex;
 
cam_periph_assert(periph, MA_OWNED);
 
+   /* Ask the SIM for connection details */
xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cts.type = CTS_TYPE_CURRENT_SETTINGS;
xpt_action((union ccb*));
if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
return;
+   nvmex = _specific.nvme;
+
/* Ask the SIM for its base transfer speed */
xpt_setup_ccb(_h, path, CAM_PRIORITY_NORMAL);
cpi.ccb_h.func_code = XPT_PATH_INQ;
xpt_action((union ccb *));
-   /* XXX NVME STUFF HERE */
+   printf("%s%d: nvme version %d.%d x%d (max x%d) lanes PCIe Gen%d (max 
Gen%d) link",
+   periph->periph_name, periph->unit_number,
+   NVME_MAJOR(nvmex->spec),
+   NVME_MINOR(nvmex->spec),
+   nvmex->lanes, nvmex->max_lanes,
+   nvmex->speed, nvmex->max_speed);
printf("\n");
 }
 
 static void
 nvme_proto_announce(struct cam_ed *device)
 {
+   struct sbuf sb;
+   charbuffer[120];
 
-   nvme_print_ident(device->nvme_cdata, device->nvme_data);
+   sbuf_new(, buffer, sizeof(buffer), SBUF_FIXEDLEN);
+   nvme_print_ident(device->nvme_cdata, device->nvme_data, );
+   sbuf_finish();
+   sbuf_putbuf();
 }
 
 static void
 nvme_proto_denounce(struct cam_ed *device)
 {
 
-   nvme_print_ident(device->nvme_cdata, device->nvme_data);
+   nvme_proto_announce(device);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"