Lines Matching refs:msg_head
164 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head) in bcm_is_invalid_tv() argument
166 if ((msg_head->ival1.tv_sec < 0) || in bcm_is_invalid_tv()
167 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
168 (msg_head->ival1.tv_usec < 0) || in bcm_is_invalid_tv()
169 (msg_head->ival1.tv_usec >= USEC_PER_SEC) || in bcm_is_invalid_tv()
170 (msg_head->ival2.tv_sec < 0) || in bcm_is_invalid_tv()
171 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
172 (msg_head->ival2.tv_usec < 0) || in bcm_is_invalid_tv()
173 (msg_head->ival2.tv_usec >= USEC_PER_SEC)) in bcm_is_invalid_tv()
430 struct bcm_msg_head msg_head; in bcm_tx_timeout_handler() local
437 memset(&msg_head, 0, sizeof(msg_head)); in bcm_tx_timeout_handler()
438 msg_head.opcode = TX_EXPIRED; in bcm_tx_timeout_handler()
439 msg_head.flags = op->flags; in bcm_tx_timeout_handler()
440 msg_head.count = op->count; in bcm_tx_timeout_handler()
441 msg_head.ival1 = op->ival1; in bcm_tx_timeout_handler()
442 msg_head.ival2 = op->ival2; in bcm_tx_timeout_handler()
443 msg_head.can_id = op->can_id; in bcm_tx_timeout_handler()
444 msg_head.nframes = 0; in bcm_tx_timeout_handler()
446 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_tx_timeout_handler()
593 struct bcm_msg_head msg_head; in bcm_rx_timeout_handler() local
602 memset(&msg_head, 0, sizeof(msg_head)); in bcm_rx_timeout_handler()
603 msg_head.opcode = RX_TIMEOUT; in bcm_rx_timeout_handler()
604 msg_head.flags = op->flags; in bcm_rx_timeout_handler()
605 msg_head.count = op->count; in bcm_rx_timeout_handler()
606 msg_head.ival1 = op->ival1; in bcm_rx_timeout_handler()
607 msg_head.ival2 = op->ival2; in bcm_rx_timeout_handler()
608 msg_head.can_id = op->can_id; in bcm_rx_timeout_handler()
609 msg_head.nframes = 0; in bcm_rx_timeout_handler()
611 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_rx_timeout_handler()
878 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, in bcm_read_op() argument
881 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex); in bcm_read_op()
887 msg_head->flags = op->flags; in bcm_read_op()
888 msg_head->count = op->count; in bcm_read_op()
889 msg_head->ival1 = op->ival1; in bcm_read_op()
890 msg_head->ival2 = op->ival2; in bcm_read_op()
891 msg_head->nframes = op->nframes; in bcm_read_op()
893 bcm_send_to_user(op, msg_head, op->frames, 0); in bcm_read_op()
901 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_tx_setup() argument
915 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) in bcm_tx_setup()
919 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_tx_setup()
923 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); in bcm_tx_setup()
932 if (msg_head->nframes > op->nframes) in bcm_tx_setup()
936 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
952 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
954 cf->can_id = msg_head->can_id; in bcm_tx_setup()
957 op->flags = msg_head->flags; in bcm_tx_setup()
966 op->can_id = msg_head->can_id; in bcm_tx_setup()
967 op->cfsiz = CFSIZ(msg_head->flags); in bcm_tx_setup()
968 op->flags = msg_head->flags; in bcm_tx_setup()
971 if (msg_head->nframes > 1) { in bcm_tx_setup()
972 op->frames = kmalloc_array(msg_head->nframes, in bcm_tx_setup()
982 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
1000 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
1002 cf->can_id = msg_head->can_id; in bcm_tx_setup()
1027 if (op->nframes != msg_head->nframes) { in bcm_tx_setup()
1028 op->nframes = msg_head->nframes; in bcm_tx_setup()
1042 op->count = msg_head->count; in bcm_tx_setup()
1043 op->ival1 = msg_head->ival1; in bcm_tx_setup()
1044 op->ival2 = msg_head->ival2; in bcm_tx_setup()
1045 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_tx_setup()
1046 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_tx_setup()
1068 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_tx_setup()
1080 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_rx_setup() argument
1088 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) { in bcm_rx_setup()
1090 msg_head->flags |= RX_FILTER_ID; in bcm_rx_setup()
1092 msg_head->nframes = 0; in bcm_rx_setup()
1096 if (msg_head->nframes > MAX_NFRAMES + 1) in bcm_rx_setup()
1099 if ((msg_head->flags & RX_RTR_FRAME) && in bcm_rx_setup()
1100 ((msg_head->nframes != 1) || in bcm_rx_setup()
1101 (!(msg_head->can_id & CAN_RTR_FLAG)))) in bcm_rx_setup()
1105 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_rx_setup()
1109 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); in bcm_rx_setup()
1118 if (msg_head->nframes > op->nframes) in bcm_rx_setup()
1121 if (msg_head->nframes) { in bcm_rx_setup()
1124 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1129 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1132 op->nframes = msg_head->nframes; in bcm_rx_setup()
1133 op->flags = msg_head->flags; in bcm_rx_setup()
1144 op->can_id = msg_head->can_id; in bcm_rx_setup()
1145 op->nframes = msg_head->nframes; in bcm_rx_setup()
1146 op->cfsiz = CFSIZ(msg_head->flags); in bcm_rx_setup()
1147 op->flags = msg_head->flags; in bcm_rx_setup()
1149 if (msg_head->nframes > 1) { in bcm_rx_setup()
1151 op->frames = kmalloc_array(msg_head->nframes, in bcm_rx_setup()
1160 op->last_frames = kcalloc(msg_head->nframes, in bcm_rx_setup()
1174 if (msg_head->nframes) { in bcm_rx_setup()
1176 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1233 op->ival1 = msg_head->ival1; in bcm_rx_setup()
1234 op->ival2 = msg_head->ival2; in bcm_rx_setup()
1235 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_rx_setup()
1236 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_rx_setup()
1285 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_rx_setup()
1341 struct bcm_msg_head msg_head; in bcm_sendmsg() local
1353 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ); in bcm_sendmsg()
1357 cfsiz = CFSIZ(msg_head.flags); in bcm_sendmsg()
1394 switch (msg_head.opcode) { in bcm_sendmsg()
1397 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1401 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1405 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1412 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1420 msg_head.opcode = TX_STATUS; in bcm_sendmsg()
1421 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex); in bcm_sendmsg()
1426 msg_head.opcode = RX_STATUS; in bcm_sendmsg()
1427 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex); in bcm_sendmsg()
1432 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ)) in bcm_sendmsg()