Lines Matching defs:i2400m

54  * The format for sending/receiving data to/from the i2400m is
79 * multiple of i2400m->bus_tx_block_size (as defined by the bus layer).
84 * Open: it is marked as active (i2400m->tx_msg is valid) and we
90 * length is aligned to i2400m->bus_tx_block_size (as set by the
135 * - The whole message has to be padded to i2400m->bus_tx_block_size;
234 * i2400m->bus_tx_kick()
236 * Now i2400m->bus_tx_kick() is the the bus-specific driver backend
239 * i2400m->bus_tx_kick()
249 #include "i2400m.h"
315 * i2400m->tx_in is right at the end of the buffer (really full
319 * i2400m->tx_in being zero would fail, so we treat is an a special
323 size_t __i2400m_tx_tail_room(struct i2400m *i2400m)
328 if (unlikely(i2400m->tx_in == 0))
330 tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
340 * @i2400m: device descriptor
428 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
434 void *i2400m_tx_fifo_push(struct i2400m *i2400m, size_t size,
437 struct device *dev = i2400m_dev(i2400m);
442 room = I2400M_TX_BUF_SIZE - (i2400m->tx_in - i2400m->tx_out);
449 tail_room = __i2400m_tx_tail_room(i2400m);
474 ptr = i2400m->tx_buf + i2400m->tx_in % I2400M_TX_BUF_SIZE;
476 i2400m->tx_in % I2400M_TX_BUF_SIZE);
477 i2400m->tx_in += size;
499 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
505 void i2400m_tx_skip_tail(struct i2400m *i2400m)
507 struct device *dev = i2400m_dev(i2400m);
508 size_t tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
509 size_t tail_room = __i2400m_tx_tail_room(i2400m);
510 struct i2400m_msg_hdr *msg = i2400m->tx_buf + tx_in;
517 i2400m->tx_in += tail_room;
530 * Assumes a TX message is active (i2400m->tx_msg).
532 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
535 unsigned i2400m_tx_fits(struct i2400m *i2400m)
537 struct i2400m_msg_hdr *msg_hdr = i2400m->tx_msg;
558 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
561 void i2400m_tx_new(struct i2400m *i2400m)
563 struct device *dev = i2400m_dev(i2400m);
566 BUG_ON(i2400m->tx_msg != NULL);
576 tx_msg = i2400m_tx_fifo_push(i2400m, I2400M_TX_PLD_SIZE,
577 i2400m->bus_tx_room_min, try_head);
581 i2400m_tx_skip_tail(i2400m);
589 i2400m->tx_msg = tx_msg;
591 tx_msg, (void *) tx_msg - i2400m->tx_buf);
613 void i2400m_tx_close(struct i2400m *i2400m)
615 struct device *dev = i2400m_dev(i2400m);
616 struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
651 * message so the size is a multiple of i2400m->bus_tx_block_size.
653 aligned_size = ALIGN(tx_msg_moved->size, i2400m->bus_tx_block_size);
656 pad_buf = i2400m_tx_fifo_push(i2400m, padding, 0, 0);
667 aligned_size, i2400m->tx_buf, i2400m->tx_in,
668 i2400m->tx_out);
677 i2400m->tx_msg = NULL;
713 int i2400m_tx(struct i2400m *i2400m, const void *buf, size_t buf_len,
717 struct device *dev = i2400m_dev(i2400m);
725 d_fnstart(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u)\n",
726 i2400m, buf, buf_len, pl_type);
732 spin_lock_irqsave(&i2400m->tx_lock, flags);
734 if (i2400m->tx_buf == NULL) {
739 if (unlikely(i2400m->tx_msg == NULL))
740 i2400m_tx_new(i2400m);
741 else if (unlikely(!i2400m_tx_fits(i2400m)
742 || (is_singleton && i2400m->tx_msg->num_pls != 0))) {
744 "%u num_pls %u)\n", i2400m_tx_fits(i2400m),
745 is_singleton, i2400m->tx_msg->num_pls);
746 i2400m_tx_close(i2400m);
747 i2400m_tx_new(i2400m);
749 if (i2400m->tx_msg == NULL)
757 if (i2400m->tx_msg->size + padded_len > I2400M_TX_MSG_SIZE) {
759 i2400m_tx_close(i2400m);
760 i2400m_tx_new(i2400m);
762 if (i2400m->tx_msg == NULL)
766 ptr = i2400m_tx_fifo_push(i2400m, padded_len,
767 i2400m->bus_tx_block_size, try_head);
770 i2400m_tx_close(i2400m);
771 i2400m_tx_skip_tail(i2400m);
778 struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
792 (void *)tx_msg - i2400m->tx_buf, (size_t)tx_msg->size,
793 num_pls+1, ptr - i2400m->tx_buf, buf_len, padded_len);
796 i2400m_tx_close(i2400m);
799 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
803 i2400m->bus_tx_kick(i2400m);
804 d_fnend(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u) = %d\n",
805 i2400m, buf, buf_len, pl_type, result);
814 * @i2400m: device descriptors
820 * It sets the state in @i2400m to indicate the bus-specific driver is
821 * transferring that message (i2400m->tx_msg_size).
830 * use. We keep the message's size in i2400m->tx_msg_size so that
837 struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *i2400m,
840 struct device *dev = i2400m_dev(i2400m);
844 d_fnstart(3, dev, "(i2400m %p bus_size %p)\n", i2400m, bus_size);
845 spin_lock_irqsave(&i2400m->tx_lock, flags);
847 if (i2400m->tx_buf == NULL)
851 if (i2400m->tx_in == i2400m->tx_out) { /* Empty FIFO? */
852 i2400m->tx_in = 0;
853 i2400m->tx_out = 0;
857 tx_msg = i2400m->tx_buf + i2400m->tx_out % I2400M_TX_BUF_SIZE;
860 i2400m->tx_out % I2400M_TX_BUF_SIZE,
862 i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
867 if (tx_msg == i2400m->tx_msg) { /* open, we are done */
870 (void *) tx_msg - i2400m->tx_buf);
876 (void *) tx_msg - i2400m->tx_buf,
878 i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
882 if (tx_msg == i2400m->tx_msg) /* open msg? */
883 i2400m_tx_close(i2400m);
887 i2400m->tx_msg_size = tx_msg->size;
891 current->pid, (void *) tx_msg - i2400m->tx_buf,
895 tx_msg_moved->sequence = le32_to_cpu(i2400m->tx_sequence++);
898 i2400m->tx_pl_num += pls; /* Update stats */
899 if (pls > i2400m->tx_pl_max)
900 i2400m->tx_pl_max = pls;
901 if (pls < i2400m->tx_pl_min)
902 i2400m->tx_pl_min = pls;
903 i2400m->tx_num++;
904 i2400m->tx_size_acc += *bus_size;
905 if (*bus_size < i2400m->tx_size_min)
906 i2400m->tx_size_min = *bus_size;
907 if (*bus_size > i2400m->tx_size_max)
908 i2400m->tx_size_max = *bus_size;
910 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
911 d_fnstart(3, dev, "(i2400m %p bus_size %p [%zu]) = %p\n",
912 i2400m, bus_size, *bus_size, tx_msg_moved);
921 * @i2400m: device descriptor
930 void i2400m_tx_msg_sent(struct i2400m *i2400m)
934 struct device *dev = i2400m_dev(i2400m);
936 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
937 spin_lock_irqsave(&i2400m->tx_lock, flags);
938 if (i2400m->tx_buf == NULL)
940 i2400m->tx_out += i2400m->tx_msg_size;
941 d_printf(2, dev, "TX: sent %zu b\n", (size_t) i2400m->tx_msg_size);
942 i2400m->tx_msg_size = 0;
943 BUG_ON(i2400m->tx_out > i2400m->tx_in);
945 n = i2400m->tx_out / I2400M_TX_BUF_SIZE;
946 i2400m->tx_out %= I2400M_TX_BUF_SIZE;
947 i2400m->tx_in -= n * I2400M_TX_BUF_SIZE;
949 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
950 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
963 int i2400m_tx_setup(struct i2400m *i2400m)
972 INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work);
985 spin_lock_irqsave(&i2400m->tx_lock, flags);
986 i2400m->tx_sequence = 0;
987 i2400m->tx_in = 0;
988 i2400m->tx_out = 0;
989 i2400m->tx_msg_size = 0;
990 i2400m->tx_msg = NULL;
991 i2400m->tx_buf = tx_buf;
992 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
994 BUG_ON(i2400m->bus_tx_block_size == 0);
1004 void i2400m_tx_release(struct i2400m *i2400m)
1007 spin_lock_irqsave(&i2400m->tx_lock, flags);
1008 kfree(i2400m->tx_buf);
1009 i2400m->tx_buf = NULL;
1010 spin_unlock_irqrestore(&i2400m->tx_lock, flags);