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);
836 static int bcm_read_op(struct list_head *ops, struct bcm_msg_head *msg_head,
839 struct bcm_op *op = bcm_find_op(ops, msg_head, ifindex);
844 /* put current values into msg_head */
845 msg_head->flags = op->flags;
846 msg_head->count = op->count;
847 msg_head->ival1 = op->ival1;
848 msg_head->ival2 = op->ival2;
849 msg_head->nframes = op->nframes;
851 bcm_send_to_user(op, msg_head, op->frames, 0);
859 static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
873 if (msg_head->nframes < 1 || msg_head->nframes > MAX_NFRAMES)
877 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head))
881 op = bcm_find_op(&bo->tx_ops, msg_head, ifindex);
890 if (msg_head->nframes > op->nframes)
894 for (i = 0; i < msg_head->nframes; i++) {
910 if (msg_head->flags & TX_CP_CAN_ID) {
912 cf->can_id = msg_head->can_id;
915 op->flags = msg_head->flags;
924 op->can_id = msg_head->can_id;
925 op->cfsiz = CFSIZ(msg_head->flags);
926 op->flags = msg_head->flags;
929 if (msg_head->nframes > 1) {
930 op->frames = kmalloc_array(msg_head->nframes,
940 for (i = 0; i < msg_head->nframes; i++) {
958 if (msg_head->flags & TX_CP_CAN_ID) {
960 cf->can_id = msg_head->can_id;
983 } /* if ((op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex))) */
985 if (op->nframes != msg_head->nframes) {
986 op->nframes = msg_head->nframes;
1000 op->count = msg_head->count;
1001 op->ival1 = msg_head->ival1;
1002 op->ival2 = msg_head->ival2;
1003 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1);
1004 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2);
1026 return msg_head->nframes * op->cfsiz + MHSIZ;
1038 static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1046 if ((msg_head->flags & RX_FILTER_ID) || (!(msg_head->nframes))) {
1048 msg_head->flags |= RX_FILTER_ID;
1050 msg_head->nframes = 0;
1054 if (msg_head->nframes > MAX_NFRAMES + 1)
1057 if ((msg_head->flags & RX_RTR_FRAME) &&
1058 ((msg_head->nframes != 1) ||
1059 (!(msg_head->can_id & CAN_RTR_FLAG))))
1063 if ((msg_head->flags & SETTIMER) && bcm_is_invalid_tv(msg_head))
1067 op = bcm_find_op(&bo->rx_ops, msg_head, ifindex);
1076 if (msg_head->nframes > op->nframes)
1079 if (msg_head->nframes) {
1082 msg_head->nframes * op->cfsiz);
1087 memset(op->last_frames, 0, msg_head->nframes * op->cfsiz);
1090 op->nframes = msg_head->nframes;
1091 op->flags = msg_head->flags;
1102 op->can_id = msg_head->can_id;
1103 op->nframes = msg_head->nframes;
1104 op->cfsiz = CFSIZ(msg_head->flags);
1105 op->flags = msg_head->flags;
1107 if (msg_head->nframes > 1) {
1109 op->frames = kmalloc_array(msg_head->nframes,
1118 op->last_frames = kcalloc(msg_head->nframes,
1132 if (msg_head->nframes) {
1134 msg_head->nframes * op->cfsiz);
1167 } /* if ((op = bcm_find_op(&bo->rx_ops, msg_head->can_id, ifindex))) */
1191 op->ival1 = msg_head->ival1;
1192 op->ival2 = msg_head->ival2;
1193 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1);
1194 op->kt_ival2 = bcm_timeval_to_ktime(msg_head->ival2);
1243 return msg_head->nframes * op->cfsiz + MHSIZ;
1299 struct bcm_msg_head msg_head;
1311 ret = memcpy_from_msg((u8 *)&msg_head, msg, MHSIZ);
1315 cfsiz = CFSIZ(msg_head.flags);
1352 switch (msg_head.opcode) {
1355 ret = bcm_tx_setup(&msg_head, msg, ifindex, sk);
1359 ret = bcm_rx_setup(&msg_head, msg, ifindex, sk);
1363 if (bcm_delete_tx_op(&bo->tx_ops, &msg_head, ifindex))
1370 if (bcm_delete_rx_op(&bo->rx_ops, &msg_head, ifindex))
1377 /* reuse msg_head for the reply to TX_READ */
1378 msg_head.opcode = TX_STATUS;
1379 ret = bcm_read_op(&bo->tx_ops, &msg_head, ifindex);
1383 /* reuse msg_head for the reply to RX_READ */
1384 msg_head.opcode = RX_STATUS;
1385 ret = bcm_read_op(&bo->rx_ops, &msg_head, ifindex);
1390 if ((msg_head.nframes != 1) || (size != cfsiz + MHSIZ))