Lines Matching defs:packet
81 /* inbuf is for packet reassembly. leave a little room for leftovers. */
88 atomic_t seqno; /* HVSI packet sequence number */
220 static inline int len_packet(const uint8_t *packet)
222 return (int)((struct hvsi_header *)packet)->len;
225 static inline int is_header(const uint8_t *packet)
227 struct hvsi_header *header = (struct hvsi_header *)packet;
231 static inline int got_packet(const struct hvsi_struct *hp, uint8_t *packet)
233 if (hp->inbuf_end < packet + sizeof(struct hvsi_header))
234 return 0; /* don't even have the packet header */
236 if (hp->inbuf_end < (packet + len_packet(packet)))
237 return 0; /* don't have the rest of the packet */
256 #define dbg_dump_packet(packet) dump_packet(packet)
259 #define dbg_dump_packet(packet) do { } while (0)
281 static void dump_packet(uint8_t *packet)
283 struct hvsi_header *header = (struct hvsi_header *)packet;
288 dump_hex(packet, header->len);
300 static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
303 struct hvsi_control *header = (struct hvsi_control *)packet;
323 printk(KERN_WARNING "hvsi%i: unknown HVSI control packet: ",
325 dump_packet(packet);
330 static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet)
332 struct hvsi_query_response *resp = (struct hvsi_query_response *)packet;
348 dump_packet(packet);
356 struct hvsi_query_response packet __ALIGNED__;
359 packet.type = VS_QUERY_RESPONSE_PACKET_HEADER;
360 packet.len = sizeof(struct hvsi_query_response);
361 packet.seqno = atomic_inc_return(&hp->seqno);
362 packet.verb = VSV_SEND_VERSION_NUMBER;
363 packet.u.version = HVSI_VERSION;
364 packet.query_seqno = query_seqno+1;
366 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
367 dbg_dump_hex((uint8_t*)&packet, packet.len);
369 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
370 if (wrote != packet.len) {
379 static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet)
381 struct hvsi_query *query = (struct hvsi_query *)packet;
390 dump_packet(packet);
425 const uint8_t *packet)
427 const struct hvsi_header *header = (const struct hvsi_header *)packet;
428 const uint8_t *data = packet + sizeof(struct hvsi_header);
466 uint8_t *packet = hp->inbuf;
485 while ((packet < hp->inbuf_end) && got_packet(hp, packet)) {
486 struct hvsi_header *header = (struct hvsi_header *)packet;
488 if (!is_header(packet)) {
489 printk(KERN_ERR "hvsi%i: got malformed packet\n", hp->index);
491 while ((packet < hp->inbuf_end) && (!is_header(packet)))
492 packet++;
496 pr_debug("%s: handling %i-byte packet\n", __func__,
497 len_packet(packet));
498 dbg_dump_packet(packet);
506 *flip = hvsi_recv_data(hp, packet);
509 hvsi_recv_control(hp, packet, hangup, handshake);
512 hvsi_recv_response(hp, packet);
515 hvsi_recv_query(hp, packet);
518 printk(KERN_ERR "hvsi%i: unknown HVSI packet type 0x%x\n",
520 dump_packet(packet);
524 packet += len_packet(packet);
537 compact_inbuf(hp, packet);
640 struct hvsi_query packet __ALIGNED__;
643 packet.type = VS_QUERY_PACKET_HEADER;
644 packet.len = sizeof(struct hvsi_query);
645 packet.seqno = atomic_inc_return(&hp->seqno);
646 packet.verb = verb;
648 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
649 dbg_dump_hex((uint8_t*)&packet, packet.len);
651 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
652 if (wrote != packet.len) {
683 struct hvsi_control packet __ALIGNED__;
686 packet.type = VS_CONTROL_PACKET_HEADER,
687 packet.seqno = atomic_inc_return(&hp->seqno);
688 packet.len = sizeof(struct hvsi_control);
689 packet.verb = VSV_SET_MODEM_CTL;
690 packet.mask = HVSI_TSDTR;
693 packet.word = HVSI_TSDTR;
695 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
696 dbg_dump_hex((uint8_t*)&packet, packet.len);
698 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
699 if (wrote != packet.len) {
726 * user" and "it was just reset before it saw our handshake packet".)
764 struct hvsi_data packet __ALIGNED__;
769 packet.type = VS_DATA_PACKET_HEADER;
770 packet.seqno = atomic_inc_return(&hp->seqno);
771 packet.len = count + sizeof(struct hvsi_header);
772 memcpy(&packet.data, buf, count);
774 ret = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
775 if (ret == packet.len) {
776 /* return the number of chars written, not the packet length */
784 struct hvsi_control packet __ALIGNED__;
786 packet.type = VS_CONTROL_PACKET_HEADER;
787 packet.seqno = atomic_inc_return(&hp->seqno);
788 packet.len = 6;
789 packet.verb = VSV_CLOSE_PROTOCOL;
791 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
792 dbg_dump_hex((uint8_t*)&packet, packet.len);
794 hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);