Lines Matching full:fifo
7 * fm10k_fifo_init - Initialize a message FIFO
8 * @fifo: pointer to FIFO
9 * @buffer: pointer to memory to be used to store FIFO
10 * @size: maximum message size to store in FIFO, must be 2^n - 1
12 static void fm10k_fifo_init(struct fm10k_mbx_fifo *fifo, u32 *buffer, u16 size) in fm10k_fifo_init() argument
14 fifo->buffer = buffer; in fm10k_fifo_init()
15 fifo->size = size; in fm10k_fifo_init()
16 fifo->head = 0; in fm10k_fifo_init()
17 fifo->tail = 0; in fm10k_fifo_init()
21 * fm10k_fifo_used - Retrieve used space in FIFO
22 * @fifo: pointer to FIFO
24 * This function returns the number of DWORDs used in the FIFO
26 static u16 fm10k_fifo_used(struct fm10k_mbx_fifo *fifo) in fm10k_fifo_used() argument
28 return fifo->tail - fifo->head; in fm10k_fifo_used()
32 * fm10k_fifo_unused - Retrieve unused space in FIFO
33 * @fifo: pointer to FIFO
35 * This function returns the number of unused DWORDs in the FIFO
37 static u16 fm10k_fifo_unused(struct fm10k_mbx_fifo *fifo) in fm10k_fifo_unused() argument
39 return fifo->size + fifo->head - fifo->tail; in fm10k_fifo_unused()
43 * fm10k_fifo_empty - Test to verify if FIFO is empty
44 * @fifo: pointer to FIFO
46 * This function returns true if the FIFO is empty, else false
48 static bool fm10k_fifo_empty(struct fm10k_mbx_fifo *fifo) in fm10k_fifo_empty() argument
50 return fifo->head == fifo->tail; in fm10k_fifo_empty()
55 * @fifo: pointer to FIFO
58 * This function returns the indices into the FIFO based on head + offset
60 static u16 fm10k_fifo_head_offset(struct fm10k_mbx_fifo *fifo, u16 offset) in fm10k_fifo_head_offset() argument
62 return (fifo->head + offset) & (fifo->size - 1); in fm10k_fifo_head_offset()
67 * @fifo: pointer to FIFO
70 * This function returns the indices into the FIFO based on tail + offset
72 static u16 fm10k_fifo_tail_offset(struct fm10k_mbx_fifo *fifo, u16 offset) in fm10k_fifo_tail_offset() argument
74 return (fifo->tail + offset) & (fifo->size - 1); in fm10k_fifo_tail_offset()
78 * fm10k_fifo_head_len - Retrieve length of first message in FIFO
79 * @fifo: pointer to FIFO
81 * This function returns the size of the first message in the FIFO
83 static u16 fm10k_fifo_head_len(struct fm10k_mbx_fifo *fifo) in fm10k_fifo_head_len() argument
85 u32 *head = fifo->buffer + fm10k_fifo_head_offset(fifo, 0); in fm10k_fifo_head_len()
87 /* verify there is at least 1 DWORD in the fifo so *head is valid */ in fm10k_fifo_head_len()
88 if (fm10k_fifo_empty(fifo)) in fm10k_fifo_head_len()
96 * fm10k_fifo_head_drop - Drop the first message in FIFO
97 * @fifo: pointer to FIFO
99 * This function returns the size of the message dropped from the FIFO
101 static u16 fm10k_fifo_head_drop(struct fm10k_mbx_fifo *fifo) in fm10k_fifo_head_drop() argument
103 u16 len = fm10k_fifo_head_len(fifo); in fm10k_fifo_head_drop()
106 fifo->head += len; in fm10k_fifo_head_drop()
112 * fm10k_fifo_drop_all - Drop all messages in FIFO
113 * @fifo: pointer to FIFO
115 * This function resets the head pointer to drop all messages in the FIFO and
116 * ensure the FIFO is empty.
118 static void fm10k_fifo_drop_all(struct fm10k_mbx_fifo *fifo) in fm10k_fifo_drop_all() argument
120 fifo->head = fifo->tail; in fm10k_fifo_drop_all()
226 * fm10k_fifo_write_copy - pulls data off of msg and places it in FIFO
227 * @fifo: pointer to FIFO
230 * @len: length of FIFO to copy into message header
233 * FIFO. In order to get something into a location other than just
236 static void fm10k_fifo_write_copy(struct fm10k_mbx_fifo *fifo, in fm10k_fifo_write_copy() argument
239 u16 end = fm10k_fifo_tail_offset(fifo, tail_offset); in fm10k_fifo_write_copy()
240 u32 *tail = fifo->buffer + end; in fm10k_fifo_write_copy()
242 /* track when we should cross the end of the FIFO */ in fm10k_fifo_write_copy()
243 end = fifo->size - end; in fm10k_fifo_write_copy()
247 memcpy(fifo->buffer, msg + end, (len - end) << 2); in fm10k_fifo_write_copy()
251 /* Copy remaining message into Tx FIFO */ in fm10k_fifo_write_copy()
256 * fm10k_fifo_enqueue - Enqueues the message to the tail of the FIFO
257 * @fifo: pointer to FIFO
262 * of the FIFO. It will return 0 on success, or a negative value on error.
264 static s32 fm10k_fifo_enqueue(struct fm10k_mbx_fifo *fifo, const u32 *msg) in fm10k_fifo_enqueue() argument
269 if (len > fifo->size) in fm10k_fifo_enqueue()
273 if (len > fm10k_fifo_unused(fifo)) in fm10k_fifo_enqueue()
276 /* Copy message into FIFO */ in fm10k_fifo_enqueue()
277 fm10k_fifo_write_copy(fifo, msg, 0, len); in fm10k_fifo_enqueue()
279 /* memory barrier to guarantee FIFO is written before tail update */ in fm10k_fifo_enqueue()
282 /* Update Tx FIFO tail */ in fm10k_fifo_enqueue()
283 fifo->tail += len; in fm10k_fifo_enqueue()
298 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_validate_msg_size() local
308 msg = fifo->buffer + fm10k_fifo_tail_offset(fifo, total_len); in fm10k_mbx_validate_msg_size()
313 /* message extends out of pushed section, but fits in FIFO */ in fm10k_mbx_validate_msg_size()
322 * fm10k_mbx_write_copy - pulls data off of Tx FIFO and places it in mbmem
326 * This function will take a section of the Tx FIFO and copy it into the
333 struct fm10k_mbx_fifo *fifo = &mbx->tx; in fm10k_mbx_write_copy() local
335 u32 *head = fifo->buffer; in fm10k_mbx_write_copy()
349 end = fm10k_fifo_head_offset(fifo, mbx->pulled); in fm10k_mbx_write_copy()
355 /* Copy message from Tx FIFO */ in fm10k_mbx_write_copy()
356 for (end = fifo->size - end; len; head = fifo->buffer) { in fm10k_mbx_write_copy()
358 /* adjust tail to match offset for FIFO */ in fm10k_mbx_write_copy()
365 /* write message to hardware FIFO */ in fm10k_mbx_write_copy()
372 * fm10k_mbx_pull_head - Pulls data off of head of Tx FIFO
379 * head of the FIFO and will place it in the MBMEM registers
386 struct fm10k_mbx_fifo *fifo = &mbx->tx; in fm10k_mbx_pull_head() local
393 len = fm10k_fifo_used(fifo) - mbx->pulled; in fm10k_mbx_pull_head()
401 /* drop pulled messages from the FIFO */ in fm10k_mbx_pull_head()
402 for (len = fm10k_fifo_head_len(fifo); in fm10k_mbx_pull_head()
404 len = fm10k_fifo_head_len(fifo)) { in fm10k_mbx_pull_head()
405 mbx->pulled -= fm10k_fifo_head_drop(fifo); in fm10k_mbx_pull_head()
410 /* Copy message out from the Tx FIFO */ in fm10k_mbx_pull_head()
415 * fm10k_mbx_read_copy - pulls data off of mbmem and places it in Rx FIFO
420 * into the Rx FIFO. The offset is based on the lower bits of the
426 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_read_copy() local
428 u32 *tail = fifo->buffer; in fm10k_mbx_read_copy()
438 end = fm10k_fifo_tail_offset(fifo, mbx->pushed); in fm10k_mbx_read_copy()
441 /* Copy message into Rx FIFO */ in fm10k_mbx_read_copy()
442 for (end = fifo->size - end; len; tail = fifo->buffer) { in fm10k_mbx_read_copy()
444 /* adjust head to match offset for FIFO */ in fm10k_mbx_read_copy()
451 /* read message from hardware FIFO */ in fm10k_mbx_read_copy()
456 /* memory barrier to guarantee FIFO is written before tail update */ in fm10k_mbx_read_copy()
461 * fm10k_mbx_push_tail - Pushes up to 15 DWORDs on to tail of FIFO
468 * copies the data into the FIFO. It will return the number of messages
475 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_push_tail() local
479 len = fm10k_fifo_unused(fifo) - mbx->pushed; in fm10k_mbx_push_tail()
491 /* Copy msg into Rx FIFO */ in fm10k_mbx_push_tail()
505 fifo->tail += len; in fm10k_mbx_push_tail()
580 * fm10k_fifo_crc - generate a CRC based off of FIFO data
581 * @fifo: pointer to FIFO
582 * @offset: offset point for start of FIFO
586 * This function generates a CRC for some region of the FIFO
588 static u16 fm10k_fifo_crc(struct fm10k_mbx_fifo *fifo, u16 offset, in fm10k_fifo_crc() argument
591 u32 *data = fifo->buffer + offset; in fm10k_fifo_crc()
593 /* track when we should cross the end of the FIFO */ in fm10k_fifo_crc()
594 offset = fifo->size - offset; in fm10k_fifo_crc()
596 /* if we are in 2 blocks process the end of the FIFO first */ in fm10k_fifo_crc()
599 data = fifo->buffer; in fm10k_fifo_crc()
640 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_verify_remote_crc() local
642 u16 offset = fm10k_fifo_tail_offset(fifo, mbx->pushed) - len; in fm10k_mbx_verify_remote_crc()
647 mbx->remote = fm10k_fifo_crc(fifo, offset, len, mbx->remote); in fm10k_mbx_verify_remote_crc()
657 * fm10k_mbx_rx_ready - Indicates that a message is ready in the Rx FIFO
660 * This function returns true if there is a message in the Rx FIFO to dequeue.
684 * fm10k_mbx_tx_complete - Indicates that the Tx FIFO has been emptied
687 * This function returns true if the Tx FIFO is empty.
695 * fm10k_mbx_dequeue_rx - Dequeues the message from the head in the Rx FIFO
705 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_dequeue_rx() local
709 /* parse Rx messages out of the Rx FIFO to empty it */ in fm10k_mbx_dequeue_rx()
710 for (cnt = 0; !fm10k_fifo_empty(fifo); cnt++) { in fm10k_mbx_dequeue_rx()
711 err = fm10k_tlv_msg_parse(hw, fifo->buffer + fifo->head, in fm10k_mbx_dequeue_rx()
716 fm10k_fifo_head_drop(fifo); in fm10k_mbx_dequeue_rx()
719 /* shift remaining bytes back to start of FIFO */ in fm10k_mbx_dequeue_rx()
720 memmove(fifo->buffer, fifo->buffer + fifo->tail, mbx->pushed << 2); in fm10k_mbx_dequeue_rx()
723 fifo->tail -= fifo->head; in fm10k_mbx_dequeue_rx()
724 fifo->head = 0; in fm10k_mbx_dequeue_rx()
730 * fm10k_mbx_enqueue_tx - Enqueues the message to the tail of the Tx FIFO
737 * of the FIFO. It will return 0 on success, or a negative value on error.
753 /* enqueue the message on the Tx FIFO */ in fm10k_mbx_enqueue_tx()
756 /* if it failed give the FIFO a chance to drain */ in fm10k_mbx_enqueue_tx()
856 struct fm10k_mbx_fifo *fifo = &mbx->tx; in fm10k_mbx_create_data_hdr() local
863 crc = fm10k_fifo_crc(fifo, fm10k_fifo_head_offset(fifo, mbx->pulled), in fm10k_mbx_create_data_hdr()
1013 * mailbox state and the remote FIFO head. It will return the length
1095 * at the head of the Tx FIFO if they are larger than max_size. It does not
1097 * the FIFO. Instead, rely on the checking to ensure that messages larger
1415 * drop all left over messages in the FIFO. in fm10k_mbx_disconnect()
1552 * buffer provided and use that to populate both the Tx and Rx FIFO by
1626 * fm10k_sm_mbx_create_data_hdr - Generate a mailbox header for local FIFO
1642 * fm10k_sm_mbx_create_connect_hdr - Generate a mailbox header for local FIFO
1765 * fm10k_sm_mbx_validate_fifo_hdr - Validate fields in the remote FIFO header
1843 * fm10k_sm_mbx_create_error_msg - Process an error in FIFO header
1870 * fm10k_sm_mbx_receive - Take message from Rx mailbox FIFO and put it in Rx
1876 * FIFO and place it in the Rx mailbox FIFO for processing by software.
1890 /* copy data to the Rx FIFO */ in fm10k_sm_mbx_receive()
1910 * fm10k_sm_mbx_transmit - Take message from Tx and put it in Tx mailbox FIFO
1915 * This function will dequeue one message from the Tx mailbox FIFO and place
1916 * it in the Tx switch manager mailbox FIFO for processing by hardware.
1921 struct fm10k_mbx_fifo *fifo = &mbx->tx; in fm10k_sm_mbx_transmit() local
1936 msg = fifo->buffer + fm10k_fifo_head_offset(fifo, len); in fm10k_sm_mbx_transmit()
1959 * mailbox state and the remote FIFO head. It will return the length
2066 /* continue until we have flushed the Rx FIFO */ in fm10k_sm_mbx_process_version_1()
2133 * buffer provided and use that to populate both the Tx and Rx FIFO by