Lines Matching refs:msg

459 static int gsm_send_packet(struct gsm_mux *gsm, struct gsm_msg *msg);
812 struct gsm_msg *msg; in gsm_send() local
817 msg = gsm_data_alloc(gsm, addr, 0, control); in gsm_send()
818 if (!msg) in gsm_send()
824 msg->data -= 3; in gsm_send()
825 dp = msg->data; in gsm_send()
832 *dp = 0xFF - gsm_fcs_add_block(INIT_FCS, msg->data, dp - msg->data); in gsm_send()
833 msg->len = (dp - msg->data) + 1; in gsm_send()
838 list_add_tail(&msg->list, &gsm->tx_ctrl_list); in gsm_send()
839 gsm->tx_bytes += msg->len; in gsm_send()
855 struct gsm_msg *msg, *nmsg; in gsm_dlci_clear_queues() local
866 list_for_each_entry_safe(msg, nmsg, &gsm->tx_data_list, list) { in gsm_dlci_clear_queues()
867 if (msg->addr != addr) in gsm_dlci_clear_queues()
869 gsm->tx_bytes -= msg->len; in gsm_dlci_clear_queues()
870 list_del(&msg->list); in gsm_dlci_clear_queues()
871 kfree(msg); in gsm_dlci_clear_queues()
943 static int gsm_send_packet(struct gsm_mux *gsm, struct gsm_msg *msg) in gsm_send_packet() argument
950 memcpy(gsm->txframe + 1, msg->data, msg->len); in gsm_send_packet()
951 gsm->txframe[msg->len + 1] = GSM0_SOF; in gsm_send_packet()
952 len = msg->len + 2; in gsm_send_packet()
955 len = gsm_stuff_frame(msg->data, gsm->txframe + 1, msg->len); in gsm_send_packet()
962 gsm_print_packet("-->", msg->addr, gsm->initiator, msg->ctrl, msg->data, in gsm_send_packet()
963 msg->len); in gsm_send_packet()
969 gsm->tx_bytes -= msg->len; in gsm_send_packet()
981 static bool gsm_is_flow_ctrl_msg(struct gsm_msg *msg) in gsm_is_flow_ctrl_msg() argument
985 if (msg->addr > 0) in gsm_is_flow_ctrl_msg()
988 switch (msg->ctrl & ~PF) { in gsm_is_flow_ctrl_msg()
992 if (gsm_read_ea_val(&cmd, msg->data + 2, msg->len - 2) < 1) in gsm_is_flow_ctrl_msg()
1017 struct gsm_msg *msg, *nmsg; in gsm_data_kick() local
1024 list_for_each_entry_safe(msg, nmsg, &gsm->tx_ctrl_list, list) { in gsm_data_kick()
1025 if (gsm->constipated && !gsm_is_flow_ctrl_msg(msg)) in gsm_data_kick()
1027 ret = gsm_send_packet(gsm, msg); in gsm_data_kick()
1033 gsm->tx_bytes -= msg->len; in gsm_data_kick()
1034 list_del(&msg->list); in gsm_data_kick()
1035 kfree(msg); in gsm_data_kick()
1039 list_del(&msg->list); in gsm_data_kick()
1040 kfree(msg); in gsm_data_kick()
1052 list_for_each_entry_safe(msg, nmsg, &gsm->tx_data_list, list) { in gsm_data_kick()
1053 dlci = gsm->dlci[msg->addr]; in gsm_data_kick()
1056 gsm->tx_bytes -= msg->len; in gsm_data_kick()
1057 list_del(&msg->list); in gsm_data_kick()
1058 kfree(msg); in gsm_data_kick()
1061 ret = gsm_send_packet(gsm, msg); in gsm_data_kick()
1067 gsm->tx_bytes -= msg->len; in gsm_data_kick()
1068 list_del(&msg->list); in gsm_data_kick()
1069 kfree(msg); in gsm_data_kick()
1073 list_del(&msg->list); in gsm_data_kick()
1074 kfree(msg); in gsm_data_kick()
1093 static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg) in __gsm_data_queue() argument
1096 u8 *dp = msg->data; in __gsm_data_queue()
1097 u8 *fcs = dp + msg->len; in __gsm_data_queue()
1101 if (msg->len < 128) in __gsm_data_queue()
1102 *--dp = (msg->len << 1) | EA; in __gsm_data_queue()
1104 *--dp = (msg->len >> 7); /* bits 7 - 15 */ in __gsm_data_queue()
1105 *--dp = (msg->len & 127) << 1; /* bits 0 - 6 */ in __gsm_data_queue()
1109 *--dp = msg->ctrl; in __gsm_data_queue()
1111 *--dp = (msg->addr << 2) | CR | EA; in __gsm_data_queue()
1113 *--dp = (msg->addr << 2) | EA; in __gsm_data_queue()
1114 *fcs = gsm_fcs_add_block(INIT_FCS, dp , msg->data - dp); in __gsm_data_queue()
1116 if (msg->ctrl == UI || msg->ctrl == (UI|PF)) in __gsm_data_queue()
1117 *fcs = gsm_fcs_add_block(*fcs, msg->data, msg->len); in __gsm_data_queue()
1120 gsm_print_packet("Q> ", msg->addr, gsm->initiator, msg->ctrl, in __gsm_data_queue()
1121 msg->data, msg->len); in __gsm_data_queue()
1125 msg->len += (msg->data - dp) + 1; in __gsm_data_queue()
1126 msg->data = dp; in __gsm_data_queue()
1129 switch (msg->ctrl & ~PF) { in __gsm_data_queue()
1132 if (msg->addr > 0) { in __gsm_data_queue()
1133 list_add_tail(&msg->list, &gsm->tx_data_list); in __gsm_data_queue()
1138 list_add_tail(&msg->list, &gsm->tx_ctrl_list); in __gsm_data_queue()
1141 gsm->tx_bytes += msg->len; in __gsm_data_queue()
1157 static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg) in gsm_data_queue() argument
1161 __gsm_data_queue(dlci, msg); in gsm_data_queue()
1179 struct gsm_msg *msg; in gsm_dlci_data_output() local
1196 msg = gsm_data_alloc(gsm, dlci->addr, size, dlci->ftype); in gsm_dlci_data_output()
1197 if (!msg) in gsm_dlci_data_output()
1199 dp = msg->data; in gsm_dlci_data_output()
1220 __gsm_data_queue(dlci, msg); in gsm_dlci_data_output()
1240 struct gsm_msg *msg; in gsm_dlci_data_output_framed() local
1272 msg = gsm_data_alloc(gsm, dlci->addr, size, dlci->ftype); in gsm_dlci_data_output_framed()
1273 if (msg == NULL) { in gsm_dlci_data_output_framed()
1278 dp = msg->data; in gsm_dlci_data_output_framed()
1287 __gsm_data_queue(dlci, msg); in gsm_dlci_data_output_framed()
1311 struct gsm_msg *msg; in gsm_dlci_modem_output() local
1329 msg = gsm_data_alloc(gsm, dlci->addr, size, dlci->ftype); in gsm_dlci_modem_output()
1330 if (!msg) { in gsm_dlci_modem_output()
1334 dp = msg->data; in gsm_dlci_modem_output()
1351 __gsm_data_queue(dlci, msg); in gsm_dlci_modem_output()
1455 struct gsm_msg *msg; in gsm_control_command() local
1458 msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); in gsm_control_command()
1459 if (msg == NULL) in gsm_control_command()
1462 msg->data[0] = (cmd << 1) | CR | EA; /* Set C/R */ in gsm_control_command()
1463 msg->data[1] = (dlen << 1) | EA; in gsm_control_command()
1464 memcpy(msg->data + 2, data, dlen); in gsm_control_command()
1465 gsm_data_queue(dlci, msg); in gsm_control_command()
1483 struct gsm_msg *msg; in gsm_control_reply() local
1486 msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); in gsm_control_reply()
1487 if (msg == NULL) in gsm_control_reply()
1489 msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */ in gsm_control_reply()
1490 msg->data[1] = (dlen << 1) | EA; in gsm_control_reply()
1491 memcpy(msg->data + 2, data, dlen); in gsm_control_reply()
1492 gsm_data_queue(dlci, msg); in gsm_control_reply()