Lines Matching refs:msg_head
151 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head) in bcm_is_invalid_tv() argument
153 if ((msg_head->ival1.tv_sec < 0) || in bcm_is_invalid_tv()
154 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
155 (msg_head->ival1.tv_usec < 0) || in bcm_is_invalid_tv()
156 (msg_head->ival1.tv_usec >= USEC_PER_SEC) || in bcm_is_invalid_tv()
157 (msg_head->ival2.tv_sec < 0) || in bcm_is_invalid_tv()
158 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
159 (msg_head->ival2.tv_usec < 0) || in bcm_is_invalid_tv()
160 (msg_head->ival2.tv_usec >= USEC_PER_SEC)) in bcm_is_invalid_tv()
402 struct bcm_msg_head msg_head; in bcm_tx_timeout_handler() local
409 memset(&msg_head, 0, sizeof(msg_head)); in bcm_tx_timeout_handler()
410 msg_head.opcode = TX_EXPIRED; in bcm_tx_timeout_handler()
411 msg_head.flags = op->flags; in bcm_tx_timeout_handler()
412 msg_head.count = op->count; in bcm_tx_timeout_handler()
413 msg_head.ival1 = op->ival1; in bcm_tx_timeout_handler()
414 msg_head.ival2 = op->ival2; in bcm_tx_timeout_handler()
415 msg_head.can_id = op->can_id; in bcm_tx_timeout_handler()
416 msg_head.nframes = 0; in bcm_tx_timeout_handler()
418 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_tx_timeout_handler()
560 struct bcm_msg_head msg_head; in bcm_rx_timeout_handler() local
569 memset(&msg_head, 0, sizeof(msg_head)); in bcm_rx_timeout_handler()
570 msg_head.opcode = RX_TIMEOUT; in bcm_rx_timeout_handler()
571 msg_head.flags = op->flags; in bcm_rx_timeout_handler()
572 msg_head.count = op->count; in bcm_rx_timeout_handler()
573 msg_head.ival1 = op->ival1; in bcm_rx_timeout_handler()
574 msg_head.ival2 = op->ival2; in bcm_rx_timeout_handler()
575 msg_head.can_id = op->can_id; in bcm_rx_timeout_handler()
576 msg_head.nframes = 0; in bcm_rx_timeout_handler()
578 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_rx_timeout_handler()
820 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, in bcm_read_op() argument
823 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex); in bcm_read_op()
829 msg_head->flags = op->flags; in bcm_read_op()
830 msg_head->count = op->count; in bcm_read_op()
831 msg_head->ival1 = op->ival1; in bcm_read_op()
832 msg_head->ival2 = op->ival2; in bcm_read_op()
833 msg_head->nframes = op->nframes; in bcm_read_op()
835 bcm_send_to_user(op, msg_head, op->frames, 0); in bcm_read_op()
843 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_tx_setup() argument
857 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) in bcm_tx_setup()
861 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_tx_setup()
865 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); in bcm_tx_setup()
874 if (msg_head->nframes > op->nframes) in bcm_tx_setup()
878 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
894 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
896 cf->can_id = msg_head->can_id; in bcm_tx_setup()
899 op->flags = msg_head->flags; in bcm_tx_setup()
908 op->can_id = msg_head->can_id; in bcm_tx_setup()
909 op->cfsiz = CFSIZ(msg_head->flags); in bcm_tx_setup()
910 op->flags = msg_head->flags; in bcm_tx_setup()
913 if (msg_head->nframes > 1) { in bcm_tx_setup()
914 op->frames = kmalloc_array(msg_head->nframes, in bcm_tx_setup()
924 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
944 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
946 cf->can_id = msg_head->can_id; in bcm_tx_setup()
971 if (op->nframes != msg_head->nframes) { in bcm_tx_setup()
972 op->nframes = msg_head->nframes; in bcm_tx_setup()
986 op->count = msg_head->count; in bcm_tx_setup()
987 op->ival1 = msg_head->ival1; in bcm_tx_setup()
988 op->ival2 = msg_head->ival2; in bcm_tx_setup()
989 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_tx_setup()
990 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_tx_setup()
1012 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_tx_setup()
1018 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_rx_setup() argument
1026 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) { in bcm_rx_setup()
1028 msg_head->flags |= RX_FILTER_ID; in bcm_rx_setup()
1030 msg_head->nframes = 0; in bcm_rx_setup()
1034 if (msg_head->nframes > MAX_NFRAMES + 1) in bcm_rx_setup()
1037 if ((msg_head->flags & RX_RTR_FRAME) && in bcm_rx_setup()
1038 ((msg_head->nframes != 1) || in bcm_rx_setup()
1039 (!(msg_head->can_id & CAN_RTR_FLAG)))) in bcm_rx_setup()
1043 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_rx_setup()
1047 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); in bcm_rx_setup()
1056 if (msg_head->nframes > op->nframes) in bcm_rx_setup()
1059 if (msg_head->nframes) { in bcm_rx_setup()
1062 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1067 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1070 op->nframes = msg_head->nframes; in bcm_rx_setup()
1071 op->flags = msg_head->flags; in bcm_rx_setup()
1082 op->can_id = msg_head->can_id; in bcm_rx_setup()
1083 op->nframes = msg_head->nframes; in bcm_rx_setup()
1084 op->cfsiz = CFSIZ(msg_head->flags); in bcm_rx_setup()
1085 op->flags = msg_head->flags; in bcm_rx_setup()
1087 if (msg_head->nframes > 1) { in bcm_rx_setup()
1089 op->frames = kmalloc_array(msg_head->nframes, in bcm_rx_setup()
1098 op->last_frames = kcalloc(msg_head->nframes, in bcm_rx_setup()
1112 if (msg_head->nframes) { in bcm_rx_setup()
1114 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1171 op->ival1 = msg_head->ival1; in bcm_rx_setup()
1172 op->ival2 = msg_head->ival2; in bcm_rx_setup()
1173 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_rx_setup()
1174 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_rx_setup()
1223 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_rx_setup()
1279 struct bcm_msg_head msg_head; in bcm_sendmsg() local
1291 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ); in bcm_sendmsg()
1295 cfsiz = CFSIZ(msg_head.flags); in bcm_sendmsg()
1332 switch (msg_head.opcode) { in bcm_sendmsg()
1335 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1339 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1343 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1350 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1358 msg_head.opcode = TX_STATUS; in bcm_sendmsg()
1359 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex); in bcm_sendmsg()
1364 msg_head.opcode = RX_STATUS; in bcm_sendmsg()
1365 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex); in bcm_sendmsg()
1370 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ)) in bcm_sendmsg()