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
;
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
;
555 /* In case PF originates prior to the fp-hsi version comparison,
556 * this has to be propagated as it affects the fastpath.
561 #ifdef CONFIG_QED_SRIOV
563 * @brief Read the VF bulletin and act on it if needed
566 * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
568 * @return enum _qed_status
570 int qed_vf_read_bulletin(struct qed_hwfn
*p_hwfn
, u8
*p_change
);
573 * @brief Get link paramters for VF from qed
576 * @param params - the link params structure to be filled for the VF
578 void qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
579 struct qed_mcp_link_params
*params
);
582 * @brief Get link state for VF from qed
585 * @param link - the link state structure to be filled for the VF
587 void qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
588 struct qed_mcp_link_state
*link
);
591 * @brief Get link capabilities for VF from qed
594 * @param p_link_caps - the link capabilities structure to be filled for the VF
596 void qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
597 struct qed_mcp_link_capabilities
*p_link_caps
);
600 * @brief Get number of Rx queues allocated for VF by qed
603 * @param num_rxqs - allocated RX queues
605 void qed_vf_get_num_rxqs(struct qed_hwfn
*p_hwfn
, u8
*num_rxqs
);
608 * @brief Get port mac address for VF
611 * @param port_mac - destination location for port mac
613 void qed_vf_get_port_mac(struct qed_hwfn
*p_hwfn
, u8
*port_mac
);
616 * @brief Get number of VLAN filters allocated for VF by qed
619 * @param num_rxqs - allocated VLAN filters
621 void qed_vf_get_num_vlan_filters(struct qed_hwfn
*p_hwfn
,
622 u8
*num_vlan_filters
);
625 * @brief Check if VF can set a MAC address
632 bool qed_vf_check_mac(struct qed_hwfn
*p_hwfn
, u8
*mac
);
635 * @brief Set firmware version information in dev_info from VFs acquire response tlv
643 void qed_vf_get_fw_version(struct qed_hwfn
*p_hwfn
,
644 u16
*fw_major
, u16
*fw_minor
,
645 u16
*fw_rev
, u16
*fw_eng
);
648 * @brief hw preparation for VF
649 * sends ACQUIRE message
655 int qed_vf_hw_prepare(struct qed_hwfn
*p_hwfn
);
658 * @brief VF - start the RX Queue by sending a message to the PF
660 * @param cid - zero based within the VF
661 * @param rx_queue_id - zero based within the VF
662 * @param sb - VF status block for this queue
663 * @param sb_index - Index within the status block
664 * @param bd_max_bytes - maximum number of bytes per bd
665 * @param bd_chain_phys_addr - physical address of bd chain
666 * @param cqe_pbl_addr - physical address of pbl
667 * @param cqe_pbl_size - pbl size
668 * @param pp_prod - pointer to the producer to be
673 int qed_vf_pf_rxq_start(struct qed_hwfn
*p_hwfn
,
678 dma_addr_t bd_chain_phys_addr
,
679 dma_addr_t cqe_pbl_addr
,
680 u16 cqe_pbl_size
, void __iomem
**pp_prod
);
683 * @brief VF - start the TX queue by sending a message to the
687 * @param tx_queue_id - zero based within the VF
688 * @param sb - status block for this queue
689 * @param sb_index - index within the status block
690 * @param bd_chain_phys_addr - physical address of tx chain
691 * @param pp_doorbell - pointer to address to which to
692 * write the doorbell too..
696 int qed_vf_pf_txq_start(struct qed_hwfn
*p_hwfn
,
701 u16 pbl_size
, void __iomem
**pp_doorbell
);
704 * @brief VF - stop the RX queue by sending a message to the PF
708 * @param cqe_completion
712 int qed_vf_pf_rxq_stop(struct qed_hwfn
*p_hwfn
,
713 u16 rx_qid
, bool cqe_completion
);
716 * @brief VF - stop the TX queue by sending a message to the PF
723 int qed_vf_pf_txq_stop(struct qed_hwfn
*p_hwfn
, u16 tx_qid
);
726 * @brief VF - send a vport update command
733 int qed_vf_pf_vport_update(struct qed_hwfn
*p_hwfn
,
734 struct qed_sp_vport_update_params
*p_params
);
738 * @brief VF - send a close message to PF
742 * @return enum _qed_status
744 int qed_vf_pf_reset(struct qed_hwfn
*p_hwfn
);
747 * @brief VF - free vf`s memories
751 * @return enum _qed_status
753 int qed_vf_pf_release(struct qed_hwfn
*p_hwfn
);
756 * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
757 * sb_id. For VFs igu sbs don't have to be contiguous
764 u16
qed_vf_get_igu_sb_id(struct qed_hwfn
*p_hwfn
, u16 sb_id
);
767 * @brief qed_vf_pf_vport_start - perform vport start for VF.
772 * @param inner_vlan_removal
774 * @param max_buffers_per_cqe,
775 * @param only_untagged - default behavior regarding vlan acceptance
777 * @return enum _qed_status
779 int qed_vf_pf_vport_start(struct qed_hwfn
*p_hwfn
,
782 u8 inner_vlan_removal
,
783 enum qed_tpa_mode tpa_mode
,
784 u8 max_buffers_per_cqe
, u8 only_untagged
);
787 * @brief qed_vf_pf_vport_stop - stop the VF's vport
791 * @return enum _qed_status
793 int qed_vf_pf_vport_stop(struct qed_hwfn
*p_hwfn
);
795 int qed_vf_pf_filter_ucast(struct qed_hwfn
*p_hwfn
,
796 struct qed_filter_ucast
*p_param
);
798 void qed_vf_pf_filter_mcast(struct qed_hwfn
*p_hwfn
,
799 struct qed_filter_mcast
*p_filter_cmd
);
802 * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
806 * @return enum _qed_status
808 int qed_vf_pf_int_cleanup(struct qed_hwfn
*p_hwfn
);
811 * @brief - return the link params in a given bulletin board
814 * @param p_params - pointer to a struct to fill with link params
817 void __qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
818 struct qed_mcp_link_params
*p_params
,
819 struct qed_bulletin_content
*p_bulletin
);
822 * @brief - return the link state in a given bulletin board
825 * @param p_link - pointer to a struct to fill with link state
828 void __qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
829 struct qed_mcp_link_state
*p_link
,
830 struct qed_bulletin_content
*p_bulletin
);
833 * @brief - return the link capabilities in a given bulletin board
836 * @param p_link - pointer to a struct to fill with link capabilities
839 void __qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
840 struct qed_mcp_link_capabilities
*p_link_caps
,
841 struct qed_bulletin_content
*p_bulletin
);
843 void qed_iov_vf_task(struct work_struct
*work
);
845 static inline void qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
846 struct qed_mcp_link_params
*params
)
850 static inline void qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
851 struct qed_mcp_link_state
*link
)
856 qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
857 struct qed_mcp_link_capabilities
*p_link_caps
)
861 static inline void qed_vf_get_num_rxqs(struct qed_hwfn
*p_hwfn
, u8
*num_rxqs
)
865 static inline void qed_vf_get_port_mac(struct qed_hwfn
*p_hwfn
, u8
*port_mac
)
869 static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn
*p_hwfn
,
870 u8
*num_vlan_filters
)
874 static inline bool qed_vf_check_mac(struct qed_hwfn
*p_hwfn
, u8
*mac
)
879 static inline void qed_vf_get_fw_version(struct qed_hwfn
*p_hwfn
,
880 u16
*fw_major
, u16
*fw_minor
,
881 u16
*fw_rev
, u16
*fw_eng
)
885 static inline int qed_vf_hw_prepare(struct qed_hwfn
*p_hwfn
)
890 static inline int qed_vf_pf_rxq_start(struct qed_hwfn
*p_hwfn
,
895 dma_addr_t bd_chain_phys_adr
,
896 dma_addr_t cqe_pbl_addr
,
897 u16 cqe_pbl_size
, void __iomem
**pp_prod
)
902 static inline int qed_vf_pf_txq_start(struct qed_hwfn
*p_hwfn
,
907 u16 pbl_size
, void __iomem
**pp_doorbell
)
912 static inline int qed_vf_pf_rxq_stop(struct qed_hwfn
*p_hwfn
,
913 u16 rx_qid
, bool cqe_completion
)
918 static inline int qed_vf_pf_txq_stop(struct qed_hwfn
*p_hwfn
, u16 tx_qid
)
924 qed_vf_pf_vport_update(struct qed_hwfn
*p_hwfn
,
925 struct qed_sp_vport_update_params
*p_params
)
930 static inline int qed_vf_pf_reset(struct qed_hwfn
*p_hwfn
)
935 static inline int qed_vf_pf_release(struct qed_hwfn
*p_hwfn
)
940 static inline u16
qed_vf_get_igu_sb_id(struct qed_hwfn
*p_hwfn
, u16 sb_id
)
945 static inline int qed_vf_pf_vport_start(struct qed_hwfn
*p_hwfn
,
948 u8 inner_vlan_removal
,
949 enum qed_tpa_mode tpa_mode
,
950 u8 max_buffers_per_cqe
,
956 static inline int qed_vf_pf_vport_stop(struct qed_hwfn
*p_hwfn
)
961 static inline int qed_vf_pf_filter_ucast(struct qed_hwfn
*p_hwfn
,
962 struct qed_filter_ucast
*p_param
)
967 static inline void qed_vf_pf_filter_mcast(struct qed_hwfn
*p_hwfn
,
968 struct qed_filter_mcast
*p_filter_cmd
)
972 static inline int qed_vf_pf_int_cleanup(struct qed_hwfn
*p_hwfn
)
977 static inline void __qed_vf_get_link_params(struct qed_hwfn
*p_hwfn
,
978 struct qed_mcp_link_params
980 struct qed_bulletin_content
985 static inline void __qed_vf_get_link_state(struct qed_hwfn
*p_hwfn
,
986 struct qed_mcp_link_state
*p_link
,
987 struct qed_bulletin_content
993 __qed_vf_get_link_caps(struct qed_hwfn
*p_hwfn
,
994 struct qed_mcp_link_capabilities
*p_link_caps
,
995 struct qed_bulletin_content
*p_bulletin
)
999 static inline void qed_iov_vf_task(struct work_struct
*work
)