Lines Matching +full:timestamp +full:- +full:names
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2004-2006 Kristian Hoegsberg <[email protected]>
13 #include <linux/firewire-constants.h>
31 #include "packet-header-definitions.h"
32 #include "phy-packet-definitions.h"
41 if (t->is_split_transaction) in try_cancel_split_timeout()
42 return del_timer(&t->split_timeout_timer); in try_cancel_split_timeout()
52 scoped_guard(spinlock_irqsave, &card->lock) { in close_transaction()
53 list_for_each_entry(iter, &card->transaction_list, link) { in close_transaction()
56 list_del_init(&iter->link); in close_transaction()
57 card->tlabel_mask &= ~(1ULL << iter->tlabel); in close_transaction()
66 return -ENOENT; in close_transaction()
68 if (!t->with_tstamp) { in close_transaction()
69 t->callback.without_tstamp(card, rcode, NULL, 0, t->callback_data); in close_transaction()
71 t->callback.with_tstamp(card, rcode, t->packet.timestamp, response_tstamp, NULL, 0, in close_transaction()
72 t->callback_data); in close_transaction()
93 if (card->driver->cancel_packet(card, &transaction->packet) == 0) in fw_cancel_transaction()
101 if (transaction->packet.ack == 0) { in fw_cancel_transaction()
102 // The timestamp is reused since it was just read now. in fw_cancel_transaction()
103 tstamp = transaction->packet.timestamp; in fw_cancel_transaction()
118 struct fw_card *card = t->card; in split_transaction_timeout_callback()
120 scoped_guard(spinlock_irqsave, &card->lock) { in split_transaction_timeout_callback()
121 if (list_empty(&t->link)) in split_transaction_timeout_callback()
123 list_del(&t->link); in split_transaction_timeout_callback()
124 card->tlabel_mask &= ~(1ULL << t->tlabel); in split_transaction_timeout_callback()
127 if (!t->with_tstamp) { in split_transaction_timeout_callback()
128 t->callback.without_tstamp(card, RCODE_CANCELLED, NULL, 0, t->callback_data); in split_transaction_timeout_callback()
130 t->callback.with_tstamp(card, RCODE_CANCELLED, t->packet.timestamp, in split_transaction_timeout_callback()
131 t->split_timeout_cycle, NULL, 0, t->callback_data); in split_transaction_timeout_callback()
138 guard(spinlock_irqsave)(&card->lock); in start_split_transaction_timeout()
140 if (list_empty(&t->link) || WARN_ON(t->is_split_transaction)) in start_split_transaction_timeout()
143 t->is_split_transaction = true; in start_split_transaction_timeout()
144 mod_timer(&t->split_timeout_timer, in start_split_transaction_timeout()
145 jiffies + card->split_timeout_jiffies); in start_split_transaction_timeout()
156 trace_async_request_outbound_complete((uintptr_t)t, card->index, packet->generation, in transmit_complete_callback()
157 packet->speed, status, packet->timestamp); in transmit_complete_callback()
161 close_transaction(t, card, RCODE_COMPLETE, packet->timestamp); in transmit_complete_callback()
165 t->split_timeout_cycle = in transmit_complete_callback()
166 compute_split_timeout_timestamp(card, packet->timestamp) & 0xffff; in transmit_complete_callback()
173 close_transaction(t, card, RCODE_BUSY, packet->timestamp); in transmit_complete_callback()
176 close_transaction(t, card, RCODE_DATA_ERROR, packet->timestamp); in transmit_complete_callback()
179 close_transaction(t, card, RCODE_TYPE_ERROR, packet->timestamp); in transmit_complete_callback()
186 close_transaction(t, card, status, packet->timestamp); in transmit_complete_callback()
200 packet->header[0] = destination_id; in fw_fill_request()
201 isoc_header_set_data_length(packet->header, length); in fw_fill_request()
202 isoc_header_set_tcode(packet->header, TCODE_STREAM_DATA); in fw_fill_request()
203 packet->header_length = 4; in fw_fill_request()
204 packet->payload = payload; in fw_fill_request()
205 packet->payload_length = length; in fw_fill_request()
216 async_header_set_retry(packet->header, RETRY_X); in fw_fill_request()
217 async_header_set_tlabel(packet->header, tlabel); in fw_fill_request()
218 async_header_set_tcode(packet->header, tcode); in fw_fill_request()
219 async_header_set_destination(packet->header, destination_id); in fw_fill_request()
220 async_header_set_source(packet->header, source_id); in fw_fill_request()
221 async_header_set_offset(packet->header, offset); in fw_fill_request()
225 async_header_set_quadlet_data(packet->header, *(u32 *)payload); in fw_fill_request()
226 packet->header_length = 16; in fw_fill_request()
227 packet->payload_length = 0; in fw_fill_request()
232 async_header_set_data_length(packet->header, length); in fw_fill_request()
233 async_header_set_extended_tcode(packet->header, ext_tcode); in fw_fill_request()
234 packet->header_length = 16; in fw_fill_request()
235 packet->payload = payload; in fw_fill_request()
236 packet->payload_length = length; in fw_fill_request()
240 packet->header_length = 12; in fw_fill_request()
241 packet->payload_length = 0; in fw_fill_request()
245 async_header_set_data_length(packet->header, length); in fw_fill_request()
246 async_header_set_extended_tcode(packet->header, ext_tcode); in fw_fill_request()
247 packet->header_length = 16; in fw_fill_request()
248 packet->payload_length = 0; in fw_fill_request()
255 packet->speed = speed; in fw_fill_request()
256 packet->generation = generation; in fw_fill_request()
257 packet->ack = 0; in fw_fill_request()
258 packet->payload_mapped = false; in fw_fill_request()
265 tlabel = card->current_tlabel; in allocate_tlabel()
266 while (card->tlabel_mask & (1ULL << tlabel)) { in allocate_tlabel()
268 if (tlabel == card->current_tlabel) in allocate_tlabel()
269 return -EBUSY; in allocate_tlabel()
272 card->current_tlabel = (tlabel + 1) & 0x3f; in allocate_tlabel()
273 card->tlabel_mask |= 1ULL << tlabel; in allocate_tlabel()
279 * __fw_send_request() - submit a request packet for transmission to generate callback for response
299 * In case of lock requests, specify one of the firewire-core specific %TCODE_
309 * The payload buffer at @data is going to be DMA-mapped except in case of
319 * the firewire-core specific %RCODE_SEND_ERROR. The other firewire-core
342 spin_lock_irqsave(&card->lock, flags); in __fw_send_request()
346 spin_unlock_irqrestore(&card->lock, flags); in __fw_send_request()
363 t->node_id = destination_id; in __fw_send_request()
364 t->tlabel = tlabel; in __fw_send_request()
365 t->card = card; in __fw_send_request()
366 t->is_split_transaction = false; in __fw_send_request()
367 timer_setup(&t->split_timeout_timer, split_transaction_timeout_callback, 0); in __fw_send_request()
368 t->callback = callback; in __fw_send_request()
369 t->with_tstamp = with_tstamp; in __fw_send_request()
370 t->callback_data = callback_data; in __fw_send_request()
372 fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, card->node_id, generation, in __fw_send_request()
374 t->packet.callback = transmit_complete_callback; in __fw_send_request()
376 list_add_tail(&t->link, &card->transaction_list); in __fw_send_request()
378 spin_unlock_irqrestore(&card->lock, flags); in __fw_send_request()
380 trace_async_request_outbound_initiate((uintptr_t)t, card->index, generation, speed, in __fw_send_request()
381 t->packet.header, payload, in __fw_send_request()
384 card->driver->send_request(card, &t->packet); in __fw_send_request()
400 memcpy(d->payload, payload, length); in transaction_callback()
401 d->rcode = rcode; in transaction_callback()
402 complete(&d->done); in transaction_callback()
406 * fw_run_transaction() - send request and sleep until transaction is completed
446 trace_async_phy_outbound_complete((uintptr_t)packet, card->index, packet->generation, status, in transmit_phy_packet_callback()
447 packet->timestamp); in transmit_phy_packet_callback()
472 gap_count = card->driver->read_phy_reg(card, 1); in fw_send_phy_config()
491 trace_async_phy_outbound_initiate((uintptr_t)&phy_config_packet, card->index, in fw_send_phy_config()
495 card->driver->send_request(card, &phy_config_packet); in fw_send_phy_config()
505 if (handler->offset < offset + length && in lookup_overlapping_address_handler()
506 offset < handler->offset + handler->length) in lookup_overlapping_address_handler()
516 return handler->offset <= offset && in is_enclosing_handler()
517 offset + length <= handler->offset + handler->length; in is_enclosing_handler()
554 * fw_core_add_address_handler() - register for incoming requests
558 * region->start, ->end, and handler->length have to be quadlet-aligned.
565 * Return value: 0 on success, non-zero otherwise.
568 * fw_core_add_address_handler() and is returned in handler->offset.
576 int ret = -EBUSY; in fw_core_add_address_handler()
578 if (region->start & 0xffff000000000003ULL || in fw_core_add_address_handler()
579 region->start >= region->end || in fw_core_add_address_handler()
580 region->end > 0x0001000000000000ULL || in fw_core_add_address_handler()
581 handler->length & 3 || in fw_core_add_address_handler()
582 handler->length == 0) in fw_core_add_address_handler()
583 return -EINVAL; in fw_core_add_address_handler()
587 handler->offset = region->start; in fw_core_add_address_handler()
588 while (handler->offset + handler->length <= region->end) { in fw_core_add_address_handler()
589 if (is_in_fcp_region(handler->offset, handler->length)) in fw_core_add_address_handler()
594 handler->offset, handler->length); in fw_core_add_address_handler()
596 handler->offset += other->length; in fw_core_add_address_handler()
598 list_add_tail_rcu(&handler->link, &address_handler_list); in fw_core_add_address_handler()
609 * fw_core_remove_address_handler() - unregister an address handler
614 * When fw_core_remove_address_handler() returns, @handler->callback() is
620 list_del_rcu(&handler->link); in fw_core_remove_address_handler()
631 u32 timestamp; member
638 kref_get(&request->kref); in fw_request_get()
650 kref_put(&request->kref, release_request); in fw_request_put()
658 trace_async_response_outbound_complete((uintptr_t)request, card->index, packet->generation, in free_response_callback()
659 packet->speed, status, packet->timestamp); in free_response_callback()
661 // Decrease the reference count since not at in-flight. in free_response_callback()
672 tcode = async_header_get_tcode(r->request_header); in fw_get_response_length()
683 data_length = async_header_get_data_length(r->request_header); in fw_get_response_length()
687 ext_tcode = async_header_get_extended_tcode(r->request_header); in fw_get_response_length()
688 data_length = async_header_get_data_length(r->request_header); in fw_get_response_length()
714 async_header_set_retry(response->header, RETRY_1); in fw_fill_response()
715 async_header_set_tlabel(response->header, tlabel); in fw_fill_response()
716 async_header_set_destination(response->header, destination); in fw_fill_response()
717 async_header_set_source(response->header, source); in fw_fill_response()
718 async_header_set_rcode(response->header, rcode); in fw_fill_response()
719 response->header[2] = 0; // The field is reserved. in fw_fill_response()
724 async_header_set_tcode(response->header, TCODE_WRITE_RESPONSE); in fw_fill_response()
725 response->header_length = 12; in fw_fill_response()
726 response->payload_length = 0; in fw_fill_response()
730 async_header_set_tcode(response->header, TCODE_READ_QUADLET_RESPONSE); in fw_fill_response()
732 async_header_set_quadlet_data(response->header, *(u32 *)payload); in fw_fill_response()
734 async_header_set_quadlet_data(response->header, 0); in fw_fill_response()
735 response->header_length = 16; in fw_fill_response()
736 response->payload_length = 0; in fw_fill_response()
741 async_header_set_tcode(response->header, tcode + 2); in fw_fill_response()
742 async_header_set_data_length(response->header, length); in fw_fill_response()
743 async_header_set_extended_tcode(response->header, extended_tcode); in fw_fill_response()
744 response->header_length = 16; in fw_fill_response()
745 response->payload = payload; in fw_fill_response()
746 response->payload_length = length; in fw_fill_response()
753 response->payload_mapped = false; in fw_fill_response()
761 u32 timestamp; in compute_split_timeout_timestamp() local
763 cycles = card->split_timeout_cycles; in compute_split_timeout_timestamp()
766 timestamp = request_timestamp & ~0x1fff; in compute_split_timeout_timestamp()
767 timestamp += (cycles / 8000) << 13; in compute_split_timeout_timestamp()
768 timestamp |= cycles % 8000; in compute_split_timeout_timestamp()
770 return timestamp; in compute_split_timeout_timestamp()
780 request_tcode = async_header_get_tcode(p->header); in allocate_request()
783 data = &p->header[3]; in allocate_request()
789 data = p->payload; in allocate_request()
790 length = async_header_get_data_length(p->header); in allocate_request()
800 length = async_header_get_data_length(p->header); in allocate_request()
804 fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", in allocate_request()
805 p->header[0], p->header[1], p->header[2]); in allocate_request()
812 kref_init(&request->kref); in allocate_request()
814 request->response.speed = p->speed; in allocate_request()
815 request->response.timestamp = in allocate_request()
816 compute_split_timeout_timestamp(card, p->timestamp); in allocate_request()
817 request->response.generation = p->generation; in allocate_request()
818 request->response.ack = 0; in allocate_request()
819 request->response.callback = free_response_callback; in allocate_request()
820 request->ack = p->ack; in allocate_request()
821 request->timestamp = p->timestamp; in allocate_request()
822 request->length = length; in allocate_request()
824 memcpy(request->data, data, length); in allocate_request()
826 memcpy(request->request_header, p->header, sizeof(p->header)); in allocate_request()
832 * fw_send_response: - send response packet for asynchronous transaction.
847 if (request->ack != ACK_PENDING || in fw_send_response()
848 HEADER_DESTINATION_IS_BROADCAST(request->request_header)) { in fw_send_response()
854 data = request->data; in fw_send_response()
858 fw_fill_response(&request->response, request->request_header, rcode, data, data_length); in fw_send_response()
860 // Increase the reference count so that the object is kept during in-flight. in fw_send_response()
863 trace_async_response_outbound_initiate((uintptr_t)request, card->index, in fw_send_response()
864 request->response.generation, request->response.speed, in fw_send_response()
865 request->response.header, data, in fw_send_response()
868 card->driver->send_response(card, &request->response); in fw_send_response()
873 * fw_get_request_speed() - returns speed at which the @request was received
878 return request->response.speed; in fw_get_request_speed()
883 * fw_request_get_timestamp: Get timestamp of the request.
886 * Get timestamp when 1394 OHCI controller receives the asynchronous request subaction. The
887 * timestamp consists of the low order 3 bits of second field and the full 13 bits of count
890 * Returns: timestamp of the request.
894 return request->timestamp; in fw_request_get_timestamp()
906 destination = async_header_get_destination(p->header); in handle_exclusive_region_request()
907 source = async_header_get_source(p->header); in handle_exclusive_region_request()
908 tcode = async_header_get_tcode(p->header); in handle_exclusive_region_request()
910 tcode = 0x10 + async_header_get_extended_tcode(p->header); in handle_exclusive_region_request()
914 request->length); in handle_exclusive_region_request()
916 handler->address_callback(card, request, tcode, destination, source, in handle_exclusive_region_request()
917 p->generation, offset, request->data, in handle_exclusive_region_request()
918 request->length, handler->callback_data); in handle_exclusive_region_request()
935 request->length > 0x200) { in handle_fcp_region_request()
941 tcode = async_header_get_tcode(p->header); in handle_fcp_region_request()
942 destination = async_header_get_destination(p->header); in handle_fcp_region_request()
943 source = async_header_get_source(p->header); in handle_fcp_region_request()
954 if (is_enclosing_handler(handler, offset, request->length)) in handle_fcp_region_request()
955 handler->address_callback(card, request, tcode, destination, source, in handle_fcp_region_request()
956 p->generation, offset, request->data, in handle_fcp_region_request()
957 request->length, handler->callback_data); in handle_fcp_region_request()
970 if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE) in fw_core_handle_request()
973 tcode = async_header_get_tcode(p->header); in fw_core_handle_request()
975 trace_async_phy_inbound((uintptr_t)p, card->index, p->generation, p->ack, p->timestamp, in fw_core_handle_request()
976 p->header[1], p->header[2]); in fw_core_handle_request()
987 trace_async_request_inbound((uintptr_t)request, card->index, p->generation, p->speed, in fw_core_handle_request()
988 p->ack, p->timestamp, p->header, request->data, in fw_core_handle_request()
989 tcode_is_read_request(tcode) ? 0 : request->length / 4); in fw_core_handle_request()
991 offset = async_header_get_offset(p->header); in fw_core_handle_request()
993 if (!is_in_fcp_region(offset, request->length)) in fw_core_handle_request()
1008 tcode = async_header_get_tcode(p->header); in fw_core_handle_response()
1009 tlabel = async_header_get_tlabel(p->header); in fw_core_handle_response()
1010 source = async_header_get_source(p->header); in fw_core_handle_response()
1011 rcode = async_header_get_rcode(p->header); in fw_core_handle_response()
1020 data = (u32 *) &p->header[3]; in fw_core_handle_response()
1031 data = p->payload; in fw_core_handle_response()
1032 data_length = async_header_get_data_length(p->header); in fw_core_handle_response()
1042 scoped_guard(spinlock_irqsave, &card->lock) { in fw_core_handle_response()
1043 list_for_each_entry(iter, &card->transaction_list, link) { in fw_core_handle_response()
1044 if (iter->node_id == source && iter->tlabel == tlabel) { in fw_core_handle_response()
1046 list_del_init(&iter->link); in fw_core_handle_response()
1047 card->tlabel_mask &= ~(1ULL << iter->tlabel); in fw_core_handle_response()
1055 trace_async_response_inbound((uintptr_t)t, card->index, p->generation, p->speed, p->ack, in fw_core_handle_response()
1056 p->timestamp, p->header, data, data_length / 4); in fw_core_handle_response()
1068 card->driver->cancel_packet(card, &t->packet); in fw_core_handle_response()
1070 if (!t->with_tstamp) { in fw_core_handle_response()
1071 t->callback.without_tstamp(card, rcode, data, data_length, t->callback_data); in fw_core_handle_response()
1073 t->callback.with_tstamp(card, rcode, t->packet.timestamp, p->timestamp, data, in fw_core_handle_response()
1074 data_length, t->callback_data); in fw_core_handle_response()
1080 * fw_rcode_string - convert a firewire result code to an error description
1085 static const char *const names[] = { in fw_rcode_string() local
1098 if ((unsigned int)rcode < ARRAY_SIZE(names) && names[rcode]) in fw_rcode_string()
1099 return names[rcode]; in fw_rcode_string()
1126 start = (offset - topology_map_region.start) / 4; in handle_topology_map()
1127 memcpy(payload, &card->topology_map[start], length); in handle_topology_map()
1145 cycles = card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); in update_split_timeout()
1150 card->split_timeout_cycles = cycles; in update_split_timeout()
1151 card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); in update_split_timeout()
1165 if (!card->priority_budget_implemented) { in handle_registers()
1173 * per IEEE 1394-2008 8.3.22.3, not IEEE 1394.1-2004 3.2.8 in handle_registers()
1174 * and 9.6, but interoperable with IEEE 1394.1-2004 bridges in handle_registers()
1184 *data = cpu_to_be32(card->driver->read_csr(card, reg)); in handle_registers()
1186 card->driver->write_csr(card, reg, be32_to_cpu(*data)); in handle_registers()
1193 card->driver->write_csr(card, CSR_STATE_CLEAR, in handle_registers()
1201 *data = cpu_to_be32(card->split_timeout_hi); in handle_registers()
1203 guard(spinlock_irqsave)(&card->lock); in handle_registers()
1205 card->split_timeout_hi = be32_to_cpu(*data) & 7; in handle_registers()
1214 *data = cpu_to_be32(card->split_timeout_lo); in handle_registers()
1216 guard(spinlock_irqsave)(&card->lock); in handle_registers()
1218 card->split_timeout_lo = be32_to_cpu(*data) & 0xfff80000; in handle_registers()
1227 *data = card->maint_utility_register; in handle_registers()
1229 card->maint_utility_register = *data; in handle_registers()
1236 *data = cpu_to_be32(card->broadcast_channel); in handle_registers()
1238 card->broadcast_channel = in handle_registers()
1332 return -ENOMEM; in fw_core_init()