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