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()
285 dump_packet(packet); in hvsi_recv_response()
293 struct hvsi_query_response packet __ALIGNED__; in hvsi_version_respond()
296 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; in hvsi_version_respond()
297 packet.hdr.len = sizeof(struct hvsi_query_response); in hvsi_version_respond()
298 packet.hdr.seqno = atomic_inc_return(&hp->seqno); in hvsi_version_respond()
299 packet.verb = VSV_SEND_VERSION_NUMBER; in hvsi_version_respond()
300 packet.u.version = HVSI_VERSION; in hvsi_version_respond()
301 packet.query_seqno = query_seqno+1; in hvsi_version_respond()
303 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_version_respond()
304 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_version_respond()
306 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_version_respond()
307 if (wrote != packet.hdr.len) { in hvsi_version_respond()
316 static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet) in hvsi_recv_query() argument
318 struct hvsi_query *query = (struct hvsi_query *)packet; in hvsi_recv_query()
327 dump_packet(packet); in hvsi_recv_query()
361 static bool hvsi_recv_data(struct hvsi_struct *hp, const uint8_t *packet) in hvsi_recv_data() argument
363 const struct hvsi_header *header = (const struct hvsi_header *)packet; in hvsi_recv_data()
364 const uint8_t *data = packet + sizeof(struct hvsi_header); in hvsi_recv_data()
402 uint8_t *packet = hp->inbuf; in hvsi_load_chunk() local
420 while ((packet < hp->inbuf_end) && got_packet(hp, packet)) { in hvsi_load_chunk()
421 struct hvsi_header *header = (struct hvsi_header *)packet; in hvsi_load_chunk()
423 if (!is_header(packet)) { in hvsi_load_chunk()
426 while ((packet < hp->inbuf_end) && (!is_header(packet))) in hvsi_load_chunk()
427 packet++; in hvsi_load_chunk()
432 len_packet(packet)); in hvsi_load_chunk()
433 dbg_dump_packet(packet); in hvsi_load_chunk()
439 flip = hvsi_recv_data(hp, packet); in hvsi_load_chunk()
442 hvsi_recv_control(hp, packet, tty, handshake); in hvsi_load_chunk()
445 hvsi_recv_response(hp, packet); in hvsi_load_chunk()
448 hvsi_recv_query(hp, packet); in hvsi_load_chunk()
453 dump_packet(packet); in hvsi_load_chunk()
457 packet += len_packet(packet); in hvsi_load_chunk()
465 compact_inbuf(hp, packet); in hvsi_load_chunk()
553 struct hvsi_query packet __ALIGNED__; in hvsi_query()
556 packet.hdr.type = VS_QUERY_PACKET_HEADER; in hvsi_query()
557 packet.hdr.len = sizeof(struct hvsi_query); in hvsi_query()
558 packet.hdr.seqno = atomic_inc_return(&hp->seqno); in hvsi_query()
559 packet.verb = verb; in hvsi_query()
561 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_query()
562 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_query()
564 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_query()
565 if (wrote != packet.hdr.len) { in hvsi_query()
596 struct hvsi_control packet __ALIGNED__; in hvsi_set_mctrl()
599 packet.hdr.type = VS_CONTROL_PACKET_HEADER, in hvsi_set_mctrl()
600 packet.hdr.seqno = atomic_inc_return(&hp->seqno); in hvsi_set_mctrl()
601 packet.hdr.len = sizeof(struct hvsi_control); in hvsi_set_mctrl()
602 packet.verb = VSV_SET_MODEM_CTL; in hvsi_set_mctrl()
603 packet.mask = HVSI_TSDTR; in hvsi_set_mctrl()
606 packet.word = HVSI_TSDTR; in hvsi_set_mctrl()
608 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_set_mctrl()
609 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_set_mctrl()
611 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_set_mctrl()
612 if (wrote != packet.hdr.len) { in hvsi_set_mctrl()
677 struct hvsi_data packet __ALIGNED__; in hvsi_put_chars()
682 packet.hdr.type = VS_DATA_PACKET_HEADER; in hvsi_put_chars()
683 packet.hdr.seqno = atomic_inc_return(&hp->seqno); in hvsi_put_chars()
684 packet.hdr.len = count + sizeof(struct hvsi_header); in hvsi_put_chars()
685 memcpy(&packet.data, buf, count); in hvsi_put_chars()
687 ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_put_chars()
688 if (ret == packet.hdr.len) { in hvsi_put_chars()
697 struct hvsi_control packet __ALIGNED__; in hvsi_close_protocol()
699 packet.hdr.type = VS_CONTROL_PACKET_HEADER; in hvsi_close_protocol()
700 packet.hdr.seqno = atomic_inc_return(&hp->seqno); in hvsi_close_protocol()
701 packet.hdr.len = 6; in hvsi_close_protocol()
702 packet.verb = VSV_CLOSE_PROTOCOL; in hvsi_close_protocol()
704 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); in hvsi_close_protocol()
705 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); in hvsi_close_protocol()
707 hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); in hvsi_close_protocol()