Lines Matching refs:msg_head

166 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head)  in bcm_is_invalid_tv()  argument
168 if ((msg_head->ival1.tv_sec < 0) || in bcm_is_invalid_tv()
169 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
170 (msg_head->ival1.tv_usec < 0) || in bcm_is_invalid_tv()
171 (msg_head->ival1.tv_usec >= USEC_PER_SEC) || in bcm_is_invalid_tv()
172 (msg_head->ival2.tv_sec < 0) || in bcm_is_invalid_tv()
173 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) || in bcm_is_invalid_tv()
174 (msg_head->ival2.tv_usec < 0) || in bcm_is_invalid_tv()
175 (msg_head->ival2.tv_usec >= USEC_PER_SEC)) in bcm_is_invalid_tv()
452 struct bcm_msg_head msg_head; in bcm_tx_timeout_handler() local
459 memset(&msg_head, 0, sizeof(msg_head)); in bcm_tx_timeout_handler()
460 msg_head.opcode = TX_EXPIRED; in bcm_tx_timeout_handler()
461 msg_head.flags = op->flags; in bcm_tx_timeout_handler()
462 msg_head.count = op->count; in bcm_tx_timeout_handler()
463 msg_head.ival1 = op->ival1; in bcm_tx_timeout_handler()
464 msg_head.ival2 = op->ival2; in bcm_tx_timeout_handler()
465 msg_head.can_id = op->can_id; in bcm_tx_timeout_handler()
466 msg_head.nframes = 0; in bcm_tx_timeout_handler()
468 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_tx_timeout_handler()
614 struct bcm_msg_head msg_head; in bcm_rx_timeout_handler() local
623 memset(&msg_head, 0, sizeof(msg_head)); in bcm_rx_timeout_handler()
624 msg_head.opcode = RX_TIMEOUT; in bcm_rx_timeout_handler()
625 msg_head.flags = op->flags; in bcm_rx_timeout_handler()
626 msg_head.count = op->count; in bcm_rx_timeout_handler()
627 msg_head.ival1 = op->ival1; in bcm_rx_timeout_handler()
628 msg_head.ival2 = op->ival2; in bcm_rx_timeout_handler()
629 msg_head.can_id = op->can_id; in bcm_rx_timeout_handler()
630 msg_head.nframes = 0; in bcm_rx_timeout_handler()
632 bcm_send_to_user(op, &msg_head, NULL, 0); in bcm_rx_timeout_handler()
899 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head, in bcm_read_op() argument
902 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex); in bcm_read_op()
908 msg_head->flags = op->flags; in bcm_read_op()
909 msg_head->count = op->count; in bcm_read_op()
910 msg_head->ival1 = op->ival1; in bcm_read_op()
911 msg_head->ival2 = op->ival2; in bcm_read_op()
912 msg_head->nframes = op->nframes; in bcm_read_op()
914 bcm_send_to_user(op, msg_head, op->frames, 0); in bcm_read_op()
922 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_tx_setup() argument
936 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES) in bcm_tx_setup()
940 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_tx_setup()
944 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex); in bcm_tx_setup()
953 if (msg_head->nframes > op->nframes) in bcm_tx_setup()
957 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
973 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
975 cf->can_id = msg_head->can_id; in bcm_tx_setup()
978 op->flags = msg_head->flags; in bcm_tx_setup()
981 if (op->nframes != msg_head->nframes || in bcm_tx_setup()
987 if (op->nframes != msg_head->nframes || in bcm_tx_setup()
990 op->nframes = msg_head->nframes; in bcm_tx_setup()
996 op->count = msg_head->count; in bcm_tx_setup()
1009 op->can_id = msg_head->can_id; in bcm_tx_setup()
1010 op->cfsiz = CFSIZ(msg_head->flags); in bcm_tx_setup()
1011 op->flags = msg_head->flags; in bcm_tx_setup()
1012 op->nframes = msg_head->nframes; in bcm_tx_setup()
1015 op->count = msg_head->count; in bcm_tx_setup()
1018 if (msg_head->nframes > 1) { in bcm_tx_setup()
1019 op->frames = kmalloc_array(msg_head->nframes, in bcm_tx_setup()
1029 for (i = 0; i < msg_head->nframes; i++) { in bcm_tx_setup()
1047 if (msg_head->flags & TX_CP_CAN_ID) { in bcm_tx_setup()
1049 cf->can_id = msg_head->can_id; in bcm_tx_setup()
1075 op->ival1 = msg_head->ival1; in bcm_tx_setup()
1076 op->ival2 = msg_head->ival2; in bcm_tx_setup()
1077 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_tx_setup()
1078 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_tx_setup()
1097 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_tx_setup()
1109 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, in bcm_rx_setup() argument
1117 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) { in bcm_rx_setup()
1119 msg_head->flags |= RX_FILTER_ID; in bcm_rx_setup()
1121 msg_head->nframes = 0; in bcm_rx_setup()
1125 if (msg_head->nframes > MAX_NFRAMES + 1) in bcm_rx_setup()
1128 if ((msg_head->flags & RX_RTR_FRAME) && in bcm_rx_setup()
1129 ((msg_head->nframes != 1) || in bcm_rx_setup()
1130 (!(msg_head->can_id & CAN_RTR_FLAG)))) in bcm_rx_setup()
1134 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head)) in bcm_rx_setup()
1138 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex); in bcm_rx_setup()
1147 if (msg_head->nframes > op->nframes) in bcm_rx_setup()
1150 if (msg_head->nframes) { in bcm_rx_setup()
1153 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1158 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1161 op->nframes = msg_head->nframes; in bcm_rx_setup()
1162 op->flags = msg_head->flags; in bcm_rx_setup()
1173 op->can_id = msg_head->can_id; in bcm_rx_setup()
1174 op->nframes = msg_head->nframes; in bcm_rx_setup()
1175 op->cfsiz = CFSIZ(msg_head->flags); in bcm_rx_setup()
1176 op->flags = msg_head->flags; in bcm_rx_setup()
1178 if (msg_head->nframes > 1) { in bcm_rx_setup()
1180 op->frames = kmalloc_array(msg_head->nframes, in bcm_rx_setup()
1189 op->last_frames = kcalloc(msg_head->nframes, in bcm_rx_setup()
1203 if (msg_head->nframes) { in bcm_rx_setup()
1205 msg_head->nframes * op->cfsiz); in bcm_rx_setup()
1259 op->ival1 = msg_head->ival1; in bcm_rx_setup()
1260 op->ival2 = msg_head->ival2; in bcm_rx_setup()
1261 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); in bcm_rx_setup()
1262 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2); in bcm_rx_setup()
1311 return msg_head->nframes * op->cfsiz + MHSIZ; in bcm_rx_setup()
1367 struct bcm_msg_head msg_head; in bcm_sendmsg() local
1379 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ); in bcm_sendmsg()
1383 cfsiz = CFSIZ(msg_head.flags); in bcm_sendmsg()
1420 switch (msg_head.opcode) { in bcm_sendmsg()
1423 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1427 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk); in bcm_sendmsg()
1431 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1438 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex)) in bcm_sendmsg()
1446 msg_head.opcode = TX_STATUS; in bcm_sendmsg()
1447 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex); in bcm_sendmsg()
1452 msg_head.opcode = RX_STATUS; in bcm_sendmsg()
1453 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex); in bcm_sendmsg()
1458 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ)) in bcm_sendmsg()