Lines Matching refs:packet

145 static inline int len_packet(const uint8_t *packet)  in len_packet()  argument
147 return (int)((struct hvsi_header *)packet)->len; in len_packet()
150 static inline int is_header(const uint8_t *packet) in is_header() argument
152 struct hvsi_header *header = (struct hvsi_header *)packet; in is_header()
156 static inline int got_packet(const struct hvsi_struct *hp, uint8_t *packet) in got_packet() argument
158 if (hp->inbuf_end < packet + sizeof(struct hvsi_header)) in got_packet()
161 if (hp->inbuf_end < (packet + len_packet(packet))) in got_packet()
181 #define dbg_dump_packet(packet) dump_packet(packet) argument
184 #define dbg_dump_packet(packet) do { } while (0) argument
206 static void dump_packet(uint8_t *packet) in dump_packet() argument
208 struct hvsi_header *header = (struct hvsi_header *)packet; in dump_packet()
213 dump_hex(packet, header->len); in dump_packet()
225 static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet, in hvsi_recv_control() argument
228 struct hvsi_control *header = (struct hvsi_control *)packet; in hvsi_recv_control()
249 dump_packet(packet); in hvsi_recv_control()
254 static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet) in hvsi_recv_response() argument
256 struct hvsi_query_response *resp = (struct hvsi_query_response *)packet; in hvsi_recv_response()
274 dump_packet(packet); in hvsi_recv_response()
282 struct hvsi_query_response packet __ALIGNED__; in hvsi_version_respond()
285 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; in hvsi_version_respond()
286 packet.hdr.len = sizeof(struct hvsi_query_response); in hvsi_version_respond()
287 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_version_respond()
288 packet.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER); in hvsi_version_respond()
289 packet.u.version = HVSI_VERSION; in hvsi_version_respond()
290 packet.query_seqno = cpu_to_be16(query_seqno+1); in hvsi_version_respond()
292 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_version_respond()
293 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_version_respond()
295 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_version_respond()
296 if (wrote != packet.hdr.len) { in hvsi_version_respond()
305 static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet) in hvsi_recv_query() argument
307 struct hvsi_query *query = (struct hvsi_query *)packet; in hvsi_recv_query()
316 dump_packet(packet); in hvsi_recv_query()
350 static bool hvsi_recv_data(struct hvsi_struct *hp, const uint8_t *packet) in hvsi_recv_data() argument
352 const struct hvsi_header *header = (const struct hvsi_header *)packet; in hvsi_recv_data()
353 const uint8_t *data = packet + sizeof(struct hvsi_header); in hvsi_recv_data()
391 uint8_t *packet = hp->inbuf; in hvsi_load_chunk() local
409 while ((packet < hp->inbuf_end) && got_packet(hp, packet)) { in hvsi_load_chunk()
410 struct hvsi_header *header = (struct hvsi_header *)packet; in hvsi_load_chunk()
412 if (!is_header(packet)) { in hvsi_load_chunk()
415 while ((packet < hp->inbuf_end) && (!is_header(packet))) in hvsi_load_chunk()
416 packet++; in hvsi_load_chunk()
421 len_packet(packet)); in hvsi_load_chunk()
422 dbg_dump_packet(packet); in hvsi_load_chunk()
428 flip = hvsi_recv_data(hp, packet); in hvsi_load_chunk()
431 hvsi_recv_control(hp, packet, tty, handshake); in hvsi_load_chunk()
434 hvsi_recv_response(hp, packet); in hvsi_load_chunk()
437 hvsi_recv_query(hp, packet); in hvsi_load_chunk()
442 dump_packet(packet); in hvsi_load_chunk()
446 packet += len_packet(packet); in hvsi_load_chunk()
454 compact_inbuf(hp, packet); in hvsi_load_chunk()
542 struct hvsi_query packet __ALIGNED__; in hvsi_query()
545 packet.hdr.type = VS_QUERY_PACKET_HEADER; in hvsi_query()
546 packet.hdr.len = sizeof(struct hvsi_query); in hvsi_query()
547 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_query()
548 packet.verb = cpu_to_be16(verb); in hvsi_query()
550 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_query()
551 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_query()
553 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_query()
554 if (wrote != packet.hdr.len) { in hvsi_query()
585 struct hvsi_control packet __ALIGNED__; in hvsi_set_mctrl()
588 packet.hdr.type = VS_CONTROL_PACKET_HEADER; in hvsi_set_mctrl()
589 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_set_mctrl()
590 packet.hdr.len = sizeof(struct hvsi_control); in hvsi_set_mctrl()
591 packet.verb = cpu_to_be16(VSV_SET_MODEM_CTL); in hvsi_set_mctrl()
592 packet.mask = cpu_to_be32(HVSI_TSDTR); in hvsi_set_mctrl()
595 packet.word = cpu_to_be32(HVSI_TSDTR); in hvsi_set_mctrl()
597 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_set_mctrl()
598 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_set_mctrl()
600 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_set_mctrl()
601 if (wrote != packet.hdr.len) { in hvsi_set_mctrl()
666 struct hvsi_data packet __ALIGNED__; in hvsi_put_chars()
671 packet.hdr.type = VS_DATA_PACKET_HEADER; in hvsi_put_chars()
672 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_put_chars()
673 packet.hdr.len = count + sizeof(struct hvsi_header); in hvsi_put_chars()
674 memcpy(&packet.data, buf, count); in hvsi_put_chars()
676 ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_put_chars()
677 if (ret == packet.hdr.len) { in hvsi_put_chars()
686 struct hvsi_control packet __ALIGNED__; in hvsi_close_protocol()
688 packet.hdr.type = VS_CONTROL_PACKET_HEADER; in hvsi_close_protocol()
689 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_close_protocol()
690 packet.hdr.len = 6; in hvsi_close_protocol()
691 packet.verb = cpu_to_be16(VSV_CLOSE_PROTOCOL); in hvsi_close_protocol()
693 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_close_protocol()
694 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_close_protocol()
696 hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_close_protocol()