static int tx_frames_to_rb(struct sbd_ring_buffer *rb)
{
	struct sk_buff_head *skb_txq = &rb->skb_q;
	int tx_bytes = 0;
	int ret = 0;

	while (1) {
		struct sk_buff *skb;
#ifdef DEBUG_MODEM_IF
		u8 *hdr;
#endif

		skb = skb_dequeue(skb_txq);
		if (unlikely(!skb))
			break;

		ret = sbd_pio_tx(rb, skb);
		if (unlikely(ret < 0)) {
			/* Take the skb back to the skb_txq */
			skb_queue_head(skb_txq, skb);
			break;
		}

		tx_bytes += ret;

#ifdef DEBUG_MODEM_IF
		hdr = skbpriv(skb)->lnk_hdr ? skb->data : NULL;
#ifdef DEBUG_MODEM_IF_IP_DATA
		if (sipc_ps_ch(rb->ch)) {
			u8 *ip_pkt = skb->data;
			if (hdr)
				ip_pkt += sipc5_get_hdr_len(hdr);
			print_ipv4_packet(ip_pkt, TX);
		}
#endif
#ifdef DEBUG_MODEM_IF_LINK_TX
		log_ipc_pkt(rb->ch, LINK, TX, skb, hdr);
#endif
#endif
		dev_kfree_skb_any(skb);
	}

	return (ret < 0) ? ret : tx_bytes;
}
void print_sipc5_link_fmt_frame(const u8 *psrc)
{
    u8 *lf;				/* Link Frame	*/
    struct sipc5_link_hdr *lh;	/* Link Header	*/
    struct sipc_fmt_hdr *fh;	/* IPC Header	*/
    int lh_len;
    int fh_len;
    u8 *data;
    int dlen;

    lf = (u8 *)psrc;

    /* Point HDLC header and IPC header */
    lh = (struct sipc5_link_hdr *)lf;
    lh_len = (u16)sipc5_get_hdr_len((u8 *)lh);
    fh = (struct sipc_fmt_hdr *)(lf + lh_len);
    fh_len = sizeof(struct sipc_fmt_hdr);

    /* Point IPC data */
    data = lf + (lh_len + fh_len);
    dlen = lh->len - (lh_len + fh_len);

    mif_err("--------------------LINK & FMT HEADER----------------------\n");

    mif_err("LINK: cfg 0x%02X, ch %d, len %d\n", lh->cfg, lh->ch, lh->len);

    mif_err("(M)0x%02X, (S)0x%02X, (T)0x%02X, mseq:%d, aseq:%d, len:%d\n",
            fh->main_cmd, fh->sub_cmd, fh->cmd_type,
            fh->msg_seq, fh->ack_seq, fh->len);

    mif_err("-----------------------IPC FMT DATA------------------------\n");

    if (dlen > 0) {
        if (dlen > 64)
            dlen = 64;
        mif_print_data(data, dlen);
    }

    mif_err("-----------------------------------------------------------\n");
}