Back to home page

OSCL-LXR

 
 

    


0001 /* bnx2x_vfpf.h: Qlogic Everest network driver.
0002  *
0003  * Copyright (c) 2011-2013 Broadcom Corporation
0004  * Copyright (c) 2014 QLogic Corporation
0005  * All rights reserved
0006  *
0007  * Unless you and Qlogic execute a separate written software license
0008  * agreement governing use of this software, this software is licensed to you
0009  * under the terms of the GNU General Public License version 2 (the “GPL”),
0010  * available at http://www.gnu.org/licenses/gpl-2.0.html, with the following
0011  * added to such license:
0012  *
0013  * As a special exception, the copyright holders of this software give you
0014  * permission to link this software with independent modules, and to copy and
0015  * distribute the resulting executable under terms of your choice, provided that
0016  * you also meet, for each linked independent module, the terms and conditions
0017  * of the license of that module.  An independent module is a module which is
0018  * not derived from this software.  The special exception does not apply to any
0019  * modifications of the software.
0020  *
0021  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
0022  * Written by: Ariel Elior <ariel.elior@qlogic.com>
0023  */
0024 #ifndef VF_PF_IF_H
0025 #define VF_PF_IF_H
0026 
0027 #ifdef CONFIG_BNX2X_SRIOV
0028 
0029 /* Common definitions for all HVs */
0030 struct vf_pf_resc_request {
0031     u8  num_rxqs;
0032     u8  num_txqs;
0033     u8  num_sbs;
0034     u8  num_mac_filters;
0035     u8  num_vlan_filters;
0036     u8  num_mc_filters; /* No limit  so superfluous */
0037 };
0038 
0039 struct hw_sb_info {
0040     u8 hw_sb_id;    /* aka absolute igu id, used to ack the sb */
0041     u8 sb_qid;  /* used to update DHC for sb */
0042 };
0043 
0044 /* HW VF-PF channel definitions
0045  * A.K.A VF-PF mailbox
0046  */
0047 #define TLV_BUFFER_SIZE         1024
0048 #define PF_VF_BULLETIN_SIZE     512
0049 
0050 #define VFPF_QUEUE_FLG_TPA      0x0001
0051 #define VFPF_QUEUE_FLG_TPA_IPV6     0x0002
0052 #define VFPF_QUEUE_FLG_TPA_GRO      0x0004
0053 #define VFPF_QUEUE_FLG_CACHE_ALIGN  0x0008
0054 #define VFPF_QUEUE_FLG_STATS        0x0010
0055 #define VFPF_QUEUE_FLG_OV       0x0020
0056 #define VFPF_QUEUE_FLG_VLAN     0x0040
0057 #define VFPF_QUEUE_FLG_COS      0x0080
0058 #define VFPF_QUEUE_FLG_HC       0x0100
0059 #define VFPF_QUEUE_FLG_DHC      0x0200
0060 #define VFPF_QUEUE_FLG_LEADING_RSS  0x0400
0061 
0062 #define VFPF_QUEUE_DROP_IP_CS_ERR   (1 << 0)
0063 #define VFPF_QUEUE_DROP_TCP_CS_ERR  (1 << 1)
0064 #define VFPF_QUEUE_DROP_TTL0        (1 << 2)
0065 #define VFPF_QUEUE_DROP_UDP_CS_ERR  (1 << 3)
0066 
0067 #define VFPF_RX_MASK_ACCEPT_NONE        0x00000000
0068 #define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST 0x00000001
0069 #define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST   0x00000002
0070 #define VFPF_RX_MASK_ACCEPT_ALL_UNICAST     0x00000004
0071 #define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST   0x00000008
0072 #define VFPF_RX_MASK_ACCEPT_BROADCAST       0x00000010
0073 #define VFPF_RX_MASK_ACCEPT_ANY_VLAN        0x00000020
0074 
0075 #define BULLETIN_CONTENT_SIZE       (sizeof(struct pf_vf_bulletin_content))
0076 #define BULLETIN_CONTENT_LEGACY_SIZE    (32)
0077 #define BULLETIN_ATTEMPTS   5 /* crc failures before throwing towel */
0078 #define BULLETIN_CRC_SEED   0
0079 
0080 enum {
0081     PFVF_STATUS_WAITING = 0,
0082     PFVF_STATUS_SUCCESS,
0083     PFVF_STATUS_FAILURE,
0084     PFVF_STATUS_NOT_SUPPORTED,
0085     PFVF_STATUS_NO_RESOURCE
0086 };
0087 
0088 /* vf pf channel tlvs */
0089 /* general tlv header (used for both vf->pf request and pf->vf response) */
0090 struct channel_tlv {
0091     u16 type;
0092     u16 length;
0093 };
0094 
0095 /* header of first vf->pf tlv carries the offset used to calculate response
0096  * buffer address
0097  */
0098 struct vfpf_first_tlv {
0099     struct channel_tlv tl;
0100     u32 resp_msg_offset;
0101 };
0102 
0103 /* header of pf->vf tlvs, carries the status of handling the request */
0104 struct pfvf_tlv {
0105     struct channel_tlv tl;
0106     u8 status;
0107     u8 padding[3];
0108 };
0109 
0110 /* response tlv used for most tlvs */
0111 struct pfvf_general_resp_tlv {
0112     struct pfvf_tlv hdr;
0113 };
0114 
0115 /* used to terminate and pad a tlv list */
0116 struct channel_list_end_tlv {
0117     struct channel_tlv tl;
0118     u8 padding[4];
0119 };
0120 
0121 /* Acquire */
0122 struct vfpf_acquire_tlv {
0123     struct vfpf_first_tlv first_tlv;
0124 
0125     struct vf_pf_vfdev_info {
0126         /* the following fields are for debug purposes */
0127         u8  vf_id;      /* ME register value */
0128         u8  vf_os;      /* e.g. Linux, W2K8 */
0129 #define VF_OS_SUBVERSION_MASK   (0x1f)
0130 #define VF_OS_MASK      (0xe0)
0131 #define VF_OS_SHIFT     (5)
0132 #define VF_OS_UNDEFINED     (0 << VF_OS_SHIFT)
0133 #define VF_OS_WINDOWS       (1 << VF_OS_SHIFT)
0134 
0135         u8 fp_hsi_ver;
0136         u8 caps;
0137 #define VF_CAP_SUPPORT_EXT_BULLETIN (1 << 0)
0138 #define VF_CAP_SUPPORT_VLAN_FILTER  (1 << 1)
0139     } vfdev_info;
0140 
0141     struct vf_pf_resc_request resc_request;
0142 
0143     aligned_u64 bulletin_addr;
0144 };
0145 
0146 /* simple operation request on queue */
0147 struct vfpf_q_op_tlv {
0148     struct vfpf_first_tlv   first_tlv;
0149     u8 vf_qid;
0150     u8 padding[3];
0151 };
0152 
0153 /* receive side scaling tlv */
0154 struct vfpf_rss_tlv {
0155     struct vfpf_first_tlv   first_tlv;
0156     u32         rss_flags;
0157 #define VFPF_RSS_MODE_DISABLED  (1 << 0)
0158 #define VFPF_RSS_MODE_REGULAR   (1 << 1)
0159 #define VFPF_RSS_SET_SRCH   (1 << 2)
0160 #define VFPF_RSS_IPV4       (1 << 3)
0161 #define VFPF_RSS_IPV4_TCP   (1 << 4)
0162 #define VFPF_RSS_IPV4_UDP   (1 << 5)
0163 #define VFPF_RSS_IPV6       (1 << 6)
0164 #define VFPF_RSS_IPV6_TCP   (1 << 7)
0165 #define VFPF_RSS_IPV6_UDP   (1 << 8)
0166     u8          rss_result_mask;
0167     u8          ind_table_size;
0168     u8          rss_key_size;
0169     u8          padding;
0170     u8          ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
0171     u32         rss_key[T_ETH_RSS_KEY]; /* hash values */
0172 };
0173 
0174 /* acquire response tlv - carries the allocated resources */
0175 struct pfvf_acquire_resp_tlv {
0176     struct pfvf_tlv hdr;
0177     struct pf_vf_pfdev_info {
0178         u32 chip_num;
0179         u32 pf_cap;
0180 #define PFVF_CAP_RSS          0x00000001
0181 #define PFVF_CAP_DHC          0x00000002
0182 #define PFVF_CAP_TPA          0x00000004
0183 #define PFVF_CAP_TPA_UPDATE   0x00000008
0184 #define PFVF_CAP_VLAN_FILTER  0x00000010
0185 
0186         char fw_ver[32];
0187         u16 db_size;
0188         u8  indices_per_sb;
0189         u8  padding;
0190     } pfdev_info;
0191     struct pf_vf_resc {
0192         /* in case of status NO_RESOURCE in message hdr, pf will fill
0193          * this struct with suggested amount of resources for next
0194          * acquire request
0195          */
0196 #define PFVF_MAX_QUEUES_PER_VF         16
0197 #define PFVF_MAX_SBS_PER_VF            16
0198         struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
0199         u8  hw_qid[PFVF_MAX_QUEUES_PER_VF];
0200         u8  num_rxqs;
0201         u8  num_txqs;
0202         u8  num_sbs;
0203         u8  num_mac_filters;
0204         u8  num_vlan_filters;
0205         u8  num_mc_filters;
0206         u8  permanent_mac_addr[ETH_ALEN];
0207         u8  current_mac_addr[ETH_ALEN];
0208         u8  padding[2];
0209     } resc;
0210 };
0211 
0212 struct vfpf_port_phys_id_resp_tlv {
0213     struct channel_tlv tl;
0214     u8 id[ETH_ALEN];
0215     u8 padding[2];
0216 };
0217 
0218 struct vfpf_fp_hsi_resp_tlv {
0219     struct channel_tlv tl;
0220     u8 is_supported;
0221     u8 padding[3];
0222 };
0223 
0224 #define VFPF_INIT_FLG_STATS_COALESCE    (1 << 0) /* when set the VFs queues
0225                           * stats will be coalesced on
0226                           * the leading RSS queue
0227                           */
0228 
0229 /* Init VF */
0230 struct vfpf_init_tlv {
0231     struct vfpf_first_tlv first_tlv;
0232     aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
0233     aligned_u64 spq_addr;
0234     aligned_u64 stats_addr;
0235     u16 stats_stride;
0236     u32 flags;
0237     u32 padding[2];
0238 };
0239 
0240 /* Setup Queue */
0241 struct vfpf_setup_q_tlv {
0242     struct vfpf_first_tlv first_tlv;
0243 
0244     struct vf_pf_rxq_params {
0245         /* physical addresses */
0246         aligned_u64 rcq_addr;
0247         aligned_u64 rcq_np_addr;
0248         aligned_u64 rxq_addr;
0249         aligned_u64 sge_addr;
0250 
0251         /* sb + hc info */
0252         u8  vf_sb;      /* index in hw_sbs[] */
0253         u8  sb_index;       /* Index in the SB */
0254         u16 hc_rate;        /* desired interrupts per sec. */
0255                     /* valid iff VFPF_QUEUE_FLG_HC */
0256         /* rx buffer info */
0257         u16 mtu;
0258         u16 buf_sz;
0259         u16 flags;      /* VFPF_QUEUE_FLG_X flags */
0260         u16 stat_id;        /* valid iff VFPF_QUEUE_FLG_STATS */
0261 
0262         /* valid iff VFPF_QUEUE_FLG_TPA */
0263         u16 sge_buf_sz;
0264         u16 tpa_agg_sz;
0265         u8 max_sge_pkt;
0266 
0267         u8 drop_flags;      /* VFPF_QUEUE_DROP_X, for Linux VMs
0268                      * all the flags are turned off
0269                      */
0270 
0271         u8 cache_line_log;  /* VFPF_QUEUE_FLG_CACHE_ALIGN */
0272         u8 padding;
0273     } rxq;
0274 
0275     struct vf_pf_txq_params {
0276         /* physical addresses */
0277         aligned_u64 txq_addr;
0278 
0279         /* sb + hc info */
0280         u8  vf_sb;      /* index in hw_sbs[] */
0281         u8  sb_index;       /* Index in the SB */
0282         u16 hc_rate;        /* desired interrupts per sec. */
0283                     /* valid iff VFPF_QUEUE_FLG_HC */
0284         u32 flags;      /* VFPF_QUEUE_FLG_X flags */
0285         u16 stat_id;        /* valid iff VFPF_QUEUE_FLG_STATS */
0286         u8  traffic_type;   /* see in setup_context() */
0287         u8  padding;
0288     } txq;
0289 
0290     u8 vf_qid;          /* index in hw_qid[] */
0291     u8 param_valid;
0292 #define VFPF_RXQ_VALID      0x01
0293 #define VFPF_TXQ_VALID      0x02
0294     u8 padding[2];
0295 };
0296 
0297 /* Set Queue Filters */
0298 struct vfpf_q_mac_vlan_filter {
0299     u32 flags;
0300 #define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
0301 #define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
0302 #define VFPF_Q_FILTER_SET       0x100   /* set/clear */
0303     u8  mac[ETH_ALEN];
0304     u16 vlan_tag;
0305 };
0306 
0307 /* configure queue filters */
0308 struct vfpf_set_q_filters_tlv {
0309     struct vfpf_first_tlv first_tlv;
0310 
0311     u32 flags;
0312 #define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 0x01
0313 #define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED    0x02
0314 #define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED  0x04
0315 
0316     u8 vf_qid;          /* index in hw_qid[] */
0317     u8 n_mac_vlan_filters;
0318     u8 n_multicast;
0319     u8 padding;
0320 
0321 #define PFVF_MAX_MAC_FILTERS                   16
0322 #define PFVF_MAX_VLAN_FILTERS                  16
0323 #define PFVF_MAX_FILTERS               (PFVF_MAX_MAC_FILTERS +\
0324                      PFVF_MAX_VLAN_FILTERS)
0325     struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
0326 
0327 #define PFVF_MAX_MULTICAST_PER_VF              32
0328     u8  multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
0329 
0330     u32 rx_mask;    /* see mask constants at the top of the file */
0331 };
0332 
0333 struct vfpf_tpa_tlv {
0334     struct vfpf_first_tlv   first_tlv;
0335 
0336     struct vf_pf_tpa_client_info {
0337         aligned_u64 sge_addr[PFVF_MAX_QUEUES_PER_VF];
0338         u8 update_ipv4;
0339         u8 update_ipv6;
0340         u8 max_tpa_queues;
0341         u8 max_sges_for_packet;
0342         u8 complete_on_both_clients;
0343         u8 dont_verify_thr;
0344         u8 tpa_mode;
0345         u16 sge_buff_size;
0346         u16 max_agg_size;
0347         u16 sge_pause_thr_low;
0348         u16 sge_pause_thr_high;
0349     } tpa_client_info;
0350 };
0351 
0352 /* close VF (disable VF) */
0353 struct vfpf_close_tlv {
0354     struct vfpf_first_tlv   first_tlv;
0355     u16         vf_id;  /* for debug */
0356     u8 padding[2];
0357 };
0358 
0359 /* release the VF's acquired resources */
0360 struct vfpf_release_tlv {
0361     struct vfpf_first_tlv   first_tlv;
0362     u16         vf_id;
0363     u8 padding[2];
0364 };
0365 
0366 struct tlv_buffer_size {
0367     u8 tlv_buffer[TLV_BUFFER_SIZE];
0368 };
0369 
0370 union vfpf_tlvs {
0371     struct vfpf_first_tlv       first_tlv;
0372     struct vfpf_acquire_tlv     acquire;
0373     struct vfpf_init_tlv        init;
0374     struct vfpf_close_tlv       close;
0375     struct vfpf_q_op_tlv        q_op;
0376     struct vfpf_setup_q_tlv     setup_q;
0377     struct vfpf_set_q_filters_tlv   set_q_filters;
0378     struct vfpf_release_tlv     release;
0379     struct vfpf_rss_tlv     update_rss;
0380     struct vfpf_tpa_tlv     update_tpa;
0381     struct channel_list_end_tlv list_end;
0382     struct tlv_buffer_size      tlv_buf_size;
0383 };
0384 
0385 union pfvf_tlvs {
0386     struct pfvf_general_resp_tlv    general_resp;
0387     struct pfvf_acquire_resp_tlv    acquire_resp;
0388     struct channel_list_end_tlv list_end;
0389     struct tlv_buffer_size      tlv_buf_size;
0390 };
0391 
0392 /* This is a structure which is allocated in the VF, which the PF may update
0393  * when it deems it necessary to do so. The bulletin board is sampled
0394  * periodically by the VF. A copy per VF is maintained in the PF (to prevent
0395  * loss of data upon multiple updates (or the need for read modify write)).
0396  */
0397 struct pf_vf_bulletin_size {
0398     u8 size[PF_VF_BULLETIN_SIZE];
0399 };
0400 
0401 struct pf_vf_bulletin_content {
0402     u32 crc;            /* crc of structure to ensure is not in
0403                      * mid-update
0404                      */
0405     u16 version;
0406     u16 length;
0407 
0408     aligned_u64 valid_bitmap;   /* bitmap indicating which fields
0409                      * hold valid values
0410                      */
0411 
0412 #define MAC_ADDR_VALID      0   /* alert the vf that a new mac address
0413                      * is available for it
0414                      */
0415 #define VLAN_VALID      1   /* when set, the vf should not access
0416                      * the vfpf channel
0417                      */
0418 #define CHANNEL_DOWN        2   /* vfpf channel is disabled. VFs are not
0419                      * to attempt to send messages on the
0420                      * channel after this bit is set
0421                      */
0422 #define LINK_VALID      3   /* alert the VF thet a new link status
0423                      * update is available for it
0424                      */
0425     u8 mac[ETH_ALEN];
0426     u8 mac_padding[2];
0427 
0428     u16 vlan;
0429     u8 vlan_padding[6];
0430 
0431     u16 link_speed;          /* Effective line speed */
0432     u8 link_speed_padding[6];
0433     u32 link_flags;          /* VFPF_LINK_REPORT_XXX flags */
0434 #define VFPF_LINK_REPORT_LINK_DOWN   (1 << 0)
0435 #define VFPF_LINK_REPORT_FULL_DUPLEX     (1 << 1)
0436 #define VFPF_LINK_REPORT_RX_FC_ON    (1 << 2)
0437 #define VFPF_LINK_REPORT_TX_FC_ON    (1 << 3)
0438     u8 link_flags_padding[4];
0439 };
0440 
0441 union pf_vf_bulletin {
0442     struct pf_vf_bulletin_content content;
0443     struct pf_vf_bulletin_size size;
0444 };
0445 
0446 #define MAX_TLVS_IN_LIST 50
0447 
0448 enum channel_tlvs {
0449     CHANNEL_TLV_NONE,
0450     CHANNEL_TLV_ACQUIRE,
0451     CHANNEL_TLV_INIT,
0452     CHANNEL_TLV_SETUP_Q,
0453     CHANNEL_TLV_SET_Q_FILTERS,
0454     CHANNEL_TLV_ACTIVATE_Q,
0455     CHANNEL_TLV_DEACTIVATE_Q,
0456     CHANNEL_TLV_TEARDOWN_Q,
0457     CHANNEL_TLV_CLOSE,
0458     CHANNEL_TLV_RELEASE,
0459     CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
0460     CHANNEL_TLV_PF_RELEASE_VF,
0461     CHANNEL_TLV_LIST_END,
0462     CHANNEL_TLV_FLR,
0463     CHANNEL_TLV_PF_SET_MAC,
0464     CHANNEL_TLV_PF_SET_VLAN,
0465     CHANNEL_TLV_UPDATE_RSS,
0466     CHANNEL_TLV_PHYS_PORT_ID,
0467     CHANNEL_TLV_UPDATE_TPA,
0468     CHANNEL_TLV_FP_HSI_SUPPORT,
0469     CHANNEL_TLV_MAX
0470 };
0471 
0472 #endif /* CONFIG_BNX2X_SRIOV */
0473 #endif /* VF_PF_IF_H */