| 105 | } |
| 106 | |
| 107 | int queue_init(cls_method_context_t hctx, const cls_queue_init_op& op) |
| 108 | { |
| 109 | //get head and its size |
| 110 | cls_queue_head head; |
| 111 | int ret = queue_read_head(hctx, head); |
| 112 | |
| 113 | //head is already initialized |
| 114 | if (ret == 0) { |
| 115 | return -EEXIST; |
| 116 | } |
| 117 | |
| 118 | if (ret < 0 && ret != -EINVAL) { |
| 119 | return ret; |
| 120 | } |
| 121 | |
| 122 | if (op.bl_urgent_data.length() > 0) { |
| 123 | head.bl_urgent_data = op.bl_urgent_data; |
| 124 | } |
| 125 | |
| 126 | head.max_head_size = QUEUE_HEAD_SIZE_1K + op.max_urgent_data_size; |
| 127 | head.queue_size = op.queue_size + head.max_head_size; |
| 128 | head.max_urgent_data_size = op.max_urgent_data_size; |
| 129 | head.tail.gen = head.front.gen = 0; |
| 130 | head.tail.offset = head.front.offset = head.max_head_size; |
| 131 | |
| 132 | CLS_LOG(20, "INFO: init_queue_op queue actual size %lu", head.queue_size); |
| 133 | CLS_LOG(20, "INFO: init_queue_op head size %lu", head.max_head_size); |
| 134 | CLS_LOG(20, "INFO: init_queue_op queue front offset %s", head.front.to_str().c_str()); |
| 135 | CLS_LOG(20, "INFO: init_queue_op queue max urgent data size %lu", head.max_urgent_data_size); |
| 136 | |
| 137 | return queue_write_head(hctx, head); |
| 138 | } |
| 139 | |
| 140 | int queue_get_capacity(cls_method_context_t hctx, cls_queue_get_capacity_ret& op_ret) |
| 141 | { |
no test coverage detected