Linux 4.19.133
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_mcp.h
blob80a6b5d1ff3386b35b9e816e5b7b30b7427cb8e7
1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
33 #ifndef _QED_MCP_H
34 #define _QED_MCP_H
36 #include <linux/types.h>
37 #include <linux/delay.h>
38 #include <linux/slab.h>
39 #include <linux/spinlock.h>
40 #include <linux/qed/qed_fcoe_if.h>
41 #include "qed_hsi.h"
42 #include "qed_dev_api.h"
44 struct qed_mcp_link_speed_params {
45 bool autoneg;
46 u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */
47 u32 forced_speed; /* In Mb/s */
50 struct qed_mcp_link_pause_params {
51 bool autoneg;
52 bool forced_rx;
53 bool forced_tx;
56 enum qed_mcp_eee_mode {
57 QED_MCP_EEE_DISABLED,
58 QED_MCP_EEE_ENABLED,
59 QED_MCP_EEE_UNSUPPORTED
62 struct qed_mcp_link_params {
63 struct qed_mcp_link_speed_params speed;
64 struct qed_mcp_link_pause_params pause;
65 u32 loopback_mode;
66 struct qed_link_eee_params eee;
69 struct qed_mcp_link_capabilities {
70 u32 speed_capabilities;
71 bool default_speed_autoneg;
72 enum qed_mcp_eee_mode default_eee;
73 u32 eee_lpi_timer;
74 u8 eee_speed_caps;
77 struct qed_mcp_link_state {
78 bool link_up;
80 u32 min_pf_rate;
82 /* Actual link speed in Mb/s */
83 u32 line_speed;
85 /* PF max speed in Mb/s, deduced from line_speed
86 * according to PF max bandwidth configuration.
88 u32 speed;
89 bool full_duplex;
91 bool an;
92 bool an_complete;
93 bool parallel_detection;
94 bool pfc_enabled;
96 #define QED_LINK_PARTNER_SPEED_1G_HD BIT(0)
97 #define QED_LINK_PARTNER_SPEED_1G_FD BIT(1)
98 #define QED_LINK_PARTNER_SPEED_10G BIT(2)
99 #define QED_LINK_PARTNER_SPEED_20G BIT(3)
100 #define QED_LINK_PARTNER_SPEED_25G BIT(4)
101 #define QED_LINK_PARTNER_SPEED_40G BIT(5)
102 #define QED_LINK_PARTNER_SPEED_50G BIT(6)
103 #define QED_LINK_PARTNER_SPEED_100G BIT(7)
104 u32 partner_adv_speed;
106 bool partner_tx_flow_ctrl_en;
107 bool partner_rx_flow_ctrl_en;
109 #define QED_LINK_PARTNER_SYMMETRIC_PAUSE (1)
110 #define QED_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
111 #define QED_LINK_PARTNER_BOTH_PAUSE (3)
112 u8 partner_adv_pause;
114 bool sfp_tx_fault;
115 bool eee_active;
116 u8 eee_adv_caps;
117 u8 eee_lp_adv_caps;
120 struct qed_mcp_function_info {
121 u8 pause_on_host;
123 enum qed_pci_personality protocol;
125 u8 bandwidth_min;
126 u8 bandwidth_max;
128 u8 mac[ETH_ALEN];
130 u64 wwn_port;
131 u64 wwn_node;
133 #define QED_MCP_VLAN_UNSET (0xffff)
134 u16 ovlan;
136 u16 mtu;
139 struct qed_mcp_nvm_common {
140 u32 offset;
141 u32 param;
142 u32 resp;
143 u32 cmd;
146 struct qed_mcp_drv_version {
147 u32 version;
148 u8 name[MCP_DRV_VER_STR_SIZE - 4];
151 struct qed_mcp_lan_stats {
152 u64 ucast_rx_pkts;
153 u64 ucast_tx_pkts;
154 u32 fcs_err;
157 struct qed_mcp_fcoe_stats {
158 u64 rx_pkts;
159 u64 tx_pkts;
160 u32 fcs_err;
161 u32 login_failure;
164 struct qed_mcp_iscsi_stats {
165 u64 rx_pdus;
166 u64 tx_pdus;
167 u64 rx_bytes;
168 u64 tx_bytes;
171 struct qed_mcp_rdma_stats {
172 u64 rx_pkts;
173 u64 tx_pkts;
174 u64 rx_bytes;
175 u64 tx_byts;
178 enum qed_mcp_protocol_type {
179 QED_MCP_LAN_STATS,
180 QED_MCP_FCOE_STATS,
181 QED_MCP_ISCSI_STATS,
182 QED_MCP_RDMA_STATS
185 union qed_mcp_protocol_stats {
186 struct qed_mcp_lan_stats lan_stats;
187 struct qed_mcp_fcoe_stats fcoe_stats;
188 struct qed_mcp_iscsi_stats iscsi_stats;
189 struct qed_mcp_rdma_stats rdma_stats;
192 enum qed_ov_eswitch {
193 QED_OV_ESWITCH_NONE,
194 QED_OV_ESWITCH_VEB,
195 QED_OV_ESWITCH_VEPA
198 enum qed_ov_client {
199 QED_OV_CLIENT_DRV,
200 QED_OV_CLIENT_USER,
201 QED_OV_CLIENT_VENDOR_SPEC
204 enum qed_ov_driver_state {
205 QED_OV_DRIVER_STATE_NOT_LOADED,
206 QED_OV_DRIVER_STATE_DISABLED,
207 QED_OV_DRIVER_STATE_ACTIVE
210 enum qed_ov_wol {
211 QED_OV_WOL_DEFAULT,
212 QED_OV_WOL_DISABLED,
213 QED_OV_WOL_ENABLED
216 enum qed_mfw_tlv_type {
217 QED_MFW_TLV_GENERIC = 0x1, /* Core driver TLVs */
218 QED_MFW_TLV_ETH = 0x2, /* L2 driver TLVs */
219 QED_MFW_TLV_FCOE = 0x4, /* FCoE protocol TLVs */
220 QED_MFW_TLV_ISCSI = 0x8, /* SCSI protocol TLVs */
221 QED_MFW_TLV_MAX = 0x16,
224 struct qed_mfw_tlv_generic {
225 #define QED_MFW_TLV_FLAGS_SIZE 2
226 struct {
227 u8 ipv4_csum_offload;
228 u8 lso_supported;
229 bool b_set;
230 } flags;
232 #define QED_MFW_TLV_MAC_COUNT 3
233 /* First entry for primary MAC, 2 secondary MACs possible */
234 u8 mac[QED_MFW_TLV_MAC_COUNT][6];
235 bool mac_set[QED_MFW_TLV_MAC_COUNT];
237 u64 rx_frames;
238 bool rx_frames_set;
239 u64 rx_bytes;
240 bool rx_bytes_set;
241 u64 tx_frames;
242 bool tx_frames_set;
243 u64 tx_bytes;
244 bool tx_bytes_set;
247 union qed_mfw_tlv_data {
248 struct qed_mfw_tlv_generic generic;
249 struct qed_mfw_tlv_eth eth;
250 struct qed_mfw_tlv_fcoe fcoe;
251 struct qed_mfw_tlv_iscsi iscsi;
255 * @brief - returns the link params of the hw function
257 * @param p_hwfn
259 * @returns pointer to link params
261 struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *);
264 * @brief - return the link state of the hw function
266 * @param p_hwfn
268 * @returns pointer to link state
270 struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *);
273 * @brief - return the link capabilities of the hw function
275 * @param p_hwfn
277 * @returns pointer to link capabilities
279 struct qed_mcp_link_capabilities
280 *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
283 * @brief Request the MFW to set the the link according to 'link_input'.
285 * @param p_hwfn
286 * @param p_ptt
287 * @param b_up - raise link if `true'. Reset link if `false'.
289 * @return int
291 int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
292 struct qed_ptt *p_ptt,
293 bool b_up);
296 * @brief Get the management firmware version value
298 * @param p_hwfn
299 * @param p_ptt
300 * @param p_mfw_ver - mfw version value
301 * @param p_running_bundle_id - image id in nvram; Optional.
303 * @return int - 0 - operation was successful.
305 int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
306 struct qed_ptt *p_ptt,
307 u32 *p_mfw_ver, u32 *p_running_bundle_id);
310 * @brief Get the MBI version value
312 * @param p_hwfn
313 * @param p_ptt
314 * @param p_mbi_ver - A pointer to a variable to be filled with the MBI version.
316 * @return int - 0 - operation was successful.
318 int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
319 struct qed_ptt *p_ptt, u32 *p_mbi_ver);
322 * @brief Get media type value of the port.
324 * @param cdev - qed dev pointer
325 * @param p_ptt
326 * @param mfw_ver - media type value
328 * @return int -
329 * 0 - Operation was successul.
330 * -EBUSY - Operation failed
332 int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
333 struct qed_ptt *p_ptt, u32 *media_type);
336 * @brief General function for sending commands to the MCP
337 * mailbox. It acquire mutex lock for the entire
338 * operation, from sending the request until the MCP
339 * response. Waiting for MCP response will be checked up
340 * to 5 seconds every 5ms.
342 * @param p_hwfn - hw function
343 * @param p_ptt - PTT required for register access
344 * @param cmd - command to be sent to the MCP.
345 * @param param - Optional param
346 * @param o_mcp_resp - The MCP response code (exclude sequence).
347 * @param o_mcp_param- Optional parameter provided by the MCP
348 * response
349 * @return int - 0 - operation
350 * was successul.
352 int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
353 struct qed_ptt *p_ptt,
354 u32 cmd,
355 u32 param,
356 u32 *o_mcp_resp,
357 u32 *o_mcp_param);
360 * @brief - drains the nig, allowing completion to pass in case of pauses.
361 * (Should be called only from sleepable context)
363 * @param p_hwfn
364 * @param p_ptt
366 int qed_mcp_drain(struct qed_hwfn *p_hwfn,
367 struct qed_ptt *p_ptt);
370 * @brief Get the flash size value
372 * @param p_hwfn
373 * @param p_ptt
374 * @param p_flash_size - flash size in bytes to be filled.
376 * @return int - 0 - operation was successul.
378 int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
379 struct qed_ptt *p_ptt,
380 u32 *p_flash_size);
383 * @brief Send driver version to MFW
385 * @param p_hwfn
386 * @param p_ptt
387 * @param version - Version value
388 * @param name - Protocol driver name
390 * @return int - 0 - operation was successul.
393 qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
394 struct qed_ptt *p_ptt,
395 struct qed_mcp_drv_version *p_ver);
398 * @brief Notify MFW about the change in base device properties
400 * @param p_hwfn
401 * @param p_ptt
402 * @param client - qed client type
404 * @return int - 0 - operation was successful.
406 int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
407 struct qed_ptt *p_ptt,
408 enum qed_ov_client client);
411 * @brief Notify MFW about the driver state
413 * @param p_hwfn
414 * @param p_ptt
415 * @param drv_state - Driver state
417 * @return int - 0 - operation was successful.
419 int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
420 struct qed_ptt *p_ptt,
421 enum qed_ov_driver_state drv_state);
424 * @brief Send MTU size to MFW
426 * @param p_hwfn
427 * @param p_ptt
428 * @param mtu - MTU size
430 * @return int - 0 - operation was successful.
432 int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
433 struct qed_ptt *p_ptt, u16 mtu);
436 * @brief Send MAC address to MFW
438 * @param p_hwfn
439 * @param p_ptt
440 * @param mac - MAC address
442 * @return int - 0 - operation was successful.
444 int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
445 struct qed_ptt *p_ptt, u8 *mac);
448 * @brief Send WOL mode to MFW
450 * @param p_hwfn
451 * @param p_ptt
452 * @param wol - WOL mode
454 * @return int - 0 - operation was successful.
456 int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
457 struct qed_ptt *p_ptt,
458 enum qed_ov_wol wol);
461 * @brief Set LED status
463 * @param p_hwfn
464 * @param p_ptt
465 * @param mode - LED mode
467 * @return int - 0 - operation was successful.
469 int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
470 struct qed_ptt *p_ptt,
471 enum qed_led_mode mode);
474 * @brief Read from nvm
476 * @param cdev
477 * @param addr - nvm offset
478 * @param p_buf - nvm read buffer
479 * @param len - buffer len
481 * @return int - 0 - operation was successful.
483 int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
486 * @brief Write to nvm
488 * @param cdev
489 * @param addr - nvm offset
490 * @param cmd - nvm command
491 * @param p_buf - nvm write buffer
492 * @param len - buffer len
494 * @return int - 0 - operation was successful.
496 int qed_mcp_nvm_write(struct qed_dev *cdev,
497 u32 cmd, u32 addr, u8 *p_buf, u32 len);
500 * @brief Put file begin
502 * @param cdev
503 * @param addr - nvm offset
505 * @return int - 0 - operation was successful.
507 int qed_mcp_nvm_put_file_begin(struct qed_dev *cdev, u32 addr);
510 * @brief Check latest response
512 * @param cdev
513 * @param p_buf - nvm write buffer
515 * @return int - 0 - operation was successful.
517 int qed_mcp_nvm_resp(struct qed_dev *cdev, u8 *p_buf);
519 struct qed_nvm_image_att {
520 u32 start_addr;
521 u32 length;
525 * @brief Allows reading a whole nvram image
527 * @param p_hwfn
528 * @param image_id - image to get attributes for
529 * @param p_image_att - image attributes structure into which to fill data
531 * @return int - 0 - operation was successful.
534 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
535 enum qed_nvm_images image_id,
536 struct qed_nvm_image_att *p_image_att);
539 * @brief Allows reading a whole nvram image
541 * @param p_hwfn
542 * @param image_id - image requested for reading
543 * @param p_buffer - allocated buffer into which to fill data
544 * @param buffer_len - length of the allocated buffer.
546 * @return 0 iff p_buffer now contains the nvram image.
548 int qed_mcp_get_nvm_image(struct qed_hwfn *p_hwfn,
549 enum qed_nvm_images image_id,
550 u8 *p_buffer, u32 buffer_len);
553 * @brief Bist register test
555 * @param p_hwfn - hw function
556 * @param p_ptt - PTT required for register access
558 * @return int - 0 - operation was successful.
560 int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
561 struct qed_ptt *p_ptt);
564 * @brief Bist clock test
566 * @param p_hwfn - hw function
567 * @param p_ptt - PTT required for register access
569 * @return int - 0 - operation was successful.
571 int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
572 struct qed_ptt *p_ptt);
575 * @brief Bist nvm test - get number of images
577 * @param p_hwfn - hw function
578 * @param p_ptt - PTT required for register access
579 * @param num_images - number of images if operation was
580 * successful. 0 if not.
582 * @return int - 0 - operation was successful.
584 int qed_mcp_bist_nvm_get_num_images(struct qed_hwfn *p_hwfn,
585 struct qed_ptt *p_ptt,
586 u32 *num_images);
589 * @brief Bist nvm test - get image attributes by index
591 * @param p_hwfn - hw function
592 * @param p_ptt - PTT required for register access
593 * @param p_image_att - Attributes of image
594 * @param image_index - Index of image to get information for
596 * @return int - 0 - operation was successful.
598 int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
599 struct qed_ptt *p_ptt,
600 struct bist_nvm_image_att *p_image_att,
601 u32 image_index);
604 * @brief - Processes the TLV request from MFW i.e., get the required TLV info
605 * from the qed client and send it to the MFW.
607 * @param p_hwfn
608 * @param p_ptt
610 * @param return 0 upon success.
612 int qed_mfw_process_tlv_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
614 /* Using hwfn number (and not pf_num) is required since in CMT mode,
615 * same pf_num may be used by two different hwfn
616 * TODO - this shouldn't really be in .h file, but until all fields
617 * required during hw-init will be placed in their correct place in shmem
618 * we need it in qed_dev.c [for readin the nvram reflection in shmem].
620 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
621 ((rel_pfid) | \
622 ((p_hwfn)->abs_pf_id & 1) << 3) : \
623 rel_pfid)
624 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
626 #define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
627 ((_p_hwfn)->cdev->num_ports_in_engine * \
628 qed_device_num_engines((_p_hwfn)->cdev)))
630 struct qed_mcp_info {
631 /* List for mailbox commands which were sent and wait for a response */
632 struct list_head cmd_list;
634 /* Spinlock used for protecting the access to the mailbox commands list
635 * and the sending of the commands.
637 spinlock_t cmd_lock;
639 /* Flag to indicate whether sending a MFW mailbox command is blocked */
640 bool b_block_cmd;
642 /* Spinlock used for syncing SW link-changes and link-changes
643 * originating from attention context.
645 spinlock_t link_lock;
647 u32 public_base;
648 u32 drv_mb_addr;
649 u32 mfw_mb_addr;
650 u32 port_addr;
651 u16 drv_mb_seq;
652 u16 drv_pulse_seq;
653 struct qed_mcp_link_params link_input;
654 struct qed_mcp_link_state link_output;
655 struct qed_mcp_link_capabilities link_capabilities;
656 struct qed_mcp_function_info func_info;
657 u8 *mfw_mb_cur;
658 u8 *mfw_mb_shadow;
659 u16 mfw_mb_length;
660 u32 mcp_hist;
662 /* Capabilties negotiated with the MFW */
663 u32 capabilities;
666 struct qed_mcp_mb_params {
667 u32 cmd;
668 u32 param;
669 void *p_data_src;
670 void *p_data_dst;
671 u8 data_src_size;
672 u8 data_dst_size;
673 u32 mcp_resp;
674 u32 mcp_param;
675 u32 flags;
676 #define QED_MB_FLAG_CAN_SLEEP (0x1 << 0)
677 #define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
678 #define QED_MB_FLAGS_IS_SET(params, flag) \
679 ({ typeof(params) __params = (params); \
680 (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
683 struct qed_drv_tlv_hdr {
684 u8 tlv_type;
685 u8 tlv_length; /* In dwords - not including this header */
686 u8 tlv_reserved;
687 #define QED_DRV_TLV_FLAGS_CHANGED 0x01
688 u8 tlv_flags;
692 * @brief Initialize the interface with the MCP
694 * @param p_hwfn - HW func
695 * @param p_ptt - PTT required for register access
697 * @return int
699 int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
700 struct qed_ptt *p_ptt);
703 * @brief Initialize the port interface with the MCP
705 * @param p_hwfn
706 * @param p_ptt
707 * Can only be called after `num_ports_in_engines' is set
709 void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
710 struct qed_ptt *p_ptt);
712 * @brief Releases resources allocated during the init process.
714 * @param p_hwfn - HW func
715 * @param p_ptt - PTT required for register access
717 * @return int
720 int qed_mcp_free(struct qed_hwfn *p_hwfn);
723 * @brief This function is called from the DPC context. After
724 * pointing PTT to the mfw mb, check for events sent by the MCP
725 * to the driver and ack them. In case a critical event
726 * detected, it will be handled here, otherwise the work will be
727 * queued to a sleepable work-queue.
729 * @param p_hwfn - HW function
730 * @param p_ptt - PTT required for register access
731 * @return int - 0 - operation
732 * was successul.
734 int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
735 struct qed_ptt *p_ptt);
737 enum qed_drv_role {
738 QED_DRV_ROLE_OS,
739 QED_DRV_ROLE_KDUMP,
742 struct qed_load_req_params {
743 /* Input params */
744 enum qed_drv_role drv_role;
745 u8 timeout_val;
746 bool avoid_eng_reset;
747 enum qed_override_force_load override_force_load;
749 /* Output params */
750 u32 load_code;
754 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
755 * returns whether this PF is the first on the engine/port or function.
757 * @param p_hwfn
758 * @param p_ptt
759 * @param p_params
761 * @return int - 0 - Operation was successful.
763 int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
764 struct qed_ptt *p_ptt,
765 struct qed_load_req_params *p_params);
768 * @brief Sends a UNLOAD_REQ message to the MFW
770 * @param p_hwfn
771 * @param p_ptt
773 * @return int - 0 - Operation was successful.
775 int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
778 * @brief Sends a UNLOAD_DONE message to the MFW
780 * @param p_hwfn
781 * @param p_ptt
783 * @return int - 0 - Operation was successful.
785 int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
788 * @brief Read the MFW mailbox into Current buffer.
790 * @param p_hwfn
791 * @param p_ptt
793 void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
794 struct qed_ptt *p_ptt);
797 * @brief Ack to mfw that driver finished FLR process for VFs
799 * @param p_hwfn
800 * @param p_ptt
801 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
803 * @param return int - 0 upon success.
805 int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
806 struct qed_ptt *p_ptt, u32 *vfs_to_ack);
809 * @brief - calls during init to read shmem of all function-related info.
811 * @param p_hwfn
813 * @param return 0 upon success.
815 int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
816 struct qed_ptt *p_ptt);
819 * @brief - Reset the MCP using mailbox command.
821 * @param p_hwfn
822 * @param p_ptt
824 * @param return 0 upon success.
826 int qed_mcp_reset(struct qed_hwfn *p_hwfn,
827 struct qed_ptt *p_ptt);
830 * @brief - Sends an NVM read command request to the MFW to get
831 * a buffer.
833 * @param p_hwfn
834 * @param p_ptt
835 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
836 * DRV_MSG_CODE_NVM_READ_NVRAM commands
837 * @param param - [0:23] - Offset [24:31] - Size
838 * @param o_mcp_resp - MCP response
839 * @param o_mcp_param - MCP response param
840 * @param o_txn_size - Buffer size output
841 * @param o_buf - Pointer to the buffer returned by the MFW.
843 * @param return 0 upon success.
845 int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
846 struct qed_ptt *p_ptt,
847 u32 cmd,
848 u32 param,
849 u32 *o_mcp_resp,
850 u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf);
853 * @brief Read from sfp
855 * @param p_hwfn - hw function
856 * @param p_ptt - PTT required for register access
857 * @param port - transceiver port
858 * @param addr - I2C address
859 * @param offset - offset in sfp
860 * @param len - buffer length
861 * @param p_buf - buffer to read into
863 * @return int - 0 - operation was successful.
865 int qed_mcp_phy_sfp_read(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
866 u32 port, u32 addr, u32 offset, u32 len, u8 *p_buf);
869 * @brief indicates whether the MFW objects [under mcp_info] are accessible
871 * @param p_hwfn
873 * @return true iff MFW is running and mcp_info is initialized
875 bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
878 * @brief request MFW to configure MSI-X for a VF
880 * @param p_hwfn
881 * @param p_ptt
882 * @param vf_id - absolute inside engine
883 * @param num_sbs - number of entries to request
885 * @return int
887 int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
888 struct qed_ptt *p_ptt, u8 vf_id, u8 num);
891 * @brief - Halt the MCP.
893 * @param p_hwfn
894 * @param p_ptt
896 * @param return 0 upon success.
898 int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
901 * @brief - Wake up the MCP.
903 * @param p_hwfn
904 * @param p_ptt
906 * @param return 0 upon success.
908 int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
910 int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
911 int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
912 int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
913 struct qed_ptt *p_ptt,
914 struct qed_mcp_link_state *p_link,
915 u8 max_bw);
916 int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
917 struct qed_ptt *p_ptt,
918 struct qed_mcp_link_state *p_link,
919 u8 min_bw);
921 int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
922 struct qed_ptt *p_ptt, u32 mask_parities);
925 * @brief - Sets the MFW's max value for the given resource
927 * @param p_hwfn
928 * @param p_ptt
929 * @param res_id
930 * @param resc_max_val
931 * @param p_mcp_resp
933 * @return int - 0 - operation was successful.
936 qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
937 struct qed_ptt *p_ptt,
938 enum qed_resources res_id,
939 u32 resc_max_val, u32 *p_mcp_resp);
942 * @brief - Gets the MFW allocation info for the given resource
944 * @param p_hwfn
945 * @param p_ptt
946 * @param res_id
947 * @param p_mcp_resp
948 * @param p_resc_num
949 * @param p_resc_start
951 * @return int - 0 - operation was successful.
954 qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
955 struct qed_ptt *p_ptt,
956 enum qed_resources res_id,
957 u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start);
960 * @brief Send eswitch mode to MFW
962 * @param p_hwfn
963 * @param p_ptt
964 * @param eswitch - eswitch mode
966 * @return int - 0 - operation was successful.
968 int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
969 struct qed_ptt *p_ptt,
970 enum qed_ov_eswitch eswitch);
972 #define QED_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP
973 #define QED_MCP_RESC_LOCK_MAX_VAL 31
975 enum qed_resc_lock {
976 QED_RESC_LOCK_DBG_DUMP = QED_MCP_RESC_LOCK_MIN_VAL,
977 QED_RESC_LOCK_PTP_PORT0,
978 QED_RESC_LOCK_PTP_PORT1,
979 QED_RESC_LOCK_PTP_PORT2,
980 QED_RESC_LOCK_PTP_PORT3,
981 QED_RESC_LOCK_RESC_ALLOC = QED_MCP_RESC_LOCK_MAX_VAL,
982 QED_RESC_LOCK_RESC_INVALID
986 * @brief - Initiates PF FLR
988 * @param p_hwfn
989 * @param p_ptt
991 * @return int - 0 - operation was successful.
993 int qed_mcp_initiate_pf_flr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
994 struct qed_resc_lock_params {
995 /* Resource number [valid values are 0..31] */
996 u8 resource;
998 /* Lock timeout value in seconds [default, none or 1..254] */
999 u8 timeout;
1000 #define QED_MCP_RESC_LOCK_TO_DEFAULT 0
1001 #define QED_MCP_RESC_LOCK_TO_NONE 255
1003 /* Number of times to retry locking */
1004 u8 retry_num;
1005 #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT 10
1007 /* The interval in usec between retries */
1008 u16 retry_interval;
1009 #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT 10000
1011 /* Use sleep or delay between retries */
1012 bool sleep_b4_retry;
1014 /* Will be set as true if the resource is free and granted */
1015 bool b_granted;
1017 /* Will be filled with the resource owner.
1018 * [0..15 = PF0-15, 16 = MFW]
1020 u8 owner;
1024 * @brief Acquires MFW generic resource lock
1026 * @param p_hwfn
1027 * @param p_ptt
1028 * @param p_params
1030 * @return int - 0 - operation was successful.
1033 qed_mcp_resc_lock(struct qed_hwfn *p_hwfn,
1034 struct qed_ptt *p_ptt, struct qed_resc_lock_params *p_params);
1036 struct qed_resc_unlock_params {
1037 /* Resource number [valid values are 0..31] */
1038 u8 resource;
1040 /* Allow to release a resource even if belongs to another PF */
1041 bool b_force;
1043 /* Will be set as true if the resource is released */
1044 bool b_released;
1048 * @brief Releases MFW generic resource lock
1050 * @param p_hwfn
1051 * @param p_ptt
1052 * @param p_params
1054 * @return int - 0 - operation was successful.
1057 qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
1058 struct qed_ptt *p_ptt,
1059 struct qed_resc_unlock_params *p_params);
1062 * @brief - default initialization for lock/unlock resource structs
1064 * @param p_lock - lock params struct to be initialized; Can be NULL
1065 * @param p_unlock - unlock params struct to be initialized; Can be NULL
1066 * @param resource - the requested resource
1067 * @paral b_is_permanent - disable retries & aging when set
1069 void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params *p_lock,
1070 struct qed_resc_unlock_params *p_unlock,
1071 enum qed_resc_lock
1072 resource, bool b_is_permanent);
1074 * @brief Learn of supported MFW features; To be done during early init
1076 * @param p_hwfn
1077 * @param p_ptt
1079 int qed_mcp_get_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1082 * @brief Inform MFW of set of features supported by driver. Should be done
1083 * inside the content of the LOAD_REQ.
1085 * @param p_hwfn
1086 * @param p_ptt
1088 int qed_mcp_set_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1091 * @brief Read ufp config from the shared memory.
1093 * @param p_hwfn
1094 * @param p_ptt
1096 void qed_mcp_read_ufp_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1099 * @brief Populate the nvm info shadow in the given hardware function
1101 * @param p_hwfn
1103 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
1105 #endif