Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmet: Implement interrupt coalescing feature support

The NVMe base specifications v2.1 mandate Supporting the interrupt
coalescing feature (NVME_FEAT_IRQ_COALESCE) for PCI controllers.
Introduce the data structure struct nvmet_feat_irq_coalesce to define
the time and threshold (thr) fields of this feature and implement the
functions nvmet_get_feat_irq_coalesce() and
nvmet_set_feat_irq_coalesce() to get and set this feature. These
functions respectively use the controller get_feature() and
set_feature() operations to fill and handle the fields of struct
nvmet_feat_irq_coalesce.

While the Linux kernel nvme driver does not use this feature and thus
will not complain if it is not implemented, other major OSes fail
initializing the NVMe device if this feature support is missing.

Support for this feature is prohibited for fabrics controllers. If a get
feature or set feature command for this feature is received for a
fabrics controller, the command is failed with an invalid field error.

Suggested-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
Tested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Damien Le Moal and committed by
Keith Busch
89b94a6c 2f2b20fa

+61 -2
+51 -2
drivers/nvme/target/admin-cmd.c
··· 1282 1282 sizeof(req->sq->ctrl->hostid)); 1283 1283 } 1284 1284 1285 + static u16 nvmet_set_feat_irq_coalesce(struct nvmet_req *req) 1286 + { 1287 + struct nvmet_ctrl *ctrl = req->sq->ctrl; 1288 + u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11); 1289 + struct nvmet_feat_irq_coalesce irqc = { 1290 + .time = (cdw11 >> 8) & 0xff, 1291 + .thr = cdw11 & 0xff, 1292 + }; 1293 + 1294 + /* 1295 + * This feature is not supported for fabrics controllers and mandatory 1296 + * for PCI controllers. 1297 + */ 1298 + if (!nvmet_is_pci_ctrl(ctrl)) { 1299 + req->error_loc = offsetof(struct nvme_common_command, cdw10); 1300 + return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; 1301 + } 1302 + 1303 + return ctrl->ops->set_feature(ctrl, NVME_FEAT_IRQ_COALESCE, &irqc); 1304 + } 1305 + 1285 1306 void nvmet_execute_set_features(struct nvmet_req *req) 1286 1307 { 1287 1308 struct nvmet_subsys *subsys = nvmet_req_subsys(req); ··· 1325 1304 } 1326 1305 nvmet_set_result(req, 1327 1306 (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16)); 1307 + break; 1308 + case NVME_FEAT_IRQ_COALESCE: 1309 + status = nvmet_set_feat_irq_coalesce(req); 1328 1310 break; 1329 1311 case NVME_FEAT_KATO: 1330 1312 status = nvmet_set_feat_kato(req); ··· 1373 1349 return 0; 1374 1350 } 1375 1351 1352 + static u16 nvmet_get_feat_irq_coalesce(struct nvmet_req *req) 1353 + { 1354 + struct nvmet_ctrl *ctrl = req->sq->ctrl; 1355 + struct nvmet_feat_irq_coalesce irqc = { }; 1356 + u16 status; 1357 + 1358 + /* 1359 + * This feature is not supported for fabrics controllers and mandatory 1360 + * for PCI controllers. 1361 + */ 1362 + if (!nvmet_is_pci_ctrl(ctrl)) { 1363 + req->error_loc = offsetof(struct nvme_common_command, cdw10); 1364 + return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; 1365 + } 1366 + 1367 + status = ctrl->ops->get_feature(ctrl, NVME_FEAT_IRQ_COALESCE, &irqc); 1368 + if (status != NVME_SC_SUCCESS) 1369 + return status; 1370 + 1371 + nvmet_set_result(req, ((u32)irqc.time << 8) | (u32)irqc.thr); 1372 + 1373 + return NVME_SC_SUCCESS; 1374 + } 1375 + 1376 1376 void nvmet_get_feat_kato(struct nvmet_req *req) 1377 1377 { 1378 1378 nvmet_set_result(req, req->sq->ctrl->kato * 1000); ··· 1431 1383 break; 1432 1384 case NVME_FEAT_ERR_RECOVERY: 1433 1385 break; 1434 - case NVME_FEAT_IRQ_COALESCE: 1435 - break; 1436 1386 case NVME_FEAT_IRQ_CONFIG: 1437 1387 break; 1438 1388 case NVME_FEAT_WRITE_ATOMIC: 1439 1389 break; 1440 1390 #endif 1391 + case NVME_FEAT_IRQ_COALESCE: 1392 + status = nvmet_get_feat_irq_coalesce(req); 1393 + break; 1441 1394 case NVME_FEAT_ASYNC_EVENT: 1442 1395 nvmet_get_feat_async_event(req); 1443 1396 break;
+10
drivers/nvme/target/nvmet.h
··· 906 906 { 907 907 percpu_ref_put(&pc_ref->ref); 908 908 } 909 + 910 + /* 911 + * Data for the get_feature() and set_feature() operations of PCI target 912 + * controllers. 913 + */ 914 + struct nvmet_feat_irq_coalesce { 915 + u8 thr; 916 + u8 time; 917 + }; 918 + 909 919 #endif /* _NVMET_H */