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
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
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
36 #include <linux/types.h>
37 #include <linux/interrupt.h>
38 #include <linux/netdevice.h>
39 #include <linux/pci.h>
40 #include <linux/skbuff.h>
41 #include <linux/types.h>
42 #include <asm/byteorder.h>
44 #include <linux/compiler.h>
45 #include <linux/kernel.h>
46 #include <linux/list.h>
47 #include <linux/slab.h>
48 #include <linux/qed/common_hsi.h>
49 #include <linux/qed/qed_chain.h>
51 enum dcbx_protocol_type {
55 DCBX_PROTOCOL_ROCE_V2,
57 DCBX_MAX_PROTOCOL_TYPE
60 #define QED_ROCE_PROTOCOL_INDEX (3)
62 #define QED_LLDP_CHASSIS_ID_STAT_LEN 4
63 #define QED_LLDP_PORT_ID_STAT_LEN 4
64 #define QED_DCBX_MAX_APP_PROTOCOL 32
65 #define QED_MAX_PFC_PRIORITIES 8
66 #define QED_DCBX_DSCP_SIZE 64
68 struct qed_dcbx_lldp_remote {
69 u32 peer_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
70 u32 peer_port_id[QED_LLDP_PORT_ID_STAT_LEN];
77 struct qed_dcbx_lldp_local {
78 u32 local_chassis_id[QED_LLDP_CHASSIS_ID_STAT_LEN];
79 u32 local_port_id[QED_LLDP_PORT_ID_STAT_LEN];
82 struct qed_dcbx_app_prio {
90 struct qed_dbcx_pfc_params {
93 u8 prio[QED_MAX_PFC_PRIORITIES];
97 enum qed_dcbx_sf_ieee_type {
98 QED_DCBX_SF_IEEE_ETHTYPE,
99 QED_DCBX_SF_IEEE_TCP_PORT,
100 QED_DCBX_SF_IEEE_UDP_PORT,
101 QED_DCBX_SF_IEEE_TCP_UDP_PORT
104 struct qed_app_entry {
106 enum qed_dcbx_sf_ieee_type sf_ieee;
110 enum dcbx_protocol_type proto_type;
113 struct qed_dcbx_params {
114 struct qed_app_entry app_entry[QED_DCBX_MAX_APP_PROTOCOL];
123 u8 ets_pri_tc_tbl[QED_MAX_PFC_PRIORITIES];
124 u8 ets_tc_bw_tbl[QED_MAX_PFC_PRIORITIES];
125 u8 ets_tc_tsa_tbl[QED_MAX_PFC_PRIORITIES];
126 struct qed_dbcx_pfc_params pfc;
130 struct qed_dcbx_admin_params {
131 struct qed_dcbx_params params;
135 struct qed_dcbx_remote_params {
136 struct qed_dcbx_params params;
140 struct qed_dcbx_operational_params {
141 struct qed_dcbx_app_prio app_prio;
142 struct qed_dcbx_params params;
151 struct qed_dcbx_get {
152 struct qed_dcbx_operational_params operational;
153 struct qed_dcbx_lldp_remote lldp_remote;
154 struct qed_dcbx_lldp_local lldp_local;
155 struct qed_dcbx_remote_params remote;
156 struct qed_dcbx_admin_params local;
159 enum qed_nvm_images {
160 QED_NVM_IMAGE_ISCSI_CFG,
161 QED_NVM_IMAGE_FCOE_CFG,
162 QED_NVM_IMAGE_NVM_CFG1,
163 QED_NVM_IMAGE_DEFAULT_CFG,
164 QED_NVM_IMAGE_NVM_META,
167 struct qed_link_eee_params {
169 #define QED_EEE_1G_ADV BIT(0)
170 #define QED_EEE_10G_ADV BIT(1)
172 /* Capabilities are represented using QED_EEE_*_ADV values */
185 struct qed_mfw_tlv_eth {
187 bool lso_maxoff_size_set;
189 bool lso_minseg_size_set;
193 bool tx_descr_size_set;
195 bool rx_descr_size_set;
199 bool tcp4_offloads_set;
201 bool tcp6_offloads_set;
203 bool tx_descr_qdepth_set;
205 bool rx_descr_qdepth_set;
207 #define QED_MFW_TLV_IOV_OFFLOAD_NONE (0)
208 #define QED_MFW_TLV_IOV_OFFLOAD_MULTIQUEUE (1)
209 #define QED_MFW_TLV_IOV_OFFLOAD_VEB (2)
210 #define QED_MFW_TLV_IOV_OFFLOAD_VEPA (3)
211 bool iov_offload_set;
217 bool num_txqs_full_set;
219 bool num_rxqs_full_set;
222 #define QED_MFW_TLV_TIME_SIZE 14
223 struct qed_mfw_tlv_time {
233 struct qed_mfw_tlv_fcoe {
235 bool scsi_timeout_set;
249 bool num_npiv_ids_set;
251 bool switch_name_set;
253 bool switch_portnum_set;
255 bool switch_portid_set;
257 bool vendor_name_set;
259 bool switch_model_set;
260 u8 switch_fw_version[8];
261 bool switch_fw_version_set;
267 #define QED_MFW_TLV_PORT_STATE_OFFLINE (0)
268 #define QED_MFW_TLV_PORT_STATE_LOOP (1)
269 #define QED_MFW_TLV_PORT_STATE_P2P (2)
270 #define QED_MFW_TLV_PORT_STATE_FABRIC (3)
272 u16 fip_tx_descr_size;
273 bool fip_tx_descr_size_set;
274 u16 fip_rx_descr_size;
275 bool fip_rx_descr_size_set;
277 bool link_failures_set;
278 u8 fcoe_boot_progress;
279 bool fcoe_boot_progress_set;
285 bool fcoe_txq_depth_set;
287 bool fcoe_rxq_depth_set;
289 bool fcoe_rx_frames_set;
291 bool fcoe_rx_bytes_set;
293 bool fcoe_tx_frames_set;
295 bool fcoe_tx_bytes_set;
298 u32 crc_err_src_fcid[5];
299 bool crc_err_src_fcid_set[5];
300 struct qed_mfw_tlv_time crc_err[5];
306 bool primtive_err_set;
308 bool disparity_err_set;
309 u16 code_violation_err;
310 bool code_violation_err_set;
312 bool flogi_param_set[4];
313 struct qed_mfw_tlv_time flogi_tstamp;
314 u32 flogi_acc_param[4];
315 bool flogi_acc_param_set[4];
316 struct qed_mfw_tlv_time flogi_acc_tstamp;
319 struct qed_mfw_tlv_time flogi_rjt_tstamp;
332 u32 plogi_dst_fcid[5];
333 bool plogi_dst_fcid_set[5];
334 struct qed_mfw_tlv_time plogi_tstamp[5];
335 u32 plogi_acc_src_fcid[5];
336 bool plogi_acc_src_fcid_set[5];
337 struct qed_mfw_tlv_time plogi_acc_tstamp[5];
344 u32 plogo_src_fcid[5];
345 bool plogo_src_fcid_set[5];
346 struct qed_mfw_tlv_time plogo_tstamp[5];
358 bool rx_abts_acc_set;
360 bool rx_abts_rjt_set;
361 u32 abts_dst_fcid[5];
362 bool abts_dst_fcid_set[5];
363 struct qed_mfw_tlv_time abts_tstamp[5];
366 u32 rx_rscn_nport[4];
367 bool rx_rscn_nport_set[4];
371 bool abort_task_sets_set;
395 bool scsi_cond_met_set;
400 u8 scsi_inter_cond_met;
401 bool scsi_inter_cond_met_set;
402 u8 scsi_rsv_conflicts;
403 bool scsi_rsv_conflicts_set;
405 bool scsi_tsk_full_set;
407 bool scsi_aca_active_set;
409 bool scsi_tsk_abort_set;
411 bool scsi_rx_chk_set[5];
412 struct qed_mfw_tlv_time scsi_chk_tstamp[5];
415 struct qed_mfw_tlv_iscsi {
417 bool target_llmnr_set;
419 bool header_digest_set;
421 bool data_digest_set;
423 #define QED_MFW_TLV_AUTH_METHOD_NONE (1)
424 #define QED_MFW_TLV_AUTH_METHOD_CHAP (2)
425 #define QED_MFW_TLV_AUTH_METHOD_MUTUAL_CHAP (3)
426 bool auth_method_set;
427 u16 boot_taget_portal;
428 bool boot_taget_portal_set;
432 bool tx_desc_size_set;
434 bool rx_desc_size_set;
436 bool boot_progress_set;
438 bool tx_desc_qdepth_set;
440 bool rx_desc_qdepth_set;
451 #define DIRECT_REG_WR(reg_addr, val) writel((u32)val, \
452 (void __iomem *)(reg_addr))
454 #define DIRECT_REG_RD(reg_addr) readl((void __iomem *)(reg_addr))
456 #define QED_COALESCE_MAX 0x1FF
457 #define QED_DEFAULT_RX_USECS 12
458 #define QED_DEFAULT_TX_USECS 48
463 struct qed_eth_pf_params {
464 /* The following parameters are used during HW-init
465 * and these parameters need to be passed as arguments
466 * to update_pf_params routine invoked before slowpath start
470 /* per-VF number of CIDs */
472 #define ETH_PF_PARAMS_VF_CONS_DEFAULT (32)
474 /* To enable arfs, previous to HW-init a positive number needs to be
475 * set [as filters require allocated searcher ILT memory].
476 * This will set the maximal number of configured steering-filters.
478 u32 num_arfs_filters;
481 struct qed_fcoe_pf_params {
482 /* The following parameters are used during protocol-init */
483 u64 glbl_q_params_addr;
484 u64 bdq_pbl_base_addr[2];
486 /* The following parameters are used during HW-init
487 * and these parameters need to be passed as arguments
488 * to update_pf_params routine invoked before slowpath start
493 /* The following parameters are used during protocol-init */
494 u16 sq_num_pbl_pages;
497 u16 cmdq_num_entries;
498 u16 rq_buffer_log_size;
501 u16 bdq_xoff_threshold[2];
502 u16 bdq_xon_threshold[2];
504 u8 num_cqs; /* num of global CQs */
510 u8 bdq_pbl_num_entries[2];
513 /* Most of the the parameters below are described in the FW iSCSI / TCP HSI */
514 struct qed_iscsi_pf_params {
515 u64 glbl_q_params_addr;
516 u64 bdq_pbl_base_addr[3];
518 u16 cmdq_num_entries;
522 /* The following parameters are used during HW-init
523 * and these parameters need to be passed as arguments
524 * to update_pf_params routine invoked before slowpath start
529 /* The following parameters are used during protocol-init */
530 u16 half_way_close_timeout;
531 u16 bdq_xoff_threshold[3];
532 u16 bdq_xon_threshold[3];
533 u16 cmdq_xoff_threshold;
534 u16 cmdq_xon_threshold;
537 u8 num_sq_pages_in_ring;
538 u8 num_r2tq_pages_in_ring;
539 u8 num_uhq_pages_in_ring;
551 u8 soc_num_of_blocks_log;
552 u8 bdq_pbl_num_entries[3];
555 struct qed_rdma_pf_params {
556 /* Supplied to QED during resource allocation (may affect the ILT and
559 u32 min_dpis; /* number of requested DPIs */
560 u32 num_qps; /* number of requested Queue Pairs */
561 u32 num_srqs; /* number of requested SRQ */
562 u8 roce_edpm_mode; /* see QED_ROCE_EDPM_MODE_ENABLE */
563 u8 gl_pi; /* protocol index */
565 /* Will allocate rate limiters to be used with QPs */
569 struct qed_pf_params {
570 struct qed_eth_pf_params eth_pf_params;
571 struct qed_fcoe_pf_params fcoe_pf_params;
572 struct qed_iscsi_pf_params iscsi_pf_params;
573 struct qed_rdma_pf_params rdma_pf_params;
584 struct status_block_e4 *sb_virt;
586 u32 sb_ack; /* Last given ack */
588 void __iomem *igu_addr;
590 #define QED_SB_INFO_INIT 0x1
591 #define QED_SB_INFO_SETUP 0x2
593 struct qed_dev *cdev;
601 struct qed_dev_info {
602 unsigned long pci_mem_start;
603 unsigned long pci_mem_end;
604 unsigned int pci_irq;
617 #define QED_MFW_VERSION_0_MASK 0x000000FF
618 #define QED_MFW_VERSION_0_OFFSET 0
619 #define QED_MFW_VERSION_1_MASK 0x0000FF00
620 #define QED_MFW_VERSION_1_OFFSET 8
621 #define QED_MFW_VERSION_2_MASK 0x00FF0000
622 #define QED_MFW_VERSION_2_OFFSET 16
623 #define QED_MFW_VERSION_3_MASK 0xFF000000
624 #define QED_MFW_VERSION_3_OFFSET 24
627 bool b_inter_pf_switch;
636 #define QED_MBI_VERSION_0_MASK 0x000000FF
637 #define QED_MBI_VERSION_0_OFFSET 0
638 #define QED_MBI_VERSION_1_MASK 0x0000FF00
639 #define QED_MBI_VERSION_1_OFFSET 8
640 #define QED_MBI_VERSION_2_MASK 0x00FF0000
641 #define QED_MBI_VERSION_2_OFFSET 16
643 enum qed_dev_type dev_type;
645 /* Output parameters for qede */
654 QED_SB_TYPE_L2_QUEUE,
665 enum qed_link_mode_bits {
666 QED_LM_FIBRE_BIT = BIT(0),
667 QED_LM_Autoneg_BIT = BIT(1),
668 QED_LM_Asym_Pause_BIT = BIT(2),
669 QED_LM_Pause_BIT = BIT(3),
670 QED_LM_1000baseT_Half_BIT = BIT(4),
671 QED_LM_1000baseT_Full_BIT = BIT(5),
672 QED_LM_10000baseKR_Full_BIT = BIT(6),
673 QED_LM_25000baseKR_Full_BIT = BIT(7),
674 QED_LM_40000baseLR4_Full_BIT = BIT(8),
675 QED_LM_50000baseKR2_Full_BIT = BIT(9),
676 QED_LM_100000baseKR4_Full_BIT = BIT(10),
680 struct qed_link_params {
683 #define QED_LINK_OVERRIDE_SPEED_AUTONEG BIT(0)
684 #define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS BIT(1)
685 #define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED BIT(2)
686 #define QED_LINK_OVERRIDE_PAUSE_CONFIG BIT(3)
687 #define QED_LINK_OVERRIDE_LOOPBACK_MODE BIT(4)
688 #define QED_LINK_OVERRIDE_EEE_CONFIG BIT(5)
693 #define QED_LINK_PAUSE_AUTONEG_ENABLE BIT(0)
694 #define QED_LINK_PAUSE_RX_ENABLE BIT(1)
695 #define QED_LINK_PAUSE_TX_ENABLE BIT(2)
697 #define QED_LINK_LOOPBACK_NONE BIT(0)
698 #define QED_LINK_LOOPBACK_INT_PHY BIT(1)
699 #define QED_LINK_LOOPBACK_EXT_PHY BIT(2)
700 #define QED_LINK_LOOPBACK_EXT BIT(3)
701 #define QED_LINK_LOOPBACK_MAC BIT(4)
703 struct qed_link_eee_params eee;
706 struct qed_link_output {
709 /* In QED_LM_* defs */
714 u32 speed; /* In Mb/s */
715 u8 duplex; /* In DUPLEX defs */
716 u8 port; /* In PORT defs */
720 /* EEE - capability & param */
724 struct qed_link_eee_params eee;
727 struct qed_probe_params {
728 enum qed_protocol protocol;
734 #define QED_DRV_VER_STR_SIZE 12
735 struct qed_slowpath_params {
741 u8 name[QED_DRV_VER_STR_SIZE];
744 #define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
746 struct qed_int_info {
747 struct msix_entry *msix;
750 /* This should be updated by the protocol driver */
754 struct qed_generic_tlvs {
755 #define QED_TLV_IP_CSUM BIT(0)
756 #define QED_TLV_LSO BIT(1)
758 #define QED_TLV_MAC_COUNT 3
759 u8 mac[QED_TLV_MAC_COUNT][ETH_ALEN];
762 #define QED_NVM_SIGNATURE 0x12435687
764 enum qed_nvm_flash_cmd {
765 QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
766 QED_NVM_FLASH_CMD_FILE_START = 0x3,
767 QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
768 QED_NVM_FLASH_CMD_NVM_MAX,
771 struct qed_common_cb_ops {
772 void (*arfs_filter_op)(void *dev, void *fltr, u8 fw_rc);
773 void (*link_update)(void *dev,
774 struct qed_link_output *link);
775 void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
776 void (*get_generic_tlv_data)(void *dev, struct qed_generic_tlvs *data);
777 void (*get_protocol_tlv_data)(void *dev, void *data);
780 struct qed_selftest_ops {
782 * @brief selftest_interrupt - Perform interrupt test
786 * @return 0 on success, error otherwise.
788 int (*selftest_interrupt)(struct qed_dev *cdev);
791 * @brief selftest_memory - Perform memory test
795 * @return 0 on success, error otherwise.
797 int (*selftest_memory)(struct qed_dev *cdev);
800 * @brief selftest_register - Perform register test
804 * @return 0 on success, error otherwise.
806 int (*selftest_register)(struct qed_dev *cdev);
809 * @brief selftest_clock - Perform clock test
813 * @return 0 on success, error otherwise.
815 int (*selftest_clock)(struct qed_dev *cdev);
818 * @brief selftest_nvram - Perform nvram test
822 * @return 0 on success, error otherwise.
824 int (*selftest_nvram) (struct qed_dev *cdev);
827 struct qed_common_ops {
828 struct qed_selftest_ops *selftest;
830 struct qed_dev* (*probe)(struct pci_dev *dev,
831 struct qed_probe_params *params);
833 void (*remove)(struct qed_dev *cdev);
835 int (*set_power_state)(struct qed_dev *cdev,
838 void (*set_name) (struct qed_dev *cdev, char name[]);
840 /* Client drivers need to make this call before slowpath_start.
841 * PF params required for the call before slowpath_start is
842 * documented within the qed_pf_params structure definition.
844 void (*update_pf_params)(struct qed_dev *cdev,
845 struct qed_pf_params *params);
846 int (*slowpath_start)(struct qed_dev *cdev,
847 struct qed_slowpath_params *params);
849 int (*slowpath_stop)(struct qed_dev *cdev);
851 /* Requests to use `cnt' interrupts for fastpath.
852 * upon success, returns number of interrupts allocated for fastpath.
854 int (*set_fp_int)(struct qed_dev *cdev,
857 /* Fills `info' with pointers required for utilizing interrupts */
858 int (*get_fp_int)(struct qed_dev *cdev,
859 struct qed_int_info *info);
861 u32 (*sb_init)(struct qed_dev *cdev,
862 struct qed_sb_info *sb_info,
864 dma_addr_t sb_phy_addr,
866 enum qed_sb_type type);
868 u32 (*sb_release)(struct qed_dev *cdev,
869 struct qed_sb_info *sb_info,
872 void (*simd_handler_config)(struct qed_dev *cdev,
875 void (*handler)(void *));
877 void (*simd_handler_clean)(struct qed_dev *cdev,
879 int (*dbg_grc)(struct qed_dev *cdev,
880 void *buffer, u32 *num_dumped_bytes);
882 int (*dbg_grc_size)(struct qed_dev *cdev);
884 int (*dbg_all_data) (struct qed_dev *cdev, void *buffer);
886 int (*dbg_all_data_size) (struct qed_dev *cdev);
889 * @brief can_link_change - can the instance change the link or not
893 * @return true if link-change is allowed, false otherwise.
895 bool (*can_link_change)(struct qed_dev *cdev);
898 * @brief set_link - set links according to params
901 * @param params - values used to override the default link configuration
903 * @return 0 on success, error otherwise.
905 int (*set_link)(struct qed_dev *cdev,
906 struct qed_link_params *params);
909 * @brief get_link - returns the current link state.
912 * @param if_link - structure to be filled with current link configuration.
914 void (*get_link)(struct qed_dev *cdev,
915 struct qed_link_output *if_link);
918 * @brief - drains chip in case Tx completions fail to arrive due to pause.
922 int (*drain)(struct qed_dev *cdev);
925 * @brief update_msglvl - update module debug level
931 void (*update_msglvl)(struct qed_dev *cdev,
935 int (*chain_alloc)(struct qed_dev *cdev,
936 enum qed_chain_use_mode intended_use,
937 enum qed_chain_mode mode,
938 enum qed_chain_cnt_type cnt_type,
941 struct qed_chain *p_chain,
942 struct qed_chain_ext_pbl *ext_pbl);
944 void (*chain_free)(struct qed_dev *cdev,
945 struct qed_chain *p_chain);
948 * @brief nvm_flash - Flash nvm data.
951 * @param name - file containing the data
953 * @return 0 on success, error otherwise.
955 int (*nvm_flash)(struct qed_dev *cdev, const char *name);
958 * @brief nvm_get_image - reads an entire image from nvram
961 * @param type - type of the request nvram image
962 * @param buf - preallocated buffer to fill with the image
963 * @param len - length of the allocated buffer
965 * @return 0 on success, error otherwise
967 int (*nvm_get_image)(struct qed_dev *cdev,
968 enum qed_nvm_images type, u8 *buf, u16 len);
971 * @brief set_coalesce - Configure Rx coalesce value in usec
974 * @param rx_coal - Rx coalesce value in usec
975 * @param tx_coal - Tx coalesce value in usec
976 * @param qid - Queue index
977 * @param sb_id - Status Block Id
979 * @return 0 on success, error otherwise.
981 int (*set_coalesce)(struct qed_dev *cdev,
982 u16 rx_coal, u16 tx_coal, void *handle);
985 * @brief set_led - Configure LED mode
988 * @param mode - LED mode
990 * @return 0 on success, error otherwise.
992 int (*set_led)(struct qed_dev *cdev,
993 enum qed_led_mode mode);
996 * @brief update_drv_state - API to inform the change in the driver state.
1002 int (*update_drv_state)(struct qed_dev *cdev, bool active);
1005 * @brief update_mac - API to inform the change in the mac address
1011 int (*update_mac)(struct qed_dev *cdev, u8 *mac);
1014 * @brief update_mtu - API to inform the change in the mtu
1020 int (*update_mtu)(struct qed_dev *cdev, u16 mtu);
1023 * @brief update_wol - update of changes in the WoL configuration
1026 * @param enabled - true iff WoL should be enabled.
1028 int (*update_wol) (struct qed_dev *cdev, bool enabled);
1031 #define MASK_FIELD(_name, _value) \
1032 ((_value) &= (_name ## _MASK))
1034 #define FIELD_VALUE(_name, _value) \
1035 ((_value & _name ## _MASK) << _name ## _SHIFT)
1037 #define SET_FIELD(value, name, flag) \
1039 (value) &= ~(name ## _MASK << name ## _SHIFT); \
1040 (value) |= (((u64)flag) << (name ## _SHIFT)); \
1043 #define GET_FIELD(value, name) \
1044 (((value) >> (name ## _SHIFT)) & name ## _MASK)
1046 /* Debug print definitions */
1047 #define DP_ERR(cdev, fmt, ...) \
1049 pr_err("[%s:%d(%s)]" fmt, \
1050 __func__, __LINE__, \
1051 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
1055 #define DP_NOTICE(cdev, fmt, ...) \
1057 if (unlikely((cdev)->dp_level <= QED_LEVEL_NOTICE)) { \
1058 pr_notice("[%s:%d(%s)]" fmt, \
1059 __func__, __LINE__, \
1060 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
1066 #define DP_INFO(cdev, fmt, ...) \
1068 if (unlikely((cdev)->dp_level <= QED_LEVEL_INFO)) { \
1069 pr_notice("[%s:%d(%s)]" fmt, \
1070 __func__, __LINE__, \
1071 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
1076 #define DP_VERBOSE(cdev, module, fmt, ...) \
1078 if (unlikely(((cdev)->dp_level <= QED_LEVEL_VERBOSE) && \
1079 ((cdev)->dp_module & module))) { \
1080 pr_notice("[%s:%d(%s)]" fmt, \
1081 __func__, __LINE__, \
1082 DP_NAME(cdev) ? DP_NAME(cdev) : "", \
1088 QED_LEVEL_VERBOSE = 0x0,
1089 QED_LEVEL_INFO = 0x1,
1090 QED_LEVEL_NOTICE = 0x2,
1091 QED_LEVEL_ERR = 0x3,
1094 #define QED_LOG_LEVEL_SHIFT (30)
1095 #define QED_LOG_VERBOSE_MASK (0x3fffffff)
1096 #define QED_LOG_INFO_MASK (0x40000000)
1097 #define QED_LOG_NOTICE_MASK (0x80000000)
1100 QED_MSG_SPQ = 0x10000,
1101 QED_MSG_STATS = 0x20000,
1102 QED_MSG_DCB = 0x40000,
1103 QED_MSG_IOV = 0x80000,
1104 QED_MSG_SP = 0x100000,
1105 QED_MSG_STORAGE = 0x200000,
1106 QED_MSG_CXT = 0x800000,
1107 QED_MSG_LL2 = 0x1000000,
1108 QED_MSG_ILT = 0x2000000,
1109 QED_MSG_RDMA = 0x4000000,
1110 QED_MSG_DEBUG = 0x8000000,
1111 /* to be added...up to 0x8000000 */
1120 struct qed_eth_stats_common {
1121 u64 no_buff_discards;
1122 u64 packet_too_big_discard;
1130 u64 mftag_filter_discards;
1131 u64 mac_filter_discards;
1132 u64 gft_filter_drop;
1139 u64 tx_err_drop_pkts;
1140 u64 tpa_coalesced_pkts;
1141 u64 tpa_coalesced_events;
1143 u64 tpa_not_coalesced_pkts;
1144 u64 tpa_coalesced_bytes;
1147 u64 rx_64_byte_packets;
1148 u64 rx_65_to_127_byte_packets;
1149 u64 rx_128_to_255_byte_packets;
1150 u64 rx_256_to_511_byte_packets;
1151 u64 rx_512_to_1023_byte_packets;
1152 u64 rx_1024_to_1518_byte_packets;
1154 u64 rx_mac_crtl_frames;
1155 u64 rx_pause_frames;
1157 u64 rx_align_errors;
1158 u64 rx_carrier_errors;
1159 u64 rx_oversize_packets;
1161 u64 rx_undersize_packets;
1163 u64 tx_64_byte_packets;
1164 u64 tx_65_to_127_byte_packets;
1165 u64 tx_128_to_255_byte_packets;
1166 u64 tx_256_to_511_byte_packets;
1167 u64 tx_512_to_1023_byte_packets;
1168 u64 tx_1024_to_1518_byte_packets;
1169 u64 tx_pause_frames;
1174 u64 rx_mac_uc_packets;
1175 u64 rx_mac_mc_packets;
1176 u64 rx_mac_bc_packets;
1177 u64 rx_mac_frames_ok;
1179 u64 tx_mac_uc_packets;
1180 u64 tx_mac_mc_packets;
1181 u64 tx_mac_bc_packets;
1182 u64 tx_mac_ctrl_frames;
1183 u64 link_change_count;
1186 struct qed_eth_stats_bb {
1187 u64 rx_1519_to_1522_byte_packets;
1188 u64 rx_1519_to_2047_byte_packets;
1189 u64 rx_2048_to_4095_byte_packets;
1190 u64 rx_4096_to_9216_byte_packets;
1191 u64 rx_9217_to_16383_byte_packets;
1192 u64 tx_1519_to_2047_byte_packets;
1193 u64 tx_2048_to_4095_byte_packets;
1194 u64 tx_4096_to_9216_byte_packets;
1195 u64 tx_9217_to_16383_byte_packets;
1196 u64 tx_lpi_entry_count;
1197 u64 tx_total_collisions;
1200 struct qed_eth_stats_ah {
1201 u64 rx_1519_to_max_byte_packets;
1202 u64 tx_1519_to_max_byte_packets;
1205 struct qed_eth_stats {
1206 struct qed_eth_stats_common common;
1209 struct qed_eth_stats_bb bb;
1210 struct qed_eth_stats_ah ah;
1214 #define QED_SB_IDX 0x0002
1217 #define TX_PI(tc) (RX_PI + 1 + tc)
1219 struct qed_sb_cnt_info {
1220 /* Original, current, and free SBs for PF */
1225 /* Original, current and free SBS for child VFs */
1231 static inline u16 qed_sb_update_sb_idx(struct qed_sb_info *sb_info)
1236 prod = le32_to_cpu(sb_info->sb_virt->prod_index) &
1237 STATUS_BLOCK_E4_PROD_INDEX_MASK;
1238 if (sb_info->sb_ack != prod) {
1239 sb_info->sb_ack = prod;
1250 * @brief This function creates an update command for interrupts that is
1251 * written to the IGU.
1253 * @param sb_info - This is the structure allocated and
1254 * initialized per status block. Assumption is
1255 * that it was initialized using qed_sb_init
1256 * @param int_cmd - Enable/Disable/Nop
1257 * @param upd_flg - whether igu consumer should be
1260 * @return inline void
1262 static inline void qed_sb_ack(struct qed_sb_info *sb_info,
1263 enum igu_int_cmd int_cmd,
1266 struct igu_prod_cons_update igu_ack = { 0 };
1268 igu_ack.sb_id_and_flags =
1269 ((sb_info->sb_ack << IGU_PROD_CONS_UPDATE_SB_INDEX_SHIFT) |
1270 (upd_flg << IGU_PROD_CONS_UPDATE_UPDATE_FLAG_SHIFT) |
1271 (int_cmd << IGU_PROD_CONS_UPDATE_ENABLE_INT_SHIFT) |
1272 (IGU_SEG_ACCESS_REG <<
1273 IGU_PROD_CONS_UPDATE_SEGMENT_ACCESS_SHIFT));
1275 DIRECT_REG_WR(sb_info->igu_addr, igu_ack.sb_id_and_flags);
1277 /* Both segments (interrupts & acks) are written to same place address;
1278 * Need to guarantee all commands will be received (in-order) by HW.
1284 static inline void __internal_ram_wr(void *p_hwfn,
1292 for (i = 0; i < size / sizeof(*data); i++)
1293 DIRECT_REG_WR(&((u32 __iomem *)addr)[i], data[i]);
1296 static inline void internal_ram_wr(void __iomem *addr,
1300 __internal_ram_wr(NULL, addr, size, data);
1306 QED_RSS_IPV4_TCP = 0x4,
1307 QED_RSS_IPV6_TCP = 0x8,
1308 QED_RSS_IPV4_UDP = 0x10,
1309 QED_RSS_IPV6_UDP = 0x20,
1312 #define QED_RSS_IND_TABLE_SIZE 128
1313 #define QED_RSS_KEY_SIZE 10 /* size in 32b chunks */