1 /* 2 * CDDL HEADER START 3 * 4 * Copyright(c) 2007-2009 Intel Corporation. All rights reserved. 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at: 10 * http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When using or redistributing this file, you may do so under the 15 * License only. No other modification of this header is permitted. 16 * 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 */ 23 24 /* 25 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 #ifndef _IGB_SW_H 30 #define _IGB_SW_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/types.h> 37 #include <sys/conf.h> 38 #include <sys/debug.h> 39 #include <sys/stropts.h> 40 #include <sys/stream.h> 41 #include <sys/strsun.h> 42 #include <sys/strlog.h> 43 #include <sys/kmem.h> 44 #include <sys/stat.h> 45 #include <sys/kstat.h> 46 #include <sys/modctl.h> 47 #include <sys/errno.h> 48 #include <sys/dlpi.h> 49 #include <sys/mac_provider.h> 50 #include <sys/mac_ether.h> 51 #include <sys/vlan.h> 52 #include <sys/ddi.h> 53 #include <sys/sunddi.h> 54 #include <sys/pci.h> 55 #include <sys/pcie.h> 56 #include <sys/sdt.h> 57 #include <sys/ethernet.h> 58 #include <sys/pattr.h> 59 #include <sys/strsubr.h> 60 #include <sys/netlb.h> 61 #include <sys/random.h> 62 #include <inet/common.h> 63 #include <inet/tcp.h> 64 #include <inet/ip.h> 65 #include <inet/mi.h> 66 #include <inet/nd.h> 67 #include <sys/ddifm.h> 68 #include <sys/fm/protocol.h> 69 #include <sys/fm/util.h> 70 #include <sys/fm/io/ddi.h> 71 #include "igb_api.h" 72 #include "igb_82575.h" 73 74 75 #define MODULE_NAME "igb" /* module name */ 76 77 #define IGB_SUCCESS DDI_SUCCESS 78 #define IGB_FAILURE DDI_FAILURE 79 80 #define IGB_UNKNOWN 0x00 81 #define IGB_INITIALIZED 0x01 82 #define IGB_STARTED 0x02 83 #define IGB_SUSPENDED 0x04 84 #define IGB_STALL 0x08 85 #define IGB_ERROR 0x80 86 87 #define IGB_RX_STOPPED 0x1 88 89 #define IGB_INTR_NONE 0 90 #define IGB_INTR_MSIX 1 91 #define IGB_INTR_MSI 2 92 #define IGB_INTR_LEGACY 3 93 94 #define IGB_ADAPTER_REGSET 1 /* mapping adapter registers */ 95 #define IGB_ADAPTER_MSIXTAB 4 /* mapping msi-x table */ 96 97 #define IGB_NO_POLL -1 98 #define IGB_NO_FREE_SLOT -1 99 100 #define MAX_NUM_UNICAST_ADDRESSES E1000_RAR_ENTRIES 101 #define MCAST_ALLOC_COUNT 256 102 #define MAX_COOKIE 18 103 #define MIN_NUM_TX_DESC 2 104 105 /* 106 * Number of settings for interrupt throttle rate (ITR). There is one of 107 * these per msi-x vector and it needs to be the maximum of all silicon 108 * types supported by this driver. 109 */ 110 #define MAX_NUM_EITR 25 111 112 /* 113 * Maximum values for user configurable parameters 114 */ 115 #define MAX_TX_RING_SIZE 4096 116 #define MAX_RX_RING_SIZE 4096 117 #define MAX_RX_GROUP_NUM 4 118 119 #define MAX_MTU 9000 120 #define MAX_RX_LIMIT_PER_INTR 4096 121 122 #define MAX_RX_COPY_THRESHOLD 9216 123 #define MAX_TX_COPY_THRESHOLD 9216 124 #define MAX_TX_RECYCLE_THRESHOLD DEFAULT_TX_RING_SIZE 125 #define MAX_TX_OVERLOAD_THRESHOLD DEFAULT_TX_RING_SIZE 126 #define MAX_TX_RESCHED_THRESHOLD DEFAULT_TX_RING_SIZE 127 #define MAX_MCAST_NUM 8192 128 129 /* 130 * Minimum values for user configurable parameters 131 */ 132 #define MIN_TX_RING_SIZE 64 133 #define MIN_RX_RING_SIZE 64 134 #define MIN_RX_GROUP_NUM 1 135 136 #define MIN_MTU ETHERMIN 137 #define MIN_RX_LIMIT_PER_INTR 16 138 139 #define MIN_RX_COPY_THRESHOLD 0 140 #define MIN_TX_COPY_THRESHOLD 0 141 #define MIN_TX_RECYCLE_THRESHOLD MIN_NUM_TX_DESC 142 #define MIN_TX_OVERLOAD_THRESHOLD MIN_NUM_TX_DESC 143 #define MIN_TX_RESCHED_THRESHOLD MIN_NUM_TX_DESC 144 #define MIN_MCAST_NUM 8 145 146 /* 147 * Default values for user configurable parameters 148 */ 149 #define DEFAULT_TX_RING_SIZE 512 150 #define DEFAULT_RX_RING_SIZE 512 151 #define DEFAULT_RX_GROUP_NUM 1 152 153 #define DEFAULT_MTU ETHERMTU 154 #define DEFAULT_RX_LIMIT_PER_INTR 256 155 156 #define DEFAULT_RX_COPY_THRESHOLD 128 157 #define DEFAULT_TX_COPY_THRESHOLD 512 158 #define DEFAULT_TX_RECYCLE_THRESHOLD (MAX_COOKIE + 1) 159 #define DEFAULT_TX_OVERLOAD_THRESHOLD MIN_NUM_TX_DESC 160 #define DEFAULT_TX_RESCHED_THRESHOLD 128 161 #define DEFAULT_MCAST_NUM 4096 162 163 #define IGB_LSO_MAXLEN 65535 164 165 #define TX_DRAIN_TIME 200 166 #define RX_DRAIN_TIME 200 167 168 #define STALL_WATCHDOG_TIMEOUT 8 /* 8 seconds */ 169 #define MAX_LINK_DOWN_TIMEOUT 8 /* 8 seconds */ 170 171 /* 172 * Defined for IP header alignment. 173 */ 174 #define IPHDR_ALIGN_ROOM 2 175 176 /* 177 * Bit flags for attach_progress 178 */ 179 #define ATTACH_PROGRESS_PCI_CONFIG 0x0001 /* PCI config setup */ 180 #define ATTACH_PROGRESS_REGS_MAP 0x0002 /* Registers mapped */ 181 #define ATTACH_PROGRESS_PROPS 0x0004 /* Properties initialized */ 182 #define ATTACH_PROGRESS_ALLOC_INTR 0x0008 /* Interrupts allocated */ 183 #define ATTACH_PROGRESS_ALLOC_RINGS 0x0010 /* Rings allocated */ 184 #define ATTACH_PROGRESS_ADD_INTR 0x0020 /* Intr handlers added */ 185 #define ATTACH_PROGRESS_LOCKS 0x0040 /* Locks initialized */ 186 #define ATTACH_PROGRESS_INIT_ADAPTER 0x0080 /* Adapter initialized */ 187 #define ATTACH_PROGRESS_STATS 0x0200 /* Kstats created */ 188 #define ATTACH_PROGRESS_MAC 0x0800 /* MAC registered */ 189 #define ATTACH_PROGRESS_ENABLE_INTR 0x1000 /* DDI interrupts enabled */ 190 #define ATTACH_PROGRESS_FMINIT 0x2000 /* FMA initialized */ 191 192 #define PROP_ADV_AUTONEG_CAP "adv_autoneg_cap" 193 #define PROP_ADV_1000FDX_CAP "adv_1000fdx_cap" 194 #define PROP_ADV_1000HDX_CAP "adv_1000hdx_cap" 195 #define PROP_ADV_100FDX_CAP "adv_100fdx_cap" 196 #define PROP_ADV_100HDX_CAP "adv_100hdx_cap" 197 #define PROP_ADV_10FDX_CAP "adv_10fdx_cap" 198 #define PROP_ADV_10HDX_CAP "adv_10hdx_cap" 199 #define PROP_DEFAULT_MTU "default_mtu" 200 #define PROP_FLOW_CONTROL "flow_control" 201 #define PROP_TX_RING_SIZE "tx_ring_size" 202 #define PROP_RX_RING_SIZE "rx_ring_size" 203 #define PROP_MR_ENABLE "mr_enable" 204 #define PROP_RX_GROUP_NUM "rx_group_number" 205 206 #define PROP_INTR_FORCE "intr_force" 207 #define PROP_TX_HCKSUM_ENABLE "tx_hcksum_enable" 208 #define PROP_RX_HCKSUM_ENABLE "rx_hcksum_enable" 209 #define PROP_LSO_ENABLE "lso_enable" 210 #define PROP_TX_HEAD_WB_ENABLE "tx_head_wb_enable" 211 #define PROP_TX_COPY_THRESHOLD "tx_copy_threshold" 212 #define PROP_TX_RECYCLE_THRESHOLD "tx_recycle_threshold" 213 #define PROP_TX_OVERLOAD_THRESHOLD "tx_overload_threshold" 214 #define PROP_TX_RESCHED_THRESHOLD "tx_resched_threshold" 215 #define PROP_RX_COPY_THRESHOLD "rx_copy_threshold" 216 #define PROP_RX_LIMIT_PER_INTR "rx_limit_per_intr" 217 #define PROP_INTR_THROTTLING "intr_throttling" 218 #define PROP_MCAST_MAX_NUM "mcast_max_num" 219 220 #define IGB_LB_NONE 0 221 #define IGB_LB_EXTERNAL 1 222 #define IGB_LB_INTERNAL_MAC 2 223 #define IGB_LB_INTERNAL_PHY 3 224 #define IGB_LB_INTERNAL_SERDES 4 225 226 enum ioc_reply { 227 IOC_INVAL = -1, /* bad, NAK with EINVAL */ 228 IOC_DONE, /* OK, reply sent */ 229 IOC_ACK, /* OK, just send ACK */ 230 IOC_REPLY /* OK, just send reply */ 231 }; 232 233 /* 234 * For s/w context extraction from a tx frame 235 */ 236 #define TX_CXT_SUCCESS 0 237 #define TX_CXT_E_LSO_CSUM (-1) 238 #define TX_CXT_E_ETHER_TYPE (-2) 239 240 #define DMA_SYNC(area, flag) ((void) ddi_dma_sync((area)->dma_handle, \ 241 0, 0, (flag))) 242 243 /* 244 * Defined for ring index operations 245 * ASSERT(index < limit) 246 * ASSERT(step < limit) 247 * ASSERT(index1 < limit) 248 * ASSERT(index2 < limit) 249 */ 250 #define NEXT_INDEX(index, step, limit) (((index) + (step)) < (limit) ? \ 251 (index) + (step) : (index) + (step) - (limit)) 252 #define PREV_INDEX(index, step, limit) ((index) >= (step) ? \ 253 (index) - (step) : (index) + (limit) - (step)) 254 #define OFFSET(index1, index2, limit) ((index1) <= (index2) ? \ 255 (index2) - (index1) : (index2) + (limit) - (index1)) 256 257 #define LINK_LIST_INIT(_LH) \ 258 (_LH)->head = (_LH)->tail = NULL 259 260 #define LIST_GET_HEAD(_LH) ((single_link_t *)((_LH)->head)) 261 262 #define LIST_POP_HEAD(_LH) \ 263 (single_link_t *)(_LH)->head; \ 264 { \ 265 if ((_LH)->head != NULL) { \ 266 (_LH)->head = (_LH)->head->link; \ 267 if ((_LH)->head == NULL) \ 268 (_LH)->tail = NULL; \ 269 } \ 270 } 271 272 #define LIST_GET_TAIL(_LH) ((single_link_t *)((_LH)->tail)) 273 274 #define LIST_PUSH_TAIL(_LH, _E) \ 275 if ((_LH)->tail != NULL) { \ 276 (_LH)->tail->link = (single_link_t *)(_E); \ 277 (_LH)->tail = (single_link_t *)(_E); \ 278 } else { \ 279 (_LH)->head = (_LH)->tail = (single_link_t *)(_E); \ 280 } \ 281 (_E)->link = NULL; 282 283 #define LIST_GET_NEXT(_LH, _E) \ 284 (((_LH)->tail == (single_link_t *)(_E)) ? \ 285 NULL : ((single_link_t *)(_E))->link) 286 287 288 typedef struct single_link { 289 struct single_link *link; 290 } single_link_t; 291 292 typedef struct link_list { 293 single_link_t *head; 294 single_link_t *tail; 295 } link_list_t; 296 297 /* 298 * Property lookups 299 */ 300 #define IGB_PROP_EXISTS(d, n) ddi_prop_exists(DDI_DEV_T_ANY, (d), \ 301 DDI_PROP_DONTPASS, (n)) 302 #define IGB_PROP_GET_INT(d, n) ddi_prop_get_int(DDI_DEV_T_ANY, (d), \ 303 DDI_PROP_DONTPASS, (n), -1) 304 305 306 /* capability/feature flags */ 307 #define IGB_FLAG_HAS_DCA (1 << 0) /* has Direct Cache Access */ 308 #define IGB_FLAG_VMDQ_POOL (1 << 1) /* has vmdq capability */ 309 #define IGB_FLAG_NEED_CTX_IDX (1 << 2) /* context descriptor needs index */ 310 311 /* function pointer for nic-specific functions */ 312 typedef void (*igb_nic_func_t)(struct igb *); 313 314 /* adapter-specific info for each supported device type */ 315 typedef struct adapter_info { 316 /* limits */ 317 uint32_t max_rx_que_num; /* maximum number of rx queues */ 318 uint32_t min_rx_que_num; /* minimum number of rx queues */ 319 uint32_t def_rx_que_num; /* default number of rx queues */ 320 uint32_t max_tx_que_num; /* maximum number of tx queues */ 321 uint32_t min_tx_que_num; /* minimum number of tx queues */ 322 uint32_t def_tx_que_num; /* default number of tx queues */ 323 uint32_t max_intr_throttle; /* maximum interrupt throttle */ 324 uint32_t min_intr_throttle; /* minimum interrupt throttle */ 325 uint32_t def_intr_throttle; /* default interrupt throttle */ 326 /* function pointers */ 327 igb_nic_func_t enable_intr; /* enable adapter interrupts */ 328 igb_nic_func_t setup_msix; /* set up msi-x vectors */ 329 /* capabilities */ 330 uint32_t flags; /* capability flags */ 331 uint32_t rxdctl_mask; /* mask for RXDCTL register */ 332 } adapter_info_t; 333 334 typedef union igb_ether_addr { 335 struct { 336 uint32_t high; 337 uint32_t low; 338 } reg; 339 struct { 340 uint8_t set; 341 uint8_t group_index; 342 uint8_t addr[ETHERADDRL]; 343 } mac; 344 } igb_ether_addr_t; 345 346 typedef enum { 347 USE_NONE, 348 USE_COPY, 349 USE_DMA 350 } tx_type_t; 351 352 typedef struct tx_context { 353 uint32_t hcksum_flags; 354 uint32_t ip_hdr_len; 355 uint32_t mac_hdr_len; 356 uint32_t l4_proto; 357 uint32_t mss; 358 uint32_t l4_hdr_len; 359 boolean_t lso_flag; 360 } tx_context_t; 361 362 /* Hold address/length of each DMA segment */ 363 typedef struct sw_desc { 364 uint64_t address; 365 size_t length; 366 } sw_desc_t; 367 368 /* Handles and addresses of DMA buffer */ 369 typedef struct dma_buffer { 370 caddr_t address; /* Virtual address */ 371 uint64_t dma_address; /* DMA (Hardware) address */ 372 ddi_acc_handle_t acc_handle; /* Data access handle */ 373 ddi_dma_handle_t dma_handle; /* DMA handle */ 374 size_t size; /* Buffer size */ 375 size_t len; /* Data length in the buffer */ 376 } dma_buffer_t; 377 378 /* 379 * Tx Control Block 380 */ 381 typedef struct tx_control_block { 382 single_link_t link; 383 uint32_t frag_num; 384 uint32_t desc_num; 385 mblk_t *mp; 386 tx_type_t tx_type; 387 ddi_dma_handle_t tx_dma_handle; 388 dma_buffer_t tx_buf; 389 sw_desc_t desc[MAX_COOKIE]; 390 } tx_control_block_t; 391 392 /* 393 * RX Control Block 394 */ 395 typedef struct rx_control_block { 396 mblk_t *mp; 397 uint32_t ref_cnt; 398 dma_buffer_t rx_buf; 399 frtn_t free_rtn; 400 struct igb_rx_data *rx_data; 401 } rx_control_block_t; 402 403 /* 404 * Software Data Structure for Tx Ring 405 */ 406 typedef struct igb_tx_ring { 407 uint32_t index; /* Ring index */ 408 uint32_t intr_vector; /* Interrupt vector index */ 409 410 /* 411 * Mutexes 412 */ 413 kmutex_t tx_lock; 414 kmutex_t recycle_lock; 415 kmutex_t tcb_head_lock; 416 kmutex_t tcb_tail_lock; 417 418 /* 419 * Tx descriptor ring definitions 420 */ 421 dma_buffer_t tbd_area; 422 union e1000_adv_tx_desc *tbd_ring; 423 uint32_t tbd_head; /* Index of next tbd to recycle */ 424 uint32_t tbd_tail; /* Index of next tbd to transmit */ 425 uint32_t tbd_free; /* Number of free tbd */ 426 427 /* 428 * Tx control block list definitions 429 */ 430 tx_control_block_t *tcb_area; 431 tx_control_block_t **work_list; 432 tx_control_block_t **free_list; 433 uint32_t tcb_head; /* Head index of free list */ 434 uint32_t tcb_tail; /* Tail index of free list */ 435 uint32_t tcb_free; /* Number of free tcb in free list */ 436 437 uint32_t *tbd_head_wb; /* Head write-back */ 438 uint32_t (*tx_recycle)(struct igb_tx_ring *); 439 440 /* 441 * s/w context structure for TCP/UDP checksum offload and LSO. 442 */ 443 tx_context_t tx_context; 444 445 /* 446 * Tx ring settings and status 447 */ 448 uint32_t ring_size; /* Tx descriptor ring size */ 449 uint32_t free_list_size; /* Tx free list size */ 450 451 boolean_t reschedule; 452 uint32_t recycle_fail; 453 uint32_t stall_watchdog; 454 455 #ifdef IGB_DEBUG 456 /* 457 * Debug statistics 458 */ 459 uint32_t stat_overload; 460 uint32_t stat_fail_no_tbd; 461 uint32_t stat_fail_no_tcb; 462 uint32_t stat_fail_dma_bind; 463 uint32_t stat_reschedule; 464 uint32_t stat_pkt_cnt; 465 #endif 466 467 /* 468 * Pointer to the igb struct 469 */ 470 struct igb *igb; 471 mac_ring_handle_t ring_handle; /* call back ring handle */ 472 } igb_tx_ring_t; 473 474 /* 475 * Software Receive Ring 476 */ 477 typedef struct igb_rx_data { 478 kmutex_t recycle_lock; /* Recycle lock, for rcb_tail */ 479 480 /* 481 * Rx descriptor ring definitions 482 */ 483 dma_buffer_t rbd_area; /* DMA buffer of rx desc ring */ 484 union e1000_adv_rx_desc *rbd_ring; /* Rx desc ring */ 485 uint32_t rbd_next; /* Index of next rx desc */ 486 487 /* 488 * Rx control block list definitions 489 */ 490 rx_control_block_t *rcb_area; 491 rx_control_block_t **work_list; /* Work list of rcbs */ 492 rx_control_block_t **free_list; /* Free list of rcbs */ 493 uint32_t rcb_head; /* Index of next free rcb */ 494 uint32_t rcb_tail; /* Index to put recycled rcb */ 495 uint32_t rcb_free; /* Number of free rcbs */ 496 497 /* 498 * Rx sw ring settings and status 499 */ 500 uint32_t ring_size; /* Rx descriptor ring size */ 501 uint32_t free_list_size; /* Rx free list size */ 502 503 uint32_t rcb_pending; 504 uint32_t flag; 505 506 struct igb_rx_ring *rx_ring; /* Pointer to rx ring */ 507 } igb_rx_data_t; 508 509 /* 510 * Software Data Structure for Rx Ring 511 */ 512 typedef struct igb_rx_ring { 513 uint32_t index; /* Ring index */ 514 uint32_t intr_vector; /* Interrupt vector index */ 515 516 igb_rx_data_t *rx_data; /* Rx software ring */ 517 518 kmutex_t rx_lock; /* Rx access lock */ 519 520 #ifdef IGB_DEBUG 521 /* 522 * Debug statistics 523 */ 524 uint32_t stat_frame_error; 525 uint32_t stat_cksum_error; 526 uint32_t stat_exceed_pkt; 527 uint32_t stat_pkt_cnt; 528 #endif 529 530 struct igb *igb; /* Pointer to igb struct */ 531 mac_ring_handle_t ring_handle; /* call back ring handle */ 532 uint32_t group_index; /* group index */ 533 uint64_t ring_gen_num; 534 } igb_rx_ring_t; 535 536 /* 537 * Software Receive Ring Group 538 */ 539 typedef struct igb_rx_group { 540 uint32_t index; /* Group index */ 541 mac_group_handle_t group_handle; /* call back group handle */ 542 struct igb *igb; /* Pointer to igb struct */ 543 } igb_rx_group_t; 544 545 typedef struct igb { 546 int instance; 547 mac_handle_t mac_hdl; 548 dev_info_t *dip; 549 struct e1000_hw hw; 550 struct igb_osdep osdep; 551 552 adapter_info_t *capab; /* adapter capabilities */ 553 554 uint32_t igb_state; 555 link_state_t link_state; 556 uint32_t link_speed; 557 uint32_t link_duplex; 558 uint32_t link_down_timeout; 559 boolean_t link_complete; 560 timeout_id_t link_tid; 561 562 uint32_t reset_count; 563 uint32_t attach_progress; 564 uint32_t loopback_mode; 565 uint32_t default_mtu; 566 uint32_t max_frame_size; 567 uint32_t dout_sync; 568 569 uint32_t rcb_pending; 570 571 uint32_t mr_enable; /* Enable multiple rings */ 572 uint32_t vmdq_mode; /* Mode of VMDq */ 573 574 /* 575 * Receive Rings and Groups 576 */ 577 igb_rx_ring_t *rx_rings; /* Array of rx rings */ 578 uint32_t num_rx_rings; /* Number of rx rings in use */ 579 uint32_t rx_ring_size; /* Rx descriptor ring size */ 580 uint32_t rx_buf_size; /* Rx buffer size */ 581 igb_rx_group_t *rx_groups; /* Array of rx groups */ 582 uint32_t num_rx_groups; /* Number of rx groups in use */ 583 584 /* 585 * Transmit Rings 586 */ 587 igb_tx_ring_t *tx_rings; /* Array of tx rings */ 588 uint32_t num_tx_rings; /* Number of tx rings in use */ 589 uint32_t tx_ring_size; /* Tx descriptor ring size */ 590 uint32_t tx_buf_size; /* Tx buffer size */ 591 592 boolean_t tx_ring_init; 593 boolean_t tx_head_wb_enable; /* Tx head wrtie-back */ 594 boolean_t tx_hcksum_enable; /* Tx h/w cksum offload */ 595 boolean_t lso_enable; /* Large Segment Offload */ 596 uint32_t tx_copy_thresh; /* Tx copy threshold */ 597 uint32_t tx_recycle_thresh; /* Tx recycle threshold */ 598 uint32_t tx_overload_thresh; /* Tx overload threshold */ 599 uint32_t tx_resched_thresh; /* Tx reschedule threshold */ 600 boolean_t rx_hcksum_enable; /* Rx h/w cksum offload */ 601 uint32_t rx_copy_thresh; /* Rx copy threshold */ 602 uint32_t rx_limit_per_intr; /* Rx pkts per interrupt */ 603 604 uint32_t intr_throttling[MAX_NUM_EITR]; 605 uint32_t intr_force; 606 607 int intr_type; 608 int intr_cnt; 609 int intr_cap; 610 size_t intr_size; 611 uint_t intr_pri; 612 ddi_intr_handle_t *htable; 613 uint32_t eims_mask; 614 uint32_t ims_mask; 615 616 kmutex_t gen_lock; /* General lock for device access */ 617 kmutex_t watchdog_lock; 618 kmutex_t link_lock; 619 kmutex_t rx_pending_lock; 620 621 boolean_t watchdog_enable; 622 boolean_t watchdog_start; 623 timeout_id_t watchdog_tid; 624 625 boolean_t unicst_init; 626 uint32_t unicst_avail; 627 uint32_t unicst_total; 628 igb_ether_addr_t unicst_addr[MAX_NUM_UNICAST_ADDRESSES]; 629 uint32_t mcast_count; 630 uint32_t mcast_alloc_count; 631 uint32_t mcast_max_num; 632 struct ether_addr *mcast_table; 633 634 /* 635 * Kstat definitions 636 */ 637 kstat_t *igb_ks; 638 639 uint32_t param_en_1000fdx_cap:1, 640 param_en_1000hdx_cap:1, 641 param_en_100t4_cap:1, 642 param_en_100fdx_cap:1, 643 param_en_100hdx_cap:1, 644 param_en_10fdx_cap:1, 645 param_en_10hdx_cap:1, 646 param_1000fdx_cap:1, 647 param_1000hdx_cap:1, 648 param_100t4_cap:1, 649 param_100fdx_cap:1, 650 param_100hdx_cap:1, 651 param_10fdx_cap:1, 652 param_10hdx_cap:1, 653 param_autoneg_cap:1, 654 param_pause_cap:1, 655 param_asym_pause_cap:1, 656 param_rem_fault:1, 657 param_adv_1000fdx_cap:1, 658 param_adv_1000hdx_cap:1, 659 param_adv_100t4_cap:1, 660 param_adv_100fdx_cap:1, 661 param_adv_100hdx_cap:1, 662 param_adv_10fdx_cap:1, 663 param_adv_10hdx_cap:1, 664 param_adv_autoneg_cap:1, 665 param_adv_pause_cap:1, 666 param_adv_asym_pause_cap:1, 667 param_adv_rem_fault:1, 668 param_lp_1000fdx_cap:1, 669 param_lp_1000hdx_cap:1, 670 param_lp_100t4_cap:1; 671 672 uint32_t param_lp_100fdx_cap:1, 673 param_lp_100hdx_cap:1, 674 param_lp_10fdx_cap:1, 675 param_lp_10hdx_cap:1, 676 param_lp_autoneg_cap:1, 677 param_lp_pause_cap:1, 678 param_lp_asym_pause_cap:1, 679 param_lp_rem_fault:1, 680 param_pad_to_32:24; 681 682 /* 683 * FMA capabilities 684 */ 685 int fm_capabilities; 686 687 ulong_t page_size; 688 } igb_t; 689 690 typedef struct igb_stat { 691 692 kstat_named_t link_speed; /* Link Speed */ 693 kstat_named_t reset_count; /* Reset Count */ 694 kstat_named_t dout_sync; /* DMA out of sync */ 695 #ifdef IGB_DEBUG 696 kstat_named_t rx_frame_error; /* Rx Error in Packet */ 697 kstat_named_t rx_cksum_error; /* Rx Checksum Error */ 698 kstat_named_t rx_exceed_pkt; /* Rx Exceed Max Pkt Count */ 699 700 kstat_named_t tx_overload; /* Tx Desc Ring Overload */ 701 kstat_named_t tx_fail_no_tcb; /* Tx Fail Freelist Empty */ 702 kstat_named_t tx_fail_no_tbd; /* Tx Fail Desc Ring Empty */ 703 kstat_named_t tx_fail_dma_bind; /* Tx Fail DMA bind */ 704 kstat_named_t tx_reschedule; /* Tx Reschedule */ 705 706 kstat_named_t gprc; /* Good Packets Received Count */ 707 kstat_named_t gptc; /* Good Packets Xmitted Count */ 708 kstat_named_t gor; /* Good Octets Received Count */ 709 kstat_named_t got; /* Good Octets Xmitd Count */ 710 kstat_named_t prc64; /* Packets Received - 64b */ 711 kstat_named_t prc127; /* Packets Received - 65-127b */ 712 kstat_named_t prc255; /* Packets Received - 127-255b */ 713 kstat_named_t prc511; /* Packets Received - 256-511b */ 714 kstat_named_t prc1023; /* Packets Received - 511-1023b */ 715 kstat_named_t prc1522; /* Packets Received - 1024-1522b */ 716 kstat_named_t ptc64; /* Packets Xmitted (64b) */ 717 kstat_named_t ptc127; /* Packets Xmitted (64-127b) */ 718 kstat_named_t ptc255; /* Packets Xmitted (128-255b) */ 719 kstat_named_t ptc511; /* Packets Xmitted (255-511b) */ 720 kstat_named_t ptc1023; /* Packets Xmitted (512-1023b) */ 721 kstat_named_t ptc1522; /* Packets Xmitted (1024-1522b */ 722 #endif 723 kstat_named_t crcerrs; /* CRC Error Count */ 724 kstat_named_t symerrs; /* Symbol Error Count */ 725 kstat_named_t mpc; /* Missed Packet Count */ 726 kstat_named_t scc; /* Single Collision Count */ 727 kstat_named_t ecol; /* Excessive Collision Count */ 728 kstat_named_t mcc; /* Multiple Collision Count */ 729 kstat_named_t latecol; /* Late Collision Count */ 730 kstat_named_t colc; /* Collision Count */ 731 kstat_named_t dc; /* Defer Count */ 732 kstat_named_t sec; /* Sequence Error Count */ 733 kstat_named_t rlec; /* Receive Length Error Count */ 734 kstat_named_t xonrxc; /* XON Received Count */ 735 kstat_named_t xontxc; /* XON Xmitted Count */ 736 kstat_named_t xoffrxc; /* XOFF Received Count */ 737 kstat_named_t xofftxc; /* Xoff Xmitted Count */ 738 kstat_named_t fcruc; /* Unknown Flow Conrol Packet Rcvd Count */ 739 kstat_named_t bprc; /* Broadcasts Pkts Received Count */ 740 kstat_named_t mprc; /* Multicast Pkts Received Count */ 741 kstat_named_t rnbc; /* Receive No Buffers Count */ 742 kstat_named_t ruc; /* Receive Undersize Count */ 743 kstat_named_t rfc; /* Receive Frag Count */ 744 kstat_named_t roc; /* Receive Oversize Count */ 745 kstat_named_t rjc; /* Receive Jabber Count */ 746 kstat_named_t tor; /* Total Octets Recvd Count */ 747 kstat_named_t tot; /* Total Octets Xmted Count */ 748 kstat_named_t tpr; /* Total Packets Received */ 749 kstat_named_t tpt; /* Total Packets Xmitted */ 750 kstat_named_t mptc; /* Multicast Packets Xmited Count */ 751 kstat_named_t bptc; /* Broadcast Packets Xmited Count */ 752 kstat_named_t algnerrc; /* Alignment Error count */ 753 kstat_named_t rxerrc; /* Rx Error Count */ 754 kstat_named_t tncrs; /* Transmit with no CRS */ 755 kstat_named_t cexterr; /* Carrier Extension Error count */ 756 kstat_named_t tsctc; /* TCP seg contexts xmit count */ 757 kstat_named_t tsctfc; /* TCP seg contexts xmit fail count */ 758 } igb_stat_t; 759 760 /* 761 * Function prototypes in e1000_osdep.c 762 */ 763 void e1000_write_pci_cfg(struct e1000_hw *, uint32_t, uint16_t *); 764 void e1000_read_pci_cfg(struct e1000_hw *, uint32_t, uint16_t *); 765 int32_t e1000_read_pcie_cap_reg(struct e1000_hw *, uint32_t, uint16_t *); 766 int32_t e1000_write_pcie_cap_reg(struct e1000_hw *, uint32_t, uint16_t *); 767 void e1000_rar_clear(struct e1000_hw *, uint32_t); 768 void e1000_rar_set_vmdq(struct e1000_hw *, const uint8_t *, uint32_t, 769 uint32_t, uint8_t); 770 771 /* 772 * Function prototypes in igb_buf.c 773 */ 774 int igb_alloc_dma(igb_t *); 775 void igb_free_dma(igb_t *); 776 void igb_free_dma_buffer(dma_buffer_t *); 777 int igb_alloc_rx_ring_data(igb_rx_ring_t *rx_ring); 778 void igb_free_rx_ring_data(igb_rx_data_t *rx_data); 779 780 /* 781 * Function prototypes in igb_main.c 782 */ 783 int igb_start(igb_t *, boolean_t); 784 void igb_stop(igb_t *, boolean_t); 785 int igb_setup_link(igb_t *, boolean_t); 786 int igb_unicst_find(igb_t *, const uint8_t *); 787 int igb_unicst_set(igb_t *, const uint8_t *, int); 788 int igb_multicst_add(igb_t *, const uint8_t *); 789 int igb_multicst_remove(igb_t *, const uint8_t *); 790 enum ioc_reply igb_loopback_ioctl(igb_t *, struct iocblk *, mblk_t *); 791 void igb_enable_watchdog_timer(igb_t *); 792 void igb_disable_watchdog_timer(igb_t *); 793 int igb_atomic_reserve(uint32_t *, uint32_t); 794 int igb_check_acc_handle(ddi_acc_handle_t); 795 int igb_check_dma_handle(ddi_dma_handle_t); 796 void igb_fm_ereport(igb_t *, char *); 797 void igb_set_fma_flags(int); 798 799 /* 800 * Function prototypes in igb_gld.c 801 */ 802 int igb_m_start(void *); 803 void igb_m_stop(void *); 804 int igb_m_promisc(void *, boolean_t); 805 int igb_m_multicst(void *, boolean_t, const uint8_t *); 806 int igb_m_unicst(void *, const uint8_t *); 807 int igb_m_stat(void *, uint_t, uint64_t *); 808 void igb_m_resources(void *); 809 void igb_m_ioctl(void *, queue_t *, mblk_t *); 810 boolean_t igb_m_getcapab(void *, mac_capab_t, void *); 811 void igb_fill_ring(void *, mac_ring_type_t, const int, const int, 812 mac_ring_info_t *, mac_ring_handle_t); 813 int igb_m_setprop(void *, const char *, mac_prop_id_t, uint_t, const void *); 814 int igb_m_getprop(void *, const char *, mac_prop_id_t, 815 uint_t, uint_t, void *, uint_t *); 816 int igb_set_priv_prop(igb_t *, const char *, uint_t, const void *); 817 int igb_get_priv_prop(igb_t *, const char *, 818 uint_t, uint_t, void *, uint_t *); 819 boolean_t igb_param_locked(mac_prop_id_t); 820 void igb_fill_group(void *arg, mac_ring_type_t, const int, 821 mac_group_info_t *, mac_group_handle_t); 822 int igb_rx_ring_intr_enable(mac_intr_handle_t); 823 int igb_rx_ring_intr_disable(mac_intr_handle_t); 824 int igb_get_def_val(igb_t *, mac_prop_id_t, uint_t, void *); 825 826 /* 827 * Function prototypes in igb_rx.c 828 */ 829 mblk_t *igb_rx(igb_rx_ring_t *, int); 830 void igb_rx_recycle(caddr_t arg); 831 832 /* 833 * Function prototypes in igb_tx.c 834 */ 835 void igb_free_tcb(tx_control_block_t *); 836 void igb_put_free_list(igb_tx_ring_t *, link_list_t *); 837 uint32_t igb_tx_recycle_legacy(igb_tx_ring_t *); 838 uint32_t igb_tx_recycle_head_wb(igb_tx_ring_t *); 839 840 /* 841 * Function prototypes in igb_log.c 842 */ 843 void igb_notice(void *, const char *, ...); 844 void igb_log(void *, const char *, ...); 845 void igb_error(void *, const char *, ...); 846 847 /* 848 * Function prototypes in igb_stat.c 849 */ 850 int igb_init_stats(igb_t *); 851 852 mblk_t *igb_rx_ring_poll(void *, int); 853 mblk_t *igb_tx_ring_send(void *, mblk_t *); 854 855 #ifdef __cplusplus 856 } 857 #endif 858 859 #endif /* _IGB_SW_H */ 860