Lines Matching refs:msg_head

145 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head)  in bcm_is_invalid_tv()  argument
147 if ((msg_head->ival1.tv_sec < 0) || in bcm_is_invalid_tv()
148 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
149 (msg_head->ival1.tv_usec < 0) || in bcm_is_invalid_tv()
150 (msg_head->ival1.tv_usec >= USEC_PER_SEC) || in bcm_is_invalid_tv()
151 (msg_head->ival2.tv_sec < 0) || in bcm_is_invalid_tv()
152 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
153 (msg_head->ival2.tv_usec < 0) || in bcm_is_invalid_tv()
154 (msg_head->ival2.tv_usec >= USEC_PER_SEC)) in bcm_is_invalid_tv()
396 struct bcm_msg_head msg_head; in bcm_tx_timeout_handler() local
403 msg_head.opcode = TX_EXPIRED; in bcm_tx_timeout_handler()
404 msg_head.flags = op->flags; in bcm_tx_timeout_handler()
405 msg_head.count = op->count; in bcm_tx_timeout_handler()
406 msg_head.ival1 = op->ival1; in bcm_tx_timeout_handler()
407 msg_head.ival2 = op->ival2; in bcm_tx_timeout_handler()
408 msg_head.can_id = op->can_id; in bcm_tx_timeout_handler()
409 msg_head.nframes = 0; in bcm_tx_timeout_handler()
411 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_tx_timeout_handler()
552 struct bcm_msg_head msg_head; in bcm_rx_timeout_handler() local
561 msg_head.opcode = RX_TIMEOUT; in bcm_rx_timeout_handler()
562 msg_head.flags = op->flags; in bcm_rx_timeout_handler()
563 msg_head.count = op->count; in bcm_rx_timeout_handler()
564 msg_head.ival1 = op->ival1; in bcm_rx_timeout_handler()
565 msg_head.ival2 = op->ival2; in bcm_rx_timeout_handler()
566 msg_head.can_id = op->can_id; in bcm_rx_timeout_handler()
567 msg_head.nframes = 0; in bcm_rx_timeout_handler()
569 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_rx_timeout_handler()
810 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, in bcm_read_op() argument
813 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex); in bcm_read_op()
819 msg_head->flags = op->flags; in bcm_read_op()
820 msg_head->count = op->count; in bcm_read_op()
821 msg_head->ival1 = op->ival1; in bcm_read_op()
822 msg_head->ival2 = op->ival2; in bcm_read_op()
823 msg_head->nframes = op->nframes; in bcm_read_op()
825 bcm_send_to_user(op, msg_head, op->frames, 0); in bcm_read_op()
833 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_tx_setup() argument
847 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) in bcm_tx_setup()
851 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_tx_setup()
855 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); in bcm_tx_setup()
864 if (msg_head->nframes > op->nframes) in bcm_tx_setup()
868 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
884 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
886 cf->can_id = msg_head->can_id; in bcm_tx_setup()
889 op->flags = msg_head->flags; in bcm_tx_setup()
898 op->can_id = msg_head->can_id; in bcm_tx_setup()
899 op->cfsiz = CFSIZ(msg_head->flags); in bcm_tx_setup()
900 op->flags = msg_head->flags; in bcm_tx_setup()
903 if (msg_head->nframes > 1) { in bcm_tx_setup()
904 op->frames = kmalloc_array(msg_head->nframes, in bcm_tx_setup()
914 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
934 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
936 cf->can_id = msg_head->can_id; in bcm_tx_setup()
961 if (op->nframes != msg_head->nframes) { in bcm_tx_setup()
962 op->nframes = msg_head->nframes; in bcm_tx_setup()
976 op->count = msg_head->count; in bcm_tx_setup()
977 op->ival1 = msg_head->ival1; in bcm_tx_setup()
978 op->ival2 = msg_head->ival2; in bcm_tx_setup()
979 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_tx_setup()
980 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_tx_setup()
1002 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_tx_setup()
1008 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_rx_setup() argument
1016 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) { in bcm_rx_setup()
1018 msg_head->flags |= RX_FILTER_ID; in bcm_rx_setup()
1020 msg_head->nframes = 0; in bcm_rx_setup()
1024 if (msg_head->nframes > MAX_NFRAMES + 1) in bcm_rx_setup()
1027 if ((msg_head->flags & RX_RTR_FRAME) && in bcm_rx_setup()
1028 ((msg_head->nframes != 1) || in bcm_rx_setup()
1029 (!(msg_head->can_id & CAN_RTR_FLAG)))) in bcm_rx_setup()
1033 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_rx_setup()
1037 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); in bcm_rx_setup()
1046 if (msg_head->nframes > op->nframes) in bcm_rx_setup()
1049 if (msg_head->nframes) { in bcm_rx_setup()
1052 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1057 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1060 op->nframes = msg_head->nframes; in bcm_rx_setup()
1061 op->flags = msg_head->flags; in bcm_rx_setup()
1072 op->can_id = msg_head->can_id; in bcm_rx_setup()
1073 op->nframes = msg_head->nframes; in bcm_rx_setup()
1074 op->cfsiz = CFSIZ(msg_head->flags); in bcm_rx_setup()
1075 op->flags = msg_head->flags; in bcm_rx_setup()
1077 if (msg_head->nframes > 1) { in bcm_rx_setup()
1079 op->frames = kmalloc_array(msg_head->nframes, in bcm_rx_setup()
1088 op->last_frames = kcalloc(msg_head->nframes, in bcm_rx_setup()
1102 if (msg_head->nframes) { in bcm_rx_setup()
1104 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1161 op->ival1 = msg_head->ival1; in bcm_rx_setup()
1162 op->ival2 = msg_head->ival2; in bcm_rx_setup()
1163 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_rx_setup()
1164 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_rx_setup()
1213 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_rx_setup()
1269 struct bcm_msg_head msg_head; in bcm_sendmsg() local
1281 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ); in bcm_sendmsg()
1285 cfsiz = CFSIZ(msg_head.flags); in bcm_sendmsg()
1322 switch (msg_head.opcode) { in bcm_sendmsg()
1325 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1329 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1333 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1340 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1348 msg_head.opcode = TX_STATUS; in bcm_sendmsg()
1349 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex); in bcm_sendmsg()
1354 msg_head.opcode = RX_STATUS; in bcm_sendmsg()
1355 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex); in bcm_sendmsg()
1360 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ)) in bcm_sendmsg()