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_OBSOLETE (1 << 0)
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
;
342 struct vfpf_vport_update_accept_param_tlv
{
343 struct channel_tlv tl
;
350 struct vfpf_vport_update_accept_any_vlan_tlv
{
351 struct channel_tlv tl
;
352 u8 update_accept_any_vlan_flg
;
358 struct vfpf_vport_update_sge_tpa_tlv
{
359 struct channel_tlv tl
;
362 #define VFPF_TPA_IPV4_EN_FLAG BIT(0)
363 #define VFPF_TPA_IPV6_EN_FLAG BIT(1)
364 #define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
365 #define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
366 #define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
368 u8 update_sge_tpa_flags
;
369 #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
370 #define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
371 #define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
373 u8 max_buffers_per_cqe
;
375 u16 deprecated_sge_buff_size
;
377 u16 tpa_min_size_to_start
;
378 u16 tpa_min_size_to_cont
;
384 /* Primary tlv as a header for various extended tlvs for
385 * various functionalities in vport update ramrod.
387 struct vfpf_vport_update_tlv
{
388 struct vfpf_first_tlv first_tlv
;
391 struct vfpf_ucast_filter_tlv
{
392 struct vfpf_first_tlv first_tlv
;
403 struct tlv_buffer_size
{
404 u8 tlv_buffer
[TLV_BUFFER_SIZE
];
408 struct vfpf_first_tlv first_tlv
;
409 struct vfpf_acquire_tlv acquire
;
410 struct vfpf_start_rxq_tlv start_rxq
;
411 struct vfpf_start_txq_tlv start_txq
;
412 struct vfpf_stop_rxqs_tlv stop_rxqs
;
413 struct vfpf_stop_txqs_tlv stop_txqs
;
414 struct vfpf_update_rxq_tlv update_rxq
;
415 struct vfpf_vport_start_tlv start_vport
;
416 struct vfpf_vport_update_tlv vport_update
;
417 struct vfpf_ucast_filter_tlv ucast_filter
;
418 struct channel_list_end_tlv list_end
;
419 struct tlv_buffer_size tlv_buf_size
;
423 struct pfvf_def_resp_tlv default_resp
;
424 struct pfvf_acquire_resp_tlv acquire_resp
;
425 struct tlv_buffer_size tlv_buf_size
;
426 struct pfvf_start_queue_resp_tlv queue_start
;
429 enum qed_bulletin_bit
{
430 /* Alert the VF that a forced MAC was set by the PF */
432 /* Alert the VF that a forced VLAN was set by the PF */
433 VLAN_ADDR_FORCED
= 2,
435 /* Indicate that `default_only_untagged' contains actual data */
436 VFPF_BULLETIN_UNTAGGED_DEFAULT
= 3,
437 VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED
= 4,
439 /* Alert the VF that suggested mac was sent by the PF.
440 * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
442 VFPF_BULLETIN_MAC_ADDR
= 5
445 struct qed_bulletin_content
{
446 /* crc of structure to ensure is not in mid-update */
451 /* bitmap indicating which fields hold valid values */
454 /* used for MAC_ADDR or MAC_ADDR_FORCED */
457 /* If valid, 1 => only untagged Rx if no vlan is configured */
458 u8 default_only_untagged
;
461 /* The following is a 'copy' of qed_mcp_link_state,
462 * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
463 * possible the structs will increase further along the road we cannot
464 * have it here; Instead we need to have all of its fields.
467 u8 req_autoneg_pause
;
473 u32 req_forced_speed
;
481 u8 parallel_detection
;
483 u8 partner_tx_flow_ctrl_en
;
484 u8 partner_rx_flow_ctrl_en
;
485 u8 partner_adv_pause
;
490 u32 partner_adv_speed
;
492 u32 capability_speed
;
499 struct qed_bulletin
{
501 struct qed_bulletin_content
*p_virt
;
506 CHANNEL_TLV_NONE
, /* ends tlv sequence */
508 CHANNEL_TLV_VPORT_START
,
509 CHANNEL_TLV_VPORT_UPDATE
,
510 CHANNEL_TLV_VPORT_TEARDOWN
,
511 CHANNEL_TLV_START_RXQ
,
512 CHANNEL_TLV_START_TXQ
,
513 CHANNEL_TLV_STOP_RXQS
,
514 CHANNEL_TLV_STOP_TXQS
,
515 CHANNEL_TLV_UPDATE_RXQ
,
516 CHANNEL_TLV_INT_CLEANUP
,
519 CHANNEL_TLV_LIST_END
,
520 CHANNEL_TLV_UCAST_FILTER
,
521 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE
,
522 CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH
,
523 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP
,
524 CHANNEL_TLV_VPORT_UPDATE_MCAST
,
525 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM
,
526 CHANNEL_TLV_VPORT_UPDATE_RSS
,
527 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN
,
528 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA
,
531 /* Required for iterating over vport-update tlvs.
532 * Will break in case non-sequential vport-update tlvs.
534 CHANNEL_TLV_VPORT_UPDATE_MAX
= CHANNEL_TLV_VPORT_UPDATE_SGE_TPA
+ 1,
537 /* This data is held in the qed_hwfn structure for VFs only. */
539 union vfpf_tlvs
*vf2pf_request
;
540 dma_addr_t vf2pf_request_phys
;
541 union pfvf_tlvs
*pf2vf_reply
;
542 dma_addr_t pf2vf_reply_phys
;
544 /* Should be taken whenever the mailbox buffers are accessed */
549 struct qed_bulletin bulletin
;
550 struct qed_bulletin_content bulletin_shadow
;
552 /* we set aside a copy of the acquire response */
553 struct pfvf_acquire_resp_tlv acquire_resp
;
556 #ifdef CONFIG_QED_SRIOV
558 * @brief Read the VF bulletin and act on it if needed
561 * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
563 * @return enum _qed_status
565 int qed_vf_read_bulletin(struct qed_hwfn
*p_hwfn
, u8
*p_change
);
568 * @brief Get link paramters for VF from qed
571 * @param params - the link params structure to be filled for the VF
573 void qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
574 struct qed_mcp_link_params
*params
);
577 * @brief Get link state for VF from qed
580 * @param link - the link state structure to be filled for the VF
582 void qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
583 struct qed_mcp_link_state
*link
);
586 * @brief Get link capabilities for VF from qed
589 * @param p_link_caps - the link capabilities structure to be filled for the VF
591 void qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
592 struct qed_mcp_link_capabilities
*p_link_caps
);
595 * @brief Get number of Rx queues allocated for VF by qed
598 * @param num_rxqs - allocated RX queues
600 void qed_vf_get_num_rxqs(struct qed_hwfn
*p_hwfn
, u8
*num_rxqs
);
603 * @brief Get port mac address for VF
606 * @param port_mac - destination location for port mac
608 void qed_vf_get_port_mac(struct qed_hwfn
*p_hwfn
, u8
*port_mac
);
611 * @brief Get number of VLAN filters allocated for VF by qed
614 * @param num_rxqs - allocated VLAN filters
616 void qed_vf_get_num_vlan_filters(struct qed_hwfn
*p_hwfn
,
617 u8
*num_vlan_filters
);
620 * @brief Check if VF can set a MAC address
627 bool qed_vf_check_mac(struct qed_hwfn
*p_hwfn
, u8
*mac
);
630 * @brief Set firmware version information in dev_info from VFs acquire response tlv
638 void qed_vf_get_fw_version(struct qed_hwfn
*p_hwfn
,
639 u16
*fw_major
, u16
*fw_minor
,
640 u16
*fw_rev
, u16
*fw_eng
);
643 * @brief hw preparation for VF
644 * sends ACQUIRE message
650 int qed_vf_hw_prepare(struct qed_hwfn
*p_hwfn
);
653 * @brief VF - start the RX Queue by sending a message to the PF
655 * @param cid - zero based within the VF
656 * @param rx_queue_id - zero based within the VF
657 * @param sb - VF status block for this queue
658 * @param sb_index - Index within the status block
659 * @param bd_max_bytes - maximum number of bytes per bd
660 * @param bd_chain_phys_addr - physical address of bd chain
661 * @param cqe_pbl_addr - physical address of pbl
662 * @param cqe_pbl_size - pbl size
663 * @param pp_prod - pointer to the producer to be
668 int qed_vf_pf_rxq_start(struct qed_hwfn
*p_hwfn
,
673 dma_addr_t bd_chain_phys_addr
,
674 dma_addr_t cqe_pbl_addr
,
675 u16 cqe_pbl_size
, void __iomem
**pp_prod
);
678 * @brief VF - start the TX queue by sending a message to the
682 * @param tx_queue_id - zero based within the VF
683 * @param sb - status block for this queue
684 * @param sb_index - index within the status block
685 * @param bd_chain_phys_addr - physical address of tx chain
686 * @param pp_doorbell - pointer to address to which to
687 * write the doorbell too..
691 int qed_vf_pf_txq_start(struct qed_hwfn
*p_hwfn
,
696 u16 pbl_size
, void __iomem
**pp_doorbell
);
699 * @brief VF - stop the RX queue by sending a message to the PF
703 * @param cqe_completion
707 int qed_vf_pf_rxq_stop(struct qed_hwfn
*p_hwfn
,
708 u16 rx_qid
, bool cqe_completion
);
711 * @brief VF - stop the TX queue by sending a message to the PF
718 int qed_vf_pf_txq_stop(struct qed_hwfn
*p_hwfn
, u16 tx_qid
);
721 * @brief VF - send a vport update command
728 int qed_vf_pf_vport_update(struct qed_hwfn
*p_hwfn
,
729 struct qed_sp_vport_update_params
*p_params
);
733 * @brief VF - send a close message to PF
737 * @return enum _qed_status
739 int qed_vf_pf_reset(struct qed_hwfn
*p_hwfn
);
742 * @brief VF - free vf`s memories
746 * @return enum _qed_status
748 int qed_vf_pf_release(struct qed_hwfn
*p_hwfn
);
751 * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
752 * sb_id. For VFs igu sbs don't have to be contiguous
759 u16
qed_vf_get_igu_sb_id(struct qed_hwfn
*p_hwfn
, u16 sb_id
);
762 * @brief qed_vf_pf_vport_start - perform vport start for VF.
767 * @param inner_vlan_removal
769 * @param max_buffers_per_cqe,
770 * @param only_untagged - default behavior regarding vlan acceptance
772 * @return enum _qed_status
774 int qed_vf_pf_vport_start(struct qed_hwfn
*p_hwfn
,
777 u8 inner_vlan_removal
,
778 enum qed_tpa_mode tpa_mode
,
779 u8 max_buffers_per_cqe
, u8 only_untagged
);
782 * @brief qed_vf_pf_vport_stop - stop the VF's vport
786 * @return enum _qed_status
788 int qed_vf_pf_vport_stop(struct qed_hwfn
*p_hwfn
);
790 int qed_vf_pf_filter_ucast(struct qed_hwfn
*p_hwfn
,
791 struct qed_filter_ucast
*p_param
);
793 void qed_vf_pf_filter_mcast(struct qed_hwfn
*p_hwfn
,
794 struct qed_filter_mcast
*p_filter_cmd
);
797 * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
801 * @return enum _qed_status
803 int qed_vf_pf_int_cleanup(struct qed_hwfn
*p_hwfn
);
806 * @brief - return the link params in a given bulletin board
809 * @param p_params - pointer to a struct to fill with link params
812 void __qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
813 struct qed_mcp_link_params
*p_params
,
814 struct qed_bulletin_content
*p_bulletin
);
817 * @brief - return the link state in a given bulletin board
820 * @param p_link - pointer to a struct to fill with link state
823 void __qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
824 struct qed_mcp_link_state
*p_link
,
825 struct qed_bulletin_content
*p_bulletin
);
828 * @brief - return the link capabilities in a given bulletin board
831 * @param p_link - pointer to a struct to fill with link capabilities
834 void __qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
835 struct qed_mcp_link_capabilities
*p_link_caps
,
836 struct qed_bulletin_content
*p_bulletin
);
838 void qed_iov_vf_task(struct work_struct
*work
);
840 static inline void qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
841 struct qed_mcp_link_params
*params
)
845 static inline void qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
846 struct qed_mcp_link_state
*link
)
851 qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
852 struct qed_mcp_link_capabilities
*p_link_caps
)
856 static inline void qed_vf_get_num_rxqs(struct qed_hwfn
*p_hwfn
, u8
*num_rxqs
)
860 static inline void qed_vf_get_port_mac(struct qed_hwfn
*p_hwfn
, u8
*port_mac
)
864 static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn
*p_hwfn
,
865 u8
*num_vlan_filters
)
869 static inline bool qed_vf_check_mac(struct qed_hwfn
*p_hwfn
, u8
*mac
)
874 static inline void qed_vf_get_fw_version(struct qed_hwfn
*p_hwfn
,
875 u16
*fw_major
, u16
*fw_minor
,
876 u16
*fw_rev
, u16
*fw_eng
)
880 static inline int qed_vf_hw_prepare(struct qed_hwfn
*p_hwfn
)
885 static inline int qed_vf_pf_rxq_start(struct qed_hwfn
*p_hwfn
,
890 dma_addr_t bd_chain_phys_adr
,
891 dma_addr_t cqe_pbl_addr
,
892 u16 cqe_pbl_size
, void __iomem
**pp_prod
)
897 static inline int qed_vf_pf_txq_start(struct qed_hwfn
*p_hwfn
,
902 u16 pbl_size
, void __iomem
**pp_doorbell
)
907 static inline int qed_vf_pf_rxq_stop(struct qed_hwfn
*p_hwfn
,
908 u16 rx_qid
, bool cqe_completion
)
913 static inline int qed_vf_pf_txq_stop(struct qed_hwfn
*p_hwfn
, u16 tx_qid
)
919 qed_vf_pf_vport_update(struct qed_hwfn
*p_hwfn
,
920 struct qed_sp_vport_update_params
*p_params
)
925 static inline int qed_vf_pf_reset(struct qed_hwfn
*p_hwfn
)
930 static inline int qed_vf_pf_release(struct qed_hwfn
*p_hwfn
)
935 static inline u16
qed_vf_get_igu_sb_id(struct qed_hwfn
*p_hwfn
, u16 sb_id
)
940 static inline int qed_vf_pf_vport_start(struct qed_hwfn
*p_hwfn
,
943 u8 inner_vlan_removal
,
944 enum qed_tpa_mode tpa_mode
,
945 u8 max_buffers_per_cqe
,
951 static inline int qed_vf_pf_vport_stop(struct qed_hwfn
*p_hwfn
)
956 static inline int qed_vf_pf_filter_ucast(struct qed_hwfn
*p_hwfn
,
957 struct qed_filter_ucast
*p_param
)
962 static inline void qed_vf_pf_filter_mcast(struct qed_hwfn
*p_hwfn
,
963 struct qed_filter_mcast
*p_filter_cmd
)
967 static inline int qed_vf_pf_int_cleanup(struct qed_hwfn
*p_hwfn
)
972 static inline void __qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
973 struct qed_mcp_link_params
975 struct qed_bulletin_content
980 static inline void __qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
981 struct qed_mcp_link_state
*p_link
,
982 struct qed_bulletin_content
988 __qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
989 struct qed_mcp_link_capabilities
*p_link_caps
,
990 struct qed_bulletin_content
*p_bulletin
)
994 static inline void qed_iov_vf_task(struct work_struct
*work
)