Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
6ee44cdc
Commit
6ee44cdc
authored
Feb 03, 2011
by
Matthew Wilcox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NVMe: Add download / activate firmware ioctls
Signed-off-by:
Matthew Wilcox
<
matthew.r.wilcox@intel.com
>
parent
7a63e07b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
6 deletions
+72
-6
drivers/block/nvme.c
drivers/block/nvme.c
+45
-0
include/linux/nvme.h
include/linux/nvme.h
+27
-6
No files found.
drivers/block/nvme.c
View file @
6ee44cdc
...
...
@@ -829,6 +829,47 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
return
status
;
}
static
int
nvme_download_firmware
(
struct
nvme_ns
*
ns
,
struct
nvme_dlfw
__user
*
udlfw
)
{
struct
nvme_dev
*
dev
=
ns
->
dev
;
struct
nvme_dlfw
dlfw
;
struct
nvme_command
c
;
int
nents
,
status
;
struct
scatterlist
*
sg
;
if
(
copy_from_user
(
&
dlfw
,
udlfw
,
sizeof
(
dlfw
)))
return
-
EFAULT
;
if
(
dlfw
.
length
>=
(
1
<<
30
))
return
-
EINVAL
;
nents
=
nvme_map_user_pages
(
dev
,
1
,
dlfw
.
addr
,
dlfw
.
length
*
4
,
&
sg
);
if
(
nents
<
0
)
return
nents
;
memset
(
&
c
,
0
,
sizeof
(
c
));
c
.
dlfw
.
opcode
=
nvme_admin_download_fw
;
c
.
dlfw
.
numd
=
cpu_to_le32
(
dlfw
.
length
);
c
.
dlfw
.
offset
=
cpu_to_le32
(
dlfw
.
offset
);
nvme_setup_prps
(
&
c
.
common
,
sg
,
dlfw
.
length
*
4
);
status
=
nvme_submit_admin_cmd
(
dev
,
&
c
,
NULL
);
nvme_unmap_user_pages
(
dev
,
0
,
dlfw
.
addr
,
dlfw
.
length
*
4
,
sg
,
nents
);
return
status
;
}
static
int
nvme_activate_firmware
(
struct
nvme_ns
*
ns
,
unsigned
long
arg
)
{
struct
nvme_dev
*
dev
=
ns
->
dev
;
struct
nvme_command
c
;
memset
(
&
c
,
0
,
sizeof
(
c
));
c
.
common
.
opcode
=
nvme_admin_activate_fw
;
c
.
common
.
rsvd10
[
0
]
=
cpu_to_le32
(
arg
);
return
nvme_submit_admin_cmd
(
dev
,
&
c
,
NULL
);
}
static
int
nvme_ioctl
(
struct
block_device
*
bdev
,
fmode_t
mode
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -843,6 +884,10 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
return
nvme_get_range_type
(
ns
,
arg
);
case
NVME_IOCTL_SUBMIT_IO
:
return
nvme_submit_io
(
ns
,
(
void
__user
*
)
arg
);
case
NVME_IOCTL_DOWNLOAD_FW
:
return
nvme_download_firmware
(
ns
,
(
void
__user
*
)
arg
);
case
NVME_IOCTL_ACTIVATE_FW
:
return
nvme_activate_firmware
(
ns
,
arg
);
default:
return
-
ENOTTY
;
}
...
...
include/linux/nvme.h
View file @
6ee44cdc
...
...
@@ -262,7 +262,7 @@ struct nvme_create_cq {
__u8
opcode
;
__u8
flags
;
__u16
command_id
;
__
le
32
rsvd1
[
5
];
__
u
32
rsvd1
[
5
];
__le64
prp1
;
__u64
rsvd8
;
__le16
cqid
;
...
...
@@ -276,14 +276,14 @@ struct nvme_create_sq {
__u8
opcode
;
__u8
flags
;
__u16
command_id
;
__
le
32
rsvd1
[
5
];
__
u
32
rsvd1
[
5
];
__le64
prp1
;
__u64
rsvd8
;
__le16
sqid
;
__le16
qsize
;
__le16
sq_flags
;
__le16
cqid
;
__
le
32
rsvd12
[
4
];
__
u
32
rsvd12
[
4
];
};
struct
nvme_delete_queue
{
...
...
@@ -292,8 +292,20 @@ struct nvme_delete_queue {
__u16
command_id
;
__u32
rsvd1
[
9
];
__le16
qid
;
__le16
rsvd10
;
__le32
rsvd11
[
5
];
__u16
rsvd10
;
__u32
rsvd11
[
5
];
};
struct
nvme_download_firmware
{
__u8
opcode
;
__u8
flags
;
__u16
command_id
;
__u32
rsvd1
[
5
];
__le64
prp1
;
__le64
prp2
;
__le32
numd
;
__le32
offset
;
__u32
rsvd12
[
4
];
};
struct
nvme_command
{
...
...
@@ -305,6 +317,7 @@ struct nvme_command {
struct
nvme_create_cq
create_cq
;
struct
nvme_create_sq
create_sq
;
struct
nvme_delete_queue
delete_queue
;
struct
nvme_download_firmware
dlfw
;
};
};
...
...
@@ -348,7 +361,7 @@ enum {
struct
nvme_completion
{
__le32
result
;
/* Used by admin commands to return data */
__
le
32
rsvd
;
__
u
32
rsvd
;
__le16
sq_head
;
/* how much of this queue may be reclaimed */
__le16
sq_id
;
/* submission queue that generated this entry */
__u16
command_id
;
/* of the command which completed */
...
...
@@ -372,9 +385,17 @@ struct nvme_user_io {
__u32
result
;
};
struct
nvme_dlfw
{
__u64
addr
;
__u32
length
;
/* In dwords */
__u32
offset
;
/* In dwords */
};
#define NVME_IOCTL_IDENTIFY_NS _IOW('N', 0x40, struct nvme_id_ns)
#define NVME_IOCTL_IDENTIFY_CTRL _IOW('N', 0x41, struct nvme_id_ctrl)
#define NVME_IOCTL_GET_RANGE_TYPE _IOW('N', 0x42, struct nvme_lba_range_type)
#define NVME_IOCTL_SUBMIT_IO _IOWR('N', 0x43, struct nvme_rw_command)
#define NVME_IOCTL_DOWNLOAD_FW _IOR('N', 0x44, struct nvme_dlfw)
#define NVME_IOCTL_ACTIVATE_FW _IO('N', 0x45)
#endif
/* _LINUX_NVME_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment