Lines Matching defs:packet
68 /* inbuf is for packet reassembly. leave a little room for leftovers. */
75 atomic_t seqno; /* HVSI packet sequence number */
145 static inline int len_packet(const uint8_t *packet)
147 return (int)((struct hvsi_header *)packet)->len;
150 static inline int is_header(const uint8_t *packet)
152 struct hvsi_header *header = (struct hvsi_header *)packet;
156 static inline int got_packet(const struct hvsi_struct *hp, uint8_t *packet)
158 if (hp->inbuf_end < packet + sizeof(struct hvsi_header))
159 return 0; /* don't even have the packet header */
161 if (hp->inbuf_end < (packet + len_packet(packet)))
162 return 0; /* don't have the rest of the packet */
181 #define dbg_dump_packet(packet) dump_packet(packet)
184 #define dbg_dump_packet(packet) do { } while (0)
206 static void dump_packet(uint8_t *packet)
208 struct hvsi_header *header = (struct hvsi_header *)packet;
213 dump_hex(packet, header->len);
225 static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
228 struct hvsi_control *header = (struct hvsi_control *)packet;
247 printk(KERN_WARNING "hvsi%i: unknown HVSI control packet: ",
249 dump_packet(packet);
254 static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet)
256 struct hvsi_query_response *resp = (struct hvsi_query_response *)packet;
274 dump_packet(packet);
282 struct hvsi_query_response packet __ALIGNED__;
285 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
286 packet.hdr.len = sizeof(struct hvsi_query_response);
287 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno));
288 packet.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);
289 packet.u.version = HVSI_VERSION;
290 packet.query_seqno = cpu_to_be16(query_seqno+1);
292 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
293 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len);
295 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len);
296 if (wrote != packet.hdr.len) {
305 static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet)
307 struct hvsi_query *query = (struct hvsi_query *)packet;
316 dump_packet(packet);
350 static bool hvsi_recv_data(struct hvsi_struct *hp, const uint8_t *packet)
352 const struct hvsi_header *header = (const struct hvsi_header *)packet;
353 const uint8_t *data = packet + sizeof(struct hvsi_header);
391 uint8_t *packet = hp->inbuf;
409 while ((packet < hp->inbuf_end) && got_packet(hp, packet)) {
410 struct hvsi_header *header = (struct hvsi_header *)packet;
412 if (!is_header(packet)) {
413 printk(KERN_ERR "hvsi%i: got malformed packet\n", hp->index);
415 while ((packet < hp->inbuf_end) && (!is_header(packet)))
416 packet++;
420 pr_debug("%s: handling %i-byte packet\n", __func__,
421 len_packet(packet));
422 dbg_dump_packet(packet);
428 flip = hvsi_recv_data(hp, packet);
431 hvsi_recv_control(hp, packet, tty, handshake);
434 hvsi_recv_response(hp, packet);
437 hvsi_recv_query(hp, packet);
440 printk(KERN_ERR "hvsi%i: unknown HVSI packet type 0x%x\n",
442 dump_packet(packet);
446 packet += len_packet(packet);
454 compact_inbuf(hp, packet);
542 struct hvsi_query packet __ALIGNED__;
545 packet.hdr.type = VS_QUERY_PACKET_HEADER;
546 packet.hdr.len = sizeof(struct hvsi_query);
547 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno));
548 packet.verb = cpu_to_be16(verb);
550 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
551 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len);
553 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len);
554 if (wrote != packet.hdr.len) {
585 struct hvsi_control packet __ALIGNED__;
588 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
589 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno));
590 packet.hdr.len = sizeof(struct hvsi_control);
591 packet.verb = cpu_to_be16(VSV_SET_MODEM_CTL);
592 packet.mask = cpu_to_be32(HVSI_TSDTR);
595 packet.word = cpu_to_be32(HVSI_TSDTR);
597 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
598 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len);
600 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len);
601 if (wrote != packet.hdr.len) {
628 * user" and "it was just reset before it saw our handshake packet".)
666 struct hvsi_data packet __ALIGNED__;
671 packet.hdr.type = VS_DATA_PACKET_HEADER;
672 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno));
673 packet.hdr.len = count + sizeof(struct hvsi_header);
674 memcpy(&packet.data, buf, count);
676 ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len);
677 if (ret == packet.hdr.len) {
678 /* return the number of chars written, not the packet length */
686 struct hvsi_control packet __ALIGNED__;
688 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
689 packet.hdr.seqno = cpu_to_be16(atomic_inc_return(&hp->seqno));
690 packet.hdr.len = 6;
691 packet.verb = cpu_to_be16(VSV_CLOSE_PROTOCOL);
693 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
694 dbg_dump_hex((uint8_t*)&packet, packet.hdr.len);
696 hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len);