fabrics-cmd.c (0fdc50dfab47d525b71a9f0d8310746cdc0c09c5) fabrics-cmd.c (136cc1ffcf0a3309c59d844cb1a4ddad964ea3d8)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * NVMe Fabrics command implementation.
4 * Copyright (c) 2015-2016 HGST, a Western Digital Company.
5 */
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7#include <linux/blkdev.h>
8#include "nvmet.h"
9
10static void nvmet_execute_prop_set(struct nvmet_req *req)
11{
12 u64 val = le64_to_cpu(req->cmd->prop_set.value);
13 u16 status = 0;
14
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * NVMe Fabrics command implementation.
4 * Copyright (c) 2015-2016 HGST, a Western Digital Company.
5 */
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7#include <linux/blkdev.h>
8#include "nvmet.h"
9
10static void nvmet_execute_prop_set(struct nvmet_req *req)
11{
12 u64 val = le64_to_cpu(req->cmd->prop_set.value);
13 u16 status = 0;
14
15 if (!nvmet_check_data_len(req, 0))
15 if (!nvmet_check_transfer_len(req, 0))
16 return;
17
18 if (req->cmd->prop_set.attrib & 1) {
19 req->error_loc =
20 offsetof(struct nvmf_property_set_command, attrib);
21 status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
22 goto out;
23 }

--- 12 unchanged lines hidden (view full) ---

36}
37
38static void nvmet_execute_prop_get(struct nvmet_req *req)
39{
40 struct nvmet_ctrl *ctrl = req->sq->ctrl;
41 u16 status = 0;
42 u64 val = 0;
43
16 return;
17
18 if (req->cmd->prop_set.attrib & 1) {
19 req->error_loc =
20 offsetof(struct nvmf_property_set_command, attrib);
21 status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
22 goto out;
23 }

--- 12 unchanged lines hidden (view full) ---

36}
37
38static void nvmet_execute_prop_get(struct nvmet_req *req)
39{
40 struct nvmet_ctrl *ctrl = req->sq->ctrl;
41 u16 status = 0;
42 u64 val = 0;
43
44 if (!nvmet_check_data_len(req, 0))
44 if (!nvmet_check_transfer_len(req, 0))
45 return;
46
47 if (req->cmd->prop_get.attrib & 1) {
48 switch (le32_to_cpu(req->cmd->prop_get.offset)) {
49 case NVME_REG_CAP:
50 val = ctrl->cap;
51 break;
52 default:

--- 98 unchanged lines hidden (view full) ---

151
152static void nvmet_execute_admin_connect(struct nvmet_req *req)
153{
154 struct nvmf_connect_command *c = &req->cmd->connect;
155 struct nvmf_connect_data *d;
156 struct nvmet_ctrl *ctrl = NULL;
157 u16 status = 0;
158
45 return;
46
47 if (req->cmd->prop_get.attrib & 1) {
48 switch (le32_to_cpu(req->cmd->prop_get.offset)) {
49 case NVME_REG_CAP:
50 val = ctrl->cap;
51 break;
52 default:

--- 98 unchanged lines hidden (view full) ---

151
152static void nvmet_execute_admin_connect(struct nvmet_req *req)
153{
154 struct nvmf_connect_command *c = &req->cmd->connect;
155 struct nvmf_connect_data *d;
156 struct nvmet_ctrl *ctrl = NULL;
157 u16 status = 0;
158
159 if (!nvmet_check_data_len(req, sizeof(struct nvmf_connect_data)))
159 if (!nvmet_check_transfer_len(req, sizeof(struct nvmf_connect_data)))
160 return;
161
162 d = kmalloc(sizeof(*d), GFP_KERNEL);
163 if (!d) {
164 status = NVME_SC_INTERNAL;
165 goto complete;
166 }
167

--- 50 unchanged lines hidden (view full) ---

218static void nvmet_execute_io_connect(struct nvmet_req *req)
219{
220 struct nvmf_connect_command *c = &req->cmd->connect;
221 struct nvmf_connect_data *d;
222 struct nvmet_ctrl *ctrl = NULL;
223 u16 qid = le16_to_cpu(c->qid);
224 u16 status = 0;
225
160 return;
161
162 d = kmalloc(sizeof(*d), GFP_KERNEL);
163 if (!d) {
164 status = NVME_SC_INTERNAL;
165 goto complete;
166 }
167

--- 50 unchanged lines hidden (view full) ---

218static void nvmet_execute_io_connect(struct nvmet_req *req)
219{
220 struct nvmf_connect_command *c = &req->cmd->connect;
221 struct nvmf_connect_data *d;
222 struct nvmet_ctrl *ctrl = NULL;
223 u16 qid = le16_to_cpu(c->qid);
224 u16 status = 0;
225
226 if (!nvmet_check_data_len(req, sizeof(struct nvmf_connect_data)))
226 if (!nvmet_check_transfer_len(req, sizeof(struct nvmf_connect_data)))
227 return;
228
229 d = kmalloc(sizeof(*d), GFP_KERNEL);
230 if (!d) {
231 status = NVME_SC_INTERNAL;
232 goto complete;
233 }
234

--- 70 unchanged lines hidden ---
227 return;
228
229 d = kmalloc(sizeof(*d), GFP_KERNEL);
230 if (!d) {
231 status = NVME_SC_INTERNAL;
232 goto complete;
233 }
234

--- 70 unchanged lines hidden ---