akaros/kern/drivers/net/bnx2x/bnx2x_vfpf.h
<<
>>
Prefs
   1/* bnx2x_vfpf.h: Broadcom Everest network driver.
   2 *
   3 * Copyright (c) 2011-2013 Broadcom Corporation
   4 *
   5 * Unless you and Broadcom execute a separate written software license
   6 * agreement governing use of this software, this software is licensed to you
   7 * under the terms of the GNU General Public License version 2, available
   8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
   9 *
  10 * Notwithstanding the above, under no circumstances may you combine this
  11 * software in any way with any other Broadcom software provided under a
  12 * license other than the GPL, without Broadcom's express prior written
  13 * consent.
  14 *
  15 * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
  16 * Written by: Ariel Elior <ariel.elior@qlogic.com>
  17 */
  18#pragma once
  19
  20#ifdef CONFIG_BNX2X_SRIOV
  21
  22/* Common definitions for all HVs */
  23struct vf_pf_resc_request {
  24        uint8_t  num_rxqs;
  25        uint8_t  num_txqs;
  26        uint8_t  num_sbs;
  27        uint8_t  num_mac_filters;
  28        uint8_t  num_vlan_filters;
  29        uint8_t  num_mc_filters; /* No limit  so superfluous */
  30};
  31
  32struct hw_sb_info {
  33        uint8_t hw_sb_id;       /* aka absolute igu id, used to ack the sb */
  34        uint8_t sb_qid; /* used to update DHC for sb */
  35};
  36
  37/* HW VF-PF channel definitions
  38 * A.K.A VF-PF mailbox
  39 */
  40#define TLV_BUFFER_SIZE                 1024
  41#define PF_VF_BULLETIN_SIZE             512
  42
  43#define VFPF_QUEUE_FLG_TPA              0x0001
  44#define VFPF_QUEUE_FLG_TPA_IPV6         0x0002
  45#define VFPF_QUEUE_FLG_TPA_GRO          0x0004
  46#define VFPF_QUEUE_FLG_CACHE_ALIGN      0x0008
  47#define VFPF_QUEUE_FLG_STATS            0x0010
  48#define VFPF_QUEUE_FLG_OV               0x0020
  49#define VFPF_QUEUE_FLG_VLAN             0x0040
  50#define VFPF_QUEUE_FLG_COS              0x0080
  51#define VFPF_QUEUE_FLG_HC               0x0100
  52#define VFPF_QUEUE_FLG_DHC              0x0200
  53#define VFPF_QUEUE_FLG_LEADING_RSS      0x0400
  54
  55#define VFPF_QUEUE_DROP_IP_CS_ERR       (1 << 0)
  56#define VFPF_QUEUE_DROP_TCP_CS_ERR      (1 << 1)
  57#define VFPF_QUEUE_DROP_TTL0            (1 << 2)
  58#define VFPF_QUEUE_DROP_UDP_CS_ERR      (1 << 3)
  59
  60#define VFPF_RX_MASK_ACCEPT_NONE                0x00000000
  61#define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST     0x00000001
  62#define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST   0x00000002
  63#define VFPF_RX_MASK_ACCEPT_ALL_UNICAST         0x00000004
  64#define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST       0x00000008
  65#define VFPF_RX_MASK_ACCEPT_BROADCAST           0x00000010
  66#define BULLETIN_CONTENT_SIZE           (sizeof(struct pf_vf_bulletin_content))
  67#define BULLETIN_CONTENT_LEGACY_SIZE    (32)
  68#define BULLETIN_ATTEMPTS       5 /* crc failures before throwing towel */
  69#define BULLETIN_CRC_SEED       0
  70
  71enum {
  72        PFVF_STATUS_WAITING = 0,
  73        PFVF_STATUS_SUCCESS,
  74        PFVF_STATUS_FAILURE,
  75        PFVF_STATUS_NOT_SUPPORTED,
  76        PFVF_STATUS_NO_RESOURCE
  77};
  78
  79/* vf pf channel tlvs */
  80/* general tlv header (used for both vf->pf request and pf->vf response) */
  81struct channel_tlv {
  82        uint16_t type;
  83        uint16_t length;
  84};
  85
  86/* header of first vf->pf tlv carries the offset used to calculate response
  87 * buffer address
  88 */
  89struct vfpf_first_tlv {
  90        struct channel_tlv tl;
  91        uint32_t resp_msg_offset;
  92};
  93
  94/* header of pf->vf tlvs, carries the status of handling the request */
  95struct pfvf_tlv {
  96        struct channel_tlv tl;
  97        uint8_t status;
  98        uint8_t padding[3];
  99};
 100
 101/* response tlv used for most tlvs */
 102struct pfvf_general_resp_tlv {
 103        struct pfvf_tlv hdr;
 104};
 105
 106/* used to terminate and pad a tlv list */
 107struct channel_list_end_tlv {
 108        struct channel_tlv tl;
 109        uint8_t padding[4];
 110};
 111
 112/* Acquire */
 113struct vfpf_acquire_tlv {
 114        struct vfpf_first_tlv first_tlv;
 115
 116        struct vf_pf_vfdev_info {
 117                /* the following fields are for debug purposes */
 118                uint8_t  vf_id;         /* ME register value */
 119                uint8_t  vf_os;         /* e.g. Linux, W2K8 */
 120#define VF_OS_SUBVERSION_MASK   (0x1f)
 121#define VF_OS_MASK              (0xe0)
 122#define VF_OS_SHIFT             (5)
 123#define VF_OS_UNDEFINED         (0 << VF_OS_SHIFT)
 124#define VF_OS_WINDOWS           (1 << VF_OS_SHIFT)
 125
 126                uint8_t fp_hsi_ver;
 127                uint8_t caps;
 128#define VF_CAP_SUPPORT_EXT_BULLETIN     (1 << 0)
 129        } vfdev_info;
 130
 131        struct vf_pf_resc_request resc_request;
 132
 133        aligned_u64 bulletin_addr;
 134};
 135
 136/* simple operation request on queue */
 137struct vfpf_q_op_tlv {
 138        struct vfpf_first_tlv   first_tlv;
 139        uint8_t vf_qid;
 140        uint8_t padding[3];
 141};
 142
 143/* receive side scaling tlv */
 144struct vfpf_rss_tlv {
 145        struct vfpf_first_tlv   first_tlv;
 146        uint32_t                        rss_flags;
 147#define VFPF_RSS_MODE_DISABLED  (1 << 0)
 148#define VFPF_RSS_MODE_REGULAR   (1 << 1)
 149#define VFPF_RSS_SET_SRCH       (1 << 2)
 150#define VFPF_RSS_IPV4           (1 << 3)
 151#define VFPF_RSS_IPV4_TCP       (1 << 4)
 152#define VFPF_RSS_IPV4_UDP       (1 << 5)
 153#define VFPF_RSS_IPV6           (1 << 6)
 154#define VFPF_RSS_IPV6_TCP       (1 << 7)
 155#define VFPF_RSS_IPV6_UDP       (1 << 8)
 156        uint8_t                 rss_result_mask;
 157        uint8_t                 ind_table_size;
 158        uint8_t                 rss_key_size;
 159        uint8_t                 padding;
 160        uint8_t                 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
 161        uint32_t                        rss_key[T_ETH_RSS_KEY]; /* hash values */
 162};
 163
 164/* acquire response tlv - carries the allocated resources */
 165struct pfvf_acquire_resp_tlv {
 166        struct pfvf_tlv hdr;
 167        struct pf_vf_pfdev_info {
 168                uint32_t chip_num;
 169                uint32_t pf_cap;
 170#define PFVF_CAP_RSS            0x00000001
 171#define PFVF_CAP_DHC            0x00000002
 172#define PFVF_CAP_TPA            0x00000004
 173#define PFVF_CAP_TPA_UPDATE     0x00000008
 174                char fw_ver[32];
 175                uint16_t db_size;
 176                uint8_t  indices_per_sb;
 177                uint8_t  padding;
 178        } pfdev_info;
 179        struct pf_vf_resc {
 180                /* in case of status NO_RESOURCE in message hdr, pf will fill
 181                 * this struct with suggested amount of resources for next
 182                 * acquire request
 183                 */
 184#define PFVF_MAX_QUEUES_PER_VF         16
 185#define PFVF_MAX_SBS_PER_VF            16
 186                struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
 187                uint8_t hw_qid[PFVF_MAX_QUEUES_PER_VF];
 188                uint8_t num_rxqs;
 189                uint8_t num_txqs;
 190                uint8_t num_sbs;
 191                uint8_t num_mac_filters;
 192                uint8_t num_vlan_filters;
 193                uint8_t num_mc_filters;
 194                uint8_t permanent_mac_addr[Eaddrlen];
 195                uint8_t current_mac_addr[Eaddrlen];
 196                uint8_t padding[2];
 197        } resc;
 198};
 199
 200struct vfpf_port_phys_id_resp_tlv {
 201        struct channel_tlv tl;
 202        uint8_t id[Eaddrlen];
 203        uint8_t padding[2];
 204};
 205
 206struct vfpf_fp_hsi_resp_tlv {
 207        struct channel_tlv tl;
 208        uint8_t is_supported;
 209        uint8_t padding[3];
 210};
 211
 212#define VFPF_INIT_FLG_STATS_COALESCE    (1 << 0) /* when set the VFs queues
 213                                                  * stats will be coalesced on
 214                                                  * the leading RSS queue
 215                                                  */
 216
 217/* Init VF */
 218struct vfpf_init_tlv {
 219        struct vfpf_first_tlv first_tlv;
 220        aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
 221        aligned_u64 spq_addr;
 222        aligned_u64 stats_addr;
 223        uint16_t stats_stride;
 224        uint32_t flags;
 225        uint32_t padding[2];
 226};
 227
 228/* Setup Queue */
 229struct vfpf_setup_q_tlv {
 230        struct vfpf_first_tlv first_tlv;
 231
 232        struct vf_pf_rxq_params {
 233                /* physical addresses */
 234                aligned_u64 rcq_addr;
 235                aligned_u64 rcq_np_addr;
 236                aligned_u64 rxq_addr;
 237                aligned_u64 sge_addr;
 238
 239                /* sb + hc info */
 240                uint8_t  vf_sb;         /* index in hw_sbs[] */
 241                uint8_t  sb_index;              /* Index in the SB */
 242                uint16_t hc_rate;               /* desired interrupts per sec. */
 243                                        /* valid iff VFPF_QUEUE_FLG_HC */
 244                /* rx buffer info */
 245                uint16_t mtu;
 246                uint16_t buf_sz;
 247                uint16_t flags;         /* VFPF_QUEUE_FLG_X flags */
 248                uint16_t stat_id;               /* valid iff VFPF_QUEUE_FLG_STATS */
 249
 250                /* valid iff VFPF_QUEUE_FLG_TPA */
 251                uint16_t sge_buf_sz;
 252                uint16_t tpa_agg_sz;
 253                uint8_t max_sge_pkt;
 254
 255                uint8_t drop_flags;             /* VFPF_QUEUE_DROP_X, for Linux VMs
 256                                         * all the flags are turned off
 257                                         */
 258
 259                uint8_t cache_line_log; /* VFPF_QUEUE_FLG_CACHE_ALIGN */
 260                uint8_t padding;
 261        } rxq;
 262
 263        struct vf_pf_txq_params {
 264                /* physical addresses */
 265                aligned_u64 txq_addr;
 266
 267                /* sb + hc info */
 268                uint8_t  vf_sb;         /* index in hw_sbs[] */
 269                uint8_t  sb_index;              /* Index in the SB */
 270                uint16_t hc_rate;               /* desired interrupts per sec. */
 271                                        /* valid iff VFPF_QUEUE_FLG_HC */
 272                uint32_t flags;         /* VFPF_QUEUE_FLG_X flags */
 273                uint16_t stat_id;               /* valid iff VFPF_QUEUE_FLG_STATS */
 274                uint8_t  traffic_type;  /* see in setup_context() */
 275                uint8_t  padding;
 276        } txq;
 277
 278        uint8_t vf_qid;                 /* index in hw_qid[] */
 279        uint8_t param_valid;
 280#define VFPF_RXQ_VALID          0x01
 281#define VFPF_TXQ_VALID          0x02
 282        uint8_t padding[2];
 283};
 284
 285/* Set Queue Filters */
 286struct vfpf_q_mac_vlan_filter {
 287        uint32_t flags;
 288#define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
 289#define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
 290#define VFPF_Q_FILTER_SET_MAC           0x100   /* set/clear */
 291        uint8_t  mac[Eaddrlen];
 292        uint16_t vlan_tag;
 293};
 294
 295/* configure queue filters */
 296struct vfpf_set_q_filters_tlv {
 297        struct vfpf_first_tlv first_tlv;
 298
 299        uint32_t flags;
 300#define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED     0x01
 301#define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED    0x02
 302#define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED      0x04
 303
 304        uint8_t vf_qid;                 /* index in hw_qid[] */
 305        uint8_t n_mac_vlan_filters;
 306        uint8_t n_multicast;
 307        uint8_t padding;
 308
 309#define PFVF_MAX_MAC_FILTERS                   16
 310#define PFVF_MAX_VLAN_FILTERS                  16
 311#define PFVF_MAX_FILTERS               (PFVF_MAX_MAC_FILTERS +\
 312                                         PFVF_MAX_VLAN_FILTERS)
 313        struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
 314
 315#define PFVF_MAX_MULTICAST_PER_VF              32
 316        uint8_t  multicast[PFVF_MAX_MULTICAST_PER_VF][Eaddrlen];
 317
 318        uint32_t rx_mask;       /* see mask constants at the top of the file */
 319};
 320
 321struct vfpf_tpa_tlv {
 322        struct vfpf_first_tlv   first_tlv;
 323
 324        struct vf_pf_tpa_client_info {
 325                aligned_u64 sge_addr[PFVF_MAX_QUEUES_PER_VF];
 326                uint8_t update_ipv4;
 327                uint8_t update_ipv6;
 328                uint8_t max_tpa_queues;
 329                uint8_t max_sges_for_packet;
 330                uint8_t complete_on_both_clients;
 331                uint8_t dont_verify_thr;
 332                uint8_t tpa_mode;
 333                uint16_t sge_buff_size;
 334                uint16_t max_agg_size;
 335                uint16_t sge_pause_thr_low;
 336                uint16_t sge_pause_thr_high;
 337        } tpa_client_info;
 338};
 339
 340/* close VF (disable VF) */
 341struct vfpf_close_tlv {
 342        struct vfpf_first_tlv   first_tlv;
 343        uint16_t                        vf_id;  /* for debug */
 344        uint8_t padding[2];
 345};
 346
 347/* release the VF's acquired resources */
 348struct vfpf_release_tlv {
 349        struct vfpf_first_tlv   first_tlv;
 350        uint16_t                        vf_id;
 351        uint8_t padding[2];
 352};
 353
 354struct tlv_buffer_size {
 355        uint8_t tlv_buffer[TLV_BUFFER_SIZE];
 356};
 357
 358union vfpf_tlvs {
 359        struct vfpf_first_tlv           first_tlv;
 360        struct vfpf_acquire_tlv         acquire;
 361        struct vfpf_init_tlv            init;
 362        struct vfpf_close_tlv           close;
 363        struct vfpf_q_op_tlv            q_op;
 364        struct vfpf_setup_q_tlv         setup_q;
 365        struct vfpf_set_q_filters_tlv   set_q_filters;
 366        struct vfpf_release_tlv         release;
 367        struct vfpf_rss_tlv             update_rss;
 368        struct vfpf_tpa_tlv             update_tpa;
 369        struct channel_list_end_tlv     list_end;
 370        struct tlv_buffer_size          tlv_buf_size;
 371};
 372
 373union pfvf_tlvs {
 374        struct pfvf_general_resp_tlv    general_resp;
 375        struct pfvf_acquire_resp_tlv    acquire_resp;
 376        struct channel_list_end_tlv     list_end;
 377        struct tlv_buffer_size          tlv_buf_size;
 378};
 379
 380/* This is a structure which is allocated in the VF, which the PF may update
 381 * when it deems it necessary to do so. The bulletin board is sampled
 382 * periodically by the VF. A copy per VF is maintained in the PF (to prevent
 383 * loss of data upon multiple updates (or the need for read modify write)).
 384 */
 385struct pf_vf_bulletin_size {
 386        uint8_t size[PF_VF_BULLETIN_SIZE];
 387};
 388
 389struct pf_vf_bulletin_content {
 390        uint32_t crc;                   /* crc of structure to ensure is not in
 391                                         * mid-update
 392                                         */
 393        uint16_t version;
 394        uint16_t length;
 395
 396        aligned_u64 valid_bitmap;       /* bitmap indicating which fields
 397                                         * hold valid values
 398                                         */
 399
 400#define MAC_ADDR_VALID          0       /* alert the vf that a new mac address
 401                                         * is available for it
 402                                         */
 403#define VLAN_VALID              1       /* when set, the vf should not access
 404                                         * the vfpf channel
 405                                         */
 406#define CHANNEL_DOWN            2       /* vfpf channel is disabled. VFs are not
 407                                         * to attempt to send messages on the
 408                                         * channel after this bit is set
 409                                         */
 410#define LINK_VALID              3       /* alert the VF thet a new link status
 411                                         * update is available for it
 412                                         */
 413        uint8_t mac[Eaddrlen];
 414        uint8_t mac_padding[2];
 415
 416        uint16_t vlan;
 417        uint8_t vlan_padding[6];
 418
 419        uint16_t link_speed;                     /* Effective line speed */
 420        uint8_t link_speed_padding[6];
 421        uint32_t link_flags;                     /* VFPF_LINK_REPORT_XXX flags */
 422#define VFPF_LINK_REPORT_LINK_DOWN       (1 << 0)
 423#define VFPF_LINK_REPORT_FULL_DUPLEX     (1 << 1)
 424#define VFPF_LINK_REPORT_RX_FC_ON        (1 << 2)
 425#define VFPF_LINK_REPORT_TX_FC_ON        (1 << 3)
 426        uint8_t link_flags_padding[4];
 427};
 428
 429union pf_vf_bulletin {
 430        struct pf_vf_bulletin_content content;
 431        struct pf_vf_bulletin_size size;
 432};
 433
 434#define MAX_TLVS_IN_LIST 50
 435
 436enum channel_tlvs {
 437        CHANNEL_TLV_NONE,
 438        CHANNEL_TLV_ACQUIRE,
 439        CHANNEL_TLV_INIT,
 440        CHANNEL_TLV_SETUP_Q,
 441        CHANNEL_TLV_SET_Q_FILTERS,
 442        CHANNEL_TLV_ACTIVATE_Q,
 443        CHANNEL_TLV_DEACTIVATE_Q,
 444        CHANNEL_TLV_TEARDOWN_Q,
 445        CHANNEL_TLV_CLOSE,
 446        CHANNEL_TLV_RELEASE,
 447        CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
 448        CHANNEL_TLV_PF_RELEASE_VF,
 449        CHANNEL_TLV_LIST_END,
 450        CHANNEL_TLV_FLR,
 451        CHANNEL_TLV_PF_SET_MAC,
 452        CHANNEL_TLV_PF_SET_VLAN,
 453        CHANNEL_TLV_UPDATE_RSS,
 454        CHANNEL_TLV_PHYS_PORT_ID,
 455        CHANNEL_TLV_UPDATE_TPA,
 456        CHANNEL_TLV_FP_HSI_SUPPORT,
 457        CHANNEL_TLV_MAX
 458};
 459
 460#endif /* CONFIG_BNX2X_SRIOV */
 461