205 current_size = fsm->slave->configured_tx_mailbox_size |
205 current_size = fsm->slave->configured_tx_mailbox_size |
206 - EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE; |
206 - EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE; |
207 } |
207 } |
208 |
208 |
209 data = ec_slave_mbox_prepare_send(fsm->slave, |
209 data = ec_slave_mbox_prepare_send(fsm->slave, |
210 fsm->datagram, EC_MBOX_TYPE_FILEACCESS, |
210 fsm->mbox,EC_MBOX_TYPE_FILEACCESS, |
211 current_size + EC_FOE_HEADER_SIZE); |
211 current_size + EC_FOE_HEADER_SIZE); |
212 if (IS_ERR(data)) |
212 if (IS_ERR(data)) |
213 return -1; |
213 return -1; |
214 |
214 |
215 EC_WRITE_U8 ( data, EC_FOE_OPCODE_DATA ); // OpCode = DataBlock req. |
215 EC_WRITE_U8 ( data, EC_FOE_OPCODE_DATA ); // OpCode = DataBlock req. |
236 fsm->tx_packet_no = 0; |
236 fsm->tx_packet_no = 0; |
237 fsm->tx_last_packet = 0; |
237 fsm->tx_last_packet = 0; |
238 |
238 |
239 current_size = fsm->tx_filename_len; |
239 current_size = fsm->tx_filename_len; |
240 |
240 |
241 data = ec_slave_mbox_prepare_send(fsm->slave, fsm->datagram, |
241 data = ec_slave_mbox_prepare_send(fsm->slave, fsm->mbox, |
242 EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE); |
242 EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE); |
243 if (IS_ERR(data)) |
243 if (IS_ERR(data)) |
244 return -1; |
244 return -1; |
245 |
245 |
246 EC_WRITE_U16( data, EC_FOE_OPCODE_WRQ); // fsm write request |
246 EC_WRITE_U16( data, EC_FOE_OPCODE_WRQ); // fsm write request |
306 */ |
306 */ |
307 void ec_fsm_foe_state_ack_check( |
307 void ec_fsm_foe_state_ack_check( |
308 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
308 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
309 ) |
309 ) |
310 { |
310 { |
311 ec_datagram_t *datagram = fsm->datagram; |
311 ec_mailbox_t *mbox = fsm->mbox; |
|
312 ec_datagram_t *datagram = mbox->datagram; |
312 ec_slave_t *slave = fsm->slave; |
313 ec_slave_t *slave = fsm->slave; |
313 |
314 |
314 #ifdef DEBUG_FOE |
315 #ifdef DEBUG_FOE |
315 printk("ec_fsm_foe_ack_check()\n"); |
316 printk("ec_fsm_foe_ack_check()\n"); |
316 #endif |
317 #endif |
317 |
318 |
318 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
319 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
319 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
320 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
320 EC_SLAVE_ERR(slave, "Failed to receive FoE mailbox check datagram: "); |
321 EC_SLAVE_ERR(slave, "Failed to receive FoE mailbox check datagram: "); |
321 ec_datagram_print_state(datagram); |
322 ec_datagram_print_state(datagram); |
322 return; |
323 return; |
323 } |
324 } |
324 |
325 |
325 if (datagram->working_counter != 1) { |
326 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
326 // slave did not put anything in the mailbox yet |
327 // slave did not put anything in the mailbox yet |
327 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
328 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
328 EC_SLAVE_ERR(slave, "Reception of FoE mailbox check datagram" |
329 EC_SLAVE_ERR(slave, "Reception of FoE mailbox check datagram" |
329 " failed: "); |
330 " failed: "); |
330 ec_datagram_print_wc_error(datagram); |
331 ec_datagram_print_wc_error(datagram); |
331 return; |
332 return; |
332 } |
333 } |
333 |
334 |
334 if (!ec_slave_mbox_check(datagram)) { |
335 if (!ec_slave_mbox_check(mbox)) { |
335 unsigned long diff_ms = |
336 unsigned long diff_ms = |
336 (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
337 (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
337 if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
338 if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
338 ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
339 ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
339 EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); |
340 EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); |
340 return; |
341 return; |
341 } |
342 } |
342 |
343 |
343 ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
344 ec_slave_mbox_prepare_check(slave, mbox); // can not fail. |
344 fsm->retries = EC_FSM_RETRIES; |
345 fsm->retries = EC_FSM_RETRIES; |
345 return; |
346 return; |
346 } |
347 } |
347 |
348 |
348 // Fetch response |
349 // Fetch response |
349 ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
350 ec_slave_mbox_prepare_fetch(slave, mbox); // can not fail. |
350 |
351 |
351 fsm->retries = EC_FSM_RETRIES; |
352 fsm->retries = EC_FSM_RETRIES; |
352 fsm->state = ec_fsm_foe_state_ack_read; |
353 fsm->state = ec_fsm_foe_state_ack_read; |
353 } |
354 } |
354 |
355 |
358 */ |
359 */ |
359 void ec_fsm_foe_state_ack_read( |
360 void ec_fsm_foe_state_ack_read( |
360 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
361 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
361 ) |
362 ) |
362 { |
363 { |
363 ec_datagram_t *datagram = fsm->datagram; |
364 ec_mailbox_t *mbox = fsm->mbox; |
|
365 ec_datagram_t *datagram = mbox->datagram; |
364 ec_slave_t *slave = fsm->slave; |
366 ec_slave_t *slave = fsm->slave; |
365 uint8_t *data, mbox_prot; |
367 uint8_t *data, mbox_prot; |
366 uint8_t opCode; |
368 uint8_t opCode; |
367 size_t rec_size; |
369 size_t rec_size; |
368 |
370 |
369 #ifdef DEBUG_FOE |
371 #ifdef DEBUG_FOE |
370 printk("ec_fsm_foe_ack_read()\n"); |
372 printk("ec_fsm_foe_ack_read()\n"); |
371 #endif |
373 #endif |
372 |
374 |
373 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
375 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
374 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
376 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
375 EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
377 EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
376 ec_datagram_print_state(datagram); |
378 ec_datagram_print_state(datagram); |
377 return; |
379 return; |
378 } |
380 } |
379 |
381 |
380 if (datagram->working_counter != 1) { |
382 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
381 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
383 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
382 EC_SLAVE_ERR(slave, "Reception of FoE ack response failed: "); |
384 EC_SLAVE_ERR(slave, "Reception of FoE ack response failed: "); |
383 ec_datagram_print_wc_error(datagram); |
385 ec_datagram_print_wc_error(datagram); |
384 return; |
386 return; |
385 } |
387 } |
386 |
388 |
387 if (!(data = ec_slave_mbox_fetch(fsm->slave, datagram, |
389 if (!(data = ec_slave_mbox_fetch(fsm->slave, fsm->mbox, |
388 &mbox_prot, &rec_size))) { |
390 &mbox_prot, &rec_size))) { |
389 ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
391 ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
390 return; |
392 return; |
391 } |
393 } |
392 |
394 |
438 */ |
440 */ |
439 void ec_fsm_foe_state_wrq_sent( |
441 void ec_fsm_foe_state_wrq_sent( |
440 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
442 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
441 ) |
443 ) |
442 { |
444 { |
443 ec_datagram_t *datagram = fsm->datagram; |
445 ec_mailbox_t *mbox = fsm->mbox; |
|
446 ec_datagram_t *datagram = mbox->datagram; |
444 ec_slave_t *slave = fsm->slave; |
447 ec_slave_t *slave = fsm->slave; |
445 |
448 |
446 #ifdef DEBUG_FOE |
449 #ifdef DEBUG_FOE |
447 printk("ec_foe_state_sent_wrq()\n"); |
450 printk("ec_foe_state_sent_wrq()\n"); |
448 #endif |
451 #endif |
449 |
452 |
450 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
453 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
451 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
454 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
452 EC_SLAVE_ERR(slave, "Failed to send FoE WRQ: "); |
455 EC_SLAVE_ERR(slave, "Failed to send FoE WRQ: "); |
453 ec_datagram_print_state(datagram); |
456 ec_datagram_print_state(datagram); |
454 return; |
457 return; |
455 } |
458 } |
456 |
459 |
457 if (datagram->working_counter != 1) { |
460 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
458 // slave did not put anything in the mailbox yet |
461 // slave did not put anything in the mailbox yet |
459 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
462 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
460 EC_SLAVE_ERR(slave, "Reception of FoE WRQ failed: "); |
463 EC_SLAVE_ERR(slave, "Reception of FoE WRQ failed: "); |
461 ec_datagram_print_wc_error(datagram); |
464 ec_datagram_print_wc_error(datagram); |
462 return; |
465 return; |
463 } |
466 } |
464 |
467 |
465 fsm->jiffies_start = datagram->jiffies_sent; |
468 fsm->jiffies_start = datagram->jiffies_sent; |
466 |
469 |
467 ec_slave_mbox_prepare_check(fsm->slave, datagram); // can not fail. |
470 ec_slave_mbox_prepare_check(fsm->slave, fsm->mbox); // can not fail. |
468 |
471 |
469 fsm->retries = EC_FSM_RETRIES; |
472 fsm->retries = EC_FSM_RETRIES; |
470 fsm->state = ec_fsm_foe_state_ack_check; |
473 fsm->state = ec_fsm_foe_state_ack_check; |
471 } |
474 } |
472 |
475 |
479 */ |
482 */ |
480 void ec_fsm_foe_state_data_sent( |
483 void ec_fsm_foe_state_data_sent( |
481 ec_fsm_foe_t *fsm /**< Foe statemachine. */ |
484 ec_fsm_foe_t *fsm /**< Foe statemachine. */ |
482 ) |
485 ) |
483 { |
486 { |
484 ec_datagram_t *datagram = fsm->datagram; |
487 ec_mailbox_t *mbox = fsm->mbox; |
|
488 ec_datagram_t *datagram = mbox->datagram; |
485 ec_slave_t *slave = fsm->slave; |
489 ec_slave_t *slave = fsm->slave; |
486 |
490 |
487 #ifdef DEBUG_FOE |
491 #ifdef DEBUG_FOE |
488 printk("ec_fsm_foe_state_data_sent()\n"); |
492 printk("ec_fsm_foe_state_data_sent()\n"); |
489 #endif |
493 #endif |
490 |
494 |
491 if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
495 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
492 ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR); |
496 ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR); |
493 EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
497 EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
494 ec_datagram_print_state(datagram); |
498 ec_datagram_print_state(datagram); |
495 return; |
499 return; |
496 } |
500 } |
497 |
501 |
498 if (fsm->datagram->working_counter != 1) { |
502 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
499 ec_foe_set_tx_error(fsm, FOE_WC_ERROR); |
503 ec_foe_set_tx_error(fsm, FOE_WC_ERROR); |
500 EC_SLAVE_ERR(slave, "Reception of FoE data send failed: "); |
504 EC_SLAVE_ERR(slave, "Reception of FoE data send failed: "); |
501 ec_datagram_print_wc_error(datagram); |
505 ec_datagram_print_wc_error(datagram); |
502 return; |
506 return; |
503 } |
507 } |
504 |
508 |
505 ec_slave_mbox_prepare_check(fsm->slave, fsm->datagram); |
509 ec_slave_mbox_prepare_check(slave, mbox); |
506 fsm->jiffies_start = jiffies; |
510 fsm->jiffies_start = jiffies; |
507 fsm->retries = EC_FSM_RETRIES; |
511 fsm->retries = EC_FSM_RETRIES; |
508 fsm->state = ec_fsm_foe_state_ack_check; |
512 fsm->state = ec_fsm_foe_state_ack_check; |
509 } |
513 } |
510 |
514 |
566 */ |
570 */ |
567 void ec_fsm_foe_state_rrq_sent( |
571 void ec_fsm_foe_state_rrq_sent( |
568 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
572 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
569 ) |
573 ) |
570 { |
574 { |
571 ec_datagram_t *datagram = fsm->datagram; |
575 ec_mailbox_t *mbox = fsm->mbox; |
|
576 ec_datagram_t *datagram = mbox->datagram; |
572 ec_slave_t *slave = fsm->slave; |
577 ec_slave_t *slave = fsm->slave; |
573 |
578 |
574 #ifdef DEBUG_FOE |
579 #ifdef DEBUG_FOE |
575 printk("ec_foe_state_rrq_sent()\n"); |
580 printk("ec_foe_state_rrq_sent()\n"); |
576 #endif |
581 #endif |
577 |
582 |
578 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
583 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
579 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
584 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
580 EC_SLAVE_ERR(slave, "Failed to send FoE RRQ: "); |
585 EC_SLAVE_ERR(slave, "Failed to send FoE RRQ: "); |
581 ec_datagram_print_state(datagram); |
586 ec_datagram_print_state(datagram); |
582 return; |
587 return; |
583 } |
588 } |
584 |
589 |
585 if (datagram->working_counter != 1) { |
590 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
586 // slave did not put anything in the mailbox yet |
591 // slave did not put anything in the mailbox yet |
587 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
592 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
588 EC_SLAVE_ERR(slave, "Reception of FoE RRQ failed: "); |
593 EC_SLAVE_ERR(slave, "Reception of FoE RRQ failed: "); |
589 ec_datagram_print_wc_error(datagram); |
594 ec_datagram_print_wc_error(datagram); |
590 return; |
595 return; |
591 } |
596 } |
592 |
597 |
593 fsm->jiffies_start = datagram->jiffies_sent; |
598 fsm->jiffies_start = datagram->jiffies_sent; |
594 |
599 |
595 ec_slave_mbox_prepare_check(fsm->slave, datagram); // can not fail. |
600 ec_slave_mbox_prepare_check(fsm->slave, fsm->mbox); // can not fail. |
596 |
601 |
597 fsm->retries = EC_FSM_RETRIES; |
602 fsm->retries = EC_FSM_RETRIES; |
598 fsm->state = ec_fsm_foe_state_data_check; |
603 fsm->state = ec_fsm_foe_state_data_check; |
599 } |
604 } |
600 |
605 |
655 */ |
660 */ |
656 void ec_fsm_foe_state_data_check( |
661 void ec_fsm_foe_state_data_check( |
657 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
662 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
658 ) |
663 ) |
659 { |
664 { |
660 ec_datagram_t *datagram = fsm->datagram; |
665 ec_mailbox_t *mbox = fsm->mbox; |
|
666 ec_datagram_t *datagram = mbox->datagram; |
661 ec_slave_t *slave = fsm->slave; |
667 ec_slave_t *slave = fsm->slave; |
662 |
668 |
663 #ifdef DEBUG_FOE |
669 #ifdef DEBUG_FOE |
664 printk("ec_fsm_foe_state_data_check()\n"); |
670 printk("ec_fsm_foe_state_data_check()\n"); |
665 #endif |
671 #endif |
666 |
672 |
667 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
673 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
668 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
674 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
669 EC_SLAVE_ERR(slave, "Failed to send FoE DATA READ: "); |
675 EC_SLAVE_ERR(slave, "Failed to send FoE DATA READ: "); |
670 ec_datagram_print_state(datagram); |
676 ec_datagram_print_state(datagram); |
671 return; |
677 return; |
672 } |
678 } |
673 |
679 |
674 if (datagram->working_counter != 1) { |
680 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
675 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
681 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
676 EC_SLAVE_ERR(slave, "Reception of FoE DATA READ: "); |
682 EC_SLAVE_ERR(slave, "Reception of FoE DATA READ: "); |
677 ec_datagram_print_wc_error(datagram); |
683 ec_datagram_print_wc_error(datagram); |
678 return; |
684 return; |
679 } |
685 } |
680 |
686 |
681 if (!ec_slave_mbox_check(datagram)) { |
687 if (!ec_slave_mbox_check(mbox)) { |
682 unsigned long diff_ms = |
688 unsigned long diff_ms = |
683 (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
689 (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
684 if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
690 if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
685 ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
691 ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
686 EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); |
692 EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); |
687 return; |
693 return; |
688 } |
694 } |
689 |
695 |
690 ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
696 ec_slave_mbox_prepare_check(slave, mbox); // can not fail. |
691 fsm->retries = EC_FSM_RETRIES; |
697 fsm->retries = EC_FSM_RETRIES; |
692 return; |
698 return; |
693 } |
699 } |
694 |
700 |
695 // Fetch response |
701 // Fetch response |
696 ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
702 ec_slave_mbox_prepare_fetch(slave, mbox); // can not fail. |
697 |
703 |
698 fsm->retries = EC_FSM_RETRIES; |
704 fsm->retries = EC_FSM_RETRIES; |
699 fsm->state = ec_fsm_foe_state_data_read; |
705 fsm->state = ec_fsm_foe_state_data_read; |
700 |
706 |
701 } |
707 } |
709 ) |
715 ) |
710 { |
716 { |
711 size_t rec_size; |
717 size_t rec_size; |
712 uint8_t *data, opCode, packet_no, mbox_prot; |
718 uint8_t *data, opCode, packet_no, mbox_prot; |
713 |
719 |
714 ec_datagram_t *datagram = fsm->datagram; |
720 ec_mailbox_t *mbox = fsm->mbox; |
|
721 ec_datagram_t *datagram = mbox->datagram; |
715 ec_slave_t *slave = fsm->slave; |
722 ec_slave_t *slave = fsm->slave; |
716 |
723 |
717 #ifdef DEBUG_FOE |
724 #ifdef DEBUG_FOE |
718 printk("ec_fsm_foe_state_data_read()\n"); |
725 printk("ec_fsm_foe_state_data_read()\n"); |
719 #endif |
726 #endif |
720 |
727 |
721 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
728 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
722 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
729 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
723 EC_SLAVE_ERR(slave, "Failed to receive FoE DATA READ datagram: "); |
730 EC_SLAVE_ERR(slave, "Failed to receive FoE DATA READ datagram: "); |
724 ec_datagram_print_state(datagram); |
731 ec_datagram_print_state(datagram); |
725 return; |
732 return; |
726 } |
733 } |
727 |
734 |
728 if (datagram->working_counter != 1) { |
735 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
729 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
736 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
730 EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: "); |
737 EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: "); |
731 ec_datagram_print_wc_error(datagram); |
738 ec_datagram_print_wc_error(datagram); |
732 return; |
739 return; |
733 } |
740 } |
734 |
741 |
735 if (!(data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot, &rec_size))) { |
742 if (!(data = ec_slave_mbox_fetch(slave, mbox, &mbox_prot, &rec_size))) { |
736 ec_foe_set_rx_error(fsm, FOE_MBOX_FETCH_ERROR); |
743 ec_foe_set_rx_error(fsm, FOE_MBOX_FETCH_ERROR); |
737 return; |
744 return; |
738 } |
745 } |
739 |
746 |
740 if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
747 if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
829 */ |
836 */ |
830 void ec_fsm_foe_state_sent_ack( |
837 void ec_fsm_foe_state_sent_ack( |
831 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
838 ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
832 ) |
839 ) |
833 { |
840 { |
834 ec_datagram_t *datagram = fsm->datagram; |
841 ec_mailbox_t *mbox = fsm->mbox; |
|
842 ec_datagram_t *datagram = mbox->datagram; |
835 ec_slave_t *slave = fsm->slave; |
843 ec_slave_t *slave = fsm->slave; |
836 |
844 |
837 #ifdef DEBUG_FOE |
845 #ifdef DEBUG_FOE |
838 printk("ec_foe_state_sent_ack()\n"); |
846 printk("ec_foe_state_sent_ack()\n"); |
839 #endif |
847 #endif |
840 |
848 |
841 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
849 if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) { |
842 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
850 ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
843 EC_SLAVE_ERR(slave, "Failed to send FoE ACK: "); |
851 EC_SLAVE_ERR(slave, "Failed to send FoE ACK: "); |
844 ec_datagram_print_state(datagram); |
852 ec_datagram_print_state(datagram); |
845 return; |
853 return; |
846 } |
854 } |
847 |
855 |
848 if (datagram->working_counter != 1) { |
856 if (!ec_mbox_is_datagram_wc(mbox,1)) { |
849 // slave did not put anything into the mailbox yet |
857 // slave did not put anything into the mailbox yet |
850 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
858 ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
851 EC_SLAVE_ERR(slave, "Reception of FoE ACK failed: "); |
859 EC_SLAVE_ERR(slave, "Reception of FoE ACK failed: "); |
852 ec_datagram_print_wc_error(datagram); |
860 ec_datagram_print_wc_error(datagram); |
853 return; |
861 return; |
854 } |
862 } |
855 |
863 |
856 fsm->jiffies_start = datagram->jiffies_sent; |
864 fsm->jiffies_start = datagram->jiffies_sent; |
857 |
865 |
858 ec_slave_mbox_prepare_check(fsm->slave, datagram); // can not fail. |
866 ec_slave_mbox_prepare_check(fsm->slave, fsm->mbox); // can not fail. |
859 |
867 |
860 if (fsm->rx_last_packet) { |
868 if (fsm->rx_last_packet) { |
861 fsm->rx_expected_packet_no = 0; |
869 fsm->rx_expected_packet_no = 0; |
862 fsm->request->data_size = fsm->rx_buffer_offset; |
870 fsm->request->data_size = fsm->rx_buffer_offset; |
863 fsm->state = ec_fsm_foe_end; |
871 fsm->state = ec_fsm_foe_end; |