Lines Matching refs:cmd

107 	int cmd;  member
312 if (nl_cmd->cmd != TCMU_CMD_UNSPEC) { in tcmu_fail_netlink_cmd()
313 pr_debug("Aborting nl cmd %d on %s\n", nl_cmd->cmd, udev->name); in tcmu_fail_netlink_cmd()
404 udev->name, dev_id, nl_cmd->cmd, completed_cmd, rc, in tcmu_genl_cmd_done()
407 if (nl_cmd->cmd != completed_cmd) { in tcmu_genl_cmd_done()
409 udev->name, completed_cmd, nl_cmd->cmd); in tcmu_genl_cmd_done()
451 .cmd = TCMU_CMD_SET_FEATURES,
457 .cmd = TCMU_CMD_ADDED_DEVICE_DONE,
463 .cmd = TCMU_CMD_REMOVED_DEVICE_DONE,
469 .cmd = TCMU_CMD_RECONFIG_DEVICE_DONE,
492 #define tcmu_cmd_set_dbi_cur(cmd, index) ((cmd)->dbi_cur = (index)) argument
493 #define tcmu_cmd_reset_dbi_cur(cmd) tcmu_cmd_set_dbi_cur(cmd, 0) argument
494 #define tcmu_cmd_set_dbi(cmd, index) ((cmd)->dbi[(cmd)->dbi_cur++] = (index)) argument
495 #define tcmu_cmd_get_dbi(cmd) ((cmd)->dbi[(cmd)->dbi_cur++]) argument
578 static inline void tcmu_cmd_set_block_cnts(struct tcmu_cmd *cmd) in tcmu_cmd_set_block_cnts() argument
581 struct se_cmd *se_cmd = cmd->se_cmd; in tcmu_cmd_set_block_cnts()
582 uint32_t blk_size = cmd->tcmu_dev->data_blk_size; in tcmu_cmd_set_block_cnts()
584 cmd->dbi_cnt = DIV_ROUND_UP(se_cmd->data_length, blk_size); in tcmu_cmd_set_block_cnts()
590 cmd->dbi_bidi_cnt = DIV_ROUND_UP(len, blk_size); in tcmu_cmd_set_block_cnts()
591 cmd->dbi_cnt += cmd->dbi_bidi_cnt; in tcmu_cmd_set_block_cnts()
592 cmd->data_len_bidi = len; in tcmu_cmd_set_block_cnts()
596 static int new_block_to_iov(struct tcmu_dev *udev, struct tcmu_cmd *cmd, in new_block_to_iov() argument
600 int dbi = tcmu_cmd_get_dbi(cmd); in new_block_to_iov()
622 static void tcmu_setup_iovs(struct tcmu_dev *udev, struct tcmu_cmd *cmd, in tcmu_setup_iovs() argument
630 dbi = new_block_to_iov(udev, cmd, iov, dbi, data_length); in tcmu_setup_iovs()
854 static int tcmu_alloc_data_space(struct tcmu_dev *udev, struct tcmu_cmd *cmd, in tcmu_alloc_data_space() argument
859 if (!cmd->dbi_cnt) in tcmu_alloc_data_space()
864 if (space < cmd->dbi_cnt) { in tcmu_alloc_data_space()
868 if (blocks_left < cmd->dbi_cnt) { in tcmu_alloc_data_space()
871 cmd->dbi_cnt * udev->data_blk_size); in tcmu_alloc_data_space()
875 udev->dbi_thresh += cmd->dbi_cnt; in tcmu_alloc_data_space()
880 iov_cnt = tcmu_get_empty_blocks(udev, cmd, cmd->se_cmd->data_length); in tcmu_alloc_data_space()
884 if (cmd->dbi_bidi_cnt) { in tcmu_alloc_data_space()
885 ret = tcmu_get_empty_blocks(udev, cmd, cmd->data_len_bidi); in tcmu_alloc_data_space()
1229 struct tcmu_cmd *cmd; in tcmu_set_next_deadline() local
1232 cmd = list_first_entry(queue, struct tcmu_cmd, queue_entry); in tcmu_set_next_deadline()
1233 mod_timer(timer, cmd->deadline); in tcmu_set_next_deadline()
1260 struct tcmu_cmd *cmd; in tcmu_tmr_notify() local
1272 cmd = se_cmd->priv; in tcmu_tmr_notify()
1274 if (cmd->cmd_id) { in tcmu_tmr_notify()
1279 cmd, udev->name); in tcmu_tmr_notify()
1281 list_del_init(&cmd->queue_entry); in tcmu_tmr_notify()
1282 tcmu_free_cmd(cmd); in tcmu_tmr_notify()
1308 cmd = se_cmd->priv; in tcmu_tmr_notify()
1309 if (cmd->cmd_id) in tcmu_tmr_notify()
1310 tmr->tmr_cmd_ids[cmd_cnt++] = cmd->cmd_id; in tcmu_tmr_notify()
1320 static bool tcmu_handle_completion(struct tcmu_cmd *cmd, in tcmu_handle_completion() argument
1323 struct se_cmd *se_cmd = cmd->se_cmd; in tcmu_handle_completion()
1324 struct tcmu_dev *udev = cmd->tcmu_dev; in tcmu_handle_completion()
1333 if (test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags)) { in tcmu_handle_completion()
1337 if (test_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags)) { in tcmu_handle_completion()
1345 list_del_init(&cmd->queue_entry); in tcmu_handle_completion()
1347 tcmu_cmd_reset_dbi_cur(cmd); in tcmu_handle_completion()
1351 cmd->se_cmd); in tcmu_handle_completion()
1373 gather_data_area(udev, cmd, true, read_len); in tcmu_handle_completion()
1375 gather_data_area(udev, cmd, false, read_len); in tcmu_handle_completion()
1387 target_complete_cmd_with_length(cmd->se_cmd, in tcmu_handle_completion()
1390 target_complete_cmd(cmd->se_cmd, entry->rsp.scsi_status); in tcmu_handle_completion()
1394 tcmu_cmd_free_data(cmd, cmd->dbi_cnt); in tcmu_handle_completion()
1395 tcmu_free_cmd(cmd); in tcmu_handle_completion()
1405 clear_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags); in tcmu_handle_completion()
1406 set_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags); in tcmu_handle_completion()
1446 struct tcmu_cmd *cmd; in tcmu_handle_completions() local
1484 cmd = xa_load(&udev->commands, entry->hdr.cmd_id); in tcmu_handle_completions()
1486 cmd = xa_erase(&udev->commands, entry->hdr.cmd_id); in tcmu_handle_completions()
1487 if (!cmd) { in tcmu_handle_completions()
1494 if (!tcmu_handle_completion(cmd, entry, keep_buf)) in tcmu_handle_completions()
1518 static void tcmu_check_expired_ring_cmd(struct tcmu_cmd *cmd) in tcmu_check_expired_ring_cmd() argument
1522 if (!time_after_eq(jiffies, cmd->deadline)) in tcmu_check_expired_ring_cmd()
1525 set_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags); in tcmu_check_expired_ring_cmd()
1526 list_del_init(&cmd->queue_entry); in tcmu_check_expired_ring_cmd()
1527 se_cmd = cmd->se_cmd; in tcmu_check_expired_ring_cmd()
1529 cmd->se_cmd = NULL; in tcmu_check_expired_ring_cmd()
1532 cmd->cmd_id, cmd->tcmu_dev->name); in tcmu_check_expired_ring_cmd()
1537 static void tcmu_check_expired_queue_cmd(struct tcmu_cmd *cmd) in tcmu_check_expired_queue_cmd() argument
1541 if (!time_after_eq(jiffies, cmd->deadline)) in tcmu_check_expired_queue_cmd()
1545 cmd, cmd->tcmu_dev->name); in tcmu_check_expired_queue_cmd()
1547 list_del_init(&cmd->queue_entry); in tcmu_check_expired_queue_cmd()
1548 se_cmd = cmd->se_cmd; in tcmu_check_expired_queue_cmd()
1549 tcmu_free_cmd(cmd); in tcmu_check_expired_queue_cmd()
1652 static int tcmu_check_and_free_pending_cmd(struct tcmu_cmd *cmd) in tcmu_check_and_free_pending_cmd() argument
1654 if (test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags) || in tcmu_check_and_free_pending_cmd()
1655 test_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags)) { in tcmu_check_and_free_pending_cmd()
1656 kmem_cache_free(tcmu_cmd_cache, cmd); in tcmu_check_and_free_pending_cmd()
1716 struct tcmu_cmd *cmd; in tcmu_dev_kref_release() local
1730 xa_for_each(&udev->commands, i, cmd) { in tcmu_dev_kref_release()
1731 if (tcmu_check_and_free_pending_cmd(cmd) != 0) in tcmu_dev_kref_release()
1963 struct tcmu_cmd *cmd; in tcmu_release() local
1969 xa_for_each(&udev->commands, i, cmd) { in tcmu_release()
1977 if (!test_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags)) in tcmu_release()
1980 cmd->cmd_id, udev->name); in tcmu_release()
1984 tcmu_cmd_free_data(cmd, cmd->dbi_cnt); in tcmu_release()
1985 tcmu_free_cmd(cmd); in tcmu_release()
2003 static int tcmu_init_genl_cmd_reply(struct tcmu_dev *udev, int cmd) in tcmu_init_genl_cmd_reply() argument
2017 pr_warn("Failing nl cmd %d on %s. Interface is blocked.\n", cmd, in tcmu_init_genl_cmd_reply()
2022 if (nl_cmd->cmd != TCMU_CMD_UNSPEC) { in tcmu_init_genl_cmd_reply()
2025 nl_cmd->cmd, udev->name); in tcmu_init_genl_cmd_reply()
2030 nl_cmd->cmd = cmd; in tcmu_init_genl_cmd_reply()
2074 nl_cmd->cmd = TCMU_CMD_UNSPEC; in tcmu_wait_genl_cmd_reply()
2082 enum tcmu_genl_cmd cmd, in tcmu_netlink_event_init() argument
2093 msg_header = genlmsg_put(skb, 0, 0, &tcmu_genl_family, 0, cmd); in tcmu_netlink_event_init()
2119 enum tcmu_genl_cmd cmd, in tcmu_netlink_event_send() argument
2126 ret = tcmu_init_genl_cmd_reply(udev, cmd); in tcmu_netlink_event_send()
2137 (ret == -ESRCH && cmd == TCMU_CMD_ADDED_DEVICE)) in tcmu_netlink_event_send()
2365 struct tcmu_cmd *cmd; in tcmu_reset_ring() local
2370 xa_for_each(&udev->commands, i, cmd) { in tcmu_reset_ring()
2372 cmd->cmd_id, udev->name, in tcmu_reset_ring()
2373 test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags) ? in tcmu_reset_ring()
2375 (test_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags) ? in tcmu_reset_ring()
2379 if (!test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags) && in tcmu_reset_ring()
2380 !test_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags)) { in tcmu_reset_ring()
2381 WARN_ON(!cmd->se_cmd); in tcmu_reset_ring()
2382 list_del_init(&cmd->queue_entry); in tcmu_reset_ring()
2383 cmd->se_cmd->priv = NULL; in tcmu_reset_ring()
2389 target_complete_cmd(cmd->se_cmd, SAM_STAT_BUSY); in tcmu_reset_ring()
2392 target_complete_cmd(cmd->se_cmd, in tcmu_reset_ring()
2396 tcmu_cmd_free_data(cmd, cmd->dbi_cnt); in tcmu_reset_ring()
2397 tcmu_free_cmd(cmd); in tcmu_reset_ring()
2668 tcmu_parse_cdb(struct se_cmd *cmd) in tcmu_parse_cdb() argument
2670 return passthrough_parse_cdb(cmd, tcmu_queue_cmd); in tcmu_parse_cdb()
3088 struct tcmu_cmd *cmd; in tcmu_free_kept_buf_store() local
3107 cmd = xas_load(&xas); in tcmu_free_kept_buf_store()
3108 if (!cmd) { in tcmu_free_kept_buf_store()
3114 if (!test_bit(TCMU_CMD_BIT_KEEP_BUF, &cmd->flags)) { in tcmu_free_kept_buf_store()
3125 tcmu_cmd_free_data(cmd, cmd->dbi_cnt); in tcmu_free_kept_buf_store()
3126 tcmu_free_cmd(cmd); in tcmu_free_kept_buf_store()
3266 struct tcmu_cmd *cmd, *tmp_cmd; in check_timedout_devices() local
3283 list_for_each_entry_safe(cmd, tmp_cmd, in check_timedout_devices()
3286 tcmu_check_expired_ring_cmd(cmd); in check_timedout_devices()
3291 list_for_each_entry_safe(cmd, tmp_cmd, &udev->qfull_queue, in check_timedout_devices()
3293 tcmu_check_expired_queue_cmd(cmd); in check_timedout_devices()