Lines Matching +full:timestamp +full:- +full:names

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net>
13 #include <linux/firewire-constants.h>
67 if (t->is_split_transaction) in try_cancel_split_timeout()
68 return del_timer(&t->split_timeout_timer); in try_cancel_split_timeout()
79 spin_lock_irqsave(&card->lock, flags); in close_transaction()
80 list_for_each_entry(iter, &card->transaction_list, link) { in close_transaction()
83 spin_unlock_irqrestore(&card->lock, flags); in close_transaction()
86 list_del_init(&iter->link); in close_transaction()
87 card->tlabel_mask &= ~(1ULL << iter->tlabel); in close_transaction()
92 spin_unlock_irqrestore(&card->lock, flags); in close_transaction()
95 if (!t->with_tstamp) { in close_transaction()
96 t->callback.without_tstamp(card, rcode, NULL, 0, t->callback_data); in close_transaction()
98 t->callback.with_tstamp(card, rcode, t->packet.timestamp, response_tstamp, in close_transaction()
99 NULL, 0, t->callback_data); in close_transaction()
105 return -ENOENT; in close_transaction()
123 if (card->driver->cancel_packet(card, &transaction->packet) == 0) in fw_cancel_transaction()
131 if (transaction->packet.ack == 0) { in fw_cancel_transaction()
132 // The timestamp is reused since it was just read now. in fw_cancel_transaction()
133 tstamp = transaction->packet.timestamp; in fw_cancel_transaction()
148 struct fw_card *card = t->card; in split_transaction_timeout_callback()
151 spin_lock_irqsave(&card->lock, flags); in split_transaction_timeout_callback()
152 if (list_empty(&t->link)) { in split_transaction_timeout_callback()
153 spin_unlock_irqrestore(&card->lock, flags); in split_transaction_timeout_callback()
156 list_del(&t->link); in split_transaction_timeout_callback()
157 card->tlabel_mask &= ~(1ULL << t->tlabel); in split_transaction_timeout_callback()
158 spin_unlock_irqrestore(&card->lock, flags); in split_transaction_timeout_callback()
160 if (!t->with_tstamp) { in split_transaction_timeout_callback()
161 t->callback.without_tstamp(card, RCODE_CANCELLED, NULL, 0, t->callback_data); in split_transaction_timeout_callback()
163 t->callback.with_tstamp(card, RCODE_CANCELLED, t->packet.timestamp, in split_transaction_timeout_callback()
164 t->split_timeout_cycle, NULL, 0, t->callback_data); in split_transaction_timeout_callback()
173 spin_lock_irqsave(&card->lock, flags); in start_split_transaction_timeout()
175 if (list_empty(&t->link) || WARN_ON(t->is_split_transaction)) { in start_split_transaction_timeout()
176 spin_unlock_irqrestore(&card->lock, flags); in start_split_transaction_timeout()
180 t->is_split_transaction = true; in start_split_transaction_timeout()
181 mod_timer(&t->split_timeout_timer, in start_split_transaction_timeout()
182 jiffies + card->split_timeout_jiffies); in start_split_transaction_timeout()
184 spin_unlock_irqrestore(&card->lock, flags); in start_split_transaction_timeout()
197 close_transaction(t, card, RCODE_COMPLETE, packet->timestamp); in transmit_complete_callback()
201 t->split_timeout_cycle = in transmit_complete_callback()
202 compute_split_timeout_timestamp(card, packet->timestamp) & 0xffff; in transmit_complete_callback()
209 close_transaction(t, card, RCODE_BUSY, packet->timestamp); in transmit_complete_callback()
212 close_transaction(t, card, RCODE_DATA_ERROR, packet->timestamp); in transmit_complete_callback()
215 close_transaction(t, card, RCODE_TYPE_ERROR, packet->timestamp); in transmit_complete_callback()
222 close_transaction(t, card, status, packet->timestamp); in transmit_complete_callback()
234 packet->header[0] = in fw_fill_request()
238 packet->header_length = 4; in fw_fill_request()
239 packet->payload = payload; in fw_fill_request()
240 packet->payload_length = length; in fw_fill_request()
251 packet->header[0] = in fw_fill_request()
256 packet->header[1] = in fw_fill_request()
258 packet->header[2] = in fw_fill_request()
263 packet->header[3] = *(u32 *)payload; in fw_fill_request()
264 packet->header_length = 16; in fw_fill_request()
265 packet->payload_length = 0; in fw_fill_request()
270 packet->header[3] = in fw_fill_request()
273 packet->header_length = 16; in fw_fill_request()
274 packet->payload = payload; in fw_fill_request()
275 packet->payload_length = length; in fw_fill_request()
279 packet->header_length = 12; in fw_fill_request()
280 packet->payload_length = 0; in fw_fill_request()
284 packet->header[3] = in fw_fill_request()
287 packet->header_length = 16; in fw_fill_request()
288 packet->payload_length = 0; in fw_fill_request()
295 packet->speed = speed; in fw_fill_request()
296 packet->generation = generation; in fw_fill_request()
297 packet->ack = 0; in fw_fill_request()
298 packet->payload_mapped = false; in fw_fill_request()
305 tlabel = card->current_tlabel; in allocate_tlabel()
306 while (card->tlabel_mask & (1ULL << tlabel)) { in allocate_tlabel()
308 if (tlabel == card->current_tlabel) in allocate_tlabel()
309 return -EBUSY; in allocate_tlabel()
312 card->current_tlabel = (tlabel + 1) & 0x3f; in allocate_tlabel()
313 card->tlabel_mask |= 1ULL << tlabel; in allocate_tlabel()
319 * __fw_send_request() - submit a request packet for transmission to generate callback for response
339 * In case of lock requests, specify one of the firewire-core specific %TCODE_
349 * The payload buffer at @data is going to be DMA-mapped except in case of
359 * the firewire-core specific %RCODE_SEND_ERROR. The other firewire-core
382 spin_lock_irqsave(&card->lock, flags); in __fw_send_request()
386 spin_unlock_irqrestore(&card->lock, flags); in __fw_send_request()
403 t->node_id = destination_id; in __fw_send_request()
404 t->tlabel = tlabel; in __fw_send_request()
405 t->card = card; in __fw_send_request()
406 t->is_split_transaction = false; in __fw_send_request()
407 timer_setup(&t->split_timeout_timer, split_transaction_timeout_callback, 0); in __fw_send_request()
408 t->callback = callback; in __fw_send_request()
409 t->with_tstamp = with_tstamp; in __fw_send_request()
410 t->callback_data = callback_data; in __fw_send_request()
412 fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, card->node_id, generation, in __fw_send_request()
414 t->packet.callback = transmit_complete_callback; in __fw_send_request()
416 list_add_tail(&t->link, &card->transaction_list); in __fw_send_request()
418 spin_unlock_irqrestore(&card->lock, flags); in __fw_send_request()
420 card->driver->send_request(card, &t->packet); in __fw_send_request()
436 memcpy(d->payload, payload, length); in transaction_callback()
437 d->rcode = rcode; in transaction_callback()
438 complete(&d->done); in transaction_callback()
442 * fw_run_transaction() - send request and sleep until transaction is completed
503 gap_count = card->driver->read_phy_reg(card, 1); in fw_send_phy_config()
520 card->driver->send_request(card, &phy_config_packet); in fw_send_phy_config()
532 if (handler->offset < offset + length && in lookup_overlapping_address_handler()
533 offset < handler->offset + handler->length) in lookup_overlapping_address_handler()
543 return handler->offset <= offset && in is_enclosing_handler()
544 offset + length <= handler->offset + handler->length; in is_enclosing_handler()
581 * fw_core_add_address_handler() - register for incoming requests
585 * region->start, ->end, and handler->length have to be quadlet-aligned.
592 * Return value: 0 on success, non-zero otherwise.
595 * fw_core_add_address_handler() and is returned in handler->offset.
603 int ret = -EBUSY; in fw_core_add_address_handler()
605 if (region->start & 0xffff000000000003ULL || in fw_core_add_address_handler()
606 region->start >= region->end || in fw_core_add_address_handler()
607 region->end > 0x0001000000000000ULL || in fw_core_add_address_handler()
608 handler->length & 3 || in fw_core_add_address_handler()
609 handler->length == 0) in fw_core_add_address_handler()
610 return -EINVAL; in fw_core_add_address_handler()
614 handler->offset = region->start; in fw_core_add_address_handler()
615 while (handler->offset + handler->length <= region->end) { in fw_core_add_address_handler()
616 if (is_in_fcp_region(handler->offset, handler->length)) in fw_core_add_address_handler()
621 handler->offset, handler->length); in fw_core_add_address_handler()
623 handler->offset += other->length; in fw_core_add_address_handler()
625 list_add_tail_rcu(&handler->link, &address_handler_list); in fw_core_add_address_handler()
638 * fw_core_remove_address_handler() - unregister an address handler
643 * When fw_core_remove_address_handler() returns, @handler->callback() is
649 list_del_rcu(&handler->link); in fw_core_remove_address_handler()
660 u32 timestamp; member
667 kref_get(&request->kref); in fw_request_get()
679 kref_put(&request->kref, release_request); in fw_request_put()
687 // Decrease the reference count since not at in-flight. in free_response_callback()
698 tcode = HEADER_GET_TCODE(r->request_header[0]); in fw_get_response_length()
709 data_length = HEADER_GET_DATA_LENGTH(r->request_header[3]); in fw_get_response_length()
713 ext_tcode = HEADER_GET_EXTENDED_TCODE(r->request_header[3]); in fw_get_response_length()
714 data_length = HEADER_GET_DATA_LENGTH(r->request_header[3]); in fw_get_response_length()
740 response->header[0] = in fw_fill_response()
744 response->header[1] = in fw_fill_response()
747 response->header[2] = 0; in fw_fill_response()
752 response->header[0] |= HEADER_TCODE(TCODE_WRITE_RESPONSE); in fw_fill_response()
753 response->header_length = 12; in fw_fill_response()
754 response->payload_length = 0; in fw_fill_response()
758 response->header[0] |= in fw_fill_response()
761 response->header[3] = *(u32 *)payload; in fw_fill_response()
763 response->header[3] = 0; in fw_fill_response()
764 response->header_length = 16; in fw_fill_response()
765 response->payload_length = 0; in fw_fill_response()
770 response->header[0] |= HEADER_TCODE(tcode + 2); in fw_fill_response()
771 response->header[3] = in fw_fill_response()
774 response->header_length = 16; in fw_fill_response()
775 response->payload = payload; in fw_fill_response()
776 response->payload_length = length; in fw_fill_response()
783 response->payload_mapped = false; in fw_fill_response()
791 u32 timestamp; in compute_split_timeout_timestamp() local
793 cycles = card->split_timeout_cycles; in compute_split_timeout_timestamp()
796 timestamp = request_timestamp & ~0x1fff; in compute_split_timeout_timestamp()
797 timestamp += (cycles / 8000) << 13; in compute_split_timeout_timestamp()
798 timestamp |= cycles % 8000; in compute_split_timeout_timestamp()
800 return timestamp; in compute_split_timeout_timestamp()
810 request_tcode = HEADER_GET_TCODE(p->header[0]); in allocate_request()
813 data = &p->header[3]; in allocate_request()
819 data = p->payload; in allocate_request()
820 length = HEADER_GET_DATA_LENGTH(p->header[3]); in allocate_request()
830 length = HEADER_GET_DATA_LENGTH(p->header[3]); in allocate_request()
834 fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", in allocate_request()
835 p->header[0], p->header[1], p->header[2]); in allocate_request()
842 kref_init(&request->kref); in allocate_request()
844 request->response.speed = p->speed; in allocate_request()
845 request->response.timestamp = in allocate_request()
846 compute_split_timeout_timestamp(card, p->timestamp); in allocate_request()
847 request->response.generation = p->generation; in allocate_request()
848 request->response.ack = 0; in allocate_request()
849 request->response.callback = free_response_callback; in allocate_request()
850 request->ack = p->ack; in allocate_request()
851 request->timestamp = p->timestamp; in allocate_request()
852 request->length = length; in allocate_request()
854 memcpy(request->data, data, length); in allocate_request()
856 memcpy(request->request_header, p->header, sizeof(p->header)); in allocate_request()
862 * fw_send_response: - send response packet for asynchronous transaction.
874 if (request->ack != ACK_PENDING || in fw_send_response()
875 HEADER_DESTINATION_IS_BROADCAST(request->request_header[0])) { in fw_send_response()
881 fw_fill_response(&request->response, request->request_header, in fw_send_response()
882 rcode, request->data, in fw_send_response()
885 fw_fill_response(&request->response, request->request_header, in fw_send_response()
888 // Increase the reference count so that the object is kept during in-flight. in fw_send_response()
891 card->driver->send_response(card, &request->response); in fw_send_response()
896 * fw_get_request_speed() - returns speed at which the @request was received
901 return request->response.speed; in fw_get_request_speed()
906 * fw_request_get_timestamp: Get timestamp of the request.
909 * Get timestamp when 1394 OHCI controller receives the asynchronous request subaction. The
910 * timestamp consists of the low order 3 bits of second field and the full 13 bits of count
913 * Returns: timestamp of the request.
917 return request->timestamp; in fw_request_get_timestamp()
929 destination = HEADER_GET_DESTINATION(p->header[0]); in handle_exclusive_region_request()
930 source = HEADER_GET_SOURCE(p->header[1]); in handle_exclusive_region_request()
931 tcode = HEADER_GET_TCODE(p->header[0]); in handle_exclusive_region_request()
933 tcode = 0x10 + HEADER_GET_EXTENDED_TCODE(p->header[3]); in handle_exclusive_region_request()
937 offset, request->length); in handle_exclusive_region_request()
939 handler->address_callback(card, request, in handle_exclusive_region_request()
941 p->generation, offset, in handle_exclusive_region_request()
942 request->data, request->length, in handle_exclusive_region_request()
943 handler->callback_data); in handle_exclusive_region_request()
960 request->length > 0x200) { in handle_fcp_region_request()
966 tcode = HEADER_GET_TCODE(p->header[0]); in handle_fcp_region_request()
967 destination = HEADER_GET_DESTINATION(p->header[0]); in handle_fcp_region_request()
968 source = HEADER_GET_SOURCE(p->header[1]); in handle_fcp_region_request()
979 if (is_enclosing_handler(handler, offset, request->length)) in handle_fcp_region_request()
980 handler->address_callback(card, request, tcode, in handle_fcp_region_request()
982 p->generation, offset, in handle_fcp_region_request()
983 request->data, in handle_fcp_region_request()
984 request->length, in handle_fcp_region_request()
985 handler->callback_data); in handle_fcp_region_request()
997 if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE) in fw_core_handle_request()
1000 if (TCODE_IS_LINK_INTERNAL(HEADER_GET_TCODE(p->header[0]))) { in fw_core_handle_request()
1011 offset = ((u64)HEADER_GET_OFFSET_HIGH(p->header[1]) << 32) | in fw_core_handle_request()
1012 p->header[2]; in fw_core_handle_request()
1014 if (!is_in_fcp_region(offset, request->length)) in fw_core_handle_request()
1030 tcode = HEADER_GET_TCODE(p->header[0]); in fw_core_handle_response()
1031 tlabel = HEADER_GET_TLABEL(p->header[0]); in fw_core_handle_response()
1032 source = HEADER_GET_SOURCE(p->header[1]); in fw_core_handle_response()
1033 rcode = HEADER_GET_RCODE(p->header[1]); in fw_core_handle_response()
1035 spin_lock_irqsave(&card->lock, flags); in fw_core_handle_response()
1036 list_for_each_entry(iter, &card->transaction_list, link) { in fw_core_handle_response()
1037 if (iter->node_id == source && iter->tlabel == tlabel) { in fw_core_handle_response()
1039 spin_unlock_irqrestore(&card->lock, flags); in fw_core_handle_response()
1042 list_del_init(&iter->link); in fw_core_handle_response()
1043 card->tlabel_mask &= ~(1ULL << iter->tlabel); in fw_core_handle_response()
1048 spin_unlock_irqrestore(&card->lock, flags); in fw_core_handle_response()
1064 data = (u32 *) &p->header[3]; in fw_core_handle_response()
1075 data = p->payload; in fw_core_handle_response()
1076 data_length = HEADER_GET_DATA_LENGTH(p->header[3]); in fw_core_handle_response()
1090 card->driver->cancel_packet(card, &t->packet); in fw_core_handle_response()
1092 if (!t->with_tstamp) { in fw_core_handle_response()
1093 t->callback.without_tstamp(card, rcode, data, data_length, t->callback_data); in fw_core_handle_response()
1095 t->callback.with_tstamp(card, rcode, t->packet.timestamp, p->timestamp, data, in fw_core_handle_response()
1096 data_length, t->callback_data); in fw_core_handle_response()
1102 * fw_rcode_string - convert a firewire result code to an error description
1107 static const char *const names[] = { in fw_rcode_string() local
1120 if ((unsigned int)rcode < ARRAY_SIZE(names) && names[rcode]) in fw_rcode_string()
1121 return names[rcode]; in fw_rcode_string()
1148 start = (offset - topology_map_region.start) / 4; in handle_topology_map()
1149 memcpy(payload, &card->topology_map[start], length); in handle_topology_map()
1167 cycles = card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); in update_split_timeout()
1172 card->split_timeout_cycles = cycles; in update_split_timeout()
1173 card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); in update_split_timeout()
1188 if (!card->priority_budget_implemented) { in handle_registers()
1196 * per IEEE 1394-2008 8.3.22.3, not IEEE 1394.1-2004 3.2.8 in handle_registers()
1197 * and 9.6, but interoperable with IEEE 1394.1-2004 bridges in handle_registers()
1207 *data = cpu_to_be32(card->driver->read_csr(card, reg)); in handle_registers()
1209 card->driver->write_csr(card, reg, be32_to_cpu(*data)); in handle_registers()
1216 card->driver->write_csr(card, CSR_STATE_CLEAR, in handle_registers()
1224 *data = cpu_to_be32(card->split_timeout_hi); in handle_registers()
1226 spin_lock_irqsave(&card->lock, flags); in handle_registers()
1227 card->split_timeout_hi = be32_to_cpu(*data) & 7; in handle_registers()
1229 spin_unlock_irqrestore(&card->lock, flags); in handle_registers()
1237 *data = cpu_to_be32(card->split_timeout_lo); in handle_registers()
1239 spin_lock_irqsave(&card->lock, flags); in handle_registers()
1240 card->split_timeout_lo = in handle_registers()
1243 spin_unlock_irqrestore(&card->lock, flags); in handle_registers()
1251 *data = card->maint_utility_register; in handle_registers()
1253 card->maint_utility_register = *data; in handle_registers()
1260 *data = cpu_to_be32(card->broadcast_channel); in handle_registers()
1262 card->broadcast_channel = in handle_registers()
1356 return -ENOMEM; in fw_core_init()