• Home
  • Raw
  • Download

Lines Matching refs:mc

424 static int pcan_usb_update_ts(struct pcan_usb_msg_context *mc)  in pcan_usb_update_ts()  argument
426 if ((mc->ptr + 2) > mc->end) in pcan_usb_update_ts()
429 mc->ts16 = get_unaligned_le16(mc->ptr); in pcan_usb_update_ts()
431 if (mc->rec_idx > 0) in pcan_usb_update_ts()
432 peak_usb_update_ts_now(&mc->pdev->time_ref, mc->ts16); in pcan_usb_update_ts()
434 peak_usb_set_ts_now(&mc->pdev->time_ref, mc->ts16); in pcan_usb_update_ts()
442 static int pcan_usb_decode_ts(struct pcan_usb_msg_context *mc, u8 first_packet) in pcan_usb_decode_ts() argument
446 if ((mc->ptr + 2) > mc->end) in pcan_usb_decode_ts()
449 mc->ts16 = get_unaligned_le16(mc->ptr); in pcan_usb_decode_ts()
450 mc->prev_ts8 = mc->ts16 & 0x00ff; in pcan_usb_decode_ts()
452 mc->ptr += 2; in pcan_usb_decode_ts()
456 if ((mc->ptr + 1) > mc->end) in pcan_usb_decode_ts()
459 ts8 = *mc->ptr++; in pcan_usb_decode_ts()
461 if (ts8 < mc->prev_ts8) in pcan_usb_decode_ts()
462 mc->ts16 += 0x100; in pcan_usb_decode_ts()
464 mc->ts16 &= 0xff00; in pcan_usb_decode_ts()
465 mc->ts16 |= ts8; in pcan_usb_decode_ts()
466 mc->prev_ts8 = ts8; in pcan_usb_decode_ts()
472 static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, in pcan_usb_decode_error() argument
481 if (!mc->pdev->time_ref.tick_count) in pcan_usb_decode_error()
485 skb = alloc_can_err_skb(mc->netdev, &cf); in pcan_usb_decode_error()
489 netdev_dbg(mc->netdev, "data overrun interrupt\n"); in pcan_usb_decode_error()
490 mc->netdev->stats.rx_over_errors++; in pcan_usb_decode_error()
491 mc->netdev->stats.rx_errors++; in pcan_usb_decode_error()
499 netdev_dbg(mc->netdev, "device Tx queue full)\n"); in pcan_usb_decode_error()
504 new_state = ((mc->pdev->bec.txerr >= 128) || in pcan_usb_decode_error()
505 (mc->pdev->bec.rxerr >= 128)) ? in pcan_usb_decode_error()
513 if (new_state != mc->pdev->dev.can.state) { in pcan_usb_decode_error()
515 (mc->pdev->bec.txerr >= mc->pdev->bec.rxerr) ? in pcan_usb_decode_error()
518 (mc->pdev->bec.txerr <= mc->pdev->bec.rxerr) ? in pcan_usb_decode_error()
521 can_change_state(mc->netdev, cf, tx_state, rx_state); in pcan_usb_decode_error()
524 can_bus_off(mc->netdev); in pcan_usb_decode_error()
530 cf->data[6] = mc->pdev->bec.txerr; in pcan_usb_decode_error()
531 cf->data[7] = mc->pdev->bec.rxerr; in pcan_usb_decode_error()
541 peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, in pcan_usb_decode_error()
553 static int pcan_usb_handle_bus_evt(struct pcan_usb_msg_context *mc, u8 ir) in pcan_usb_handle_bus_evt() argument
555 struct pcan_usb *pdev = mc->pdev; in pcan_usb_handle_bus_evt()
563 pdev->bec.rxerr = mc->ptr[1]; in pcan_usb_handle_bus_evt()
564 pdev->bec.txerr = mc->ptr[2]; in pcan_usb_handle_bus_evt()
578 static int pcan_usb_decode_status(struct pcan_usb_msg_context *mc, in pcan_usb_decode_status() argument
586 if ((mc->ptr + 2) > mc->end) in pcan_usb_decode_status()
589 f = mc->ptr[PCAN_USB_CMD_FUNC]; in pcan_usb_decode_status()
590 n = mc->ptr[PCAN_USB_CMD_NUM]; in pcan_usb_decode_status()
591 mc->ptr += PCAN_USB_CMD_ARGS; in pcan_usb_decode_status()
594 int err = pcan_usb_decode_ts(mc, !mc->rec_ts_idx); in pcan_usb_decode_status()
602 mc->rec_ts_idx++; in pcan_usb_decode_status()
607 err = pcan_usb_decode_error(mc, n, status_len); in pcan_usb_decode_status()
624 if (pcan_usb_update_ts(mc)) in pcan_usb_decode_status()
630 err = pcan_usb_handle_bus_evt(mc, n); in pcan_usb_decode_status()
635 netdev_err(mc->netdev, "unexpected function %u\n", f); in pcan_usb_decode_status()
639 if ((mc->ptr + rec_len) > mc->end) in pcan_usb_decode_status()
642 mc->ptr += rec_len; in pcan_usb_decode_status()
650 static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) in pcan_usb_decode_data() argument
658 skb = alloc_can_skb(mc->netdev, &cf); in pcan_usb_decode_data()
663 if ((mc->ptr + 4) > mc->end) in pcan_usb_decode_data()
666 can_id_flags = get_unaligned_le32(mc->ptr); in pcan_usb_decode_data()
668 mc->ptr += 4; in pcan_usb_decode_data()
670 if ((mc->ptr + 2) > mc->end) in pcan_usb_decode_data()
673 can_id_flags = get_unaligned_le16(mc->ptr); in pcan_usb_decode_data()
675 mc->ptr += 2; in pcan_usb_decode_data()
678 can_frame_set_cc_len(cf, rec_len, mc->pdev->dev.can.ctrlmode); in pcan_usb_decode_data()
681 if (pcan_usb_decode_ts(mc, !mc->rec_ts_idx)) in pcan_usb_decode_data()
685 mc->rec_ts_idx++; in pcan_usb_decode_data()
692 if ((mc->ptr + rec_len) > mc->end) in pcan_usb_decode_data()
695 memcpy(cf->data, mc->ptr, cf->len); in pcan_usb_decode_data()
696 mc->ptr += rec_len; in pcan_usb_decode_data()
700 mc->ptr++; in pcan_usb_decode_data()
703 mc->netdev->stats.rx_bytes += cf->len; in pcan_usb_decode_data()
705 mc->netdev->stats.rx_packets++; in pcan_usb_decode_data()
709 peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, &hwts->hwtstamp); in pcan_usb_decode_data()
726 struct pcan_usb_msg_context mc = { in pcan_usb_decode_msg() local
735 for (err = 0; mc.rec_idx < mc.rec_cnt && !err; mc.rec_idx++) { in pcan_usb_decode_msg()
736 u8 sl = *mc.ptr++; in pcan_usb_decode_msg()
740 err = pcan_usb_decode_status(&mc, sl); in pcan_usb_decode_msg()
743 err = pcan_usb_decode_data(&mc, sl); in pcan_usb_decode_msg()