Lines Matching defs:msg_head
152 static bool bcm_is_invalid_tv(struct bcm_msg_head *msg_head)
154 if ((msg_head->ival1.tv_sec < 0) ||
155 (msg_head->ival1.tv_sec > BCM_TIMER_SEC_MAX) ||
156 (msg_head->ival1.tv_usec < 0) ||
157 (msg_head->ival1.tv_usec >= USEC_PER_SEC) ||
158 (msg_head->ival2.tv_sec < 0) ||
159 (msg_head->ival2.tv_sec > BCM_TIMER_SEC_MAX) ||
160 (msg_head->ival2.tv_usec < 0) ||
161 (msg_head->ival2.tv_usec >= USEC_PER_SEC))
404 struct bcm_msg_head msg_head;
411 memset(&msg_head, 0, sizeof(msg_head));
412 msg_head.opcode = TX_EXPIRED;
413 msg_head.flags = op->flags;
414 msg_head.count = op->count;
415 msg_head.ival1 = op->ival1;
416 msg_head.ival2 = op->ival2;
417 msg_head.can_id = op->can_id;
418 msg_head.nframes = 0;
420 bcm_send_to_user(op, &msg_head, NULL, 0);
562 struct bcm_msg_head msg_head;
571 memset(&msg_head, 0, sizeof(msg_head));
572 msg_head.opcode = RX_TIMEOUT;
573 msg_head.flags = op->flags;
574 msg_head.count = op->count;
575 msg_head.ival1 = op->ival1;
576 msg_head.ival2 = op->ival2;
577 msg_head.can_id = op->can_id;
578 msg_head.nframes = 0;
580 bcm_send_to_user(op, &msg_head, NULL, 0);
831 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head,
834 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex);
839 /* put current values into msg_head */
840 msg_head->flags = op->flags;
841 msg_head->count = op->count;
842 msg_head->ival1 = op->ival1;
843 msg_head->ival2 = op->ival2;
844 msg_head->nframes = op->nframes;
846 bcm_send_to_user(op, msg_head, op->frames, 0);
854 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
868 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES)
872 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head))
876 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex);
885 if (msg_head->nframes > op->nframes)
889 for (i = 0; i < msg_head->nframes; i++) {
905 if (msg_head->flags & TX_CP_CAN_ID) {
907 cf->can_id = msg_head->can_id;
910 op->flags = msg_head->flags;
919 op->can_id = msg_head->can_id;
920 op->cfsiz = CFSIZ(msg_head->flags);
921 op->flags = msg_head->flags;
924 if (msg_head->nframes > 1) {
925 op->frames = kmalloc_array(msg_head->nframes,
935 for (i = 0; i < msg_head->nframes; i++) {
953 if (msg_head->flags & TX_CP_CAN_ID) {
955 cf->can_id = msg_head->can_id;
978 } /* if ((op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex))) */
980 if (op->nframes != msg_head->nframes) {
981 op->nframes = msg_head->nframes;
995 op->count = msg_head->count;
996 op->ival1 = msg_head->ival1;
997 op->ival2 = msg_head->ival2;
998 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1);
999 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2);
1021 return msg_head->nframes * op->cfsiz + MHSIZ;
1033 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1041 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) {
1043 msg_head->flags |= RX_FILTER_ID;
1045 msg_head->nframes = 0;
1049 if (msg_head->nframes > MAX_NFRAMES + 1)
1052 if ((msg_head->flags & RX_RTR_FRAME) &&
1053 ((msg_head->nframes != 1) ||
1054 (!(msg_head->can_id & CAN_RTR_FLAG))))
1058 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head))
1062 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex);
1071 if (msg_head->nframes > op->nframes)
1074 if (msg_head->nframes) {
1077 msg_head->nframes * op->cfsiz);
1082 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz);
1085 op->nframes = msg_head->nframes;
1086 op->flags = msg_head->flags;
1097 op->can_id = msg_head->can_id;
1098 op->nframes = msg_head->nframes;
1099 op->cfsiz = CFSIZ(msg_head->flags);
1100 op->flags = msg_head->flags;
1102 if (msg_head->nframes > 1) {
1104 op->frames = kmalloc_array(msg_head->nframes,
1113 op->last_frames = kcalloc(msg_head->nframes,
1127 if (msg_head->nframes) {
1129 msg_head->nframes * op->cfsiz);
1162 } /* if ((op = bcm_find_op(&bo->rx_ops, msg_head->can_id, ifindex))) */
1186 op->ival1 = msg_head->ival1;
1187 op->ival2 = msg_head->ival2;
1188 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1);
1189 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2);
1238 return msg_head->nframes * op->cfsiz + MHSIZ;
1294 struct bcm_msg_head msg_head;
1306 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ);
1310 cfsiz = CFSIZ(msg_head.flags);
1347 switch (msg_head.opcode) {
1350 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk);
1354 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk);
1358 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex))
1365 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex))
1372 /* reuse msg_head for the reply to TX_READ */
1373 msg_head.opcode = TX_STATUS;
1374 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex);
1378 /* reuse msg_head for the reply to RX_READ */
1379 msg_head.opcode = RX_STATUS;
1380 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex);
1385 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ))