Lines Matching refs:msg_head
147 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head) in bcm_is_invalid_tv() argument
149 if ((msg_head->ival1.tv_sec < 0) || in bcm_is_invalid_tv()
150 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
151 (msg_head->ival1.tv_usec < 0) || in bcm_is_invalid_tv()
152 (msg_head->ival1.tv_usec >= USEC_PER_SEC) || in bcm_is_invalid_tv()
153 (msg_head->ival2.tv_sec < 0) || in bcm_is_invalid_tv()
154 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
155 (msg_head->ival2.tv_usec < 0) || in bcm_is_invalid_tv()
156 (msg_head->ival2.tv_usec >= USEC_PER_SEC)) in bcm_is_invalid_tv()
398 struct bcm_msg_head msg_head; in bcm_tx_timeout_handler() local
405 msg_head.opcode = TX_EXPIRED; in bcm_tx_timeout_handler()
406 msg_head.flags = op->flags; in bcm_tx_timeout_handler()
407 msg_head.count = op->count; in bcm_tx_timeout_handler()
408 msg_head.ival1 = op->ival1; in bcm_tx_timeout_handler()
409 msg_head.ival2 = op->ival2; in bcm_tx_timeout_handler()
410 msg_head.can_id = op->can_id; in bcm_tx_timeout_handler()
411 msg_head.nframes = 0; in bcm_tx_timeout_handler()
413 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_tx_timeout_handler()
554 struct bcm_msg_head msg_head; in bcm_rx_timeout_handler() local
563 msg_head.opcode = RX_TIMEOUT; in bcm_rx_timeout_handler()
564 msg_head.flags = op->flags; in bcm_rx_timeout_handler()
565 msg_head.count = op->count; in bcm_rx_timeout_handler()
566 msg_head.ival1 = op->ival1; in bcm_rx_timeout_handler()
567 msg_head.ival2 = op->ival2; in bcm_rx_timeout_handler()
568 msg_head.can_id = op->can_id; in bcm_rx_timeout_handler()
569 msg_head.nframes = 0; in bcm_rx_timeout_handler()
571 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_rx_timeout_handler()
812 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, in bcm_read_op() argument
815 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex); in bcm_read_op()
821 msg_head->flags = op->flags; in bcm_read_op()
822 msg_head->count = op->count; in bcm_read_op()
823 msg_head->ival1 = op->ival1; in bcm_read_op()
824 msg_head->ival2 = op->ival2; in bcm_read_op()
825 msg_head->nframes = op->nframes; in bcm_read_op()
827 bcm_send_to_user(op, msg_head, op->frames, 0); in bcm_read_op()
835 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_tx_setup() argument
849 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) in bcm_tx_setup()
853 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_tx_setup()
857 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); in bcm_tx_setup()
866 if (msg_head->nframes > op->nframes) in bcm_tx_setup()
870 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
886 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
888 cf->can_id = msg_head->can_id; in bcm_tx_setup()
891 op->flags = msg_head->flags; in bcm_tx_setup()
900 op->can_id = msg_head->can_id; in bcm_tx_setup()
901 op->cfsiz = CFSIZ(msg_head->flags); in bcm_tx_setup()
902 op->flags = msg_head->flags; in bcm_tx_setup()
905 if (msg_head->nframes > 1) { in bcm_tx_setup()
906 op->frames = kmalloc_array(msg_head->nframes, in bcm_tx_setup()
916 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
936 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
938 cf->can_id = msg_head->can_id; in bcm_tx_setup()
963 if (op->nframes != msg_head->nframes) { in bcm_tx_setup()
964 op->nframes = msg_head->nframes; in bcm_tx_setup()
978 op->count = msg_head->count; in bcm_tx_setup()
979 op->ival1 = msg_head->ival1; in bcm_tx_setup()
980 op->ival2 = msg_head->ival2; in bcm_tx_setup()
981 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_tx_setup()
982 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_tx_setup()
1004 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_tx_setup()
1010 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_rx_setup() argument
1018 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) { in bcm_rx_setup()
1020 msg_head->flags |= RX_FILTER_ID; in bcm_rx_setup()
1022 msg_head->nframes = 0; in bcm_rx_setup()
1026 if (msg_head->nframes > MAX_NFRAMES + 1) in bcm_rx_setup()
1029 if ((msg_head->flags & RX_RTR_FRAME) && in bcm_rx_setup()
1030 ((msg_head->nframes != 1) || in bcm_rx_setup()
1031 (!(msg_head->can_id & CAN_RTR_FLAG)))) in bcm_rx_setup()
1035 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_rx_setup()
1039 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); in bcm_rx_setup()
1048 if (msg_head->nframes > op->nframes) in bcm_rx_setup()
1051 if (msg_head->nframes) { in bcm_rx_setup()
1054 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1059 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1062 op->nframes = msg_head->nframes; in bcm_rx_setup()
1063 op->flags = msg_head->flags; in bcm_rx_setup()
1074 op->can_id = msg_head->can_id; in bcm_rx_setup()
1075 op->nframes = msg_head->nframes; in bcm_rx_setup()
1076 op->cfsiz = CFSIZ(msg_head->flags); in bcm_rx_setup()
1077 op->flags = msg_head->flags; in bcm_rx_setup()
1079 if (msg_head->nframes > 1) { in bcm_rx_setup()
1081 op->frames = kmalloc_array(msg_head->nframes, in bcm_rx_setup()
1090 op->last_frames = kcalloc(msg_head->nframes, in bcm_rx_setup()
1104 if (msg_head->nframes) { in bcm_rx_setup()
1106 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1163 op->ival1 = msg_head->ival1; in bcm_rx_setup()
1164 op->ival2 = msg_head->ival2; in bcm_rx_setup()
1165 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_rx_setup()
1166 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_rx_setup()
1215 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_rx_setup()
1271 struct bcm_msg_head msg_head; in bcm_sendmsg() local
1283 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ); in bcm_sendmsg()
1287 cfsiz = CFSIZ(msg_head.flags); in bcm_sendmsg()
1324 switch (msg_head.opcode) { in bcm_sendmsg()
1327 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1331 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1335 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1342 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1350 msg_head.opcode = TX_STATUS; in bcm_sendmsg()
1351 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex); in bcm_sendmsg()
1356 msg_head.opcode = RX_STATUS; in bcm_sendmsg()
1357 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex); in bcm_sendmsg()
1362 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ)) in bcm_sendmsg()