linux/drivers/net/ethernet/intel/ice/ice_type.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/* Copyright (c) 2018, Intel Corporation. */
   3
   4#ifndef _ICE_TYPE_H_
   5#define _ICE_TYPE_H_
   6
   7#include "ice_status.h"
   8#include "ice_hw_autogen.h"
   9#include "ice_osdep.h"
  10#include "ice_controlq.h"
  11#include "ice_lan_tx_rx.h"
  12
  13#define ICE_BYTES_PER_WORD      2
  14#define ICE_BYTES_PER_DWORD     4
  15
  16static inline bool ice_is_tc_ena(u8 bitmap, u8 tc)
  17{
  18        return test_bit(tc, (unsigned long *)&bitmap);
  19}
  20
  21/* Driver always calls main vsi_handle first */
  22#define ICE_MAIN_VSI_HANDLE             0
  23
  24/* debug masks - set these bits in hw->debug_mask to control output */
  25#define ICE_DBG_INIT            BIT_ULL(1)
  26#define ICE_DBG_FW_LOG          BIT_ULL(3)
  27#define ICE_DBG_LINK            BIT_ULL(4)
  28#define ICE_DBG_PHY             BIT_ULL(5)
  29#define ICE_DBG_QCTX            BIT_ULL(6)
  30#define ICE_DBG_NVM             BIT_ULL(7)
  31#define ICE_DBG_LAN             BIT_ULL(8)
  32#define ICE_DBG_SW              BIT_ULL(13)
  33#define ICE_DBG_SCHED           BIT_ULL(14)
  34#define ICE_DBG_RES             BIT_ULL(17)
  35#define ICE_DBG_AQ_MSG          BIT_ULL(24)
  36#define ICE_DBG_AQ_CMD          BIT_ULL(27)
  37#define ICE_DBG_USER            BIT_ULL(31)
  38
  39enum ice_aq_res_ids {
  40        ICE_NVM_RES_ID = 1,
  41        ICE_SPD_RES_ID,
  42        ICE_CHANGE_LOCK_RES_ID,
  43        ICE_GLOBAL_CFG_LOCK_RES_ID
  44};
  45
  46/* FW update timeout definitions are in milliseconds */
  47#define ICE_NVM_TIMEOUT                 180000
  48#define ICE_CHANGE_LOCK_TIMEOUT         1000
  49#define ICE_GLOBAL_CFG_LOCK_TIMEOUT     3000
  50
  51enum ice_aq_res_access_type {
  52        ICE_RES_READ = 1,
  53        ICE_RES_WRITE
  54};
  55
  56enum ice_fc_mode {
  57        ICE_FC_NONE = 0,
  58        ICE_FC_RX_PAUSE,
  59        ICE_FC_TX_PAUSE,
  60        ICE_FC_FULL,
  61        ICE_FC_PFC,
  62        ICE_FC_DFLT
  63};
  64
  65enum ice_fec_mode {
  66        ICE_FEC_NONE = 0,
  67        ICE_FEC_RS,
  68        ICE_FEC_BASER,
  69        ICE_FEC_AUTO
  70};
  71
  72enum ice_set_fc_aq_failures {
  73        ICE_SET_FC_AQ_FAIL_NONE = 0,
  74        ICE_SET_FC_AQ_FAIL_GET,
  75        ICE_SET_FC_AQ_FAIL_SET,
  76        ICE_SET_FC_AQ_FAIL_UPDATE
  77};
  78
  79/* Various MAC types */
  80enum ice_mac_type {
  81        ICE_MAC_UNKNOWN = 0,
  82        ICE_MAC_GENERIC,
  83};
  84
  85/* Media Types */
  86enum ice_media_type {
  87        ICE_MEDIA_UNKNOWN = 0,
  88        ICE_MEDIA_FIBER,
  89        ICE_MEDIA_BASET,
  90        ICE_MEDIA_BACKPLANE,
  91        ICE_MEDIA_DA,
  92};
  93
  94enum ice_vsi_type {
  95        ICE_VSI_PF = 0,
  96        ICE_VSI_VF,
  97        ICE_VSI_LB = 6,
  98};
  99
 100struct ice_link_status {
 101        /* Refer to ice_aq_phy_type for bits definition */
 102        u64 phy_type_low;
 103        u64 phy_type_high;
 104        u8 topo_media_conflict;
 105        u16 max_frame_size;
 106        u16 link_speed;
 107        u16 req_speeds;
 108        u8 lse_ena;     /* Link Status Event notification */
 109        u8 link_info;
 110        u8 an_info;
 111        u8 ext_info;
 112        u8 fec_info;
 113        u8 pacing;
 114        /* Refer to #define from module_type[ICE_MODULE_TYPE_TOTAL_BYTE] of
 115         * ice_aqc_get_phy_caps structure
 116         */
 117        u8 module_type[ICE_MODULE_TYPE_TOTAL_BYTE];
 118};
 119
 120/* Different reset sources for which a disable queue AQ call has to be made in
 121 * order to clean the Tx scheduler as a part of the reset
 122 */
 123enum ice_disq_rst_src {
 124        ICE_NO_RESET = 0,
 125        ICE_VM_RESET,
 126        ICE_VF_RESET,
 127};
 128
 129/* PHY info such as phy_type, etc... */
 130struct ice_phy_info {
 131        struct ice_link_status link_info;
 132        struct ice_link_status link_info_old;
 133        u64 phy_type_low;
 134        u64 phy_type_high;
 135        enum ice_media_type media_type;
 136        u8 get_link_info;
 137};
 138
 139/* Common HW capabilities for SW use */
 140struct ice_hw_common_caps {
 141        u32 valid_functions;
 142
 143        /* Tx/Rx queues */
 144        u16 num_rxq;            /* Number/Total Rx queues */
 145        u16 rxq_first_id;       /* First queue ID for Rx queues */
 146        u16 num_txq;            /* Number/Total Tx queues */
 147        u16 txq_first_id;       /* First queue ID for Tx queues */
 148
 149        /* MSI-X vectors */
 150        u16 num_msix_vectors;
 151        u16 msix_vector_first_id;
 152
 153        /* Max MTU for function or device */
 154        u16 max_mtu;
 155
 156        /* Virtualization support */
 157        u8 sr_iov_1_1;                  /* SR-IOV enabled */
 158
 159        /* RSS related capabilities */
 160        u16 rss_table_size;             /* 512 for PFs and 64 for VFs */
 161        u8 rss_table_entry_width;       /* RSS Entry width in bits */
 162
 163        u8 dcb;
 164};
 165
 166/* Function specific capabilities */
 167struct ice_hw_func_caps {
 168        struct ice_hw_common_caps common_cap;
 169        u32 num_allocd_vfs;             /* Number of allocated VFs */
 170        u32 vf_base_id;                 /* Logical ID of the first VF */
 171        u32 guar_num_vsi;
 172};
 173
 174/* Device wide capabilities */
 175struct ice_hw_dev_caps {
 176        struct ice_hw_common_caps common_cap;
 177        u32 num_vfs_exposed;            /* Total number of VFs exposed */
 178        u32 num_vsi_allocd_to_host;     /* Excluding EMP VSI */
 179};
 180
 181/* MAC info */
 182struct ice_mac_info {
 183        u8 lan_addr[ETH_ALEN];
 184        u8 perm_addr[ETH_ALEN];
 185};
 186
 187/* Reset types used to determine which kind of reset was requested. These
 188 * defines match what the RESET_TYPE field of the GLGEN_RSTAT register.
 189 * ICE_RESET_PFR does not match any RESET_TYPE field in the GLGEN_RSTAT register
 190 * because its reset source is different than the other types listed.
 191 */
 192enum ice_reset_req {
 193        ICE_RESET_POR   = 0,
 194        ICE_RESET_INVAL = 0,
 195        ICE_RESET_CORER = 1,
 196        ICE_RESET_GLOBR = 2,
 197        ICE_RESET_EMPR  = 3,
 198        ICE_RESET_PFR   = 4,
 199};
 200
 201/* Bus parameters */
 202struct ice_bus_info {
 203        u16 device;
 204        u8 func;
 205};
 206
 207/* Flow control (FC) parameters */
 208struct ice_fc_info {
 209        enum ice_fc_mode current_mode;  /* FC mode in effect */
 210        enum ice_fc_mode req_mode;      /* FC mode requested by caller */
 211};
 212
 213/* NVM Information */
 214struct ice_nvm_info {
 215        u32 eetrack;              /* NVM data version */
 216        u32 oem_ver;              /* OEM version info */
 217        u16 sr_words;             /* Shadow RAM size in words */
 218        u16 ver;                  /* NVM package version */
 219        u8 blank_nvm_mode;        /* is NVM empty (no FW present) */
 220};
 221
 222/* Max number of port to queue branches w.r.t topology */
 223#define ICE_MAX_TRAFFIC_CLASS 8
 224#define ICE_TXSCHED_MAX_BRANCHES ICE_MAX_TRAFFIC_CLASS
 225
 226#define ice_for_each_traffic_class(_i)  \
 227        for ((_i) = 0; (_i) < ICE_MAX_TRAFFIC_CLASS; (_i)++)
 228
 229#define ICE_INVAL_TEID 0xFFFFFFFF
 230
 231struct ice_sched_node {
 232        struct ice_sched_node *parent;
 233        struct ice_sched_node *sibling; /* next sibling in the same layer */
 234        struct ice_sched_node **children;
 235        struct ice_aqc_txsched_elem_data info;
 236        u32 agg_id;                     /* aggregator group ID */
 237        u16 vsi_handle;
 238        u8 in_use;                      /* suspended or in use */
 239        u8 tx_sched_layer;              /* Logical Layer (1-9) */
 240        u8 num_children;
 241        u8 tc_num;
 242        u8 owner;
 243#define ICE_SCHED_NODE_OWNER_LAN        0
 244};
 245
 246/* Access Macros for Tx Sched Elements data */
 247#define ICE_TXSCHED_GET_NODE_TEID(x) le32_to_cpu((x)->info.node_teid)
 248
 249/* The aggregator type determines if identifier is for a VSI group,
 250 * aggregator group, aggregator of queues, or queue group.
 251 */
 252enum ice_agg_type {
 253        ICE_AGG_TYPE_UNKNOWN = 0,
 254        ICE_AGG_TYPE_VSI,
 255        ICE_AGG_TYPE_AGG, /* aggregator */
 256        ICE_AGG_TYPE_Q,
 257        ICE_AGG_TYPE_QG
 258};
 259
 260#define ICE_SCHED_DFLT_RL_PROF_ID       0
 261#define ICE_SCHED_DFLT_BW_WT            1
 262
 263/* VSI type list entry to locate corresponding VSI/ag nodes */
 264struct ice_sched_vsi_info {
 265        struct ice_sched_node *vsi_node[ICE_MAX_TRAFFIC_CLASS];
 266        struct ice_sched_node *ag_node[ICE_MAX_TRAFFIC_CLASS];
 267        struct list_head list_entry;
 268        u16 max_lanq[ICE_MAX_TRAFFIC_CLASS];
 269};
 270
 271/* driver defines the policy */
 272struct ice_sched_tx_policy {
 273        u16 max_num_vsis;
 274        u8 max_num_lan_qs_per_tc[ICE_MAX_TRAFFIC_CLASS];
 275        u8 rdma_ena;
 276};
 277
 278/* CEE or IEEE 802.1Qaz ETS Configuration data */
 279struct ice_dcb_ets_cfg {
 280        u8 willing;
 281        u8 cbs;
 282        u8 maxtcs;
 283        u8 prio_table[ICE_MAX_TRAFFIC_CLASS];
 284        u8 tcbwtable[ICE_MAX_TRAFFIC_CLASS];
 285        u8 tsatable[ICE_MAX_TRAFFIC_CLASS];
 286};
 287
 288/* CEE or IEEE 802.1Qaz PFC Configuration data */
 289struct ice_dcb_pfc_cfg {
 290        u8 willing;
 291        u8 mbc;
 292        u8 pfccap;
 293        u8 pfcena;
 294};
 295
 296/* CEE or IEEE 802.1Qaz Application Priority data */
 297struct ice_dcb_app_priority_table {
 298        u16 prot_id;
 299        u8 priority;
 300        u8 selector;
 301};
 302
 303#define ICE_MAX_USER_PRIORITY   8
 304#define ICE_DCBX_MAX_APPS       32
 305#define ICE_LLDPDU_SIZE         1500
 306#define ICE_TLV_STATUS_OPER     0x1
 307#define ICE_TLV_STATUS_SYNC     0x2
 308#define ICE_TLV_STATUS_ERR      0x4
 309#define ICE_APP_PROT_ID_FCOE    0x8906
 310#define ICE_APP_PROT_ID_ISCSI   0x0cbc
 311#define ICE_APP_PROT_ID_FIP     0x8914
 312#define ICE_APP_SEL_ETHTYPE     0x1
 313#define ICE_APP_SEL_TCPIP       0x2
 314#define ICE_CEE_APP_SEL_ETHTYPE 0x0
 315#define ICE_CEE_APP_SEL_TCPIP   0x1
 316
 317struct ice_dcbx_cfg {
 318        u32 numapps;
 319        u32 tlv_status; /* CEE mode TLV status */
 320        struct ice_dcb_ets_cfg etscfg;
 321        struct ice_dcb_ets_cfg etsrec;
 322        struct ice_dcb_pfc_cfg pfc;
 323        struct ice_dcb_app_priority_table app[ICE_DCBX_MAX_APPS];
 324        u8 dcbx_mode;
 325#define ICE_DCBX_MODE_CEE       0x1
 326#define ICE_DCBX_MODE_IEEE      0x2
 327        u8 app_mode;
 328#define ICE_DCBX_APPS_NON_WILLING       0x1
 329};
 330
 331struct ice_port_info {
 332        struct ice_sched_node *root;    /* Root Node per Port */
 333        struct ice_hw *hw;              /* back pointer to HW instance */
 334        u32 last_node_teid;             /* scheduler last node info */
 335        u16 sw_id;                      /* Initial switch ID belongs to port */
 336        u16 pf_vf_num;
 337        u8 port_state;
 338#define ICE_SCHED_PORT_STATE_INIT       0x0
 339#define ICE_SCHED_PORT_STATE_READY      0x1
 340        u8 lport;
 341#define ICE_LPORT_MASK                  0xff
 342        u16 dflt_tx_vsi_rule_id;
 343        u16 dflt_tx_vsi_num;
 344        u16 dflt_rx_vsi_rule_id;
 345        u16 dflt_rx_vsi_num;
 346        struct ice_fc_info fc;
 347        struct ice_mac_info mac;
 348        struct ice_phy_info phy;
 349        struct mutex sched_lock;        /* protect access to TXSched tree */
 350        struct ice_dcbx_cfg local_dcbx_cfg;     /* Oper/Local Cfg */
 351        /* DCBX info */
 352        struct ice_dcbx_cfg remote_dcbx_cfg;    /* Peer Cfg */
 353        struct ice_dcbx_cfg desired_dcbx_cfg;   /* CEE Desired Cfg */
 354        /* LLDP/DCBX Status */
 355        u8 dcbx_status:3;               /* see ICE_DCBX_STATUS_DIS */
 356        u8 is_sw_lldp:1;
 357        u8 is_vf:1;
 358};
 359
 360struct ice_switch_info {
 361        struct list_head vsi_list_map_head;
 362        struct ice_sw_recipe *recp_list;
 363};
 364
 365/* FW logging configuration */
 366struct ice_fw_log_evnt {
 367        u8 cfg : 4;     /* New event enables to configure */
 368        u8 cur : 4;     /* Current/active event enables */
 369};
 370
 371struct ice_fw_log_cfg {
 372        u8 cq_en : 1;    /* FW logging is enabled via the control queue */
 373        u8 uart_en : 1;  /* FW logging is enabled via UART for all PFs */
 374        u8 actv_evnts;   /* Cumulation of currently enabled log events */
 375
 376#define ICE_FW_LOG_EVNT_INFO    (ICE_AQC_FW_LOG_INFO_EN >> ICE_AQC_FW_LOG_EN_S)
 377#define ICE_FW_LOG_EVNT_INIT    (ICE_AQC_FW_LOG_INIT_EN >> ICE_AQC_FW_LOG_EN_S)
 378#define ICE_FW_LOG_EVNT_FLOW    (ICE_AQC_FW_LOG_FLOW_EN >> ICE_AQC_FW_LOG_EN_S)
 379#define ICE_FW_LOG_EVNT_ERR     (ICE_AQC_FW_LOG_ERR_EN >> ICE_AQC_FW_LOG_EN_S)
 380        struct ice_fw_log_evnt evnts[ICE_AQC_FW_LOG_ID_MAX];
 381};
 382
 383/* Port hardware description */
 384struct ice_hw {
 385        u8 __iomem *hw_addr;
 386        void *back;
 387        struct ice_aqc_layer_props *layer_info;
 388        struct ice_port_info *port_info;
 389        u64 debug_mask;         /* bitmap for debug mask */
 390        enum ice_mac_type mac_type;
 391
 392        /* pci info */
 393        u16 device_id;
 394        u16 vendor_id;
 395        u16 subsystem_device_id;
 396        u16 subsystem_vendor_id;
 397        u8 revision_id;
 398
 399        u8 pf_id;               /* device profile info */
 400
 401        /* Tx Scheduler values */
 402        u16 num_tx_sched_layers;
 403        u16 num_tx_sched_phys_layers;
 404        u8 flattened_layers;
 405        u8 max_cgds;
 406        u8 sw_entry_point_layer;
 407        u16 max_children[ICE_AQC_TOPO_MAX_LEVEL_NUM];
 408        struct list_head agg_list;      /* lists all aggregator */
 409
 410        struct ice_vsi_ctx *vsi_ctx[ICE_MAX_VSI];
 411        u8 evb_veb;             /* true for VEB, false for VEPA */
 412        u8 reset_ongoing;       /* true if HW is in reset, false otherwise */
 413        struct ice_bus_info bus;
 414        struct ice_nvm_info nvm;
 415        struct ice_hw_dev_caps dev_caps;        /* device capabilities */
 416        struct ice_hw_func_caps func_caps;      /* function capabilities */
 417
 418        struct ice_switch_info *switch_info;    /* switch filter lists */
 419
 420        /* Control Queue info */
 421        struct ice_ctl_q_info adminq;
 422        struct ice_ctl_q_info mailboxq;
 423
 424        u8 api_branch;          /* API branch version */
 425        u8 api_maj_ver;         /* API major version */
 426        u8 api_min_ver;         /* API minor version */
 427        u8 api_patch;           /* API patch version */
 428        u8 fw_branch;           /* firmware branch version */
 429        u8 fw_maj_ver;          /* firmware major version */
 430        u8 fw_min_ver;          /* firmware minor version */
 431        u8 fw_patch;            /* firmware patch version */
 432        u32 fw_build;           /* firmware build number */
 433
 434        struct ice_fw_log_cfg fw_log;
 435
 436/* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL
 437 * register. Used for determining the ITR/intrl granularity during
 438 * initialization.
 439 */
 440#define ICE_MAX_AGG_BW_200G     0x0
 441#define ICE_MAX_AGG_BW_100G     0X1
 442#define ICE_MAX_AGG_BW_50G      0x2
 443#define ICE_MAX_AGG_BW_25G      0x3
 444        /* ITR granularity for different speeds */
 445#define ICE_ITR_GRAN_ABOVE_25   2
 446#define ICE_ITR_GRAN_MAX_25     4
 447        /* ITR granularity in 1 us */
 448        u8 itr_gran;
 449        /* INTRL granularity for different speeds */
 450#define ICE_INTRL_GRAN_ABOVE_25 4
 451#define ICE_INTRL_GRAN_MAX_25   8
 452        /* INTRL granularity in 1 us */
 453        u8 intrl_gran;
 454
 455        u8 ucast_shared;        /* true if VSIs can share unicast addr */
 456
 457};
 458
 459/* Statistics collected by each port, VSI, VEB, and S-channel */
 460struct ice_eth_stats {
 461        u64 rx_bytes;                   /* gorc */
 462        u64 rx_unicast;                 /* uprc */
 463        u64 rx_multicast;               /* mprc */
 464        u64 rx_broadcast;               /* bprc */
 465        u64 rx_discards;                /* rdpc */
 466        u64 rx_unknown_protocol;        /* rupp */
 467        u64 tx_bytes;                   /* gotc */
 468        u64 tx_unicast;                 /* uptc */
 469        u64 tx_multicast;               /* mptc */
 470        u64 tx_broadcast;               /* bptc */
 471        u64 tx_discards;                /* tdpc */
 472        u64 tx_errors;                  /* tepc */
 473};
 474
 475/* Statistics collected by the MAC */
 476struct ice_hw_port_stats {
 477        /* eth stats collected by the port */
 478        struct ice_eth_stats eth;
 479        /* additional port specific stats */
 480        u64 tx_dropped_link_down;       /* tdold */
 481        u64 crc_errors;                 /* crcerrs */
 482        u64 illegal_bytes;              /* illerrc */
 483        u64 error_bytes;                /* errbc */
 484        u64 mac_local_faults;           /* mlfc */
 485        u64 mac_remote_faults;          /* mrfc */
 486        u64 rx_len_errors;              /* rlec */
 487        u64 link_xon_rx;                /* lxonrxc */
 488        u64 link_xoff_rx;               /* lxoffrxc */
 489        u64 link_xon_tx;                /* lxontxc */
 490        u64 link_xoff_tx;               /* lxofftxc */
 491        u64 priority_xon_rx[8];         /* pxonrxc[8] */
 492        u64 priority_xoff_rx[8];        /* pxoffrxc[8] */
 493        u64 priority_xon_tx[8];         /* pxontxc[8] */
 494        u64 priority_xoff_tx[8];        /* pxofftxc[8] */
 495        u64 priority_xon_2_xoff[8];     /* pxon2offc[8] */
 496        u64 rx_size_64;                 /* prc64 */
 497        u64 rx_size_127;                /* prc127 */
 498        u64 rx_size_255;                /* prc255 */
 499        u64 rx_size_511;                /* prc511 */
 500        u64 rx_size_1023;               /* prc1023 */
 501        u64 rx_size_1522;               /* prc1522 */
 502        u64 rx_size_big;                /* prc9522 */
 503        u64 rx_undersize;               /* ruc */
 504        u64 rx_fragments;               /* rfc */
 505        u64 rx_oversize;                /* roc */
 506        u64 rx_jabber;                  /* rjc */
 507        u64 tx_size_64;                 /* ptc64 */
 508        u64 tx_size_127;                /* ptc127 */
 509        u64 tx_size_255;                /* ptc255 */
 510        u64 tx_size_511;                /* ptc511 */
 511        u64 tx_size_1023;               /* ptc1023 */
 512        u64 tx_size_1522;               /* ptc1522 */
 513        u64 tx_size_big;                /* ptc9522 */
 514};
 515
 516/* Checksum and Shadow RAM pointers */
 517#define ICE_SR_NVM_DEV_STARTER_VER      0x18
 518#define ICE_SR_NVM_EETRACK_LO           0x2D
 519#define ICE_SR_NVM_EETRACK_HI           0x2E
 520#define ICE_NVM_VER_LO_SHIFT            0
 521#define ICE_NVM_VER_LO_MASK             (0xff << ICE_NVM_VER_LO_SHIFT)
 522#define ICE_NVM_VER_HI_SHIFT            12
 523#define ICE_NVM_VER_HI_MASK             (0xf << ICE_NVM_VER_HI_SHIFT)
 524#define ICE_OEM_VER_PATCH_SHIFT         0
 525#define ICE_OEM_VER_PATCH_MASK          (0xff << ICE_OEM_VER_PATCH_SHIFT)
 526#define ICE_OEM_VER_BUILD_SHIFT         8
 527#define ICE_OEM_VER_BUILD_MASK          (0xffff << ICE_OEM_VER_BUILD_SHIFT)
 528#define ICE_OEM_VER_SHIFT               24
 529#define ICE_OEM_VER_MASK                (0xff << ICE_OEM_VER_SHIFT)
 530#define ICE_SR_SECTOR_SIZE_IN_WORDS     0x800
 531#define ICE_SR_WORDS_IN_1KB             512
 532
 533/* Hash redirection LUT for VSI - maximum array size */
 534#define ICE_VSIQF_HLUT_ARRAY_SIZE       ((VSIQF_HLUT_MAX_INDEX + 1) * 4)
 535
 536#endif /* _ICE_TYPE_H_ */
 537