Lines Matching +full:hardware +full:- +full:fifo
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2019 Intel Corporation. */
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()
54 * fm10k_fifo_head_offset - returns indices of head with given offset
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()
66 * fm10k_fifo_tail_offset - returns indices of tail with given 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()
124 * fm10k_mbx_index_len - Convert a head/tail index into a length value
134 u16 len = tail - head; in fm10k_mbx_index_len()
138 len -= 2; in fm10k_mbx_index_len()
140 return len & ((mbx->mbmem_len << 1) - 1); in fm10k_mbx_index_len()
144 * fm10k_mbx_tail_add - Determine new tail value with added offset
153 u16 tail = (mbx->tail + offset + 1) & ((mbx->mbmem_len << 1) - 1); in fm10k_mbx_tail_add()
156 return (tail > mbx->tail) ? --tail : ++tail; in fm10k_mbx_tail_add()
160 * fm10k_mbx_tail_sub - Determine new tail value with subtracted offset
169 u16 tail = (mbx->tail - offset - 1) & ((mbx->mbmem_len << 1) - 1); in fm10k_mbx_tail_sub()
172 return (tail < mbx->tail) ? ++tail : --tail; in fm10k_mbx_tail_sub()
176 * fm10k_mbx_head_add - Determine new head value with added offset
185 u16 head = (mbx->head + offset + 1) & ((mbx->mbmem_len << 1) - 1); in fm10k_mbx_head_add()
188 return (head > mbx->head) ? --head : ++head; in fm10k_mbx_head_add()
192 * fm10k_mbx_head_sub - Determine new head value with subtracted offset
201 u16 head = (mbx->head - offset - 1) & ((mbx->mbmem_len << 1) - 1); in fm10k_mbx_head_sub()
204 return (head < mbx->head) ? ++head : --head; in fm10k_mbx_head_sub()
208 * fm10k_mbx_pushed_tail_len - Retrieve the length of message being pushed
216 u32 *tail = mbx->rx.buffer + fm10k_fifo_tail_offset(&mbx->rx, 0); in fm10k_mbx_pushed_tail_len()
219 if (!mbx->pushed) in fm10k_mbx_pushed_tail_len()
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()
289 * fm10k_mbx_validate_msg_size - Validate incoming message based on size
293 * This function analyzes the frame and will return a non-zero value when
298 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_validate_msg_size() local
302 len += mbx->pushed; in fm10k_mbx_validate_msg_size()
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()
314 if ((len < total_len) && (msg_len <= mbx->max_size)) in fm10k_mbx_validate_msg_size()
318 return (len < total_len) ? len : (len - total_len); in fm10k_mbx_validate_msg_size()
322 * fm10k_mbx_write_copy - pulls data off of Tx FIFO and places it in mbmem
323 * @hw: pointer to hardware structure
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
334 u32 mbmem = mbx->mbmem_reg; in fm10k_mbx_write_copy()
335 u32 *head = fifo->buffer; in fm10k_mbx_write_copy()
338 if (!mbx->tail_len) in fm10k_mbx_write_copy()
342 mask = mbx->mbmem_len - 1; in fm10k_mbx_write_copy()
343 len = mbx->tail_len; 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()
363 mbx->tx_mbmem_pulled++; in fm10k_mbx_write_copy()
365 /* write message to hardware FIFO */ in fm10k_mbx_write_copy()
367 } while (--len && --end); in fm10k_mbx_write_copy()
372 * fm10k_mbx_pull_head - Pulls data off of head of Tx FIFO
373 * @hw: pointer to hardware structure
379 * head of the FIFO and will place it in the MBMEM registers
385 u16 mbmem_len, len, ack = fm10k_mbx_index_len(mbx, head, mbx->tail); in fm10k_mbx_pull_head()
386 struct fm10k_mbx_fifo *fifo = &mbx->tx; in fm10k_mbx_pull_head() local
389 mbx->pulled += mbx->tail_len - ack; in fm10k_mbx_pull_head()
392 mbmem_len = mbx->mbmem_len - 1; in fm10k_mbx_pull_head()
393 len = fm10k_fifo_used(fifo) - mbx->pulled; in fm10k_mbx_pull_head()
398 mbx->tail = fm10k_mbx_tail_add(mbx, len - ack); in fm10k_mbx_pull_head()
399 mbx->tail_len = len; 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()
403 len && (mbx->pulled >= len); 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()
406 mbx->tx_messages++; in fm10k_mbx_pull_head()
407 mbx->tx_dwords += len; 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
416 * @hw: pointer to hardware structure
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
427 u32 mbmem = mbx->mbmem_reg ^ mbx->mbmem_len; in fm10k_mbx_read_copy()
428 u32 *tail = fifo->buffer; in fm10k_mbx_read_copy()
432 len = mbx->head_len; in fm10k_mbx_read_copy()
434 if (head >= mbx->mbmem_len) 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()
445 head &= mbx->mbmem_len - 1; in fm10k_mbx_read_copy()
449 mbx->rx_mbmem_pushed++; in fm10k_mbx_read_copy()
451 /* read message from hardware FIFO */ in fm10k_mbx_read_copy()
453 } while (--len && --end); 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
462 * @hw: pointer to hardware structure
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
476 u16 len, seq = fm10k_mbx_index_len(mbx, mbx->head, tail); in fm10k_mbx_push_tail()
479 len = fm10k_fifo_unused(fifo) - mbx->pushed; in fm10k_mbx_push_tail()
484 mbx->head = fm10k_mbx_head_add(mbx, len); in fm10k_mbx_push_tail()
485 mbx->head_len = len; in fm10k_mbx_push_tail()
491 /* Copy msg into Rx FIFO */ in fm10k_mbx_push_tail()
499 mbx->pushed += len; in fm10k_mbx_push_tail()
503 len && (mbx->pushed >= len); in fm10k_mbx_push_tail()
505 fifo->tail += len; in fm10k_mbx_push_tail()
506 mbx->pushed -= len; in fm10k_mbx_push_tail()
507 mbx->rx_messages++; in fm10k_mbx_push_tail()
508 mbx->rx_dwords += len; in fm10k_mbx_push_tail()
514 /* pre-generated data for generating the CRC based on the poly 0xAC9A. */
550 * fm10k_crc_16b - Generate a 16 bit CRC for a region of 16 bit data
564 while (len--) { in fm10k_crc_16b()
569 if (!(len--)) in fm10k_crc_16b()
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()
600 len -= offset; in fm10k_fifo_crc()
608 * fm10k_mbx_update_local_crc - Update the local CRC for outgoing data
615 * mbx->local.
619 u16 len = mbx->tail_len - fm10k_mbx_index_len(mbx, head, mbx->tail); in fm10k_mbx_update_local_crc()
622 head = fm10k_fifo_head_offset(&mbx->tx, mbx->pulled); in fm10k_mbx_update_local_crc()
625 mbx->local = fm10k_fifo_crc(&mbx->tx, head, len, mbx->local); in fm10k_mbx_update_local_crc()
629 * fm10k_mbx_verify_remote_crc - Verify the CRC is correct for current data
633 * end and generate a CRC for it. This is stored in mbx->remote. The
634 * CRC for the header is then computed and if the result is non-zero this
640 struct fm10k_mbx_fifo *fifo = &mbx->rx; in fm10k_mbx_verify_remote_crc() local
641 u16 len = mbx->head_len; in fm10k_mbx_verify_remote_crc()
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()
650 crc = fm10k_crc_16b(&mbx->mbx_hdr, mbx->remote, 1); 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.
664 u16 msg_size = fm10k_fifo_head_len(&mbx->rx); in fm10k_mbx_rx_ready()
666 return msg_size && (fm10k_fifo_used(&mbx->rx) >= msg_size); in fm10k_mbx_rx_ready()
670 * fm10k_mbx_tx_ready - Indicates that the mailbox is in state ready for Tx
678 u16 fifo_unused = fm10k_fifo_unused(&mbx->tx); in fm10k_mbx_tx_ready()
680 return (mbx->state == FM10K_STATE_OPEN) && (fifo_unused >= len); in fm10k_mbx_tx_ready()
684 * fm10k_mbx_tx_complete - Indicates that the Tx FIFO has been emptied
687 * This function returns true if the Tx FIFO is empty.
691 return fm10k_fifo_empty(&mbx->tx); in fm10k_mbx_tx_complete()
695 * fm10k_mbx_dequeue_rx - Dequeues the message from the head in the Rx FIFO
696 * @hw: pointer to hardware structure
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()
712 mbx, mbx->msg_data); in fm10k_mbx_dequeue_rx()
714 mbx->rx_parse_err++; 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
731 * @hw: pointer to hardware structure
737 * of the FIFO. It will return 0 on success, or a negative value on error.
742 u32 countdown = mbx->timeout; in fm10k_mbx_enqueue_tx()
745 switch (mbx->state) { in fm10k_mbx_enqueue_tx()
753 /* enqueue the message on the Tx FIFO */ in fm10k_mbx_enqueue_tx()
754 err = fm10k_fifo_enqueue(&mbx->tx, msg); in fm10k_mbx_enqueue_tx()
756 /* if it failed give the FIFO a chance to drain */ in fm10k_mbx_enqueue_tx()
758 countdown--; in fm10k_mbx_enqueue_tx()
759 udelay(mbx->udelay); in fm10k_mbx_enqueue_tx()
760 mbx->ops.process(hw, mbx); in fm10k_mbx_enqueue_tx()
761 err = fm10k_fifo_enqueue(&mbx->tx, msg); in fm10k_mbx_enqueue_tx()
766 mbx->timeout = 0; in fm10k_mbx_enqueue_tx()
767 mbx->tx_busy++; in fm10k_mbx_enqueue_tx()
774 if (!mbx->tail_len) in fm10k_mbx_enqueue_tx()
775 mbx->ops.process(hw, mbx); in fm10k_mbx_enqueue_tx()
781 * fm10k_mbx_read - Copies the mbmem to local message buffer
782 * @hw: pointer to hardware structure
790 if (mbx->mbx_hdr) in fm10k_mbx_read()
794 if (fm10k_read_reg(hw, mbx->mbx_reg) & FM10K_MBX_REQ_INTERRUPT) in fm10k_mbx_read()
795 mbx->mbx_lock = FM10K_MBX_ACK; in fm10k_mbx_read()
798 fm10k_write_reg(hw, mbx->mbx_reg, in fm10k_mbx_read()
802 mbx->mbx_hdr = fm10k_read_reg(hw, mbx->mbmem_reg ^ mbx->mbmem_len); in fm10k_mbx_read()
808 * fm10k_mbx_write - Copies the local message buffer to mbmem
809 * @hw: pointer to hardware structure
816 u32 mbmem = mbx->mbmem_reg; in fm10k_mbx_write()
819 fm10k_write_reg(hw, mbmem, mbx->mbx_hdr); in fm10k_mbx_write()
822 if (mbx->mbx_lock) in fm10k_mbx_write()
823 fm10k_write_reg(hw, mbx->mbx_reg, mbx->mbx_lock); in fm10k_mbx_write()
826 mbx->mbx_hdr = 0; in fm10k_mbx_write()
827 mbx->mbx_lock = 0; in fm10k_mbx_write()
831 * fm10k_mbx_create_connect_hdr - Generate a connect mailbox header
838 mbx->mbx_lock |= FM10K_MBX_REQ; in fm10k_mbx_create_connect_hdr()
840 mbx->mbx_hdr = FM10K_MSG_HDR_FIELD_SET(FM10K_MSG_CONNECT, TYPE) | in fm10k_mbx_create_connect_hdr()
841 FM10K_MSG_HDR_FIELD_SET(mbx->head, HEAD) | in fm10k_mbx_create_connect_hdr()
842 FM10K_MSG_HDR_FIELD_SET(mbx->rx.size - 1, CONNECT_SIZE); in fm10k_mbx_create_connect_hdr()
846 * fm10k_mbx_create_data_hdr - Generate a data mailbox header
854 FM10K_MSG_HDR_FIELD_SET(mbx->tail, TAIL) | in fm10k_mbx_create_data_hdr()
855 FM10K_MSG_HDR_FIELD_SET(mbx->head, HEAD); in fm10k_mbx_create_data_hdr()
856 struct fm10k_mbx_fifo *fifo = &mbx->tx; in fm10k_mbx_create_data_hdr() local
859 if (mbx->tail_len) in fm10k_mbx_create_data_hdr()
860 mbx->mbx_lock |= FM10K_MBX_REQ; in fm10k_mbx_create_data_hdr()
863 crc = fm10k_fifo_crc(fifo, fm10k_fifo_head_offset(fifo, mbx->pulled), in fm10k_mbx_create_data_hdr()
864 mbx->tail_len, mbx->local); in fm10k_mbx_create_data_hdr()
868 mbx->mbx_hdr = hdr | FM10K_MSG_HDR_FIELD_SET(crc, CRC); in fm10k_mbx_create_data_hdr()
872 * fm10k_mbx_create_disconnect_hdr - Generate a disconnect mailbox header
880 FM10K_MSG_HDR_FIELD_SET(mbx->tail, TAIL) | in fm10k_mbx_create_disconnect_hdr()
881 FM10K_MSG_HDR_FIELD_SET(mbx->head, HEAD); in fm10k_mbx_create_disconnect_hdr()
882 u16 crc = fm10k_crc_16b(&hdr, mbx->local, 1); in fm10k_mbx_create_disconnect_hdr()
884 mbx->mbx_lock |= FM10K_MBX_ACK; in fm10k_mbx_create_disconnect_hdr()
887 mbx->mbx_hdr = hdr | FM10K_MSG_HDR_FIELD_SET(crc, CRC); in fm10k_mbx_create_disconnect_hdr()
891 * fm10k_mbx_create_fake_disconnect_hdr - Generate a false disconnect mbox hdr
896 * start up after mbx->connect.
901 FM10K_MSG_HDR_FIELD_SET(mbx->head, TAIL) | in fm10k_mbx_create_fake_disconnect_hdr()
902 FM10K_MSG_HDR_FIELD_SET(mbx->tail, HEAD); in fm10k_mbx_create_fake_disconnect_hdr()
903 u16 crc = fm10k_crc_16b(&hdr, mbx->local, 1); in fm10k_mbx_create_fake_disconnect_hdr()
905 mbx->mbx_lock |= FM10K_MBX_ACK; in fm10k_mbx_create_fake_disconnect_hdr()
908 mbx->mbx_hdr = hdr | FM10K_MSG_HDR_FIELD_SET(crc, CRC); in fm10k_mbx_create_fake_disconnect_hdr()
912 * fm10k_mbx_create_error_msg - Generate an error message
935 mbx->mbx_lock |= FM10K_MBX_REQ; in fm10k_mbx_create_error_msg()
937 mbx->mbx_hdr = FM10K_MSG_HDR_FIELD_SET(FM10K_MSG_ERROR, TYPE) | in fm10k_mbx_create_error_msg()
939 FM10K_MSG_HDR_FIELD_SET(mbx->head, HEAD); in fm10k_mbx_create_error_msg()
943 * fm10k_mbx_validate_msg_hdr - Validate common fields in the message header
953 const u32 *hdr = &mbx->mbx_hdr; in fm10k_mbx_validate_msg_hdr()
967 if (tail != mbx->head) in fm10k_mbx_validate_msg_hdr()
975 if (fm10k_mbx_index_len(mbx, head, mbx->tail) > mbx->tail_len) in fm10k_mbx_validate_msg_hdr()
981 if (fm10k_mbx_index_len(mbx, mbx->head, tail) < mbx->mbmem_len) in fm10k_mbx_validate_msg_hdr()
1007 * fm10k_mbx_create_reply - Generate reply based on state and remote head
1008 * @hw: pointer to hardware structure
1013 * mailbox state and the remote FIFO head. It will return the length
1020 switch (mbx->state) { in fm10k_mbx_create_reply()
1030 if (mbx->tail_len || (mbx->state == FM10K_STATE_OPEN)) in fm10k_mbx_create_reply()
1051 * fm10k_mbx_reset_work- Reset internal pointers for any pending work
1063 mbx->max_size = mbx->rx.size - 1; in fm10k_mbx_reset_work()
1065 /* update mbx->pulled to account for tail_len and ack */ in fm10k_mbx_reset_work()
1066 head = FM10K_MSG_HDR_FIELD_GET(mbx->mbx_hdr, HEAD); in fm10k_mbx_reset_work()
1067 ack = fm10k_mbx_index_len(mbx, head, mbx->tail); in fm10k_mbx_reset_work()
1068 mbx->pulled += mbx->tail_len - ack; in fm10k_mbx_reset_work()
1071 while (fm10k_fifo_head_len(&mbx->tx) && mbx->pulled) { in fm10k_mbx_reset_work()
1072 len = fm10k_fifo_head_drop(&mbx->tx); in fm10k_mbx_reset_work()
1073 mbx->tx_dropped++; in fm10k_mbx_reset_work()
1074 if (mbx->pulled >= len) in fm10k_mbx_reset_work()
1075 mbx->pulled -= len; in fm10k_mbx_reset_work()
1077 mbx->pulled = 0; in fm10k_mbx_reset_work()
1081 mbx->pushed = 0; in fm10k_mbx_reset_work()
1082 mbx->pulled = 0; in fm10k_mbx_reset_work()
1083 mbx->tail_len = 0; in fm10k_mbx_reset_work()
1084 mbx->head_len = 0; in fm10k_mbx_reset_work()
1085 mbx->rx.tail = 0; in fm10k_mbx_reset_work()
1086 mbx->rx.head = 0; in fm10k_mbx_reset_work()
1090 * fm10k_mbx_update_max_size - Update the max_size and drop any large messages
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
1104 mbx->max_size = size; in fm10k_mbx_update_max_size()
1107 for (len = fm10k_fifo_head_len(&mbx->tx); in fm10k_mbx_update_max_size()
1109 len = fm10k_fifo_head_len(&mbx->tx)) { in fm10k_mbx_update_max_size()
1110 fm10k_fifo_head_drop(&mbx->tx); in fm10k_mbx_update_max_size()
1111 mbx->tx_dropped++; in fm10k_mbx_update_max_size()
1116 * fm10k_mbx_connect_reset - Reset following request for reset
1128 mbx->local = FM10K_MBX_CRC_SEED; in fm10k_mbx_connect_reset()
1129 mbx->remote = FM10K_MBX_CRC_SEED; in fm10k_mbx_connect_reset()
1132 if (mbx->state == FM10K_STATE_OPEN) in fm10k_mbx_connect_reset()
1133 mbx->state = FM10K_STATE_CONNECT; in fm10k_mbx_connect_reset()
1135 mbx->state = FM10K_STATE_CLOSED; in fm10k_mbx_connect_reset()
1139 * fm10k_mbx_process_connect - Process connect header
1140 * @hw: pointer to hardware structure
1150 const enum fm10k_mbx_state state = mbx->state; in fm10k_mbx_process_connect()
1151 const u32 *hdr = &mbx->mbx_hdr; in fm10k_mbx_process_connect()
1161 /* reset any in-progress work */ in fm10k_mbx_process_connect()
1166 if (size > mbx->rx.size) { in fm10k_mbx_process_connect()
1167 mbx->max_size = mbx->rx.size - 1; in fm10k_mbx_process_connect()
1170 mbx->state = FM10K_STATE_OPEN; in fm10k_mbx_process_connect()
1180 mbx->tail = head; in fm10k_mbx_process_connect()
1186 * fm10k_mbx_process_data - Process data header
1187 * @hw: pointer to hardware structure
1197 const u32 *hdr = &mbx->mbx_hdr; in fm10k_mbx_process_data()
1206 if (mbx->state == FM10K_STATE_CONNECT) { in fm10k_mbx_process_data()
1207 mbx->tail = head; in fm10k_mbx_process_data()
1208 mbx->state = FM10K_STATE_OPEN; in fm10k_mbx_process_data()
1228 * fm10k_mbx_process_disconnect - Process disconnect header
1229 * @hw: pointer to hardware structure
1239 const enum fm10k_mbx_state state = mbx->state; in fm10k_mbx_process_disconnect()
1240 const u32 *hdr = &mbx->mbx_hdr; in fm10k_mbx_process_disconnect()
1248 if (mbx->pushed) in fm10k_mbx_process_disconnect()
1251 /* we have already verified mbx->head == tail so we know this is 0 */ in fm10k_mbx_process_disconnect()
1252 mbx->head_len = 0; in fm10k_mbx_process_disconnect()
1267 if (head != mbx->tail) in fm10k_mbx_process_disconnect()
1270 /* reset any in-progress work */ in fm10k_mbx_process_disconnect()
1281 * fm10k_mbx_process_error - Process error header
1282 * @hw: pointer to hardware structure
1292 const u32 *hdr = &mbx->mbx_hdr; in fm10k_mbx_process_error()
1298 switch (mbx->state) { in fm10k_mbx_process_error()
1305 mbx->local = FM10K_MBX_CRC_SEED; in fm10k_mbx_process_error()
1306 mbx->remote = FM10K_MBX_CRC_SEED; in fm10k_mbx_process_error()
1309 mbx->tail = head; in fm10k_mbx_process_error()
1312 if (mbx->state == FM10K_STATE_OPEN) { in fm10k_mbx_process_error()
1313 mbx->state = FM10K_STATE_CONNECT; in fm10k_mbx_process_error()
1324 return fm10k_mbx_create_reply(hw, mbx, mbx->tail); in fm10k_mbx_process_error()
1328 * fm10k_mbx_process - Process mailbox interrupt
1329 * @hw: pointer to hardware structure
1342 if (mbx->state == FM10K_STATE_CLOSED) in fm10k_mbx_process()
1355 switch (FM10K_MSG_HDR_FIELD_GET(mbx->mbx_hdr, TYPE)) { in fm10k_mbx_process()
1385 * fm10k_mbx_disconnect - Shutdown mailbox connection
1386 * @hw: pointer to hardware structure
1400 int timeout = mbx->timeout ? FM10K_MBX_DISCONNECT_TIMEOUT : 0; in fm10k_mbx_disconnect()
1403 mbx->state = FM10K_STATE_DISCONNECT; in fm10k_mbx_disconnect()
1406 fm10k_write_reg(hw, mbx->mbx_reg, FM10K_MBX_REQ | in fm10k_mbx_disconnect()
1410 mbx->ops.process(hw, mbx); in fm10k_mbx_disconnect()
1411 timeout -= FM10K_MBX_POLL_DELAY; in fm10k_mbx_disconnect()
1412 } while ((timeout > 0) && (mbx->state != FM10K_STATE_CLOSED)); in fm10k_mbx_disconnect()
1415 * drop all left over messages in the FIFO. in fm10k_mbx_disconnect()
1418 fm10k_fifo_drop_all(&mbx->tx); in fm10k_mbx_disconnect()
1420 fm10k_write_reg(hw, mbx->mbmem_reg, 0); in fm10k_mbx_disconnect()
1424 * fm10k_mbx_connect - Start mailbox connection
1425 * @hw: pointer to hardware structure
1439 if (!mbx->rx.buffer) in fm10k_mbx_connect()
1443 if (mbx->state != FM10K_STATE_CLOSED) in fm10k_mbx_connect()
1447 mbx->timeout = FM10K_MBX_INIT_TIMEOUT; in fm10k_mbx_connect()
1450 mbx->state = FM10K_STATE_CONNECT; in fm10k_mbx_connect()
1456 fm10k_write_reg(hw, mbx->mbmem_reg ^ mbx->mbmem_len, mbx->mbx_hdr); in fm10k_mbx_connect()
1459 mbx->mbx_lock = FM10K_MBX_REQ_INTERRUPT | FM10K_MBX_ACK_INTERRUPT | in fm10k_mbx_connect()
1470 * fm10k_mbx_validate_handlers - Validate layout of message parsing data
1486 while (msg_data->id != FM10K_TLV_ERROR) { in fm10k_mbx_validate_handlers()
1488 if (!msg_data->func) in fm10k_mbx_validate_handlers()
1492 attr = msg_data->attr; in fm10k_mbx_validate_handlers()
1494 while (attr->id != FM10K_TLV_ERROR) { in fm10k_mbx_validate_handlers()
1495 id = attr->id; in fm10k_mbx_validate_handlers()
1498 if (id >= attr->id) in fm10k_mbx_validate_handlers()
1506 if (attr->id != FM10K_TLV_ERROR) in fm10k_mbx_validate_handlers()
1510 id = msg_data->id; in fm10k_mbx_validate_handlers()
1513 if (id >= msg_data->id) in fm10k_mbx_validate_handlers()
1518 if ((msg_data->id != FM10K_TLV_ERROR) || !msg_data->func) in fm10k_mbx_validate_handlers()
1525 * fm10k_mbx_register_handlers - Register a set of handler ops for mailbox
1539 mbx->msg_data = msg_data; in fm10k_mbx_register_handlers()
1545 * fm10k_pfvf_mbx_init - Initialize mailbox memory for PF/VF mailbox
1546 * @hw: pointer to hardware structure
1552 * buffer provided and use that to populate both the Tx and Rx FIFO by
1562 switch (hw->mac.type) { in fm10k_pfvf_mbx_init()
1564 mbx->mbx_reg = FM10K_VFMBX; in fm10k_pfvf_mbx_init()
1565 mbx->mbmem_reg = FM10K_VFMBMEM(FM10K_VFMBMEM_VF_XOR); in fm10k_pfvf_mbx_init()
1568 /* there are only 64 VF <-> PF mailboxes */ in fm10k_pfvf_mbx_init()
1570 mbx->mbx_reg = FM10K_MBX(id); in fm10k_pfvf_mbx_init()
1571 mbx->mbmem_reg = FM10K_MBMEM_VF(id, 0); in fm10k_pfvf_mbx_init()
1580 mbx->state = FM10K_STATE_CLOSED; in fm10k_pfvf_mbx_init()
1587 mbx->msg_data = msg_data; in fm10k_pfvf_mbx_init()
1592 mbx->timeout = 0; in fm10k_pfvf_mbx_init()
1593 mbx->udelay = FM10K_MBX_INIT_DELAY; in fm10k_pfvf_mbx_init()
1596 mbx->tail = 1; in fm10k_pfvf_mbx_init()
1597 mbx->head = 1; in fm10k_pfvf_mbx_init()
1600 mbx->local = FM10K_MBX_CRC_SEED; in fm10k_pfvf_mbx_init()
1601 mbx->remote = FM10K_MBX_CRC_SEED; in fm10k_pfvf_mbx_init()
1604 mbx->max_size = FM10K_MBX_MSG_MAX_SIZE; in fm10k_pfvf_mbx_init()
1605 mbx->mbmem_len = FM10K_VFMBMEM_VF_XOR; in fm10k_pfvf_mbx_init()
1608 fm10k_fifo_init(&mbx->tx, mbx->buffer, FM10K_MBX_TX_BUFFER_SIZE); in fm10k_pfvf_mbx_init()
1609 fm10k_fifo_init(&mbx->rx, &mbx->buffer[FM10K_MBX_TX_BUFFER_SIZE], in fm10k_pfvf_mbx_init()
1613 mbx->ops.connect = fm10k_mbx_connect; in fm10k_pfvf_mbx_init()
1614 mbx->ops.disconnect = fm10k_mbx_disconnect; in fm10k_pfvf_mbx_init()
1615 mbx->ops.rx_ready = fm10k_mbx_rx_ready; in fm10k_pfvf_mbx_init()
1616 mbx->ops.tx_ready = fm10k_mbx_tx_ready; in fm10k_pfvf_mbx_init()
1617 mbx->ops.tx_complete = fm10k_mbx_tx_complete; in fm10k_pfvf_mbx_init()
1618 mbx->ops.enqueue_tx = fm10k_mbx_enqueue_tx; in fm10k_pfvf_mbx_init()
1619 mbx->ops.process = fm10k_mbx_process; in fm10k_pfvf_mbx_init()
1620 mbx->ops.register_handlers = fm10k_mbx_register_handlers; in fm10k_pfvf_mbx_init()
1626 * fm10k_sm_mbx_create_data_hdr - Generate a mailbox header for local FIFO
1633 if (mbx->tail_len) in fm10k_sm_mbx_create_data_hdr()
1634 mbx->mbx_lock |= FM10K_MBX_REQ; in fm10k_sm_mbx_create_data_hdr()
1636 mbx->mbx_hdr = FM10K_MSG_HDR_FIELD_SET(mbx->tail, SM_TAIL) | in fm10k_sm_mbx_create_data_hdr()
1637 FM10K_MSG_HDR_FIELD_SET(mbx->remote, SM_VER) | in fm10k_sm_mbx_create_data_hdr()
1638 FM10K_MSG_HDR_FIELD_SET(mbx->head, SM_HEAD); in fm10k_sm_mbx_create_data_hdr()
1642 * fm10k_sm_mbx_create_connect_hdr - Generate a mailbox header for local FIFO
1650 if (mbx->local) in fm10k_sm_mbx_create_connect_hdr()
1651 mbx->mbx_lock |= FM10K_MBX_REQ; in fm10k_sm_mbx_create_connect_hdr()
1653 mbx->mbx_hdr = FM10K_MSG_HDR_FIELD_SET(mbx->tail, SM_TAIL) | in fm10k_sm_mbx_create_connect_hdr()
1654 FM10K_MSG_HDR_FIELD_SET(mbx->remote, SM_VER) | in fm10k_sm_mbx_create_connect_hdr()
1655 FM10K_MSG_HDR_FIELD_SET(mbx->head, SM_HEAD) | in fm10k_sm_mbx_create_connect_hdr()
1660 * fm10k_sm_mbx_connect_reset - Reset following request for reset
1671 mbx->local = FM10K_SM_MBX_VERSION; in fm10k_sm_mbx_connect_reset()
1672 mbx->remote = 0; in fm10k_sm_mbx_connect_reset()
1675 mbx->tail = 1; in fm10k_sm_mbx_connect_reset()
1676 mbx->head = 1; in fm10k_sm_mbx_connect_reset()
1679 mbx->state = FM10K_STATE_CONNECT; in fm10k_sm_mbx_connect_reset()
1683 * fm10k_sm_mbx_connect - Start switch manager mailbox connection
1684 * @hw: pointer to hardware structure
1697 if (!mbx->rx.buffer) in fm10k_sm_mbx_connect()
1701 if (mbx->state != FM10K_STATE_CLOSED) in fm10k_sm_mbx_connect()
1705 mbx->timeout = FM10K_MBX_INIT_TIMEOUT; in fm10k_sm_mbx_connect()
1708 mbx->state = FM10K_STATE_CONNECT; in fm10k_sm_mbx_connect()
1709 mbx->max_size = FM10K_MBX_MSG_MAX_SIZE; in fm10k_sm_mbx_connect()
1715 mbx->mbx_lock = FM10K_MBX_REQ_INTERRUPT | FM10K_MBX_ACK_INTERRUPT | in fm10k_sm_mbx_connect()
1726 * fm10k_sm_mbx_disconnect - Shutdown mailbox connection
1727 * @hw: pointer to hardware structure
1741 int timeout = mbx->timeout ? FM10K_MBX_DISCONNECT_TIMEOUT : 0; in fm10k_sm_mbx_disconnect()
1744 mbx->state = FM10K_STATE_DISCONNECT; in fm10k_sm_mbx_disconnect()
1747 fm10k_write_reg(hw, mbx->mbx_reg, FM10K_MBX_REQ | in fm10k_sm_mbx_disconnect()
1751 mbx->ops.process(hw, mbx); in fm10k_sm_mbx_disconnect()
1752 timeout -= FM10K_MBX_POLL_DELAY; in fm10k_sm_mbx_disconnect()
1753 } while ((timeout > 0) && (mbx->state != FM10K_STATE_CLOSED)); in fm10k_sm_mbx_disconnect()
1756 mbx->state = FM10K_STATE_CLOSED; in fm10k_sm_mbx_disconnect()
1757 mbx->remote = 0; in fm10k_sm_mbx_disconnect()
1759 fm10k_fifo_drop_all(&mbx->tx); in fm10k_sm_mbx_disconnect()
1761 fm10k_write_reg(hw, mbx->mbmem_reg, 0); in fm10k_sm_mbx_disconnect()
1765 * fm10k_sm_mbx_validate_fifo_hdr - Validate fields in the remote FIFO header
1774 const u32 *hdr = &mbx->mbx_hdr; in fm10k_sm_mbx_validate_fifo_hdr()
1789 if (mbx->tail < head) in fm10k_sm_mbx_validate_fifo_hdr()
1790 head += mbx->mbmem_len - 1; in fm10k_sm_mbx_validate_fifo_hdr()
1791 if (tail < mbx->head) in fm10k_sm_mbx_validate_fifo_hdr()
1792 tail += mbx->mbmem_len - 1; in fm10k_sm_mbx_validate_fifo_hdr()
1793 if (fm10k_mbx_index_len(mbx, head, mbx->tail) > mbx->tail_len) in fm10k_sm_mbx_validate_fifo_hdr()
1795 if (fm10k_mbx_index_len(mbx, mbx->head, tail) < mbx->mbmem_len) in fm10k_sm_mbx_validate_fifo_hdr()
1806 * fm10k_sm_mbx_process_error - Process header with error flag set
1816 const enum fm10k_mbx_state state = mbx->state; in fm10k_sm_mbx_process_error()
1821 mbx->remote = 0; in fm10k_sm_mbx_process_error()
1829 if (mbx->remote) { in fm10k_sm_mbx_process_error()
1830 while (mbx->local > 1) in fm10k_sm_mbx_process_error()
1831 mbx->local--; in fm10k_sm_mbx_process_error()
1832 mbx->remote = 0; in fm10k_sm_mbx_process_error()
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
1871 * @hw: pointer to hardware structure
1876 * FIFO and place it in the Rx mailbox FIFO for processing by software.
1883 u16 mbmem_len = mbx->mbmem_len - 1; in fm10k_sm_mbx_receive()
1887 if (tail < mbx->head) in fm10k_sm_mbx_receive()
1890 /* copy data to the Rx FIFO */ in fm10k_sm_mbx_receive()
1899 mbx->head = fm10k_mbx_head_sub(mbx, mbx->pushed); in fm10k_sm_mbx_receive()
1900 mbx->pushed = 0; in fm10k_sm_mbx_receive()
1903 if (mbx->head > mbmem_len) in fm10k_sm_mbx_receive()
1904 mbx->head -= mbmem_len; in fm10k_sm_mbx_receive()
1910 * fm10k_sm_mbx_transmit - Take message from Tx and put it in Tx mailbox FIFO
1911 * @hw: pointer to hardware structure
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
1923 u16 mbmem_len = mbx->mbmem_len - 1; in fm10k_sm_mbx_transmit()
1927 if (mbx->tail < head) in fm10k_sm_mbx_transmit()
1936 msg = fifo->buffer + fm10k_fifo_head_offset(fifo, len); in fm10k_sm_mbx_transmit()
1939 } while ((len <= mbx->tail_len) && (len < mbmem_len)); in fm10k_sm_mbx_transmit()
1942 if (mbx->tail_len > tail_len) { in fm10k_sm_mbx_transmit()
1943 mbx->tail = fm10k_mbx_tail_sub(mbx, mbx->tail_len - tail_len); in fm10k_sm_mbx_transmit()
1944 mbx->tail_len = tail_len; in fm10k_sm_mbx_transmit()
1948 if (mbx->tail > mbmem_len) in fm10k_sm_mbx_transmit()
1949 mbx->tail -= mbmem_len; in fm10k_sm_mbx_transmit()
1953 * fm10k_sm_mbx_create_reply - Generate reply based on state and remote head
1954 * @hw: pointer to hardware structure
1959 * mailbox state and the remote FIFO head. It will return the length
1966 switch (mbx->state) { in fm10k_sm_mbx_create_reply()
1973 if (mbx->tail_len || (mbx->state == FM10K_STATE_OPEN)) { in fm10k_sm_mbx_create_reply()
1976 mbx->remote = 0; in fm10k_sm_mbx_create_reply()
1990 * fm10k_sm_mbx_process_reset - Process header with version == 0 (RESET)
1991 * @hw: pointer to hardware structure
1996 * into the connect state in order to re-establish the connection. This
2004 const enum fm10k_mbx_state state = mbx->state; in fm10k_sm_mbx_process_reset()
2009 mbx->state = FM10K_STATE_CLOSED; in fm10k_sm_mbx_process_reset()
2010 mbx->remote = 0; in fm10k_sm_mbx_process_reset()
2011 mbx->local = 0; in fm10k_sm_mbx_process_reset()
2020 mbx->remote = mbx->local; in fm10k_sm_mbx_process_reset()
2026 fm10k_sm_mbx_create_reply(hw, mbx, mbx->tail); in fm10k_sm_mbx_process_reset()
2032 * fm10k_sm_mbx_process_version_1 - Process header with version == 1
2033 * @hw: pointer to hardware structure
2042 const u32 *hdr = &mbx->mbx_hdr; in fm10k_sm_mbx_process_version_1()
2051 if (mbx->state == FM10K_STATE_CONNECT) { in fm10k_sm_mbx_process_version_1()
2052 if (!mbx->remote) in fm10k_sm_mbx_process_version_1()
2054 if (mbx->remote != 1) in fm10k_sm_mbx_process_version_1()
2057 mbx->state = FM10K_STATE_OPEN; in fm10k_sm_mbx_process_version_1()
2066 /* continue until we have flushed the Rx FIFO */ in fm10k_sm_mbx_process_version_1()
2076 * fm10k_sm_mbx_process - Process switch manager mailbox interrupt
2077 * @hw: pointer to hardware structure
2090 if (mbx->state == FM10K_STATE_CLOSED) in fm10k_sm_mbx_process()
2102 if (FM10K_MSG_HDR_FIELD_GET(mbx->mbx_hdr, SM_ERR)) { in fm10k_sm_mbx_process()
2107 switch (FM10K_MSG_HDR_FIELD_GET(mbx->mbx_hdr, SM_VER)) { in fm10k_sm_mbx_process()
2127 * fm10k_sm_mbx_init - Initialize mailbox memory for PF/SM mailbox
2128 * @hw: pointer to hardware structure
2133 * buffer provided and use that to populate both the Tx and Rx FIFO by
2143 mbx->mbx_reg = FM10K_GMBX; in fm10k_sm_mbx_init()
2144 mbx->mbmem_reg = FM10K_MBMEM_PF(0); in fm10k_sm_mbx_init()
2147 mbx->state = FM10K_STATE_CLOSED; in fm10k_sm_mbx_init()
2154 mbx->msg_data = msg_data; in fm10k_sm_mbx_init()
2159 mbx->timeout = 0; in fm10k_sm_mbx_init()
2160 mbx->udelay = FM10K_MBX_INIT_DELAY; in fm10k_sm_mbx_init()
2163 mbx->max_size = FM10K_MBX_MSG_MAX_SIZE; in fm10k_sm_mbx_init()
2164 mbx->mbmem_len = FM10K_MBMEM_PF_XOR; in fm10k_sm_mbx_init()
2167 fm10k_fifo_init(&mbx->tx, mbx->buffer, FM10K_MBX_TX_BUFFER_SIZE); in fm10k_sm_mbx_init()
2168 fm10k_fifo_init(&mbx->rx, &mbx->buffer[FM10K_MBX_TX_BUFFER_SIZE], in fm10k_sm_mbx_init()
2172 mbx->ops.connect = fm10k_sm_mbx_connect; in fm10k_sm_mbx_init()
2173 mbx->ops.disconnect = fm10k_sm_mbx_disconnect; in fm10k_sm_mbx_init()
2174 mbx->ops.rx_ready = fm10k_mbx_rx_ready; in fm10k_sm_mbx_init()
2175 mbx->ops.tx_ready = fm10k_mbx_tx_ready; in fm10k_sm_mbx_init()
2176 mbx->ops.tx_complete = fm10k_mbx_tx_complete; in fm10k_sm_mbx_init()
2177 mbx->ops.enqueue_tx = fm10k_mbx_enqueue_tx; in fm10k_sm_mbx_init()
2178 mbx->ops.process = fm10k_sm_mbx_process; in fm10k_sm_mbx_init()
2179 mbx->ops.register_handlers = fm10k_mbx_register_handlers; in fm10k_sm_mbx_init()