Lines Matching +full:report +full:- +full:speed +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/dma-mapping.h>
53 for (desc_idx = FBNIC_IPC_MBX_DESC_LEN; --desc_idx;) { in fbnic_mbx_init_desc_ring()
66 spin_lock_init(&fbd->fw_tx_lock); in fbnic_mbx_init()
70 memset(&fbd->mbx[i], 0, sizeof(struct fbnic_fw_mbx)); in fbnic_mbx_init()
72 /* Do not auto-clear the FW mailbox interrupt, let SW clear it */ in fbnic_mbx_init()
85 struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx]; in fbnic_mbx_map_msg()
86 u8 tail = mbx->tail; in fbnic_mbx_map_msg()
90 if (!mbx->ready || !fbnic_fw_present(fbd)) in fbnic_mbx_map_msg()
91 return -ENODEV; in fbnic_mbx_map_msg()
96 if (mbx->head == ((tail + 1) % FBNIC_IPC_MBX_DESC_LEN)) in fbnic_mbx_map_msg()
97 return -EBUSY; in fbnic_mbx_map_msg()
99 addr = dma_map_single(fbd->dev, msg, PAGE_SIZE, direction); in fbnic_mbx_map_msg()
100 if (dma_mapping_error(fbd->dev, addr)) { in fbnic_mbx_map_msg()
103 return -ENOSPC; in fbnic_mbx_map_msg()
106 mbx->buf_info[tail].msg = msg; in fbnic_mbx_map_msg()
107 mbx->buf_info[tail].addr = addr; in fbnic_mbx_map_msg()
109 mbx->tail = (tail + 1) % FBNIC_IPC_MBX_DESC_LEN; in fbnic_mbx_map_msg()
111 fw_wr32(fbd, FBNIC_IPC_MBX(mbx_idx, mbx->tail), 0); in fbnic_mbx_map_msg()
125 struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx]; in fbnic_mbx_unmap_and_free_msg()
128 if (!mbx->buf_info[desc_idx].msg) in fbnic_mbx_unmap_and_free_msg()
133 dma_unmap_single(fbd->dev, mbx->buf_info[desc_idx].addr, in fbnic_mbx_unmap_and_free_msg()
136 free_page((unsigned long)mbx->buf_info[desc_idx].msg); in fbnic_mbx_unmap_and_free_msg()
137 mbx->buf_info[desc_idx].msg = NULL; in fbnic_mbx_unmap_and_free_msg()
146 for (i = FBNIC_IPC_MBX_DESC_LEN; i--;) in fbnic_mbx_clean_desc_ring()
163 struct fbnic_fw_mbx *rx_mbx = &fbd->mbx[FBNIC_IPC_MBX_RX_IDX]; in fbnic_mbx_alloc_rx_msgs()
164 u8 tail = rx_mbx->tail, head = rx_mbx->head, count; in fbnic_mbx_alloc_rx_msgs()
170 if (!rx_mbx->ready) in fbnic_mbx_alloc_rx_msgs()
171 return -ENODEV; in fbnic_mbx_alloc_rx_msgs()
174 count = (head - tail - 1) % FBNIC_IPC_MBX_DESC_LEN; in fbnic_mbx_alloc_rx_msgs()
175 while (!err && count--) { in fbnic_mbx_alloc_rx_msgs()
181 err = -ENOMEM; in fbnic_mbx_alloc_rx_msgs()
200 spin_lock_irqsave(&fbd->fw_tx_lock, flags); in fbnic_mbx_map_tlv_msg()
203 le16_to_cpu(msg->hdr.len) * sizeof(u32), 1); in fbnic_mbx_map_tlv_msg()
205 spin_unlock_irqrestore(&fbd->fw_tx_lock, flags); in fbnic_mbx_map_tlv_msg()
212 struct fbnic_fw_mbx *tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX]; in fbnic_mbx_process_tx_msgs()
213 u8 head = tx_mbx->head; in fbnic_mbx_process_tx_msgs()
216 while (head != tx_mbx->tail) { in fbnic_mbx_process_tx_msgs()
228 tx_mbx->head = head; in fbnic_mbx_process_tx_msgs()
232 * fbnic_fw_xmit_simple_msg - Transmit a simple single TLV message w/o data
238 * -EOPNOTSUPP: Is not ASIC so mailbox is not supported
239 * -ENODEV: Device I/O error
240 * -ENOMEM: Failed to allocate message
241 * -EBUSY: No space in mailbox
242 * -ENOSPC: DMA mapping failed
255 return -ENODEV; in fbnic_fw_xmit_simple_msg()
259 return -ENOMEM; in fbnic_fw_xmit_simple_msg()
269 * fbnic_fw_xmit_cap_msg - Allocate and populate a FW capabilities message
283 return (err == -EOPNOTSUPP) ? 0 : err; in fbnic_fw_xmit_cap_msg()
288 struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx]; in fbnic_mbx_postinit_desc_ring()
291 if (mbx->ready) in fbnic_mbx_postinit_desc_ring()
294 mbx->ready = true; in fbnic_mbx_postinit_desc_ring()
308 !fbd->fw_cap.running.mgmt.version) in fbnic_mbx_postinit_desc_ring()
309 fbd->fw_cap.running.mgmt.version = 1; in fbnic_mbx_postinit_desc_ring()
332 * fbnic_fw_xmit_ownership_msg - Create and transmit a host ownership message
350 return -ENODEV; in fbnic_fw_xmit_ownership_msg()
354 return -ENOMEM; in fbnic_fw_xmit_ownership_msg()
369 fbd->last_heartbeat_response = req_time - HZ; in fbnic_fw_xmit_ownership_msg()
371 fbd->last_heartbeat_request = req_time; in fbnic_fw_xmit_ownership_msg()
374 fbd->fw_heartbeat_enabled = take_ownership; in fbnic_fw_xmit_ownership_msg()
412 int attr_len = le16_to_cpu(attr->hdr.len) / sizeof(u32) - 1; in fbnic_fw_parse_bmc_addrs()
418 return -ENOSPC; in fbnic_fw_parse_bmc_addrs()
442 u32 speed = 0, fec = 0; in fbnic_fw_parse_cap_resp() local
448 fbd->fw_cap.running.mgmt.version); in fbnic_fw_parse_cap_resp()
450 if (!fbd->fw_cap.running.mgmt.version) in fbnic_fw_parse_cap_resp()
451 return -EINVAL; in fbnic_fw_parse_cap_resp()
453 if (fbd->fw_cap.running.mgmt.version < MIN_FW_VERSION_CODE) { in fbnic_fw_parse_cap_resp()
456 fbnic_mk_fw_ver_str(fbd->fw_cap.running.mgmt.version, in fbnic_fw_parse_cap_resp()
458 …dev_err(fbd->dev, "Device firmware version(%s) is older than minimum required version(%02d.%02d.%0… in fbnic_fw_parse_cap_resp()
466 fbd->mbx[FBNIC_IPC_MBX_TX_IDX].ready = false; in fbnic_fw_parse_cap_resp()
467 return -EINVAL; in fbnic_fw_parse_cap_resp()
471 fbd->fw_cap.running.mgmt.commit, in fbnic_fw_parse_cap_resp()
474 dev_warn(fbd->dev, "Firmware did not send mgmt commit!\n"); in fbnic_fw_parse_cap_resp()
477 fbd->fw_cap.stored.mgmt.version); in fbnic_fw_parse_cap_resp()
479 fbd->fw_cap.stored.mgmt.commit, in fbnic_fw_parse_cap_resp()
483 fbd->fw_cap.running.bootloader.version); in fbnic_fw_parse_cap_resp()
485 fbd->fw_cap.running.bootloader.commit, in fbnic_fw_parse_cap_resp()
489 fbd->fw_cap.stored.bootloader.version); in fbnic_fw_parse_cap_resp()
491 fbd->fw_cap.stored.bootloader.commit, in fbnic_fw_parse_cap_resp()
495 fbd->fw_cap.stored.undi.version); in fbnic_fw_parse_cap_resp()
497 fbd->fw_cap.stored.undi.commit, in fbnic_fw_parse_cap_resp()
501 fbd->fw_cap.active_slot = active_slot; in fbnic_fw_parse_cap_resp()
503 get_unsigned_result(FBNIC_FW_CAP_RESP_FW_LINK_SPEED, speed); in fbnic_fw_parse_cap_resp()
505 fbd->fw_cap.link_speed = speed; in fbnic_fw_parse_cap_resp()
506 fbd->fw_cap.link_fec = fec; in fbnic_fw_parse_cap_resp()
514 return -EINVAL; in fbnic_fw_parse_cap_resp()
516 err = fbnic_fw_parse_bmc_addrs(fbd->fw_cap.bmc_mac_addr, in fbnic_fw_parse_cap_resp()
523 memset(fbd->fw_cap.bmc_mac_addr, 0, in fbnic_fw_parse_cap_resp()
524 sizeof(fbd->fw_cap.bmc_mac_addr)); in fbnic_fw_parse_cap_resp()
527 fbd->fw_cap.bmc_present = bmc_present; in fbnic_fw_parse_cap_resp()
530 fbd->fw_cap.all_multi = all_multi; in fbnic_fw_parse_cap_resp()
545 fbd->last_heartbeat_response = jiffies; in fbnic_fw_parse_ownership_resp()
559 fbd->last_heartbeat_response = jiffies; in fbnic_fw_parse_heartbeat_resp()
571 return -ENODEV; in fbnic_fw_xmit_heartbeat_message()
575 return -ENOMEM; in fbnic_fw_xmit_heartbeat_message()
581 fbd->last_heartbeat_request = req_time; in fbnic_fw_xmit_heartbeat_message()
592 unsigned long last_response = fbd->last_heartbeat_response; in fbnic_fw_heartbeat_current()
593 unsigned long last_request = fbd->last_heartbeat_request; in fbnic_fw_heartbeat_current()
600 int err = -ETIMEDOUT; in fbnic_fw_init_heartbeat()
604 return -ENODEV; in fbnic_fw_init_heartbeat()
606 while (attempts--) { in fbnic_fw_init_heartbeat()
617 dev_warn(fbd->dev, in fbnic_fw_init_heartbeat()
628 unsigned long last_request = fbd->last_heartbeat_request; in fbnic_fw_check_heartbeat()
638 if (!fbd->fw_heartbeat_enabled) in fbnic_fw_check_heartbeat()
643 dev_warn(fbd->dev, in fbnic_fw_check_heartbeat()
645 fbd->fw_heartbeat_enabled = false; in fbnic_fw_check_heartbeat()
651 dev_warn(fbd->dev, "Failed to send heartbeat message\n"); in fbnic_fw_check_heartbeat()
666 struct fbnic_fw_mbx *rx_mbx = &fbd->mbx[FBNIC_IPC_MBX_RX_IDX]; in fbnic_mbx_process_rx_msgs()
667 u8 head = rx_mbx->head; in fbnic_mbx_process_rx_msgs()
670 while (head != rx_mbx->tail) { in fbnic_mbx_process_rx_msgs()
678 dma_unmap_single(fbd->dev, rx_mbx->buf_info[head].addr, in fbnic_mbx_process_rx_msgs()
681 msg = rx_mbx->buf_info[head].msg; in fbnic_mbx_process_rx_msgs()
689 /* Report descriptors with length greater than page size */ in fbnic_mbx_process_rx_msgs()
691 dev_warn(fbd->dev, in fbnic_mbx_process_rx_msgs()
697 if (le16_to_cpu(msg->hdr.len) * sizeof(u32) > length) in fbnic_mbx_process_rx_msgs()
698 dev_warn(fbd->dev, "Mailbox message length mismatch\n"); in fbnic_mbx_process_rx_msgs()
703 dev_warn(fbd->dev, "Unable to process message: %d\n", in fbnic_mbx_process_rx_msgs()
710 dev_dbg(fbd->dev, "Parsed msg type %d\n", msg->hdr.type); in fbnic_mbx_process_rx_msgs()
713 free_page((unsigned long)rx_mbx->buf_info[head].msg); in fbnic_mbx_process_rx_msgs()
714 rx_mbx->buf_info[head].msg = NULL; in fbnic_mbx_process_rx_msgs()
721 rx_mbx->head = head; in fbnic_mbx_process_rx_msgs()
742 return -ENODEV; in fbnic_mbx_poll_tx_ready()
744 tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX]; in fbnic_mbx_poll_tx_ready()
745 while (!tx_mbx->ready && --attempts) { in fbnic_mbx_poll_tx_ready()
757 return attempts ? 0 : -ETIMEDOUT; in fbnic_mbx_poll_tx_ready()
771 tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX]; in fbnic_mbx_flush_tx()
774 if (!tx_mbx->ready) in fbnic_mbx_flush_tx()
781 u8 head = tx_mbx->head; in fbnic_mbx_flush_tx()
783 if (head == tx_mbx->tail) in fbnic_mbx_flush_tx()
789 count += (tx_mbx->head - head) % FBNIC_IPC_MBX_DESC_LEN; in fbnic_mbx_flush_tx()
790 } while (count < FBNIC_IPC_MBX_DESC_LEN && --attempts); in fbnic_mbx_flush_tx()
796 struct fbnic_fw_ver *mgmt = &fbd->fw_cap.running.mgmt; in fbnic_get_fw_ver_commit_str()
799 if (mgmt->commit[0]) in fbnic_get_fw_ver_commit_str()
802 fbnic_mk_full_fw_ver_str(mgmt->version, delim, mgmt->commit, in fbnic_get_fw_ver_commit_str()