Lines Matching refs:packet

158 static inline int len_packet(const uint8_t *packet)  in len_packet()  argument
160 return (int)((struct hvsi_header *)packet)->len; in len_packet()
163 static inline int is_header(const uint8_t *packet) in is_header() argument
165 struct hvsi_header *header = (struct hvsi_header *)packet; in is_header()
169 static inline int got_packet(const struct hvsi_struct *hp, uint8_t *packet) in got_packet() argument
171 if (hp->inbuf_end < packet + sizeof(struct hvsi_header)) in got_packet()
174 if (hp->inbuf_end < (packet + len_packet(packet))) in got_packet()
194 #define dbg_dump_packet(packet) dump_packet(packet) argument
197 #define dbg_dump_packet(packet) do { } while (0) argument
219 static void dump_packet(uint8_t *packet) in dump_packet() argument
221 struct hvsi_header *header = (struct hvsi_header *)packet; in dump_packet()
226 dump_hex(packet, header->len); in dump_packet()
238 static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet, in hvsi_recv_control() argument
241 struct hvsi_control *header = (struct hvsi_control *)packet; in hvsi_recv_control()
262 dump_packet(packet); in hvsi_recv_control()
267 static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet) in hvsi_recv_response() argument
269 struct hvsi_query_response *resp = (struct hvsi_query_response *)packet; in hvsi_recv_response()
287 dump_packet(packet); in hvsi_recv_response()
295 struct hvsi_query_response packet __ALIGNED__; in hvsi_version_respond()
298 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; in hvsi_version_respond()
299 packet.hdr.len = sizeof(struct hvsi_query_response); in hvsi_version_respond()
300 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_version_respond()
301 packet.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER); in hvsi_version_respond()
302 packet.u.version = HVSI_VERSION; in hvsi_version_respond()
303 packet.query_seqno = cpu_to_be16(query_seqno+1); in hvsi_version_respond()
305 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_version_respond()
306 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_version_respond()
308 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_version_respond()
309 if (wrote != packet.hdr.len) { in hvsi_version_respond()
318 static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet) in hvsi_recv_query() argument
320 struct hvsi_query *query = (struct hvsi_query *)packet; in hvsi_recv_query()
329 dump_packet(packet); in hvsi_recv_query()
363 static bool hvsi_recv_data(struct hvsi_struct *hp, const uint8_t *packet) in hvsi_recv_data() argument
365 const struct hvsi_header *header = (const struct hvsi_header *)packet; in hvsi_recv_data()
366 const uint8_t *data = packet + sizeof(struct hvsi_header); in hvsi_recv_data()
404 uint8_t *packet = hp->inbuf; in hvsi_load_chunk() local
422 while ((packet < hp->inbuf_end) && got_packet(hp, packet)) { in hvsi_load_chunk()
423 struct hvsi_header *header = (struct hvsi_header *)packet; in hvsi_load_chunk()
425 if (!is_header(packet)) { in hvsi_load_chunk()
428 while ((packet < hp->inbuf_end) && (!is_header(packet))) in hvsi_load_chunk()
429 packet++; in hvsi_load_chunk()
434 len_packet(packet)); in hvsi_load_chunk()
435 dbg_dump_packet(packet); in hvsi_load_chunk()
441 flip = hvsi_recv_data(hp, packet); in hvsi_load_chunk()
444 hvsi_recv_control(hp, packet, tty, handshake); in hvsi_load_chunk()
447 hvsi_recv_response(hp, packet); in hvsi_load_chunk()
450 hvsi_recv_query(hp, packet); in hvsi_load_chunk()
455 dump_packet(packet); in hvsi_load_chunk()
459 packet += len_packet(packet); in hvsi_load_chunk()
467 compact_inbuf(hp, packet); in hvsi_load_chunk()
555 struct hvsi_query packet __ALIGNED__; in hvsi_query()
558 packet.hdr.type = VS_QUERY_PACKET_HEADER; in hvsi_query()
559 packet.hdr.len = sizeof(struct hvsi_query); in hvsi_query()
560 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_query()
561 packet.verb = cpu_to_be16(verb); in hvsi_query()
563 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_query()
564 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_query()
566 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_query()
567 if (wrote != packet.hdr.len) { in hvsi_query()
598 struct hvsi_control packet __ALIGNED__; in hvsi_set_mctrl()
601 packet.hdr.type = VS_CONTROL_PACKET_HEADER; in hvsi_set_mctrl()
602 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_set_mctrl()
603 packet.hdr.len = sizeof(struct hvsi_control); in hvsi_set_mctrl()
604 packet.verb = cpu_to_be16(VSV_SET_MODEM_CTL); in hvsi_set_mctrl()
605 packet.mask = cpu_to_be32(HVSI_TSDTR); in hvsi_set_mctrl()
608 packet.word = cpu_to_be32(HVSI_TSDTR); in hvsi_set_mctrl()
610 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_set_mctrl()
611 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_set_mctrl()
613 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_set_mctrl()
614 if (wrote != packet.hdr.len) { in hvsi_set_mctrl()
679 struct hvsi_data packet __ALIGNED__; in hvsi_put_chars()
684 packet.hdr.type = VS_DATA_PACKET_HEADER; in hvsi_put_chars()
685 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_put_chars()
686 packet.hdr.len = count + sizeof(struct hvsi_header); in hvsi_put_chars()
687 memcpy(&packet.data, buf, count); in hvsi_put_chars()
689 ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_put_chars()
690 if (ret == packet.hdr.len) { in hvsi_put_chars()
699 struct hvsi_control packet __ALIGNED__; in hvsi_close_protocol()
701 packet.hdr.type = VS_CONTROL_PACKET_HEADER; in hvsi_close_protocol()
702 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno)); in hvsi_close_protocol()
703 packet.hdr.len = 6; in hvsi_close_protocol()
704 packet.verb = cpu_to_be16(VSV_CLOSE_PROTOCOL); in hvsi_close_protocol()
706 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_close_protocol()
707 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_close_protocol()
709 hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_close_protocol()