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 */
102 struct vf_pf_resc_request resc_request;
109 /* receive side scaling tlv */
110 struct vfpf_vport_update_rss_tlv {
111 struct channel_tlv tl;
114 #define VFPF_UPDATE_RSS_CONFIG_FLAG BIT(0)
115 #define VFPF_UPDATE_RSS_CAPS_FLAG BIT(1)
116 #define VFPF_UPDATE_RSS_IND_TABLE_FLAG BIT(2)
117 #define VFPF_UPDATE_RSS_KEY_FLAG BIT(3)
121 u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
122 u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
123 u32 rss_key[T_ETH_RSS_KEY_SIZE];
126 struct pfvf_storm_stats {
131 struct pfvf_stats_info {
132 struct pfvf_storm_stats mstats;
133 struct pfvf_storm_stats pstats;
134 struct pfvf_storm_stats tstats;
135 struct pfvf_storm_stats ustats;
138 struct pfvf_acquire_resp_tlv {
141 struct pf_vf_pfdev_info {
151 #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED BIT(0)
152 #define PFVF_ACQUIRE_CAP_100G BIT(1) /* If set, 100g PF */
153 /* There are old PF versions where the PF might mistakenly override the sanity
154 * mechanism [version-based] and allow a VF that can't be supported to pass
155 * the acquisition phase.
156 * To overcome this, PFs now indicate that they're past that point and the new
157 * VFs would fail probe on the older PFs that fail to do so.
159 #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE BIT(2)
165 /* These should match the PF's qed_dev values */
171 struct pfvf_stats_info stats_info;
173 u8 port_mac[ETH_ALEN];
178 #define PFVF_MAX_QUEUES_PER_VF 16
179 #define PFVF_MAX_SBS_PER_VF 16
180 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
181 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
182 u8 cid[PFVF_MAX_QUEUES_PER_VF];
197 struct pfvf_start_queue_resp_tlv {
199 u32 offset; /* offset to consumer/producer of queue */
204 struct vfpf_start_rxq_tlv {
205 struct vfpf_first_tlv first_tlv;
207 /* physical addresses */
209 u64 deprecated_sge_addr;
215 u16 hc_rate; /* desired interrupts per sec. */
223 struct vfpf_start_txq_tlv {
224 struct vfpf_first_tlv first_tlv;
226 /* physical addresses */
233 u32 flags; /* VFPF_QUEUE_FLG_X flags */
234 u16 hc_rate; /* desired interrupts per sec. */
240 struct vfpf_stop_rxqs_tlv {
241 struct vfpf_first_tlv first_tlv;
250 struct vfpf_stop_txqs_tlv {
251 struct vfpf_first_tlv first_tlv;
258 struct vfpf_update_rxq_tlv {
259 struct vfpf_first_tlv first_tlv;
261 u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
266 #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG BIT(0)
267 #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG BIT(1)
268 #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG BIT(2)
273 /* Set Queue Filters */
274 struct vfpf_q_mac_vlan_filter {
276 #define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
277 #define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
278 #define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
287 struct vfpf_vport_start_tlv {
288 struct vfpf_first_tlv first_tlv;
290 u64 sb_addr[PFVF_MAX_SBS_PER_VF];
297 u8 inner_vlan_removal;
300 u8 max_buffers_per_cqe;
305 /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
306 struct vfpf_vport_update_activate_tlv {
307 struct channel_tlv tl;
314 struct vfpf_vport_update_tx_switch_tlv {
315 struct channel_tlv tl;
320 struct vfpf_vport_update_vlan_strip_tlv {
321 struct channel_tlv tl;
326 struct vfpf_vport_update_mcast_bin_tlv {
327 struct channel_tlv tl;
333 struct vfpf_vport_update_accept_param_tlv {
334 struct channel_tlv tl;
341 struct vfpf_vport_update_accept_any_vlan_tlv {
342 struct channel_tlv tl;
343 u8 update_accept_any_vlan_flg;
349 struct vfpf_vport_update_sge_tpa_tlv {
350 struct channel_tlv tl;
353 #define VFPF_TPA_IPV4_EN_FLAG BIT(0)
354 #define VFPF_TPA_IPV6_EN_FLAG BIT(1)
355 #define VFPF_TPA_PKT_SPLIT_FLAG BIT(2)
356 #define VFPF_TPA_HDR_DATA_SPLIT_FLAG BIT(3)
357 #define VFPF_TPA_GRO_CONSIST_FLAG BIT(4)
359 u8 update_sge_tpa_flags;
360 #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
361 #define VFPF_UPDATE_TPA_EN_FLAG BIT(1)
362 #define VFPF_UPDATE_TPA_PARAM_FLAG BIT(2)
364 u8 max_buffers_per_cqe;
366 u16 deprecated_sge_buff_size;
368 u16 tpa_min_size_to_start;
369 u16 tpa_min_size_to_cont;
375 /* Primary tlv as a header for various extended tlvs for
376 * various functionalities in vport update ramrod.
378 struct vfpf_vport_update_tlv {
379 struct vfpf_first_tlv first_tlv;
382 struct vfpf_ucast_filter_tlv {
383 struct vfpf_first_tlv first_tlv;
394 struct tlv_buffer_size {
395 u8 tlv_buffer[TLV_BUFFER_SIZE];
399 struct vfpf_first_tlv first_tlv;
400 struct vfpf_acquire_tlv acquire;
401 struct vfpf_start_rxq_tlv start_rxq;
402 struct vfpf_start_txq_tlv start_txq;
403 struct vfpf_stop_rxqs_tlv stop_rxqs;
404 struct vfpf_stop_txqs_tlv stop_txqs;
405 struct vfpf_update_rxq_tlv update_rxq;
406 struct vfpf_vport_start_tlv start_vport;
407 struct vfpf_vport_update_tlv vport_update;
408 struct vfpf_ucast_filter_tlv ucast_filter;
409 struct channel_list_end_tlv list_end;
410 struct tlv_buffer_size tlv_buf_size;
414 struct pfvf_def_resp_tlv default_resp;
415 struct pfvf_acquire_resp_tlv acquire_resp;
416 struct tlv_buffer_size tlv_buf_size;
417 struct pfvf_start_queue_resp_tlv queue_start;
420 enum qed_bulletin_bit {
421 /* Alert the VF that a forced VLAN was set by the PF */
422 VLAN_ADDR_FORCED = 2,
424 /* Indicate that `default_only_untagged' contains actual data */
425 VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
426 VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
430 struct qed_bulletin_content {
431 /* crc of structure to ensure is not in mid-update */
436 /* bitmap indicating which fields hold valid values */
439 /* used for MAC_ADDR or MAC_ADDR_FORCED */
442 /* If valid, 1 => only untagged Rx if no vlan is configured */
443 u8 default_only_untagged;
446 /* The following is a 'copy' of qed_mcp_link_state,
447 * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
448 * possible the structs will increase further along the road we cannot
449 * have it here; Instead we need to have all of its fields.
452 u8 req_autoneg_pause;
458 u32 req_forced_speed;
466 u8 parallel_detection;
468 u8 partner_tx_flow_ctrl_en;
469 u8 partner_rx_flow_ctrl_en;
470 u8 partner_adv_pause;
475 u32 partner_adv_speed;
477 u32 capability_speed;
484 struct qed_bulletin {
486 struct qed_bulletin_content *p_virt;
491 CHANNEL_TLV_NONE, /* ends tlv sequence */
493 CHANNEL_TLV_VPORT_START,
494 CHANNEL_TLV_VPORT_UPDATE,
495 CHANNEL_TLV_VPORT_TEARDOWN,
496 CHANNEL_TLV_START_RXQ,
497 CHANNEL_TLV_START_TXQ,
498 CHANNEL_TLV_STOP_RXQS,
499 CHANNEL_TLV_STOP_TXQS,
500 CHANNEL_TLV_UPDATE_RXQ,
501 CHANNEL_TLV_INT_CLEANUP,
504 CHANNEL_TLV_LIST_END,
505 CHANNEL_TLV_UCAST_FILTER,
506 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
507 CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
508 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
509 CHANNEL_TLV_VPORT_UPDATE_MCAST,
510 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
511 CHANNEL_TLV_VPORT_UPDATE_RSS,
512 CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
513 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
516 /* Required for iterating over vport-update tlvs.
517 * Will break in case non-sequential vport-update tlvs.
519 CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
522 /* This data is held in the qed_hwfn structure for VFs only. */
524 union vfpf_tlvs *vf2pf_request;
525 dma_addr_t vf2pf_request_phys;
526 union pfvf_tlvs *pf2vf_reply;
527 dma_addr_t pf2vf_reply_phys;
529 /* Should be taken whenever the mailbox buffers are accessed */
534 struct qed_bulletin bulletin;
535 struct qed_bulletin_content bulletin_shadow;
537 /* we set aside a copy of the acquire response */
538 struct pfvf_acquire_resp_tlv acquire_resp;
541 #ifdef CONFIG_QED_SRIOV
543 * @brief Read the VF bulletin and act on it if needed
546 * @param p_change - qed fills 1 iff bulletin board has changed, 0 otherwise.
548 * @return enum _qed_status
550 int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
553 * @brief Get link paramters for VF from qed
556 * @param params - the link params structure to be filled for the VF
558 void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
559 struct qed_mcp_link_params *params);
562 * @brief Get link state for VF from qed
565 * @param link - the link state structure to be filled for the VF
567 void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
568 struct qed_mcp_link_state *link);
571 * @brief Get link capabilities for VF from qed
574 * @param p_link_caps - the link capabilities structure to be filled for the VF
576 void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
577 struct qed_mcp_link_capabilities *p_link_caps);
580 * @brief Get number of Rx queues allocated for VF by qed
583 * @param num_rxqs - allocated RX queues
585 void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
588 * @brief Get port mac address for VF
591 * @param port_mac - destination location for port mac
593 void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
596 * @brief Get number of VLAN filters allocated for VF by qed
599 * @param num_rxqs - allocated VLAN filters
601 void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
602 u8 *num_vlan_filters);
605 * @brief Set firmware version information in dev_info from VFs acquire response tlv
613 void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
614 u16 *fw_major, u16 *fw_minor,
615 u16 *fw_rev, u16 *fw_eng);
618 * @brief hw preparation for VF
619 * sends ACQUIRE message
625 int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
628 * @brief VF - start the RX Queue by sending a message to the PF
630 * @param cid - zero based within the VF
631 * @param rx_queue_id - zero based within the VF
632 * @param sb - VF status block for this queue
633 * @param sb_index - Index within the status block
634 * @param bd_max_bytes - maximum number of bytes per bd
635 * @param bd_chain_phys_addr - physical address of bd chain
636 * @param cqe_pbl_addr - physical address of pbl
637 * @param cqe_pbl_size - pbl size
638 * @param pp_prod - pointer to the producer to be
643 int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
648 dma_addr_t bd_chain_phys_addr,
649 dma_addr_t cqe_pbl_addr,
650 u16 cqe_pbl_size, void __iomem **pp_prod);
653 * @brief VF - start the TX queue by sending a message to the
657 * @param tx_queue_id - zero based within the VF
658 * @param sb - status block for this queue
659 * @param sb_index - index within the status block
660 * @param bd_chain_phys_addr - physical address of tx chain
661 * @param pp_doorbell - pointer to address to which to
662 * write the doorbell too..
666 int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
671 u16 pbl_size, void __iomem **pp_doorbell);
674 * @brief VF - stop the RX queue by sending a message to the PF
678 * @param cqe_completion
682 int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
683 u16 rx_qid, bool cqe_completion);
686 * @brief VF - stop the TX queue by sending a message to the PF
693 int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, u16 tx_qid);
696 * @brief VF - send a vport update command
703 int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
704 struct qed_sp_vport_update_params *p_params);
708 * @brief VF - send a close message to PF
712 * @return enum _qed_status
714 int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
717 * @brief VF - free vf`s memories
721 * @return enum _qed_status
723 int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
726 * @brief qed_vf_get_igu_sb_id - Get the IGU SB ID for a given
727 * sb_id. For VFs igu sbs don't have to be contiguous
734 u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
737 * @brief qed_vf_pf_vport_start - perform vport start for VF.
742 * @param inner_vlan_removal
744 * @param max_buffers_per_cqe,
745 * @param only_untagged - default behavior regarding vlan acceptance
747 * @return enum _qed_status
749 int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
752 u8 inner_vlan_removal,
753 enum qed_tpa_mode tpa_mode,
754 u8 max_buffers_per_cqe, u8 only_untagged);
757 * @brief qed_vf_pf_vport_stop - stop the VF's vport
761 * @return enum _qed_status
763 int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
765 int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
766 struct qed_filter_ucast *p_param);
768 void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
769 struct qed_filter_mcast *p_filter_cmd);
772 * @brief qed_vf_pf_int_cleanup - clean the SB of the VF
776 * @return enum _qed_status
778 int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
781 * @brief - return the link params in a given bulletin board
784 * @param p_params - pointer to a struct to fill with link params
787 void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
788 struct qed_mcp_link_params *p_params,
789 struct qed_bulletin_content *p_bulletin);
792 * @brief - return the link state in a given bulletin board
795 * @param p_link - pointer to a struct to fill with link state
798 void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
799 struct qed_mcp_link_state *p_link,
800 struct qed_bulletin_content *p_bulletin);
803 * @brief - return the link capabilities in a given bulletin board
806 * @param p_link - pointer to a struct to fill with link capabilities
809 void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
810 struct qed_mcp_link_capabilities *p_link_caps,
811 struct qed_bulletin_content *p_bulletin);
813 void qed_iov_vf_task(struct work_struct *work);
815 static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
816 struct qed_mcp_link_params *params)
820 static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
821 struct qed_mcp_link_state *link)
826 qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
827 struct qed_mcp_link_capabilities *p_link_caps)
831 static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
835 static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
839 static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
840 u8 *num_vlan_filters)
844 static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
845 u16 *fw_major, u16 *fw_minor,
846 u16 *fw_rev, u16 *fw_eng)
850 static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
855 static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
860 dma_addr_t bd_chain_phys_adr,
861 dma_addr_t cqe_pbl_addr,
862 u16 cqe_pbl_size, void __iomem **pp_prod)
867 static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
872 u16 pbl_size, void __iomem **pp_doorbell)
877 static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
878 u16 rx_qid, bool cqe_completion)
883 static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, u16 tx_qid)
889 qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
890 struct qed_sp_vport_update_params *p_params)
895 static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
900 static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
905 static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
910 static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
913 u8 inner_vlan_removal,
914 enum qed_tpa_mode tpa_mode,
915 u8 max_buffers_per_cqe,
921 static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
926 static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
927 struct qed_filter_ucast *p_param)
932 static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
933 struct qed_filter_mcast *p_filter_cmd)
937 static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
942 static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
943 struct qed_mcp_link_params
945 struct qed_bulletin_content
950 static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
951 struct qed_mcp_link_state *p_link,
952 struct qed_bulletin_content
958 __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
959 struct qed_mcp_link_capabilities *p_link_caps,
960 struct qed_bulletin_content *p_bulletin)
964 static inline void qed_iov_vf_task(struct work_struct *work)