• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/net/can/

Lines Matching refs:op

166 	struct bcm_op *op;
175 list_for_each_entry(op, &bo->rx_ops, list) {
180 if (!op->frames_abs)
184 op->can_id, bcm_proc_getifname(ifname, op->ifindex));
185 seq_printf(m, "[%u]%c ", op->nframes,
186 (op->flags & RX_CHECK_DLC)?'d':' ');
187 if (op->kt_ival1.tv64)
190 ktime_to_us(op->kt_ival1));
192 if (op->kt_ival2.tv64)
195 ktime_to_us(op->kt_ival2));
198 op->frames_filtered, op->frames_abs);
200 reduction = 100 - (op->frames_filtered * 100) / op->frames_abs;
206 list_for_each_entry(op, &bo->tx_ops, list) {
209 op->can_id,
210 bcm_proc_getifname(ifname, op->ifindex),
211 op->nframes);
213 if (op->kt_ival1.tv64)
215 (long long) ktime_to_us(op->kt_ival1));
217 if (op->kt_ival2.tv64)
219 (long long) ktime_to_us(op->kt_ival2));
221 seq_printf(m, "# sent %ld\n", op->frames_abs);
242 * of the given bcm tx op
244 static void bcm_can_tx(struct bcm_op *op)
248 struct can_frame *cf = &op->frames[op->currframe];
251 if (!op->ifindex)
254 dev = dev_get_by_index(&init_net, op->ifindex);
268 skb->sk = op->sk;
272 op->currframe++;
273 op->frames_abs++;
276 if (op->currframe >= op->nframes)
277 op->currframe = 0;
286 static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
292 struct sock *sk = op->sk;
320 skb->tstamp = op->rx_stamp;
334 addr->can_ifindex = op->rx_ifindex;
348 struct bcm_op *op = (struct bcm_op *)data;
351 if (op->kt_ival1.tv64 && (op->count > 0)) {
353 op->count--;
354 if (!op->count && (op->flags & TX_COUNTEVT)) {
358 msg_head.flags = op->flags;
359 msg_head.count = op->count;
360 msg_head.ival1 = op->ival1;
361 msg_head.ival2 = op->ival2;
362 msg_head.can_id = op->can_id;
365 bcm_send_to_user(op, &msg_head, NULL, 0);
369 if (op->kt_ival1.tv64 && (op->count > 0)) {
372 bcm_can_tx(op);
373 hrtimer_start(&op->timer,
374 ktime_add(ktime_get(), op->kt_ival1),
378 if (op->kt_ival2.tv64) {
381 bcm_can_tx(op);
382 hrtimer_start(&op->timer,
383 ktime_add(ktime_get(), op->kt_ival2),
394 struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
396 tasklet_schedule(&op->tsklet);
404 static void bcm_rx_changed(struct bcm_op *op, struct can_frame *data)
409 op->frames_filtered++;
412 if (op->frames_filtered > ULONG_MAX/100)
413 op->frames_filtered = op->frames_abs = 0;
419 head.flags = op->flags;
420 head.count = op->count;
421 head.ival1 = op->ival1;
422 head.ival2 = op->ival2;
423 head.can_id = op->can_id;
426 bcm_send_to_user(op, &head, data, 1);
434 static void bcm_rx_update_and_send(struct bcm_op *op,
444 if (!op->kt_ival2.tv64) {
446 bcm_rx_changed(op, lastdata);
451 if (hrtimer_active(&op->thrtimer))
455 if (!op->kt_lastmsg.tv64)
459 if (ktime_us_delta(ktime_get(), op->kt_lastmsg) <
460 ktime_to_us(op->kt_ival2)) {
462 hrtimer_start(&op->thrtimer,
463 ktime_add(op->kt_lastmsg, op->kt_ival2),
470 bcm_rx_changed(op, lastdata);
471 op->kt_lastmsg = ktime_get();
476 * received data stored in op->last_frames[]
478 static void bcm_rx_cmp_to_index(struct bcm_op *op, unsigned int index,
486 if (!(op->last_frames[index].can_dlc & RX_RECV)) {
488 bcm_rx_update_and_send(op, &op->last_frames[index], rxdata);
494 if ((GET_U64(&op->frames[index]) & GET_U64(rxdata)) !=
495 (GET_U64(&op->frames[index]) & GET_U64(&op->last_frames[index]))) {
496 bcm_rx_update_and_send(op, &op->last_frames[index], rxdata);
500 if (op->flags & RX_CHECK_DLC) {
502 if (rxdata->can_dlc != (op->last_frames[index].can_dlc &
504 bcm_rx_update_and_send(op, &op->last_frames[index],
514 static void bcm_rx_starttimer(struct bcm_op *op)
516 if (op->flags & RX_NO_AUTOTIMER)
519 if (op->kt_ival1.tv64)
520 hrtimer_start(&op->timer, op->kt_ival1, HRTIMER_MODE_REL);
525 struct bcm_op *op = (struct bcm_op *)data;
530 msg_head.flags = op->flags;
531 msg_head.count = op->count;
532 msg_head.ival1 = op->ival1;
533 msg_head.ival2 = op->ival2;
534 msg_head.can_id = op->can_id;
537 bcm_send_to_user(op, &msg_head, NULL, 0);
545 struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
548 tasklet_hi_schedule(&op->tsklet);
553 if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) {
555 memset(op->last_frames, 0, op->nframes * CFSIZ);
564 static inline int bcm_rx_do_flush(struct bcm_op *op, int update,
567 if ((op->last_frames) && (op->last_frames[index].can_dlc & RX_THR)) {
569 bcm_rx_changed(op, &op->last_frames[index]);
581 static int bcm_rx_thr_flush(struct bcm_op *op, int update)
585 if (op->nframes > 1) {
589 for (i = 1; i < op->nframes; i++)
590 updated += bcm_rx_do_flush(op, update, i);
594 updated += bcm_rx_do_flush(op, update, 0);
602 struct bcm_op *op = (struct bcm_op *)data;
605 bcm_rx_thr_flush(op, 1);
614 struct bcm_op *op = container_of(hrtimer, struct bcm_op, thrtimer);
616 tasklet_schedule(&op->thrtsklet);
618 if (bcm_rx_thr_flush(op, 0)) {
619 hrtimer_forward(hrtimer, ktime_get(), op->kt_ival2);
623 op->kt_lastmsg = ktime_set(0, 0);
633 struct bcm_op *op = (struct bcm_op *)data;
638 hrtimer_cancel(&op->timer);
640 if (op->can_id != rxframe->can_id)
644 op->rx_stamp = skb->tstamp;
646 op->rx_ifindex = skb->dev->ifindex;
648 op->frames_abs++;
650 if (op->flags & RX_RTR_FRAME) {
651 /* send reply for RTR-request (placed in op->frames[0]) */
652 bcm_can_tx(op);
656 if (op->flags & RX_FILTER_ID) {
658 bcm_rx_update_and_send(op, &op->last_frames[0], rxframe);
662 if (op->nframes == 1) {
664 bcm_rx_cmp_to_index(op, 0, rxframe);
668 if (op->nframes > 1) {
676 for (i = 1; i < op->nframes; i++) {
677 if ((GET_U64(&op->frames[0]) & GET_U64(rxframe)) ==
678 (GET_U64(&op->frames[0]) &
679 GET_U64(&op->frames[i]))) {
680 bcm_rx_cmp_to_index(op, i, rxframe);
687 bcm_rx_starttimer(op);
691 * helpers for bcm_op handling: find & delete bcm [rx|tx] op elements
696 struct bcm_op *op;
698 list_for_each_entry(op, ops, list) {
699 if ((op->can_id == can_id) && (op->ifindex == ifindex))
700 return op;
706 static void bcm_remove_op(struct bcm_op *op)
708 hrtimer_cancel(&op->timer);
709 hrtimer_cancel(&op->thrtimer);
711 if (op->tsklet.func)
712 tasklet_kill(&op->tsklet);
714 if (op->thrtsklet.func)
715 tasklet_kill(&op->thrtsklet);
717 if ((op->frames) && (op->frames != &op->sframe))
718 kfree(op->frames);
720 if ((op->last_frames) && (op->last_frames != &op->last_sframe))
721 kfree(op->last_frames);
723 kfree(op);
726 static void bcm_rx_unreg(struct net_device *dev, struct bcm_op *op)
728 if (op->rx_reg_dev == dev) {
729 can_rx_unregister(dev, op->can_id, REGMASK(op->can_id),
730 bcm_rx_handler, op);
733 op->rx_reg_dev = NULL;
736 "mismatch %p %p\n", op->rx_reg_dev, dev);
740 * bcm_delete_rx_op - find and remove a rx op (returns number of removed ops)
744 struct bcm_op *op, *n;
746 list_for_each_entry_safe(op, n, ops, list) {
747 if ((op->can_id == can_id) && (op->ifindex == ifindex)) {
754 if (op->ifindex) {
760 if (op->rx_reg_dev) {
764 op->ifindex);
766 bcm_rx_unreg(dev, op);
771 can_rx_unregister(NULL, op->can_id,
772 REGMASK(op->can_id),
773 bcm_rx_handler, op);
775 list_del(&op->list);
776 bcm_remove_op(op);
785 * bcm_delete_tx_op - find and remove a tx op (returns number of removed ops)
789 struct bcm_op *op, *n;
791 list_for_each_entry_safe(op, n, ops, list) {
792 if ((op->can_id == can_id) && (op->ifindex == ifindex)) {
793 list_del(&op->list);
794 bcm_remove_op(op);
808 struct bcm_op *op = bcm_find_op(ops, msg_head->can_id, ifindex);
810 if (!op)
814 msg_head->flags = op->flags;
815 msg_head->count = op->count;
816 msg_head->ival1 = op->ival1;
817 msg_head->ival2 = op->ival2;
818 msg_head->nframes = op->nframes;
820 bcm_send_to_user(op, msg_head, op->frames, 0);
826 * bcm_tx_setup - create or update a bcm tx op (for bcm_sendmsg)
832 struct bcm_op *op;
845 op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex);
847 if (op) {
855 if (msg_head->nframes > op->nframes)
860 err = memcpy_fromiovec((u8 *)&op->frames[i],
863 if (op->frames[i].can_dlc > 8)
871 op->frames[i].can_id = msg_head->can_id;
878 op = kzalloc(OPSIZ, GFP_KERNEL);
879 if (!op)
882 op->can_id = msg_head->can_id;
886 op->frames = kmalloc(msg_head->nframes * CFSIZ,
888 if (!op->frames) {
889 kfree(op);
893 op->frames = &op->sframe;
896 err = memcpy_fromiovec((u8 *)&op->frames[i],
899 if (op->frames[i].can_dlc > 8)
903 if (op->frames != &op->sframe)
904 kfree(op->frames);
905 kfree(op);
911 op->frames[i].can_id = msg_head->can_id;
916 op->last_frames = NULL;
919 op->sk = sk;
920 op->ifindex = ifindex;
923 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
924 op->timer.function = bcm_tx_timeout_handler;
927 tasklet_init(&op->tsklet, bcm_tx_timeout_tsklet,
928 (unsigned long) op);
931 hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
934 list_add(&op->list, &bo->tx_ops);
936 } /* if ((op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex))) */
938 if (op->nframes != msg_head->nframes) {
939 op->nframes = msg_head->nframes;
941 op->currframe = 0;
946 op->flags = msg_head->flags;
948 if (op->flags & TX_RESET_MULTI_IDX) {
950 op->currframe = 0;
953 if (op->flags & SETTIMER) {
955 op->count = msg_head->count;
956 op->ival1 = msg_head->ival1;
957 op->ival2 = msg_head->ival2;
958 op->kt_ival1 = timeval_to_ktime(msg_head->ival1);
959 op->kt_ival2 = timeval_to_ktime(msg_head->ival2);
962 if (!op->kt_ival1.tv64 && !op->kt_ival2.tv64)
963 hrtimer_cancel(&op->timer);
966 if ((op->flags & STARTTIMER) &&
967 ((op->kt_ival1.tv64 && op->count) || op->kt_ival2.tv64)) {
970 op->flags |= TX_ANNOUNCE;
972 if (op->kt_ival1.tv64 && (op->count > 0)) {
973 /* op->count-- is done in bcm_tx_timeout_handler */
974 hrtimer_start(&op->timer, op->kt_ival1,
977 hrtimer_start(&op->timer, op->kt_ival2,
981 if (op->flags & TX_ANNOUNCE)
982 bcm_can_tx(op);
988 * bcm_rx_setup - create or update a bcm rx op (for bcm_sendmsg)
994 struct bcm_op *op;
1015 op = bcm_find_op(&bo->rx_ops, msg_head->can_id, ifindex);
1016 if (op) {
1024 if (msg_head->nframes > op->nframes)
1029 err = memcpy_fromiovec((u8 *)op->frames,
1036 memset(op->last_frames, 0, msg_head->nframes * CFSIZ);
1039 op->nframes = msg_head->nframes;
1046 op = kzalloc(OPSIZ, GFP_KERNEL);
1047 if (!op)
1050 op->can_id = msg_head->can_id;
1051 op->nframes = msg_head->nframes;
1055 op->frames = kmalloc(msg_head->nframes * CFSIZ,
1057 if (!op->frames) {
1058 kfree(op);
1063 op->last_frames = kzalloc(msg_head->nframes * CFSIZ,
1065 if (!op->last_frames) {
1066 kfree(op->frames);
1067 kfree(op);
1072 op->frames = &op->sframe;
1073 op->last_frames = &op->last_sframe;
1077 err = memcpy_fromiovec((u8 *)op->frames, msg->msg_iov,
1080 if (op->frames != &op->sframe)
1081 kfree(op->frames);
1082 if (op->last_frames != &op->last_sframe)
1083 kfree(op->last_frames);
1084 kfree(op);
1090 op->sk = sk;
1091 op->ifindex = ifindex;
1094 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1095 op->timer.function = bcm_rx_timeout_handler;
1098 tasklet_init(&op->tsklet, bcm_rx_timeout_tsklet,
1099 (unsigned long) op);
1101 hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1102 op->thrtimer.function = bcm_rx_thr_handler;
1105 tasklet_init(&op->thrtsklet, bcm_rx_thr_tsklet,
1106 (unsigned long) op);
1109 list_add(&op->list, &bo->rx_ops);
1114 } /* if ((op = bcm_find_op(&bo->rx_ops, msg_head->can_id, ifindex))) */
1117 op->flags = msg_head->flags;
1119 if (op->flags & RX_RTR_FRAME) {
1122 hrtimer_cancel(&op->thrtimer);
1123 hrtimer_cancel(&op->timer);
1130 if ((op->flags & TX_CP_CAN_ID) ||
1131 (op->frames[0].can_id == op->can_id))
1132 op->frames[0].can_id = op->can_id & ~CAN_RTR_FLAG;
1135 if (op->flags & SETTIMER) {
1138 op->ival1 = msg_head->ival1;
1139 op->ival2 = msg_head->ival2;
1140 op->kt_ival1 = timeval_to_ktime(msg_head->ival1);
1141 op->kt_ival2 = timeval_to_ktime(msg_head->ival2);
1144 if (!op->kt_ival1.tv64)
1145 hrtimer_cancel(&op->timer);
1151 op->kt_lastmsg = ktime_set(0, 0);
1152 hrtimer_cancel(&op->thrtimer);
1153 bcm_rx_thr_flush(op, 1);
1156 if ((op->flags & STARTTIMER) && op->kt_ival1.tv64)
1157 hrtimer_start(&op->timer, op->kt_ival1,
1168 err = can_rx_register(dev, op->can_id,
1169 REGMASK(op->can_id),
1170 bcm_rx_handler, op,
1173 op->rx_reg_dev = dev;
1178 err = can_rx_register(NULL, op->can_id,
1179 REGMASK(op->can_id),
1180 bcm_rx_handler, op, "bcm");
1182 /* this bcm rx op is broken -> remove it */
1183 list_del(&op->list);
1184 bcm_remove_op(op);
1352 struct bcm_op *op;
1367 list_for_each_entry(op, &bo->rx_ops, list)
1368 if (op->rx_reg_dev == dev)
1369 bcm_rx_unreg(dev, op);
1428 struct bcm_op *op, *next;
1436 list_for_each_entry_safe(op, next, &bo->tx_ops, list)
1437 bcm_remove_op(op);
1439 list_for_each_entry_safe(op, next, &bo->rx_ops, list) {
1444 if (op->ifindex) {
1450 if (op->rx_reg_dev) {
1453 dev = dev_get_by_index(&init_net, op->ifindex);
1455 bcm_rx_unreg(dev, op);
1460 can_rx_unregister(NULL, op->can_id,
1461 REGMASK(op->can_id),
1462 bcm_rx_handler, op);
1464 bcm_remove_op(op);