Lines Matching refs:msg_head

152 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head)  in bcm_is_invalid_tv()  argument
154 if ((msg_head->ival1.tv_sec < 0) || in bcm_is_invalid_tv()
155 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
156 (msg_head->ival1.tv_usec < 0) || in bcm_is_invalid_tv()
157 (msg_head->ival1.tv_usec >= USEC_PER_SEC) || in bcm_is_invalid_tv()
158 (msg_head->ival2.tv_sec < 0) || in bcm_is_invalid_tv()
159 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
160 (msg_head->ival2.tv_usec < 0) || in bcm_is_invalid_tv()
161 (msg_head->ival2.tv_usec >= USEC_PER_SEC)) in bcm_is_invalid_tv()
404 struct bcm_msg_head msg_head; in bcm_tx_timeout_handler() local
411 memset(&msg_head, 0, sizeof(msg_head)); in bcm_tx_timeout_handler()
412 msg_head.opcode = TX_EXPIRED; in bcm_tx_timeout_handler()
413 msg_head.flags = op->flags; in bcm_tx_timeout_handler()
414 msg_head.count = op->count; in bcm_tx_timeout_handler()
415 msg_head.ival1 = op->ival1; in bcm_tx_timeout_handler()
416 msg_head.ival2 = op->ival2; in bcm_tx_timeout_handler()
417 msg_head.can_id = op->can_id; in bcm_tx_timeout_handler()
418 msg_head.nframes = 0; in bcm_tx_timeout_handler()
420 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_tx_timeout_handler()
562 struct bcm_msg_head msg_head; in bcm_rx_timeout_handler() local
571 memset(&msg_head, 0, sizeof(msg_head)); in bcm_rx_timeout_handler()
572 msg_head.opcode = RX_TIMEOUT; in bcm_rx_timeout_handler()
573 msg_head.flags = op->flags; in bcm_rx_timeout_handler()
574 msg_head.count = op->count; in bcm_rx_timeout_handler()
575 msg_head.ival1 = op->ival1; in bcm_rx_timeout_handler()
576 msg_head.ival2 = op->ival2; in bcm_rx_timeout_handler()
577 msg_head.can_id = op->can_id; in bcm_rx_timeout_handler()
578 msg_head.nframes = 0; in bcm_rx_timeout_handler()
580 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_rx_timeout_handler()
836 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, in bcm_read_op() argument
839 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex); in bcm_read_op()
845 msg_head->flags = op->flags; in bcm_read_op()
846 msg_head->count = op->count; in bcm_read_op()
847 msg_head->ival1 = op->ival1; in bcm_read_op()
848 msg_head->ival2 = op->ival2; in bcm_read_op()
849 msg_head->nframes = op->nframes; in bcm_read_op()
851 bcm_send_to_user(op, msg_head, op->frames, 0); in bcm_read_op()
859 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_tx_setup() argument
873 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) in bcm_tx_setup()
877 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_tx_setup()
881 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); in bcm_tx_setup()
890 if (msg_head->nframes > op->nframes) in bcm_tx_setup()
894 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
910 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
912 cf->can_id = msg_head->can_id; in bcm_tx_setup()
915 op->flags = msg_head->flags; in bcm_tx_setup()
924 op->can_id = msg_head->can_id; in bcm_tx_setup()
925 op->cfsiz = CFSIZ(msg_head->flags); in bcm_tx_setup()
926 op->flags = msg_head->flags; in bcm_tx_setup()
929 if (msg_head->nframes > 1) { in bcm_tx_setup()
930 op->frames = kmalloc_array(msg_head->nframes, in bcm_tx_setup()
940 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
960 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
962 cf->can_id = msg_head->can_id; in bcm_tx_setup()
987 if (op->nframes != msg_head->nframes) { in bcm_tx_setup()
988 op->nframes = msg_head->nframes; in bcm_tx_setup()
1002 op->count = msg_head->count; in bcm_tx_setup()
1003 op->ival1 = msg_head->ival1; in bcm_tx_setup()
1004 op->ival2 = msg_head->ival2; in bcm_tx_setup()
1005 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_tx_setup()
1006 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_tx_setup()
1028 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_tx_setup()
1034 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_rx_setup() argument
1042 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) { in bcm_rx_setup()
1044 msg_head->flags |= RX_FILTER_ID; in bcm_rx_setup()
1046 msg_head->nframes = 0; in bcm_rx_setup()
1050 if (msg_head->nframes > MAX_NFRAMES + 1) in bcm_rx_setup()
1053 if ((msg_head->flags & RX_RTR_FRAME) && in bcm_rx_setup()
1054 ((msg_head->nframes != 1) || in bcm_rx_setup()
1055 (!(msg_head->can_id & CAN_RTR_FLAG)))) in bcm_rx_setup()
1059 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_rx_setup()
1063 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); in bcm_rx_setup()
1072 if (msg_head->nframes > op->nframes) in bcm_rx_setup()
1075 if (msg_head->nframes) { in bcm_rx_setup()
1078 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1083 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1086 op->nframes = msg_head->nframes; in bcm_rx_setup()
1087 op->flags = msg_head->flags; in bcm_rx_setup()
1098 op->can_id = msg_head->can_id; in bcm_rx_setup()
1099 op->nframes = msg_head->nframes; in bcm_rx_setup()
1100 op->cfsiz = CFSIZ(msg_head->flags); in bcm_rx_setup()
1101 op->flags = msg_head->flags; in bcm_rx_setup()
1103 if (msg_head->nframes > 1) { in bcm_rx_setup()
1105 op->frames = kmalloc_array(msg_head->nframes, in bcm_rx_setup()
1114 op->last_frames = kcalloc(msg_head->nframes, in bcm_rx_setup()
1128 if (msg_head->nframes) { in bcm_rx_setup()
1130 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1187 op->ival1 = msg_head->ival1; in bcm_rx_setup()
1188 op->ival2 = msg_head->ival2; in bcm_rx_setup()
1189 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_rx_setup()
1190 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_rx_setup()
1239 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_rx_setup()
1295 struct bcm_msg_head msg_head; in bcm_sendmsg() local
1307 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ); in bcm_sendmsg()
1311 cfsiz = CFSIZ(msg_head.flags); in bcm_sendmsg()
1348 switch (msg_head.opcode) { in bcm_sendmsg()
1351 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1355 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1359 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1366 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1374 msg_head.opcode = TX_STATUS; in bcm_sendmsg()
1375 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex); in bcm_sendmsg()
1380 msg_head.opcode = RX_STATUS; in bcm_sendmsg()
1381 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex); in bcm_sendmsg()
1386 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ)) in bcm_sendmsg()