NVME support is only for x86 and powerpc64.

Implement MK_NVME now that the expression for where NVMe is
complicated. Default it to "yes" for x86 and powerpc64 and
no everywhere else. Use it in camcontrol to define WITH_NVME
for those platforms where we support nvme.

This should fix the newly introduced nvme files to camcontrol
which were building everywhere.

Pointy Hat To: imp
Sponsored by: Netflix
This commit is contained in:
Warner Losh 2018-06-14 01:15:19 +00:00
parent 21e289d49b
commit f0f8a1af01
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335101
7 changed files with 27 additions and 4 deletions

View File

@ -82,6 +82,7 @@ SUBDIR.${MK_IPFW}+= natd
SUBDIR.${MK_ISCSI}+= iscontrol SUBDIR.${MK_ISCSI}+= iscontrol
SUBDIR.${MK_NAND}+= nandfs SUBDIR.${MK_NAND}+= nandfs
SUBDIR.${MK_NAND}+= newfs_nandfs SUBDIR.${MK_NAND}+= newfs_nandfs
SUBDIR.${MK_NVME}+= nvmecontrol
SUBDIR.${MK_OPENSSL}+= decryptcore SUBDIR.${MK_OPENSSL}+= decryptcore
SUBDIR.${MK_PF}+= pfctl SUBDIR.${MK_PF}+= pfctl
SUBDIR.${MK_PF}+= pflogd SUBDIR.${MK_PF}+= pflogd

View File

@ -2,4 +2,3 @@
SUBDIR += bsdlabel SUBDIR += bsdlabel
SUBDIR += fdisk SUBDIR += fdisk
SUBDIR += nvmecontrol

View File

@ -2,5 +2,4 @@
SUBDIR += bsdlabel SUBDIR += bsdlabel
SUBDIR += fdisk SUBDIR += fdisk
SUBDIR += nvmecontrol
SUBDIR += sconfig SUBDIR += sconfig

View File

@ -2,4 +2,3 @@
SUBDIR += bsdlabel SUBDIR += bsdlabel
SUBDIR += fdisk SUBDIR += fdisk
SUBDIR += nvmecontrol

View File

@ -1,5 +1,7 @@
# $FreeBSD$ # $FreeBSD$
.include <src.opts.mk>
PACKAGE=runtime PACKAGE=runtime
PROG= camcontrol PROG= camcontrol
SRCS= camcontrol.c util.c SRCS= camcontrol.c util.c
@ -8,11 +10,13 @@ SRCS+= attrib.c epc.c fwdownload.c modeedit.c persist.c progress.c timestamp.c z
.else .else
CFLAGS+= -DMINIMALISTIC CFLAGS+= -DMINIMALISTIC
.endif .endif
.if ${MK_NVME} != "no"
.PATH: ${SRCTOP}/sbin/nvmecontrol .PATH: ${SRCTOP}/sbin/nvmecontrol
CFLAGS+= -I${SRCTOP}/sbin/nvmecontrol CFLAGS+= -I${SRCTOP}/sbin/nvmecontrol -DWITH_NVME
SRCS+= identify_ext.c nc_util.c SRCS+= identify_ext.c nc_util.c
.PATH: ${SRCTOP}/sys/dev/nvme .PATH: ${SRCTOP}/sys/dev/nvme
SRCS+= nvme_util.c SRCS+= nvme_util.c
.endif
# This is verboten # This is verboten
.if ${MACHINE_CPUARCH} == "arm" .if ${MACHINE_CPUARCH} == "arm"
WARNS?= 3 WARNS?= 3

View File

@ -63,7 +63,9 @@ __FBSDID("$FreeBSD$");
#include <cam/mmc/mmc_all.h> #include <cam/mmc/mmc_all.h>
#include <camlib.h> #include <camlib.h>
#include "camcontrol.h" #include "camcontrol.h"
#ifdef WITH_NVME
#include "nvmecontrol_ext.h" #include "nvmecontrol_ext.h"
#endif
typedef enum { typedef enum {
CAM_CMD_NONE = 0x00000000, CAM_CMD_NONE = 0x00000000,
@ -281,7 +283,9 @@ static int print_dev_ata(struct device_match_result *dev_result, char *tmpstr);
static int print_dev_semb(struct device_match_result *dev_result, char *tmpstr); static int print_dev_semb(struct device_match_result *dev_result, char *tmpstr);
static int print_dev_mmcsd(struct device_match_result *dev_result, static int print_dev_mmcsd(struct device_match_result *dev_result,
char *tmpstr); char *tmpstr);
#ifdef WITH_NVME
static int print_dev_nvme(struct device_match_result *dev_result, char *tmpstr); static int print_dev_nvme(struct device_match_result *dev_result, char *tmpstr);
#endif
#ifndef MINIMALISTIC #ifndef MINIMALISTIC
static int testunitready(struct cam_device *device, int task_attr, static int testunitready(struct cam_device *device, int task_attr,
int retry_count, int timeout, int quiet); int retry_count, int timeout, int quiet);
@ -602,12 +606,14 @@ getdevtree(int argc, char **argv, char *combinedopt)
skip_device = 1; skip_device = 1;
break; break;
} }
#ifdef WITH_NVME
} else if (dev_result->protocol == PROTO_NVME) { } else if (dev_result->protocol == PROTO_NVME) {
if (print_dev_nvme(dev_result, if (print_dev_nvme(dev_result,
&tmpstr[0]) != 0) { &tmpstr[0]) != 0) {
skip_device = 1; skip_device = 1;
break; break;
} }
#endif
} else { } else {
sprintf(tmpstr, "<>"); sprintf(tmpstr, "<>");
} }
@ -763,6 +769,7 @@ print_dev_mmcsd(struct device_match_result *dev_result, char *tmpstr)
return (0); return (0);
} }
#ifdef WITH_NVME
static int static int
nvme_get_cdata(struct cam_device *dev, struct nvme_controller_data *cdata) nvme_get_cdata(struct cam_device *dev, struct nvme_controller_data *cdata)
{ {
@ -824,6 +831,7 @@ print_dev_nvme(struct device_match_result *dev_result, char *tmpstr)
cam_close_device(dev); cam_close_device(dev);
return (0); return (0);
} }
#endif
#ifndef MINIMALISTIC #ifndef MINIMALISTIC
static int static int
@ -2402,6 +2410,7 @@ ataidentify(struct cam_device *device, int retry_count, int timeout)
return (0); return (0);
} }
#ifdef WITH_NVME
static int static int
nvmeidentify(struct cam_device *device, int retry_count __unused, int timeout __unused) nvmeidentify(struct cam_device *device, int retry_count __unused, int timeout __unused)
{ {
@ -2413,10 +2422,12 @@ nvmeidentify(struct cam_device *device, int retry_count __unused, int timeout __
return (0); return (0);
} }
#endif
static int static int
identify(struct cam_device *device, int retry_count, int timeout) identify(struct cam_device *device, int retry_count, int timeout)
{ {
#ifdef WITH_NVME
struct ccb_pathinq cpi; struct ccb_pathinq cpi;
if (get_cpi(device, &cpi) != 0) { if (get_cpi(device, &cpi) != 0) {
@ -2427,6 +2438,7 @@ identify(struct cam_device *device, int retry_count, int timeout)
if (cpi.protocol == PROTO_NVME) { if (cpi.protocol == PROTO_NVME) {
return (nvmeidentify(device, retry_count, timeout)); return (nvmeidentify(device, retry_count, timeout));
} }
#endif
return (ataidentify(device, retry_count, timeout)); return (ataidentify(device, retry_count, timeout));
} }
#endif /* MINIMALISTIC */ #endif /* MINIMALISTIC */
@ -5206,6 +5218,7 @@ cts_print(struct cam_device *device, struct ccb_trans_settings *cts)
"enabled" : "disabled"); "enabled" : "disabled");
} }
} }
#ifdef WITH_NVME
if (cts->protocol == PROTO_NVME) { if (cts->protocol == PROTO_NVME) {
struct ccb_trans_settings_nvme *nvmex = struct ccb_trans_settings_nvme *nvmex =
&cts->xport_specific.nvme; &cts->xport_specific.nvme;
@ -5222,6 +5235,7 @@ cts_print(struct cam_device *device, struct ccb_trans_settings *cts)
nvmex->speed, nvmex->max_speed); nvmex->speed, nvmex->max_speed);
} }
} }
#endif
} }
/* /*

View File

@ -322,6 +322,13 @@ __DEFAULT_NO_OPTIONS+=CXGBETOOL
__DEFAULT_NO_OPTIONS+=MLX5TOOL __DEFAULT_NO_OPTIONS+=MLX5TOOL
.endif .endif
# NVME is only x86 and powerpc64
.if ${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64"
__DEFAULT_YES_OPTIONS+=NVME
.else
__DEFAULT_NO_OPTIONS+=NVME
.endif
.include <bsd.mkopt.mk> .include <bsd.mkopt.mk>
# #