Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /* QLogic qed NIC Driver
0003  * Copyright (c) 2015-2017  QLogic Corporation
0004  */
0005 
0006 #ifndef _QED_VF_H
0007 #define _QED_VF_H
0008 
0009 #include "qed_l2.h"
0010 #include "qed_mcp.h"
0011 
0012 #define T_ETH_INDIRECTION_TABLE_SIZE 128
0013 #define T_ETH_RSS_KEY_SIZE 10
0014 
0015 struct vf_pf_resc_request {
0016     u8 num_rxqs;
0017     u8 num_txqs;
0018     u8 num_sbs;
0019     u8 num_mac_filters;
0020     u8 num_vlan_filters;
0021     u8 num_mc_filters;
0022     u8 num_cids;
0023     u8 padding;
0024 };
0025 
0026 struct hw_sb_info {
0027     u16 hw_sb_id;
0028     u8 sb_qid;
0029     u8 padding[5];
0030 };
0031 
0032 #define TLV_BUFFER_SIZE                 1024
0033 
0034 enum {
0035     PFVF_STATUS_WAITING,
0036     PFVF_STATUS_SUCCESS,
0037     PFVF_STATUS_FAILURE,
0038     PFVF_STATUS_NOT_SUPPORTED,
0039     PFVF_STATUS_NO_RESOURCE,
0040     PFVF_STATUS_FORCED,
0041     PFVF_STATUS_MALICIOUS,
0042 };
0043 
0044 /* vf pf channel tlvs */
0045 /* general tlv header (used for both vf->pf request and pf->vf response) */
0046 struct channel_tlv {
0047     u16 type;
0048     u16 length;
0049 };
0050 
0051 /* header of first vf->pf tlv carries the offset used to calculate response
0052  * buffer address
0053  */
0054 struct vfpf_first_tlv {
0055     struct channel_tlv tl;
0056     u32 padding;
0057     u64 reply_address;
0058 };
0059 
0060 /* header of pf->vf tlvs, carries the status of handling the request */
0061 struct pfvf_tlv {
0062     struct channel_tlv tl;
0063     u8 status;
0064     u8 padding[3];
0065 };
0066 
0067 /* response tlv used for most tlvs */
0068 struct pfvf_def_resp_tlv {
0069     struct pfvf_tlv hdr;
0070 };
0071 
0072 /* used to terminate and pad a tlv list */
0073 struct channel_list_end_tlv {
0074     struct channel_tlv tl;
0075     u8 padding[4];
0076 };
0077 
0078 #define VFPF_ACQUIRE_OS_LINUX (0)
0079 #define VFPF_ACQUIRE_OS_WINDOWS (1)
0080 #define VFPF_ACQUIRE_OS_ESX (2)
0081 #define VFPF_ACQUIRE_OS_SOLARIS (3)
0082 #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
0083 
0084 struct vfpf_acquire_tlv {
0085     struct vfpf_first_tlv first_tlv;
0086 
0087     struct vf_pf_vfdev_info {
0088 #define VFPF_ACQUIRE_CAP_PRE_FP_HSI     BIT(0) /* VF pre-FP hsi version */
0089 #define VFPF_ACQUIRE_CAP_100G       BIT(1) /* VF can support 100g */
0090     /* A requirement for supporting multi-Tx queues on a single queue-zone,
0091      * VF would pass qids as additional information whenever passing queue
0092      * references.
0093      */
0094 #define VFPF_ACQUIRE_CAP_QUEUE_QIDS     BIT(2)
0095 
0096     /* The VF is using the physical bar. While this is mostly internal
0097      * to the VF, might affect the number of CIDs supported assuming
0098      * QUEUE_QIDS is set.
0099      */
0100 #define VFPF_ACQUIRE_CAP_PHYSICAL_BAR   BIT(3)
0101         u64 capabilities;
0102         u8 fw_major;
0103         u8 fw_minor;
0104         u8 fw_revision;
0105         u8 fw_engineering;
0106         u32 driver_version;
0107         u16 opaque_fid; /* ME register value */
0108         u8 os_type; /* VFPF_ACQUIRE_OS_* value */
0109         u8 eth_fp_hsi_major;
0110         u8 eth_fp_hsi_minor;
0111         u8 padding[3];
0112     } vfdev_info;
0113 
0114     struct vf_pf_resc_request resc_request;
0115 
0116     u64 bulletin_addr;
0117     u32 bulletin_size;
0118     u32 padding;
0119 };
0120 
0121 /* receive side scaling tlv */
0122 struct vfpf_vport_update_rss_tlv {
0123     struct channel_tlv tl;
0124 
0125     u8 update_rss_flags;
0126 #define VFPF_UPDATE_RSS_CONFIG_FLAG       BIT(0)
0127 #define VFPF_UPDATE_RSS_CAPS_FLAG         BIT(1)
0128 #define VFPF_UPDATE_RSS_IND_TABLE_FLAG    BIT(2)
0129 #define VFPF_UPDATE_RSS_KEY_FLAG          BIT(3)
0130 
0131     u8 rss_enable;
0132     u8 rss_caps;
0133     u8 rss_table_size_log;  /* The table size is 2 ^ rss_table_size_log */
0134     u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
0135     u32 rss_key[T_ETH_RSS_KEY_SIZE];
0136 };
0137 
0138 struct pfvf_storm_stats {
0139     u32 address;
0140     u32 len;
0141 };
0142 
0143 struct pfvf_stats_info {
0144     struct pfvf_storm_stats mstats;
0145     struct pfvf_storm_stats pstats;
0146     struct pfvf_storm_stats tstats;
0147     struct pfvf_storm_stats ustats;
0148 };
0149 
0150 struct pfvf_acquire_resp_tlv {
0151     struct pfvf_tlv hdr;
0152 
0153     struct pf_vf_pfdev_info {
0154         u32 chip_num;
0155         u32 mfw_ver;
0156 
0157         u16 fw_major;
0158         u16 fw_minor;
0159         u16 fw_rev;
0160         u16 fw_eng;
0161 
0162         u64 capabilities;
0163 #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED   BIT(0)
0164 #define PFVF_ACQUIRE_CAP_100G           BIT(1)  /* If set, 100g PF */
0165 /* There are old PF versions where the PF might mistakenly override the sanity
0166  * mechanism [version-based] and allow a VF that can't be supported to pass
0167  * the acquisition phase.
0168  * To overcome this, PFs now indicate that they're past that point and the new
0169  * VFs would fail probe on the older PFs that fail to do so.
0170  */
0171 #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE   BIT(2)
0172 
0173     /* PF expects queues to be received with additional qids */
0174 #define PFVF_ACQUIRE_CAP_QUEUE_QIDS             BIT(3)
0175 
0176         u16 db_size;
0177         u8 indices_per_sb;
0178         u8 os_type;
0179 
0180         /* These should match the PF's qed_dev values */
0181         u16 chip_rev;
0182         u8 dev_type;
0183 
0184         /* Doorbell bar size configured in HW: log(size) or 0 */
0185         u8 bar_size;
0186 
0187         struct pfvf_stats_info stats_info;
0188 
0189         u8 port_mac[ETH_ALEN];
0190 
0191         /* It's possible PF had to configure an older fastpath HSI
0192          * [in case VF is newer than PF]. This is communicated back
0193          * to the VF. It can also be used in case of error due to
0194          * non-matching versions to shed light in VF about failure.
0195          */
0196         u8 major_fp_hsi;
0197         u8 minor_fp_hsi;
0198     } pfdev_info;
0199 
0200     struct pf_vf_resc {
0201 #define PFVF_MAX_QUEUES_PER_VF      16
0202 #define PFVF_MAX_SBS_PER_VF     16
0203         struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
0204         u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
0205         u8 cid[PFVF_MAX_QUEUES_PER_VF];
0206 
0207         u8 num_rxqs;
0208         u8 num_txqs;
0209         u8 num_sbs;
0210         u8 num_mac_filters;
0211         u8 num_vlan_filters;
0212         u8 num_mc_filters;
0213         u8 num_cids;
0214         u8 padding;
0215     } resc;
0216 
0217     u32 bulletin_size;
0218     u32 padding;
0219 };
0220 
0221 struct pfvf_start_queue_resp_tlv {
0222     struct pfvf_tlv hdr;
0223     u32 offset;     /* offset to consumer/producer of queue */
0224     u8 padding[4];
0225 };
0226 
0227 /* Extended queue information - additional index for reference inside qzone.
0228  * If communicated between VF/PF, each TLV relating to queues should be
0229  * extended by one such [or have a future base TLV that already contains info].
0230  */
0231 struct vfpf_qid_tlv {
0232     struct channel_tlv tl;
0233     u8 qid;
0234     u8 padding[3];
0235 };
0236 
0237 /* Setup Queue */
0238 struct vfpf_start_rxq_tlv {
0239     struct vfpf_first_tlv first_tlv;
0240 
0241     /* physical addresses */
0242     u64 rxq_addr;
0243     u64 deprecated_sge_addr;
0244     u64 cqe_pbl_addr;
0245 
0246     u16 cqe_pbl_size;
0247     u16 hw_sb;
0248     u16 rx_qid;
0249     u16 hc_rate;        /* desired interrupts per sec. */
0250 
0251     u16 bd_max_bytes;
0252     u16 stat_id;
0253     u8 sb_index;
0254     u8 padding[3];
0255 };
0256 
0257 struct vfpf_start_txq_tlv {
0258     struct vfpf_first_tlv first_tlv;
0259 
0260     /* physical addresses */
0261     u64 pbl_addr;
0262     u16 pbl_size;
0263     u16 stat_id;
0264     u16 tx_qid;
0265     u16 hw_sb;
0266 
0267     u32 flags;      /* VFPF_QUEUE_FLG_X flags */
0268     u16 hc_rate;        /* desired interrupts per sec. */
0269     u8 sb_index;
0270     u8 padding[3];
0271 };
0272 
0273 /* Stop RX Queue */
0274 struct vfpf_stop_rxqs_tlv {
0275     struct vfpf_first_tlv first_tlv;
0276 
0277     u16 rx_qid;
0278 
0279     /* this field is deprecated and should *always* be set to '1' */
0280     u8 num_rxqs;
0281     u8 cqe_completion;
0282     u8 padding[4];
0283 };
0284 
0285 /* Stop TX Queues */
0286 struct vfpf_stop_txqs_tlv {
0287     struct vfpf_first_tlv first_tlv;
0288 
0289     u16 tx_qid;
0290 
0291     /* this field is deprecated and should *always* be set to '1' */
0292     u8 num_txqs;
0293     u8 padding[5];
0294 };
0295 
0296 struct vfpf_update_rxq_tlv {
0297     struct vfpf_first_tlv first_tlv;
0298 
0299     u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
0300 
0301     u16 rx_qid;
0302     u8 num_rxqs;
0303     u8 flags;
0304 #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG    BIT(0)
0305 #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG          BIT(1)
0306 #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG        BIT(2)
0307 
0308     u8 padding[4];
0309 };
0310 
0311 /* Set Queue Filters */
0312 struct vfpf_q_mac_vlan_filter {
0313     u32 flags;
0314 #define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
0315 #define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
0316 #define VFPF_Q_FILTER_SET_MAC           0x100   /* set/clear */
0317 
0318     u8 mac[ETH_ALEN];
0319     u16 vlan_tag;
0320 
0321     u8 padding[4];
0322 };
0323 
0324 /* Start a vport */
0325 struct vfpf_vport_start_tlv {
0326     struct vfpf_first_tlv first_tlv;
0327 
0328     u64 sb_addr[PFVF_MAX_SBS_PER_VF];
0329 
0330     u32 tpa_mode;
0331     u16 dep1;
0332     u16 mtu;
0333 
0334     u8 vport_id;
0335     u8 inner_vlan_removal;
0336 
0337     u8 only_untagged;
0338     u8 max_buffers_per_cqe;
0339 
0340     u8 padding[4];
0341 };
0342 
0343 /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
0344 struct vfpf_vport_update_activate_tlv {
0345     struct channel_tlv tl;
0346     u8 update_rx;
0347     u8 update_tx;
0348     u8 active_rx;
0349     u8 active_tx;
0350 };
0351 
0352 struct vfpf_vport_update_tx_switch_tlv {
0353     struct channel_tlv tl;
0354     u8 tx_switching;
0355     u8 padding[3];
0356 };
0357 
0358 struct vfpf_vport_update_vlan_strip_tlv {
0359     struct channel_tlv tl;
0360     u8 remove_vlan;
0361     u8 padding[3];
0362 };
0363 
0364 struct vfpf_vport_update_mcast_bin_tlv {
0365     struct channel_tlv tl;
0366     u8 padding[4];
0367 
0368     /* There are only 256 approx bins, and in HSI they're divided into
0369      * 32-bit values. As old VFs used to set-bit to the values on its side,
0370      * the upper half of the array is never expected to contain any data.
0371      */
0372     u64 bins[4];
0373     u64 obsolete_bins[4];
0374 };
0375 
0376 struct vfpf_vport_update_accept_param_tlv {
0377     struct channel_tlv tl;
0378     u8 update_rx_mode;
0379     u8 update_tx_mode;
0380     u8 rx_accept_filter;
0381     u8 tx_accept_filter;
0382 };
0383 
0384 struct vfpf_vport_update_accept_any_vlan_tlv {
0385     struct channel_tlv tl;
0386     u8 update_accept_any_vlan_flg;
0387     u8 accept_any_vlan;
0388 
0389     u8 padding[2];
0390 };
0391 
0392 struct vfpf_vport_update_sge_tpa_tlv {
0393     struct channel_tlv tl;
0394 
0395     u16 sge_tpa_flags;
0396 #define VFPF_TPA_IPV4_EN_FLAG       BIT(0)
0397 #define VFPF_TPA_IPV6_EN_FLAG       BIT(1)
0398 #define VFPF_TPA_PKT_SPLIT_FLAG     BIT(2)
0399 #define VFPF_TPA_HDR_DATA_SPLIT_FLAG    BIT(3)
0400 #define VFPF_TPA_GRO_CONSIST_FLAG   BIT(4)
0401 
0402     u8 update_sge_tpa_flags;
0403 #define VFPF_UPDATE_SGE_DEPRECATED_FLAG BIT(0)
0404 #define VFPF_UPDATE_TPA_EN_FLAG     BIT(1)
0405 #define VFPF_UPDATE_TPA_PARAM_FLAG  BIT(2)
0406 
0407     u8 max_buffers_per_cqe;
0408 
0409     u16 deprecated_sge_buff_size;
0410     u16 tpa_max_size;
0411     u16 tpa_min_size_to_start;
0412     u16 tpa_min_size_to_cont;
0413 
0414     u8 tpa_max_aggs_num;
0415     u8 padding[7];
0416 };
0417 
0418 /* Primary tlv as a header for various extended tlvs for
0419  * various functionalities in vport update ramrod.
0420  */
0421 struct vfpf_vport_update_tlv {
0422     struct vfpf_first_tlv first_tlv;
0423 };
0424 
0425 struct vfpf_ucast_filter_tlv {
0426     struct vfpf_first_tlv first_tlv;
0427 
0428     u8 opcode;
0429     u8 type;
0430 
0431     u8 mac[ETH_ALEN];
0432 
0433     u16 vlan;
0434     u16 padding[3];
0435 };
0436 
0437 /* tunnel update param tlv */
0438 struct vfpf_update_tunn_param_tlv {
0439     struct vfpf_first_tlv first_tlv;
0440 
0441     u8 tun_mode_update_mask;
0442     u8 tunn_mode;
0443     u8 update_tun_cls;
0444     u8 vxlan_clss;
0445     u8 l2gre_clss;
0446     u8 ipgre_clss;
0447     u8 l2geneve_clss;
0448     u8 ipgeneve_clss;
0449     u8 update_geneve_port;
0450     u8 update_vxlan_port;
0451     u16 geneve_port;
0452     u16 vxlan_port;
0453     u8 padding[2];
0454 };
0455 
0456 struct pfvf_update_tunn_param_tlv {
0457     struct pfvf_tlv hdr;
0458 
0459     u16 tunn_feature_mask;
0460     u8 vxlan_mode;
0461     u8 l2geneve_mode;
0462     u8 ipgeneve_mode;
0463     u8 l2gre_mode;
0464     u8 ipgre_mode;
0465     u8 vxlan_clss;
0466     u8 l2gre_clss;
0467     u8 ipgre_clss;
0468     u8 l2geneve_clss;
0469     u8 ipgeneve_clss;
0470     u16 vxlan_udp_port;
0471     u16 geneve_udp_port;
0472 };
0473 
0474 struct tlv_buffer_size {
0475     u8 tlv_buffer[TLV_BUFFER_SIZE];
0476 };
0477 
0478 struct vfpf_update_coalesce {
0479     struct vfpf_first_tlv first_tlv;
0480     u16 rx_coal;
0481     u16 tx_coal;
0482     u16 qid;
0483     u8 padding[2];
0484 };
0485 
0486 struct vfpf_read_coal_req_tlv {
0487     struct vfpf_first_tlv first_tlv;
0488     u16 qid;
0489     u8 is_rx;
0490     u8 padding[5];
0491 };
0492 
0493 struct pfvf_read_coal_resp_tlv {
0494     struct pfvf_tlv hdr;
0495     u16 coal;
0496     u8 padding[6];
0497 };
0498 
0499 struct vfpf_bulletin_update_mac_tlv {
0500     struct vfpf_first_tlv first_tlv;
0501     u8 mac[ETH_ALEN];
0502     u8 padding[2];
0503 };
0504 
0505 union vfpf_tlvs {
0506     struct vfpf_first_tlv first_tlv;
0507     struct vfpf_acquire_tlv acquire;
0508     struct vfpf_start_rxq_tlv start_rxq;
0509     struct vfpf_start_txq_tlv start_txq;
0510     struct vfpf_stop_rxqs_tlv stop_rxqs;
0511     struct vfpf_stop_txqs_tlv stop_txqs;
0512     struct vfpf_update_rxq_tlv update_rxq;
0513     struct vfpf_vport_start_tlv start_vport;
0514     struct vfpf_vport_update_tlv vport_update;
0515     struct vfpf_ucast_filter_tlv ucast_filter;
0516     struct vfpf_update_tunn_param_tlv tunn_param_update;
0517     struct vfpf_update_coalesce update_coalesce;
0518     struct vfpf_read_coal_req_tlv read_coal_req;
0519     struct vfpf_bulletin_update_mac_tlv bulletin_update_mac;
0520     struct tlv_buffer_size tlv_buf_size;
0521 };
0522 
0523 union pfvf_tlvs {
0524     struct pfvf_def_resp_tlv default_resp;
0525     struct pfvf_acquire_resp_tlv acquire_resp;
0526     struct tlv_buffer_size tlv_buf_size;
0527     struct pfvf_start_queue_resp_tlv queue_start;
0528     struct pfvf_update_tunn_param_tlv tunn_param_resp;
0529     struct pfvf_read_coal_resp_tlv read_coal_resp;
0530 };
0531 
0532 enum qed_bulletin_bit {
0533     /* Alert the VF that a forced MAC was set by the PF */
0534     MAC_ADDR_FORCED = 0,
0535     /* Alert the VF that a forced VLAN was set by the PF */
0536     VLAN_ADDR_FORCED = 2,
0537 
0538     /* Indicate that `default_only_untagged' contains actual data */
0539     VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
0540     VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
0541 
0542     /* Alert the VF that suggested mac was sent by the PF.
0543      * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set.
0544      */
0545     VFPF_BULLETIN_MAC_ADDR = 5
0546 };
0547 
0548 struct qed_bulletin_content {
0549     /* crc of structure to ensure is not in mid-update */
0550     u32 crc;
0551 
0552     u32 version;
0553 
0554     /* bitmap indicating which fields hold valid values */
0555     u64 valid_bitmap;
0556 
0557     /* used for MAC_ADDR or MAC_ADDR_FORCED */
0558     u8 mac[ETH_ALEN];
0559 
0560     /* If valid, 1 => only untagged Rx if no vlan is configured */
0561     u8 default_only_untagged;
0562     u8 padding;
0563 
0564     /* The following is a 'copy' of qed_mcp_link_state,
0565      * qed_mcp_link_params and qed_mcp_link_capabilities. Since it's
0566      * possible the structs will increase further along the road we cannot
0567      * have it here; Instead we need to have all of its fields.
0568      */
0569     u8 req_autoneg;
0570     u8 req_autoneg_pause;
0571     u8 req_forced_rx;
0572     u8 req_forced_tx;
0573     u8 padding2[4];
0574 
0575     u32 req_adv_speed;
0576     u32 req_forced_speed;
0577     u32 req_loopback;
0578     u32 padding3;
0579 
0580     u8 link_up;
0581     u8 full_duplex;
0582     u8 autoneg;
0583     u8 autoneg_complete;
0584     u8 parallel_detection;
0585     u8 pfc_enabled;
0586     u8 partner_tx_flow_ctrl_en;
0587     u8 partner_rx_flow_ctrl_en;
0588     u8 partner_adv_pause;
0589     u8 sfp_tx_fault;
0590     u16 vxlan_udp_port;
0591     u16 geneve_udp_port;
0592     u8 padding4[2];
0593 
0594     u32 speed;
0595     u32 partner_adv_speed;
0596 
0597     u32 capability_speed;
0598 
0599     /* Forced vlan */
0600     u16 pvid;
0601     u16 padding5;
0602 };
0603 
0604 struct qed_bulletin {
0605     dma_addr_t phys;
0606     struct qed_bulletin_content *p_virt;
0607     u32 size;
0608 };
0609 
0610 enum {
0611     CHANNEL_TLV_NONE,   /* ends tlv sequence */
0612     CHANNEL_TLV_ACQUIRE,
0613     CHANNEL_TLV_VPORT_START,
0614     CHANNEL_TLV_VPORT_UPDATE,
0615     CHANNEL_TLV_VPORT_TEARDOWN,
0616     CHANNEL_TLV_START_RXQ,
0617     CHANNEL_TLV_START_TXQ,
0618     CHANNEL_TLV_STOP_RXQS,
0619     CHANNEL_TLV_STOP_TXQS,
0620     CHANNEL_TLV_UPDATE_RXQ,
0621     CHANNEL_TLV_INT_CLEANUP,
0622     CHANNEL_TLV_CLOSE,
0623     CHANNEL_TLV_RELEASE,
0624     CHANNEL_TLV_LIST_END,
0625     CHANNEL_TLV_UCAST_FILTER,
0626     CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
0627     CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
0628     CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
0629     CHANNEL_TLV_VPORT_UPDATE_MCAST,
0630     CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
0631     CHANNEL_TLV_VPORT_UPDATE_RSS,
0632     CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
0633     CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
0634     CHANNEL_TLV_UPDATE_TUNN_PARAM,
0635     CHANNEL_TLV_COALESCE_UPDATE,
0636     CHANNEL_TLV_QID,
0637     CHANNEL_TLV_COALESCE_READ,
0638     CHANNEL_TLV_BULLETIN_UPDATE_MAC,
0639     CHANNEL_TLV_MAX,
0640 
0641     /* Required for iterating over vport-update tlvs.
0642      * Will break in case non-sequential vport-update tlvs.
0643      */
0644     CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
0645 };
0646 
0647 /* Default number of CIDs [total of both Rx and Tx] to be requested
0648  * by default, and maximum possible number.
0649  */
0650 #define QED_ETH_VF_DEFAULT_NUM_CIDS (32)
0651 #define QED_ETH_VF_MAX_NUM_CIDS (250)
0652 
0653 /* This data is held in the qed_hwfn structure for VFs only. */
0654 struct qed_vf_iov {
0655     union vfpf_tlvs *vf2pf_request;
0656     dma_addr_t vf2pf_request_phys;
0657     union pfvf_tlvs *pf2vf_reply;
0658     dma_addr_t pf2vf_reply_phys;
0659 
0660     /* Should be taken whenever the mailbox buffers are accessed */
0661     struct mutex mutex;
0662     u8 *offset;
0663 
0664     /* Bulletin Board */
0665     struct qed_bulletin bulletin;
0666     struct qed_bulletin_content bulletin_shadow;
0667 
0668     /* we set aside a copy of the acquire response */
0669     struct pfvf_acquire_resp_tlv acquire_resp;
0670 
0671     /* In case PF originates prior to the fp-hsi version comparison,
0672      * this has to be propagated as it affects the fastpath.
0673      */
0674     bool b_pre_fp_hsi;
0675 
0676     /* Current day VFs are passing the SBs physical address on vport
0677      * start, and as they lack an IGU mapping they need to store the
0678      * addresses of previously registered SBs.
0679      * Even if we were to change configuration flow, due to backward
0680      * compatibility [with older PFs] we'd still need to store these.
0681      */
0682     struct qed_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF];
0683 
0684     /* Determines whether VF utilizes doorbells via limited register
0685      * bar or via the doorbell bar.
0686      */
0687     bool b_doorbell_bar;
0688 };
0689 
0690 /**
0691  * qed_vf_pf_set_coalesce(): VF - Set Rx/Tx coalesce per VF's relative queue.
0692  *                                Coalesce value '0' will omit the
0693  *                                configuration.
0694  *
0695  * @p_hwfn: HW device data.
0696  * @rx_coal: coalesce value in micro second for rx queue.
0697  * @tx_coal: coalesce value in micro second for tx queue.
0698  * @p_cid: queue cid.
0699  *
0700  * Return: Int.
0701  *
0702  **/
0703 int qed_vf_pf_set_coalesce(struct qed_hwfn *p_hwfn,
0704                u16 rx_coal,
0705                u16 tx_coal, struct qed_queue_cid *p_cid);
0706 
0707 /**
0708  * qed_vf_pf_get_coalesce(): VF - Get coalesce per VF's relative queue.
0709  *
0710  * @p_hwfn: HW device data.
0711  * @p_coal: coalesce value in micro second for VF queues.
0712  * @p_cid: queue cid.
0713  *
0714  * Return: Int.
0715  **/
0716 int qed_vf_pf_get_coalesce(struct qed_hwfn *p_hwfn,
0717                u16 *p_coal, struct qed_queue_cid *p_cid);
0718 
0719 #ifdef CONFIG_QED_SRIOV
0720 /**
0721  * qed_vf_read_bulletin(): Read the VF bulletin and act on it if needed.
0722  *
0723  * @p_hwfn: HW device data.
0724  * @p_change: qed fills 1 iff bulletin board has changed, 0 otherwise.
0725  *
0726  * Return: enum _qed_status.
0727  */
0728 int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change);
0729 
0730 /**
0731  * qed_vf_get_link_params(): Get link parameters for VF from qed
0732  *
0733  * @p_hwfn: HW device data.
0734  * @params: the link params structure to be filled for the VF.
0735  *
0736  * Return: Void.
0737  */
0738 void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
0739                 struct qed_mcp_link_params *params);
0740 
0741 /**
0742  * qed_vf_get_link_state(): Get link state for VF from qed.
0743  *
0744  * @p_hwfn: HW device data.
0745  * @link: the link state structure to be filled for the VF
0746  *
0747  * Return: Void.
0748  */
0749 void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
0750                struct qed_mcp_link_state *link);
0751 
0752 /**
0753  * qed_vf_get_link_caps(): Get link capabilities for VF from qed.
0754  *
0755  * @p_hwfn: HW device data.
0756  * @p_link_caps: the link capabilities structure to be filled for the VF
0757  *
0758  * Return: Void.
0759  */
0760 void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
0761               struct qed_mcp_link_capabilities *p_link_caps);
0762 
0763 /**
0764  * qed_vf_get_num_rxqs(): Get number of Rx queues allocated for VF by qed
0765  *
0766  * @p_hwfn: HW device data.
0767  * @num_rxqs: allocated RX queues
0768  *
0769  * Return: Void.
0770  */
0771 void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs);
0772 
0773 /**
0774  * qed_vf_get_num_txqs(): Get number of Rx queues allocated for VF by qed
0775  *
0776  * @p_hwfn: HW device data.
0777  * @num_txqs: allocated RX queues
0778  *
0779  * Return: Void.
0780  */
0781 void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs);
0782 
0783 /**
0784  * qed_vf_get_num_cids(): Get number of available connections
0785  *                        [both Rx and Tx] for VF
0786  *
0787  * @p_hwfn: HW device data.
0788  * @num_cids: allocated number of connections
0789  *
0790  * Return: Void.
0791  */
0792 void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids);
0793 
0794 /**
0795  * qed_vf_get_port_mac(): Get port mac address for VF.
0796  *
0797  * @p_hwfn: HW device data.
0798  * @port_mac: destination location for port mac
0799  *
0800  * Return: Void.
0801  */
0802 void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac);
0803 
0804 /**
0805  * qed_vf_get_num_vlan_filters(): Get number of VLAN filters allocated
0806  *                                for VF by qed.
0807  *
0808  * @p_hwfn: HW device data.
0809  * @num_vlan_filters: allocated VLAN filters
0810  *
0811  * Return: Void.
0812  */
0813 void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
0814                  u8 *num_vlan_filters);
0815 
0816 /**
0817  * qed_vf_get_num_mac_filters(): Get number of MAC filters allocated
0818  *                               for VF by qed
0819  *
0820  * @p_hwfn: HW device data.
0821  * @num_mac_filters: allocated MAC filters
0822  *
0823  * Return: Void.
0824  */
0825 void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn, u8 *num_mac_filters);
0826 
0827 /**
0828  * qed_vf_check_mac(): Check if VF can set a MAC address
0829  *
0830  * @p_hwfn: HW device data.
0831  * @mac: Mac.
0832  *
0833  * Return: bool.
0834  */
0835 bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac);
0836 
0837 /**
0838  * qed_vf_get_fw_version(): Set firmware version information
0839  *                          in dev_info from VFs acquire response tlv
0840  *
0841  * @p_hwfn: HW device data.
0842  * @fw_major: FW major.
0843  * @fw_minor: FW minor.
0844  * @fw_rev: FW rev.
0845  * @fw_eng: FW eng.
0846  *
0847  * Return: Void.
0848  */
0849 void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
0850                u16 *fw_major, u16 *fw_minor,
0851                u16 *fw_rev, u16 *fw_eng);
0852 
0853 /**
0854  * qed_vf_hw_prepare(): hw preparation for VF  sends ACQUIRE message
0855  *
0856  * @p_hwfn: HW device data.
0857  *
0858  * Return: Int.
0859  */
0860 int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn);
0861 
0862 /**
0863  * qed_vf_pf_rxq_start(): start the RX Queue by sending a message to the PF
0864  *
0865  * @p_hwfn: HW device data.
0866  * @p_cid: Only relative fields are relevant
0867  * @bd_max_bytes: maximum number of bytes per bd
0868  * @bd_chain_phys_addr: physical address of bd chain
0869  * @cqe_pbl_addr: physical address of pbl
0870  * @cqe_pbl_size: pbl size
0871  * @pp_prod: pointer to the producer to be used in fastpath
0872  *
0873  * Return: Int.
0874  */
0875 int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
0876             struct qed_queue_cid *p_cid,
0877             u16 bd_max_bytes,
0878             dma_addr_t bd_chain_phys_addr,
0879             dma_addr_t cqe_pbl_addr,
0880             u16 cqe_pbl_size, void __iomem **pp_prod);
0881 
0882 /**
0883  * qed_vf_pf_txq_start(): VF - start the TX queue by sending a message to the
0884  *                        PF.
0885  *
0886  * @p_hwfn: HW device data.
0887  * @p_cid: CID.
0888  * @pbl_addr: PBL address.
0889  * @pbl_size: PBL Size.
0890  * @pp_doorbell: pointer to address to which to write the doorbell too.
0891  *
0892  * Return: Int.
0893  */
0894 int
0895 qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
0896             struct qed_queue_cid *p_cid,
0897             dma_addr_t pbl_addr,
0898             u16 pbl_size, void __iomem **pp_doorbell);
0899 
0900 /**
0901  * qed_vf_pf_rxq_stop(): VF - stop the RX queue by sending a message to the PF.
0902  *
0903  * @p_hwfn: HW device data.
0904  * @p_cid: CID.
0905  * @cqe_completion: CQE Completion.
0906  *
0907  * Return: Int.
0908  */
0909 int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
0910                struct qed_queue_cid *p_cid, bool cqe_completion);
0911 
0912 /**
0913  * qed_vf_pf_txq_stop(): VF - stop the TX queue by sending a message to the PF.
0914  *
0915  * @p_hwfn: HW device data.
0916  * @p_cid: CID.
0917  *
0918  * Return: Int.
0919  */
0920 int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, struct qed_queue_cid *p_cid);
0921 
0922 /**
0923  * qed_vf_pf_vport_update(): VF - send a vport update command.
0924  *
0925  * @p_hwfn: HW device data.
0926  * @p_params: Params
0927  *
0928  * Return: Int.
0929  */
0930 int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
0931                struct qed_sp_vport_update_params *p_params);
0932 
0933 /**
0934  * qed_vf_pf_reset(): VF - send a close message to PF.
0935  *
0936  * @p_hwfn: HW device data.
0937  *
0938  * Return: enum _qed_status
0939  */
0940 int qed_vf_pf_reset(struct qed_hwfn *p_hwfn);
0941 
0942 /**
0943  * qed_vf_pf_release(): VF - free vf`s memories.
0944  *
0945  * @p_hwfn: HW device data.
0946  *
0947  * Return: enum _qed_status
0948  */
0949 int qed_vf_pf_release(struct qed_hwfn *p_hwfn);
0950 
0951 /**
0952  * qed_vf_get_igu_sb_id(): Get the IGU SB ID for a given
0953  *        sb_id. For VFs igu sbs don't have to be contiguous
0954  *
0955  * @p_hwfn: HW device data.
0956  * @sb_id: SB ID.
0957  *
0958  * Return: INLINE u16
0959  */
0960 u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id);
0961 
0962 /**
0963  * qed_vf_set_sb_info(): Stores [or removes] a configured sb_info.
0964  *
0965  * @p_hwfn: HW device data.
0966  * @sb_id: zero-based SB index [for fastpath]
0967  * @p_sb:  may be NULL [during removal].
0968  *
0969  * Return: Void.
0970  */
0971 void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn,
0972             u16 sb_id, struct qed_sb_info *p_sb);
0973 
0974 /**
0975  * qed_vf_pf_vport_start(): perform vport start for VF.
0976  *
0977  * @p_hwfn: HW device data.
0978  * @vport_id: Vport ID.
0979  * @mtu: MTU.
0980  * @inner_vlan_removal: Innter VLAN removal.
0981  * @tpa_mode: TPA mode
0982  * @max_buffers_per_cqe: Max buffer pre CQE.
0983  * @only_untagged: default behavior regarding vlan acceptance
0984  *
0985  * Return: enum _qed_status
0986  */
0987 int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
0988               u8 vport_id,
0989               u16 mtu,
0990               u8 inner_vlan_removal,
0991               enum qed_tpa_mode tpa_mode,
0992               u8 max_buffers_per_cqe, u8 only_untagged);
0993 
0994 /**
0995  * qed_vf_pf_vport_stop(): stop the VF's vport
0996  *
0997  * @p_hwfn: HW device data.
0998  *
0999  * Return: enum _qed_status
1000  */
1001 int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn);
1002 
1003 int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
1004                struct qed_filter_ucast *p_param);
1005 
1006 void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
1007                 struct qed_filter_mcast *p_filter_cmd);
1008 
1009 /**
1010  * qed_vf_pf_int_cleanup(): clean the SB of the VF
1011  *
1012  * @p_hwfn: HW device data.
1013  *
1014  * Return: enum _qed_status
1015  */
1016 int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn);
1017 
1018 /**
1019  * __qed_vf_get_link_params(): return the link params in a given bulletin board
1020  *
1021  * @p_hwfn: HW device data.
1022  * @p_params: pointer to a struct to fill with link params
1023  * @p_bulletin: Bulletin.
1024  *
1025  * Return: Void.
1026  */
1027 void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
1028                   struct qed_mcp_link_params *p_params,
1029                   struct qed_bulletin_content *p_bulletin);
1030 
1031 /**
1032  * __qed_vf_get_link_state(): return the link state in a given bulletin board
1033  *
1034  * @p_hwfn: HW device data.
1035  * @p_link: pointer to a struct to fill with link state
1036  * @p_bulletin: Bulletin.
1037  *
1038  * Return: Void.
1039  */
1040 void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
1041                  struct qed_mcp_link_state *p_link,
1042                  struct qed_bulletin_content *p_bulletin);
1043 
1044 /**
1045  * __qed_vf_get_link_caps(): return the link capabilities in a given
1046  *                           bulletin board
1047  *
1048  * @p_hwfn: HW device data.
1049  * @p_link_caps: pointer to a struct to fill with link capabilities
1050  * @p_bulletin: Bulletin.
1051  *
1052  * Return: Void.
1053  */
1054 void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
1055                 struct qed_mcp_link_capabilities *p_link_caps,
1056                 struct qed_bulletin_content *p_bulletin);
1057 
1058 void qed_iov_vf_task(struct work_struct *work);
1059 void qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun);
1060 int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
1061                   struct qed_tunnel_info *p_tunn);
1062 
1063 u32 qed_vf_hw_bar_size(struct qed_hwfn *p_hwfn, enum BAR_ID bar_id);
1064 /**
1065  * qed_vf_pf_bulletin_update_mac(): Ask PF to update the MAC address in
1066  *                                  it's bulletin board
1067  *
1068  * @p_hwfn: HW device data.
1069  * @p_mac: mac address to be updated in bulletin board
1070  *
1071  * Return: Int.
1072  */
1073 int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn, const u8 *p_mac);
1074 
1075 #else
1076 static inline void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
1077                       struct qed_mcp_link_params *params)
1078 {
1079 }
1080 
1081 static inline void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
1082                      struct qed_mcp_link_state *link)
1083 {
1084 }
1085 
1086 static inline void
1087 qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
1088              struct qed_mcp_link_capabilities *p_link_caps)
1089 {
1090 }
1091 
1092 static inline void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
1093 {
1094 }
1095 
1096 static inline void qed_vf_get_num_txqs(struct qed_hwfn *p_hwfn, u8 *num_txqs)
1097 {
1098 }
1099 
1100 static inline void qed_vf_get_num_cids(struct qed_hwfn *p_hwfn, u8 *num_cids)
1101 {
1102 }
1103 
1104 static inline void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
1105 {
1106 }
1107 
1108 static inline void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn,
1109                            u8 *num_vlan_filters)
1110 {
1111 }
1112 
1113 static inline void qed_vf_get_num_mac_filters(struct qed_hwfn *p_hwfn,
1114                           u8 *num_mac_filters)
1115 {
1116 }
1117 
1118 static inline bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
1119 {
1120     return false;
1121 }
1122 
1123 static inline void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
1124                      u16 *fw_major, u16 *fw_minor,
1125                      u16 *fw_rev, u16 *fw_eng)
1126 {
1127 }
1128 
1129 static inline int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
1130 {
1131     return -EINVAL;
1132 }
1133 
1134 static inline int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
1135                       struct qed_queue_cid *p_cid,
1136                       u16 bd_max_bytes,
1137                       dma_addr_t bd_chain_phys_adr,
1138                       dma_addr_t cqe_pbl_addr,
1139                       u16 cqe_pbl_size, void __iomem **pp_prod)
1140 {
1141     return -EINVAL;
1142 }
1143 
1144 static inline int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
1145                       struct qed_queue_cid *p_cid,
1146                       dma_addr_t pbl_addr,
1147                       u16 pbl_size, void __iomem **pp_doorbell)
1148 {
1149     return -EINVAL;
1150 }
1151 
1152 static inline int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn,
1153                      struct qed_queue_cid *p_cid,
1154                      bool cqe_completion)
1155 {
1156     return -EINVAL;
1157 }
1158 
1159 static inline int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn,
1160                      struct qed_queue_cid *p_cid)
1161 {
1162     return -EINVAL;
1163 }
1164 
1165 static inline int
1166 qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
1167                struct qed_sp_vport_update_params *p_params)
1168 {
1169     return -EINVAL;
1170 }
1171 
1172 static inline int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
1173 {
1174     return -EINVAL;
1175 }
1176 
1177 static inline int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
1178 {
1179     return -EINVAL;
1180 }
1181 
1182 static inline u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
1183 {
1184     return 0;
1185 }
1186 
1187 static inline void qed_vf_set_sb_info(struct qed_hwfn *p_hwfn, u16 sb_id,
1188                       struct qed_sb_info *p_sb)
1189 {
1190 }
1191 
1192 static inline int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
1193                     u8 vport_id,
1194                     u16 mtu,
1195                     u8 inner_vlan_removal,
1196                     enum qed_tpa_mode tpa_mode,
1197                     u8 max_buffers_per_cqe,
1198                     u8 only_untagged)
1199 {
1200     return -EINVAL;
1201 }
1202 
1203 static inline int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
1204 {
1205     return -EINVAL;
1206 }
1207 
1208 static inline int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
1209                      struct qed_filter_ucast *p_param)
1210 {
1211     return -EINVAL;
1212 }
1213 
1214 static inline void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
1215                       struct qed_filter_mcast *p_filter_cmd)
1216 {
1217 }
1218 
1219 static inline int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
1220 {
1221     return -EINVAL;
1222 }
1223 
1224 static inline void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
1225                         struct qed_mcp_link_params
1226                         *p_params,
1227                         struct qed_bulletin_content
1228                         *p_bulletin)
1229 {
1230 }
1231 
1232 static inline void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
1233                        struct qed_mcp_link_state *p_link,
1234                        struct qed_bulletin_content
1235                        *p_bulletin)
1236 {
1237 }
1238 
1239 static inline void
1240 __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
1241                struct qed_mcp_link_capabilities *p_link_caps,
1242                struct qed_bulletin_content *p_bulletin)
1243 {
1244 }
1245 
1246 static inline void qed_iov_vf_task(struct work_struct *work)
1247 {
1248 }
1249 
1250 static inline void
1251 qed_vf_set_vf_start_tunn_update_param(struct qed_tunnel_info *p_tun)
1252 {
1253 }
1254 
1255 static inline int qed_vf_pf_tunnel_param_update(struct qed_hwfn *p_hwfn,
1256                         struct qed_tunnel_info *p_tunn)
1257 {
1258     return -EINVAL;
1259 }
1260 
1261 static inline int qed_vf_pf_bulletin_update_mac(struct qed_hwfn *p_hwfn,
1262                         const u8 *p_mac)
1263 {
1264     return -EINVAL;
1265 }
1266 
1267 static inline u32
1268 qed_vf_hw_bar_size(struct qed_hwfn  *p_hwfn,
1269            enum BAR_ID bar_id)
1270 {
1271     return 0;
1272 }
1273 #endif
1274 
1275 #endif