1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
15 #define T_ETH_INDIRECTION_TABLE_SIZE 128
16 #define T_ETH_RSS_KEY_SIZE 10
18 struct vf_pf_resc_request {
34 #define TLV_BUFFER_SIZE 1024
40 PFVF_STATUS_NOT_SUPPORTED,
41 PFVF_STATUS_NO_RESOURCE,
45 /* vf pf channel tlvs */
46 /* general tlv header (used for both vf->pf request and pf->vf response) */
52 /* header of first vf->pf tlv carries the offset used to calculate reponse
55 struct vfpf_first_tlv {
56 struct channel_tlv tl;
61 /* header of pf->vf tlvs, carries the status of handling the request */
63 struct channel_tlv tl;
68 /* response tlv used for most tlvs */
69 struct pfvf_def_resp_tlv {
73 /* used to terminate and pad a tlv list */
74 struct channel_list_end_tlv {
75 struct channel_tlv tl;
79 #define VFPF_ACQUIRE_OS_LINUX (0)
80 #define VFPF_ACQUIRE_OS_WINDOWS (1)
81 #define VFPF_ACQUIRE_OS_ESX (2)
82 #define VFPF_ACQUIRE_OS_SOLARIS (3)
83 #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
85 struct vfpf_acquire_tlv {
86 struct vfpf_first_tlv first_tlv;
88 struct vf_pf_vfdev_info {
89 #define VFPF_ACQUIRE_CAP_PRE_FP_HSI (1 << 0) /* VF pre-FP hsi version */
90 #define VFPF_ACQUIRE_CAP_100G (1 << 1) /* VF can support 100g */
97 u16 opaque_fid; /* ME register value */
98 u8 os_type; /* VFPF_ACQUIRE_OS_* value */
104 struct vf_pf_resc_request resc_request;
111 /* receive side scaling tlv */
112 struct vfpf_vport_update_rss_tlv {
113 struct channel_tlv tl;
116 #define VFPF_UPDATE_RSS_CONFIG_FLAG BIT(0)
117 #define VFPF_UPDATE_RSS_CAPS_FLAG BIT(1)
118 #define VFPF_UPDATE_RSS_IND_TABLE_FLAG BIT(2)
119 #define VFPF_UPDATE_RSS_KEY_FLAG BIT(3)
123 u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
124 u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
125 u32 rss_key[T_ETH_RSS_KEY_SIZE];
128 struct pfvf_storm_stats {
133 struct pfvf_stats_info {
134 struct pfvf_storm_stats mstats;
135 struct pfvf_storm_stats pstats;
136 struct pfvf_storm_stats tstats;
137 struct pfvf_storm_stats ustats;
140 struct pfvf_acquire_resp_tlv {
143 struct pf_vf_pfdev_info {
153 #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED BIT(0)
154 #define PFVF_ACQUIRE_CAP_100G BIT(1) /* If set, 100g PF */
155 /* There are old PF versions where the PF might mistakenly override the sanity
156 * mechanism [version-based] and allow a VF that can't be supported to pass
157 * the acquisition phase.
158 * To overcome this, PFs now indicate that they're past that point and the new
159 * VFs would fail probe on the older PFs that fail to do so.
161 #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE BIT(2)
167 /* These should match the PF's qed_dev values */
173 struct pfvf_stats_info stats_info;
175 u8 port_mac[ETH_ALEN];
177 /* It's possible PF had to configure an older fastpath HSI
178 * [in case VF is newer than PF]. This is communicated back
179 * to the VF. It can also be used in case of error due to
180 * non-matching versions to shed light in VF about failure.
187 #define PFVF_MAX_QUEUES_PER_VF 16
188 #define PFVF_MAX_SBS_PER_VF 16
189 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
190 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
191 u8 cid[PFVF_MAX_QUEUES_PER_VF];
206 struct pfvf_start_queue_resp_tlv {
208 u32 offset; /* offset to consumer/producer of queue */
213 struct vfpf_start_rxq_tlv {
214 struct vfpf_first_tlv first_tlv;
216 /* physical addresses */
218 u64 deprecated_sge_addr;
224 u16 hc_rate; /* desired interrupts per sec. */
232 struct vfpf_start_txq_tlv {
233 struct vfpf_first_tlv first_tlv;
235 /* physical addresses */
242 u32 flags; /* VFPF_QUEUE_FLG_X flags */
243 u16 hc_rate; /* desired interrupts per sec. */
249 struct vfpf_stop_rxqs_tlv {
250 struct vfpf_first_tlv first_tlv;
259 struct vfpf_stop_txqs_tlv {
260 struct vfpf_first_tlv first_tlv;
267 struct vfpf_update_rxq_tlv {
268 struct vfpf_first_tlv first_tlv;
270 u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
275 #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG BIT(0)
276 #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG BIT(1)
277 #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG BIT(2)
282 /* Set Queue Filters */
283 struct vfpf_q_mac_vlan_filter {
285 #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
286 #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
287 #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
296 struct vfpf_vport_start_tlv {
297 struct vfpf_first_tlv first_tlv;
299 u64 sb_addr[PFVF_MAX_SBS_PER_VF];
306 u8 inner_vlan_removal;
309 u8 max_buffers_per_cqe;
314 /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
315 struct vfpf_vport_update_activate_tlv {
316 struct channel_tlv tl;
323 struct vfpf_vport_update_tx_switch_tlv {
324 struct channel_tlv tl;
329 struct vfpf_vport_update_vlan_strip_tlv {
330 struct channel_tlv tl;
335 struct vfpf_vport_update_mcast_bin_tlv {
336 struct channel_tlv tl;
339 /* There are only 256 approx bins, and in HSI they're divided into
340 * 32-bit values. As old VFs used to set-bit to the values on its side,
341 * the upper half of the array is never expected to contain any data.
344 u64 obsolete_bins[4];
347 struct vfpf_vport_update_accept_param_tlv {
348 struct channel_tlv tl;
355 struct vfpf_vport_update_accept_any_vlan_tlv {
356 struct channel_tlv tl;
357 u8 update_accept_any_vlan_flg;
363 struct vfpf_vport_update_sge_tpa_tlv {
364 struct channel_tlv tl;
367 #define VFPF_TPA_IPV4_EN_FLAG BIT(0)
368 #define VFPF_TPA_IPV6_EN_FLAG BIT(1)
369 #define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
370 #define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
371 #define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
373 u8 update_sge_tpa_flags;
374 #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
375 #define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
376 #define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
378 u8 max_buffers_per_cqe;
380 u16 deprecated_sge_buff_size;
382 u16 tpa_min_size_to_start;
383 u16 tpa_min_size_to_cont;
389 /* Primary tlv as a header for various extended tlvs for
390 * various functionalities in vport update ramrod.
392 struct vfpf_vport_update_tlv {
393 struct vfpf_first_tlv first_tlv;
396 struct vfpf_ucast_filter_tlv {
397 struct vfpf_first_tlv first_tlv;
408 struct tlv_buffer_size {
409 u8 tlv_buffer[TLV_BUFFER_SIZE];
413 struct vfpf_first_tlv first_tlv;
414 struct vfpf_acquire_tlv acquire;
415 struct vfpf_start_rxq_tlv start_rxq;
416 struct vfpf_start_txq_tlv start_txq;
417 struct vfpf_stop_rxqs_tlv stop_rxqs;
418 struct vfpf_stop_txqs_tlv stop_txqs;
419 struct vfpf_update_rxq_tlv update_rxq;
420 struct vfpf_vport_start_tlv start_vport;
421 struct vfpf_vport_update_tlv vport_update;
422 struct vfpf_ucast_filter_tlv ucast_filter;
423 struct channel_list_end_tlv list_end;
424 struct tlv_buffer_size tlv_buf_size;
428 struct pfvf_def_resp_tlv default_resp;
429 struct pfvf_acquire_resp_tlv acquire_resp;
430 struct tlv_buffer_size tlv_buf_size;
431 struct pfvf_start_queue_resp_tlv queue_start;
434 enum qed_bulletin_bit {
435 /* Alert the VF that a forced MAC was set by the PF */
437 /* Alert the VF that a forced VLAN was set by the PF */
438 VLAN_ADDR_FORCED = 2,
440 /* Indicate that `default_only_untagged' contains actual data */
441 VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
442 VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
444 /* Alert the VF that suggested mac was sent by the PF.
445 * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
447 VFPF_BULLETIN_MAC_ADDR = 5
450 struct qed_bulletin_content {
451 /* crc of structure to ensure is not in mid-update */
456 /* bitmap indicating which fields hold valid values */
459 /* used for MAC_ADDR or MAC_ADDR_FORCED */
462 /* If valid, 1 => only untagged Rx if no vlan is configured */
463 u8 default_only_untagged;
466 /* The following is a 'copy' of qed_mcp_link_state,
467 * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
468 * possible the structs will increase further along the road we cannot
469 * have it here; Instead we need to have all of its fields.
472 u8 req_autoneg_pause;
478 u32 req_forced_speed;
486 u8 parallel_detection;
488 u8 partner_tx_flow_ctrl_en;
489 u8 partner_rx_flow_ctrl_en;
490 u8 partner_adv_pause;
495 u32 partner_adv_speed;
497 u32 capability_speed;
504 struct qed_bulletin {
506 struct qed_bulletin_content *p_virt;
511 CHANNEL_TLV_NONE, /* ends tlv sequence */
513 CHANNEL_TLV_VPORT_START,
514 CHANNEL_TLV_VPORT_UPDATE,
515 CHANNEL_TLV_VPORT_TEARDOWN,
516 CHANNEL_TLV_START_RXQ,
517 CHANNEL_TLV_START_TXQ,
518 CHANNEL_TLV_STOP_RXQS,
519 CHANNEL_TLV_STOP_TXQS,
520 CHANNEL_TLV_UPDATE_RXQ,
521 CHANNEL_TLV_INT_CLEANUP,
524 CHANNEL_TLV_LIST_END,
525 CHANNEL_TLV_UCAST_FILTER,
526 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
527 CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
528 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
529 CHANNEL_TLV_VPORT_UPDATE_MCAST,
530 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
531 CHANNEL_TLV_VPORT_UPDATE_RSS,
532 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
533 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
536 /* Required for iterating over vport-update tlvs.
537 * Will break in case non-sequential vport-update tlvs.
539 CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
542 /* This data is held in the qed_hwfn structure for VFs only. */
544 union vfpf_tlvs *vf2pf_request;
545 dma_addr_t vf2pf_request_phys;
546 union pfvf_tlvs *pf2vf_reply;
547 dma_addr_t pf2vf_reply_phys;
549 /* Should be taken whenever the mailbox buffers are accessed */
554 struct qed_bulletin bulletin;
555 struct qed_bulletin_content bulletin_shadow;
557 /* we set aside a copy of the acquire response */
558 struct pfvf_acquire_resp_tlv acquire_resp;
560 /* In case PF originates prior to the fp-hsi version comparison,
561 * this has to be propagated as it affects the fastpath.
566 #ifdef CONFIG_QED_SRIOV
568 * @brief Read the VF bulletin and act on it if needed
571 * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
573 * @return enum _qed_status
575 int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
578 * @brief Get link paramters for VF from qed
581 * @param params - the link params structure to be filled for the VF
583 void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
584 struct qed_mcp_link_params *params);
587 * @brief Get link state for VF from qed
590 * @param link - the link state structure to be filled for the VF
592 void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
593 struct qed_mcp_link_state *link);
596 * @brief Get link capabilities for VF from qed
599 * @param p_link_caps - the link capabilities structure to be filled for the VF
601 void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
602 struct qed_mcp_link_capabilities *p_link_caps);
605 * @brief Get number of Rx queues allocated for VF by qed
608 * @param num_rxqs - allocated RX queues
610 void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
613 * @brief Get port mac address for VF
616 * @param port_mac - destination location for port mac
618 void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
621 * @brief Get number of VLAN filters allocated for VF by qed
624 * @param num_rxqs - allocated VLAN filters
626 void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
627 u8 *num_vlan_filters);
630 * @brief Check if VF can set a MAC address
637 bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
640 * @brief Set firmware version information in dev_info from VFs acquire response tlv
648 void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
649 u16 *fw_major, u16 *fw_minor,
650 u16 *fw_rev, u16 *fw_eng);
653 * @brief hw preparation for VF
654 * sends ACQUIRE message
660 int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
663 * @brief VF - start the RX Queue by sending a message to the PF
665 * @param cid - zero based within the VF
666 * @param rx_queue_id - zero based within the VF
667 * @param sb - VF status block for this queue
668 * @param sb_index - Index within the status block
669 * @param bd_max_bytes - maximum number of bytes per bd
670 * @param bd_chain_phys_addr - physical address of bd chain
671 * @param cqe_pbl_addr - physical address of pbl
672 * @param cqe_pbl_size - pbl size
673 * @param pp_prod - pointer to the producer to be
678 int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
683 dma_addr_t bd_chain_phys_addr,
684 dma_addr_t cqe_pbl_addr,
685 u16 cqe_pbl_size, void __iomem **pp_prod);
688 * @brief VF - start the TX queue by sending a message to the
692 * @param tx_queue_id - zero based within the VF
693 * @param sb - status block for this queue
694 * @param sb_index - index within the status block
695 * @param bd_chain_phys_addr - physical address of tx chain
696 * @param pp_doorbell - pointer to address to which to
697 * write the doorbell too..
701 int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
706 u16 pbl_size, void __iomem **pp_doorbell);
709 * @brief VF - stop the RX queue by sending a message to the PF
713 * @param cqe_completion
717 int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
718 u16 rx_qid, bool cqe_completion);
721 * @brief VF - stop the TX queue by sending a message to the PF
728 int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, u16 tx_qid);
731 * @brief VF - send a vport update command
738 int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
739 struct qed_sp_vport_update_params *p_params);
743 * @brief VF - send a close message to PF
747 * @return enum _qed_status
749 int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
752 * @brief VF - free vf`s memories
756 * @return enum _qed_status
758 int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
761 * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
762 * sb_id. For VFs igu sbs don't have to be contiguous
769 u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
772 * @brief qed_vf_pf_vport_start - perform vport start for VF.
777 * @param inner_vlan_removal
779 * @param max_buffers_per_cqe,
780 * @param only_untagged - default behavior regarding vlan acceptance
782 * @return enum _qed_status
784 int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
787 u8 inner_vlan_removal,
788 enum qed_tpa_mode tpa_mode,
789 u8 max_buffers_per_cqe, u8 only_untagged);
792 * @brief qed_vf_pf_vport_stop - stop the VF's vport
796 * @return enum _qed_status
798 int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
800 int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
801 struct qed_filter_ucast *p_param);
803 void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
804 struct qed_filter_mcast *p_filter_cmd);
807 * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
811 * @return enum _qed_status
813 int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
816 * @brief - return the link params in a given bulletin board
819 * @param p_params - pointer to a struct to fill with link params
822 void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
823 struct qed_mcp_link_params *p_params,
824 struct qed_bulletin_content *p_bulletin);
827 * @brief - return the link state in a given bulletin board
830 * @param p_link - pointer to a struct to fill with link state
833 void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
834 struct qed_mcp_link_state *p_link,
835 struct qed_bulletin_content *p_bulletin);
838 * @brief - return the link capabilities in a given bulletin board
841 * @param p_link - pointer to a struct to fill with link capabilities
844 void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
845 struct qed_mcp_link_capabilities *p_link_caps,
846 struct qed_bulletin_content *p_bulletin);
848 void qed_iov_vf_task(struct work_struct *work);
850 static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
851 struct qed_mcp_link_params *params)
855 static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
856 struct qed_mcp_link_state *link)
861 qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
862 struct qed_mcp_link_capabilities *p_link_caps)
866 static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
870 static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
874 static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
875 u8 *num_vlan_filters)
879 static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
884 static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
885 u16 *fw_major, u16 *fw_minor,
886 u16 *fw_rev, u16 *fw_eng)
890 static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
895 static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
900 dma_addr_t bd_chain_phys_adr,
901 dma_addr_t cqe_pbl_addr,
902 u16 cqe_pbl_size, void __iomem **pp_prod)
907 static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
912 u16 pbl_size, void __iomem **pp_doorbell)
917 static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
918 u16 rx_qid, bool cqe_completion)
923 static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, u16 tx_qid)
929 qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
930 struct qed_sp_vport_update_params *p_params)
935 static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
940 static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
945 static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
950 static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
953 u8 inner_vlan_removal,
954 enum qed_tpa_mode tpa_mode,
955 u8 max_buffers_per_cqe,
961 static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
966 static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
967 struct qed_filter_ucast *p_param)
972 static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
973 struct qed_filter_mcast *p_filter_cmd)
977 static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
982 static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
983 struct qed_mcp_link_params
985 struct qed_bulletin_content
990 static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
991 struct qed_mcp_link_state *p_link,
992 struct qed_bulletin_content
998 __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
999 struct qed_mcp_link_capabilities *p_link_caps,
1000 struct qed_bulletin_content *p_bulletin)
1004 static inline void qed_iov_vf_task(struct work_struct *work)