1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_NXGE_NXGE_H 27 #define _SYS_NXGE_NXGE_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <nxge_mac.h> 34 #include <nxge_ipp.h> 35 #include <nxge_fflp.h> 36 37 /* 38 * NXGE diagnostics IOCTLS. 39 */ 40 #define NXGE_IOC ((((('N' << 8) + 'X') << 8) + 'G') << 8) 41 42 #define NXGE_GET64 (NXGE_IOC|1) 43 #define NXGE_PUT64 (NXGE_IOC|2) 44 #define NXGE_GET_TX_RING_SZ (NXGE_IOC|3) 45 #define NXGE_GET_TX_DESC (NXGE_IOC|4) 46 #define NXGE_GLOBAL_RESET (NXGE_IOC|5) 47 #define NXGE_TX_SIDE_RESET (NXGE_IOC|6) 48 #define NXGE_RX_SIDE_RESET (NXGE_IOC|7) 49 #define NXGE_RESET_MAC (NXGE_IOC|8) 50 51 #define NXGE_GET_MII (NXGE_IOC|11) 52 #define NXGE_PUT_MII (NXGE_IOC|12) 53 #define NXGE_RTRACE (NXGE_IOC|13) 54 #define NXGE_RTRACE_TEST (NXGE_IOC|20) 55 #define NXGE_TX_REGS_DUMP (NXGE_IOC|21) 56 #define NXGE_RX_REGS_DUMP (NXGE_IOC|22) 57 #define NXGE_INT_REGS_DUMP (NXGE_IOC|23) 58 #define NXGE_VIR_REGS_DUMP (NXGE_IOC|24) 59 #define NXGE_VIR_INT_REGS_DUMP (NXGE_IOC|25) 60 #define NXGE_RDUMP (NXGE_IOC|26) 61 #define NXGE_RDC_GRPS_DUMP (NXGE_IOC|27) 62 #define NXGE_PIO_TEST (NXGE_IOC|28) 63 64 #define NXGE_GET_TCAM (NXGE_IOC|29) 65 #define NXGE_PUT_TCAM (NXGE_IOC|30) 66 #define NXGE_INJECT_ERR (NXGE_IOC|40) 67 68 #define NXGE_OK 0 69 #define NXGE_ERROR 0x40000000 70 #define NXGE_DDI_FAILED 0x20000000 71 #define NXGE_GET_PORT_NUM(n) n 72 73 /* 74 * Definitions for module_info. 75 */ 76 #define NXGE_IDNUM (0) /* module ID number */ 77 #define NXGE_DRIVER_NAME "nxge" /* module name */ 78 79 #define NXGE_MINPSZ (0) /* min packet size */ 80 #define NXGE_MAXPSZ (ETHERMTU) /* max packet size */ 81 #define NXGE_HIWAT (2048 * NXGE_MAXPSZ) /* hi-water mark */ 82 #define NXGE_LOWAT (1) /* lo-water mark */ 83 #define NXGE_HIWAT_MAX (192000 * NXGE_MAXPSZ) 84 #define NXGE_HIWAT_MIN (2 * NXGE_MAXPSZ) 85 #define NXGE_LOWAT_MAX (192000 * NXGE_MAXPSZ) 86 #define NXGE_LOWAT_MIN (1) 87 88 #ifndef D_HOTPLUG 89 #define D_HOTPLUG 0x00 90 #endif 91 92 #define INIT_BUCKET_SIZE 16 /* Initial Hash Bucket Size */ 93 94 #define NXGE_CHECK_TIMER (5000) 95 96 typedef enum { 97 param_instance, 98 param_main_instance, 99 param_function_number, 100 param_partition_id, 101 param_read_write_mode, 102 param_fw_version, 103 param_port_mode, 104 param_niu_cfg_type, 105 param_tx_quick_cfg, 106 param_rx_quick_cfg, 107 param_master_cfg_enable, 108 param_master_cfg_value, 109 110 param_autoneg, 111 param_anar_10gfdx, 112 param_anar_10ghdx, 113 param_anar_1000fdx, 114 param_anar_1000hdx, 115 param_anar_100T4, 116 param_anar_100fdx, 117 param_anar_100hdx, 118 param_anar_10fdx, 119 param_anar_10hdx, 120 121 param_anar_asmpause, 122 param_anar_pause, 123 param_use_int_xcvr, 124 param_enable_ipg0, 125 param_ipg0, 126 param_ipg1, 127 param_ipg2, 128 param_accept_jumbo, 129 param_txdma_weight, 130 param_txdma_channels_begin, 131 132 param_txdma_channels, 133 param_txdma_info, 134 param_rxdma_channels_begin, 135 param_rxdma_channels, 136 param_rxdma_drr_weight, 137 param_rxdma_full_header, 138 param_rxdma_info, 139 param_rxdma_rbr_size, 140 param_rxdma_rcr_size, 141 param_default_port_rdc, 142 param_rxdma_intr_time, 143 param_rxdma_intr_pkts, 144 145 param_rdc_grps_start, 146 param_rx_rdc_grps, 147 param_default_grp0_rdc, 148 param_default_grp1_rdc, 149 param_default_grp2_rdc, 150 param_default_grp3_rdc, 151 param_default_grp4_rdc, 152 param_default_grp5_rdc, 153 param_default_grp6_rdc, 154 param_default_grp7_rdc, 155 156 param_info_rdc_groups, 157 param_start_ldg, 158 param_max_ldg, 159 param_mac_2rdc_grp, 160 param_vlan_2rdc_grp, 161 param_fcram_part_cfg, 162 param_fcram_access_ratio, 163 param_tcam_access_ratio, 164 param_tcam_enable, 165 param_hash_lookup_enable, 166 param_llc_snap_enable, 167 168 param_h1_init_value, 169 param_h2_init_value, 170 param_class_cfg_ether_usr1, 171 param_class_cfg_ether_usr2, 172 param_class_cfg_ip_usr4, 173 param_class_cfg_ip_usr5, 174 param_class_cfg_ip_usr6, 175 param_class_cfg_ip_usr7, 176 param_class_opt_ip_usr4, 177 param_class_opt_ip_usr5, 178 param_class_opt_ip_usr6, 179 param_class_opt_ip_usr7, 180 param_class_opt_ipv4_tcp, 181 param_class_opt_ipv4_udp, 182 param_class_opt_ipv4_ah, 183 param_class_opt_ipv4_sctp, 184 param_class_opt_ipv6_tcp, 185 param_class_opt_ipv6_udp, 186 param_class_opt_ipv6_ah, 187 param_class_opt_ipv6_sctp, 188 param_nxge_debug_flag, 189 param_npi_debug_flag, 190 param_dump_rdc, 191 param_dump_tdc, 192 param_dump_mac_regs, 193 param_dump_ipp_regs, 194 param_dump_fflp_regs, 195 param_dump_vlan_table, 196 param_dump_rdc_table, 197 param_dump_ptrs, 198 param_end 199 } nxge_param_index_t; 200 201 typedef enum { 202 SOLARIS_DOMAIN, 203 SOLARIS_SERVICE_DOMAIN, 204 SOLARIS_GUEST_DOMAIN, 205 LINUX_SERVICE_DOMAIN, 206 LINUX_GUEST_DOMAIN 207 } nxge_environs_t; 208 209 /* 210 * Named Dispatch Parameter Management Structure 211 */ 212 typedef int (*nxge_ndgetf_t)(p_nxge_t, queue_t *, MBLKP, caddr_t, cred_t *); 213 typedef int (*nxge_ndsetf_t)(p_nxge_t, queue_t *, 214 MBLKP, char *, caddr_t, cred_t *); 215 216 #define NXGE_PARAM_READ 0x00000001ULL 217 #define NXGE_PARAM_WRITE 0x00000002ULL 218 #define NXGE_PARAM_SHARED 0x00000004ULL 219 #define NXGE_PARAM_PRIV 0x00000008ULL 220 #define NXGE_PARAM_RW NXGE_PARAM_READ | NXGE_PARAM_WRITE 221 #define NXGE_PARAM_RWS NXGE_PARAM_RW | NXGE_PARAM_SHARED 222 #define NXGE_PARAM_RWP NXGE_PARAM_RW | NXGE_PARAM_PRIV 223 224 #define NXGE_PARAM_RXDMA 0x00000010ULL 225 #define NXGE_PARAM_TXDMA 0x00000020ULL 226 #define NXGE_PARAM_CLASS_GEN 0x00000040ULL 227 #define NXGE_PARAM_MAC 0x00000080ULL 228 #define NXGE_PARAM_CLASS_BIN NXGE_PARAM_CLASS_GEN | NXGE_PARAM_BASE_BIN 229 #define NXGE_PARAM_CLASS_HEX NXGE_PARAM_CLASS_GEN | NXGE_PARAM_BASE_HEX 230 #define NXGE_PARAM_CLASS NXGE_PARAM_CLASS_HEX 231 232 #define NXGE_PARAM_CMPLX 0x00010000ULL 233 #define NXGE_PARAM_NDD_WR_OK 0x00020000ULL 234 #define NXGE_PARAM_INIT_ONLY 0x00040000ULL 235 #define NXGE_PARAM_INIT_CONFIG 0x00080000ULL 236 237 #define NXGE_PARAM_READ_PROP 0x00100000ULL 238 #define NXGE_PARAM_PROP_ARR32 0x00200000ULL 239 #define NXGE_PARAM_PROP_ARR64 0x00400000ULL 240 #define NXGE_PARAM_PROP_STR 0x00800000ULL 241 242 #define NXGE_PARAM_BASE_DEC 0x00000000ULL 243 #define NXGE_PARAM_BASE_BIN 0x10000000ULL 244 #define NXGE_PARAM_BASE_HEX 0x20000000ULL 245 #define NXGE_PARAM_BASE_STR 0x40000000ULL 246 #define NXGE_PARAM_DONT_SHOW 0x80000000ULL 247 248 #define NXGE_PARAM_ARRAY_CNT_MASK 0x0000ffff00000000ULL 249 #define NXGE_PARAM_ARRAY_CNT_SHIFT 32ULL 250 #define NXGE_PARAM_ARRAY_ALLOC_MASK 0xffff000000000000ULL 251 #define NXGE_PARAM_ARRAY_ALLOC_SHIFT 48ULL 252 253 typedef struct _nxge_param_t { 254 int (*getf)(); 255 int (*setf)(); /* null for read only */ 256 uint64_t type; /* R/W/ Common/Port/ .... */ 257 uint64_t minimum; 258 uint64_t maximum; 259 uint64_t value; /* for array params, pointer to value array */ 260 uint64_t old_value; /* for array params, pointer to old_value array */ 261 char *fcode_name; 262 char *name; 263 } nxge_param_t, *p_nxge_param_t; 264 265 266 /* 267 * Do not change the order of the elements of this enum as that will 268 * break the driver code. 269 */ 270 typedef enum { 271 nxge_lb_normal, 272 nxge_lb_ext10g, 273 nxge_lb_ext1000, 274 nxge_lb_ext100, 275 nxge_lb_ext10, 276 nxge_lb_phy10g, 277 nxge_lb_phy1000, 278 nxge_lb_phy, 279 nxge_lb_serdes10g, 280 nxge_lb_serdes1000, 281 nxge_lb_serdes, 282 nxge_lb_mac10g, 283 nxge_lb_mac1000, 284 nxge_lb_mac 285 } nxge_lb_t; 286 287 enum nxge_mac_state { 288 NXGE_MAC_STOPPED = 0, 289 NXGE_MAC_STARTED, 290 NXGE_MAC_STOPPING 291 }; 292 293 /* 294 * Private DLPI full dlsap address format. 295 */ 296 typedef struct _nxge_dladdr_t { 297 ether_addr_st dl_phys; 298 uint16_t dl_sap; 299 } nxge_dladdr_t, *p_nxge_dladdr_t; 300 301 typedef struct _mc_addr_t { 302 ether_addr_st multcast_addr; 303 uint_t mc_addr_cnt; 304 } mc_addr_t, *p_mc_addr_t; 305 306 typedef struct _mc_bucket_t { 307 p_mc_addr_t addr_list; 308 uint_t list_size; 309 } mc_bucket_t, *p_mc_bucket_t; 310 311 typedef struct _mc_table_t { 312 p_mc_bucket_t bucket_list; 313 uint_t buckets_used; 314 } mc_table_t, *p_mc_table_t; 315 316 typedef struct _filter_t { 317 uint32_t all_phys_cnt; 318 uint32_t all_multicast_cnt; 319 uint32_t all_sap_cnt; 320 } filter_t, *p_filter_t; 321 322 typedef struct _nxge_port_stats_t { 323 /* 324 * Overall structure size 325 */ 326 size_t stats_size; 327 328 /* 329 * Link Input/Output stats 330 */ 331 uint64_t ipackets; 332 uint64_t ierrors; 333 uint64_t opackets; 334 uint64_t oerrors; 335 uint64_t collisions; 336 337 /* 338 * MIB II variables 339 */ 340 uint64_t rbytes; /* # bytes received */ 341 uint64_t obytes; /* # bytes transmitted */ 342 uint32_t multircv; /* # multicast packets received */ 343 uint32_t multixmt; /* # multicast packets for xmit */ 344 uint32_t brdcstrcv; /* # broadcast packets received */ 345 uint32_t brdcstxmt; /* # broadcast packets for xmit */ 346 uint32_t norcvbuf; /* # rcv packets discarded */ 347 uint32_t noxmtbuf; /* # xmit packets discarded */ 348 349 /* 350 * Lets the user know the MTU currently in use by 351 * the physical MAC port. 352 */ 353 nxge_lb_t lb_mode; 354 uint32_t qos_mode; 355 uint32_t trunk_mode; 356 uint32_t poll_mode; 357 358 /* 359 * Tx Statistics. 360 */ 361 uint32_t tx_inits; 362 uint32_t tx_starts; 363 uint32_t tx_nocanput; 364 uint32_t tx_msgdup_fail; 365 uint32_t tx_allocb_fail; 366 uint32_t tx_no_desc; 367 uint32_t tx_dma_bind_fail; 368 uint32_t tx_uflo; 369 uint32_t tx_hdr_pkts; 370 uint32_t tx_ddi_pkts; 371 uint32_t tx_dvma_pkts; 372 373 uint32_t tx_max_pend; 374 375 /* 376 * Rx Statistics. 377 */ 378 uint32_t rx_inits; 379 uint32_t rx_hdr_pkts; 380 uint32_t rx_mtu_pkts; 381 uint32_t rx_split_pkts; 382 uint32_t rx_no_buf; 383 uint32_t rx_no_comp_wb; 384 uint32_t rx_ov_flow; 385 uint32_t rx_len_mm; 386 uint32_t rx_tag_err; 387 uint32_t rx_nocanput; 388 uint32_t rx_msgdup_fail; 389 uint32_t rx_allocb_fail; 390 391 /* 392 * Receive buffer management statistics. 393 */ 394 uint32_t rx_new_pages; 395 uint32_t rx_new_hdr_pgs; 396 uint32_t rx_new_mtu_pgs; 397 uint32_t rx_new_nxt_pgs; 398 uint32_t rx_reused_pgs; 399 uint32_t rx_hdr_drops; 400 uint32_t rx_mtu_drops; 401 uint32_t rx_nxt_drops; 402 403 /* 404 * Receive flow statistics 405 */ 406 uint32_t rx_rel_flow; 407 uint32_t rx_rel_bit; 408 409 uint32_t rx_pkts_dropped; 410 411 /* 412 * PCI-E Bus Statistics. 413 */ 414 uint32_t pci_bus_speed; 415 uint32_t pci_err; 416 uint32_t pci_rta_err; 417 uint32_t pci_rma_err; 418 uint32_t pci_parity_err; 419 uint32_t pci_bad_ack_err; 420 uint32_t pci_drto_err; 421 uint32_t pci_dmawz_err; 422 uint32_t pci_dmarz_err; 423 424 uint32_t rx_taskq_waits; 425 426 uint32_t tx_jumbo_pkts; 427 428 /* 429 * Some statistics added to support bringup, these 430 * should be removed. 431 */ 432 uint32_t user_defined; 433 } nxge_port_stats_t, *p_nxge_port_stats_t; 434 435 436 typedef struct _nxge_stats_t { 437 /* 438 * Overall structure size 439 */ 440 size_t stats_size; 441 442 kstat_t *ksp; 443 kstat_t *rdc_ksp[NXGE_MAX_RDCS]; 444 kstat_t *tdc_ksp[NXGE_MAX_TDCS]; 445 kstat_t *rdc_sys_ksp; 446 kstat_t *fflp_ksp[1]; 447 kstat_t *ipp_ksp; 448 kstat_t *txc_ksp; 449 kstat_t *mac_ksp; 450 kstat_t *zcp_ksp; 451 kstat_t *port_ksp; 452 kstat_t *mmac_ksp; 453 454 nxge_mac_stats_t mac_stats; /* Common MAC Statistics */ 455 nxge_xmac_stats_t xmac_stats; /* XMAC Statistics */ 456 nxge_bmac_stats_t bmac_stats; /* BMAC Statistics */ 457 458 nxge_rx_ring_stats_t rx_stats; /* per port RX stats */ 459 nxge_ipp_stats_t ipp_stats; /* per port IPP stats */ 460 nxge_zcp_stats_t zcp_stats; /* per port IPP stats */ 461 nxge_rx_ring_stats_t rdc_stats[NXGE_MAX_RDCS]; /* per rdc stats */ 462 nxge_rdc_sys_stats_t rdc_sys_stats; /* per port RDC stats */ 463 464 nxge_tx_ring_stats_t tx_stats; /* per port TX stats */ 465 nxge_txc_stats_t txc_stats; /* per port TX stats */ 466 nxge_tx_ring_stats_t tdc_stats[NXGE_MAX_TDCS]; /* per tdc stats */ 467 nxge_fflp_stats_t fflp_stats; /* fflp stats */ 468 nxge_port_stats_t port_stats; /* fflp stats */ 469 nxge_mmac_stats_t mmac_stats; /* Multi mac. stats */ 470 471 } nxge_stats_t, *p_nxge_stats_t; 472 473 typedef struct _nxge_intr_t { 474 boolean_t intr_registered; /* interrupts are registered */ 475 boolean_t intr_enabled; /* interrupts are enabled */ 476 boolean_t niu_msi_enable; /* debug or configurable? */ 477 int intr_types; /* interrupt types supported */ 478 int intr_type; /* interrupt type to add */ 479 int max_int_cnt; /* max MSIX/INT HW supports */ 480 int start_inum; /* start inum (in sequence?) */ 481 int msi_intx_cnt; /* # msi/intx ints returned */ 482 int intr_added; /* # ints actually needed */ 483 int intr_cap; /* interrupt capabilities */ 484 size_t intr_size; /* size of array to allocate */ 485 ddi_intr_handle_t *htable; /* For array of interrupts */ 486 /* Add interrupt number for each interrupt vector */ 487 int pri; 488 } nxge_intr_t, *p_nxge_intr_t; 489 490 typedef struct _nxge_ldgv_t { 491 uint8_t ndma_ldvs; 492 uint8_t nldvs; 493 uint8_t maxldgs; 494 uint8_t maxldvs; 495 uint8_t ldg_intrs; 496 uint32_t tmres; 497 p_nxge_ldg_t ldgp; 498 p_nxge_ldv_t ldvp; 499 p_nxge_ldv_t ldvp_syserr; 500 int ldvp_syserr_allocated; 501 } nxge_ldgv_t, *p_nxge_ldgv_t; 502 503 typedef enum { 504 NXGE_TRANSMIT_GROUP, /* Legacy transmit group */ 505 NXGE_RECEIVE_GROUP, /* Legacy receive group */ 506 NXGE_VR_GROUP, /* Virtualization Region group */ 507 EXT_TRANSMIT_GROUP, /* External (Crossbow) transmit group */ 508 EXT_RECEIVE_GROUP /* External (Crossbow) receive group */ 509 } nxge_grp_type_t; 510 511 #define NXGE_ILLEGAL_CHANNEL (NXGE_MAX_TDCS + 1) 512 513 typedef uint8_t nxge_channel_t; 514 515 typedef struct nxge_grp { 516 nxge_t *nxge; 517 nxge_grp_type_t type; /* Tx or Rx */ 518 519 int sequence; /* When it was created. */ 520 int index; /* nxge_grp_set_t.group[index] */ 521 522 struct nx_dc *dc; /* Linked list of DMA channels. */ 523 size_t count; /* A count of <dc> above. */ 524 525 boolean_t active; /* Is it being used? */ 526 527 dc_map_t map; /* A bitmap of the channels in <dc>. */ 528 nxge_channel_t legend[NXGE_MAX_TDCS]; 529 530 } nxge_grp_t; 531 532 typedef struct { 533 lg_map_t map; 534 size_t count; 535 } lg_data_t; 536 537 typedef struct { 538 dc_map_t map; 539 size_t count; 540 } dc_data_t; 541 542 #define NXGE_DC_SET(map, channel) map |= (1 << channel) 543 #define NXGE_DC_RESET(map, channel) map &= (~(1 << channel)) 544 545 #define NXGE_LOGICAL_GROUP_MAX NXGE_MAX_TDCS 546 547 typedef struct { 548 int sequence; /* To order groups in time. */ 549 550 /* These are this instance's logical groups. */ 551 nxge_grp_t *group[NXGE_LOGICAL_GROUP_MAX]; 552 lg_data_t lg; 553 554 dc_data_t shared; /* These DCs are being shared. */ 555 dc_data_t owned; /* These DCs belong to me. */ 556 dc_data_t dead; /* These DCs are in an error state. */ 557 558 } nxge_grp_set_t; 559 560 /* 561 * Receive Ring Group 562 * One of the advanced virtualization features is the ability to bundle 563 * multiple Receive Rings in a single group. One or more MAC addresses may 564 * be assigned to a group. Incoming packets destined to the group's MAC 565 * address(es) are delivered to any ring member, according to a programmable 566 * or predefined RTS policy. Member rings can be polled individually. 567 * RX ring groups can come with a predefined set of member rings, or they 568 * are programmable by adding and removing rings to/from them. 569 */ 570 typedef struct _nxge_rx_ring_group_t { 571 mac_group_handle_t ghandle; 572 p_nxge_t nxgep; 573 int gindex; 574 int sindex; 575 } nxge_rx_ring_group_t; 576 577 /* 578 * Ring Handle 579 */ 580 typedef struct _nxge_ring_handle_t { 581 p_nxge_t nxgep; 582 int index; /* port-wise */ 583 mac_ring_handle_t ring_handle; 584 } nxge_ring_handle_t; 585 586 /* 587 * Share Handle 588 */ 589 typedef struct _nxge_share_handle_t { 590 p_nxge_t nxgep; /* Driver Handle */ 591 int index; 592 void *vrp; 593 uint64_t tmap; 594 uint64_t rmap; 595 int rxgroup; 596 boolean_t active; 597 } nxge_share_handle_t; 598 599 /* 600 * Neptune Device instance state information. 601 * 602 * Each instance is dynamically allocated on first attach. 603 */ 604 struct _nxge_t { 605 dev_info_t *dip; /* device instance */ 606 dev_info_t *p_dip; /* Parent's device instance */ 607 int instance; /* instance number */ 608 int function_num; /* device function number */ 609 int nports; /* # of ports on this device */ 610 int board_ver; /* Board Version */ 611 int use_partition; /* partition is enabled */ 612 uint32_t drv_state; /* driver state bit flags */ 613 uint64_t nxge_debug_level; /* driver state bit flags */ 614 kmutex_t genlock[1]; 615 enum nxge_mac_state nxge_mac_state; 616 ddi_softintr_t resched_id; /* reschedule callback */ 617 boolean_t resched_needed; 618 boolean_t resched_running; 619 620 p_dev_regs_t dev_regs; 621 npi_handle_t npi_handle; 622 npi_handle_t npi_pci_handle; 623 npi_handle_t npi_reg_handle; 624 npi_handle_t npi_msi_handle; 625 npi_handle_t npi_vreg_handle; 626 npi_handle_t npi_v2reg_handle; 627 628 nxge_xcvr_table_t xcvr; 629 boolean_t hot_swappable_phy; 630 boolean_t phy_absent; 631 uint32_t xcvr_addr; 632 uint16_t chip_id; 633 nxge_mac_t mac; 634 nxge_ipp_t ipp; 635 nxge_txc_t txc; 636 nxge_classify_t classifier; 637 638 mac_handle_t mach; /* mac module handle */ 639 p_nxge_stats_t statsp; 640 uint32_t param_count; 641 p_nxge_param_t param_arr; 642 643 uint32_t param_en_pause:1, 644 param_en_asym_pause:1, 645 param_en_1000fdx:1, 646 param_en_100fdx:1, 647 param_en_10fdx:1, 648 param_pad_to_32:27; 649 650 nxge_hw_list_t *nxge_hw_p; /* pointer to per Neptune */ 651 niu_type_t niu_type; 652 platform_type_t platform_type; 653 boolean_t os_addr_mode32; /* set to 1 for 32 bit mode */ 654 655 uint8_t def_rdc; 656 657 nxge_intr_t nxge_intr_type; 658 nxge_dma_pt_cfg_t pt_config; 659 nxge_class_pt_cfg_t class_config; 660 661 /* Logical device and group data structures. */ 662 p_nxge_ldgv_t ldgvp; 663 664 npi_vpd_info_t vpd_info; 665 666 ether_addr_st factaddr; /* factory mac address */ 667 ether_addr_st ouraddr; /* individual address */ 668 kmutex_t ouraddr_lock; /* lock to protect to uradd */ 669 670 ddi_iblock_cookie_t interrupt_cookie; 671 672 /* 673 * Blocks of memory may be pre-allocated by the 674 * partition manager or the driver. They may include 675 * blocks for configuration and buffers. The idea is 676 * to preallocate big blocks of contiguous areas in 677 * system memory (i.e. with IOMMU). These blocks then 678 * will be broken up to a fixed number of blocks with 679 * each block having the same block size (4K, 8K, 16K or 680 * 32K) in the case of buffer blocks. For systems that 681 * do not support DVMA, more than one big block will be 682 * allocated. 683 */ 684 uint32_t rx_default_block_size; 685 nxge_rx_block_size_t rx_bksize_code; 686 687 p_nxge_dma_pool_t rx_buf_pool_p; 688 p_nxge_dma_pool_t rx_cntl_pool_p; 689 690 p_nxge_dma_pool_t tx_buf_pool_p; 691 p_nxge_dma_pool_t tx_cntl_pool_p; 692 693 /* Receive buffer block ring and completion ring. */ 694 p_rx_rbr_rings_t rx_rbr_rings; 695 p_rx_rcr_rings_t rx_rcr_rings; 696 p_rx_mbox_areas_t rx_mbox_areas_p; 697 698 uint32_t start_rdc; 699 uint32_t max_rdcs; 700 uint32_t rdc_mask; 701 702 /* Transmit descriptors rings */ 703 p_tx_rings_t tx_rings; 704 p_tx_mbox_areas_t tx_mbox_areas_p; 705 706 uint32_t start_tdc; 707 uint32_t max_tdcs; 708 709 ddi_dma_handle_t dmasparehandle; 710 711 ulong_t sys_page_sz; 712 ulong_t sys_page_mask; 713 int suspended; 714 715 mii_bmsr_t bmsr; /* xcvr status at last poll. */ 716 mii_bmsr_t soft_bmsr; /* xcvr status kept by SW. */ 717 718 kmutex_t mif_lock; /* Lock to protect the list. */ 719 720 void (*mii_read)(); 721 void (*mii_write)(); 722 void (*mii_poll)(); 723 filter_t filter; /* Current instance filter */ 724 p_hash_filter_t hash_filter; /* Multicast hash filter. */ 725 krwlock_t filter_lock; /* Lock to protect filters. */ 726 727 ulong_t sys_burst_sz; 728 729 uint8_t cache_line; 730 731 timeout_id_t nxge_link_poll_timerid; 732 timeout_id_t nxge_timerid; 733 734 uint_t need_periodic_reclaim; 735 timeout_id_t reclaim_timer; 736 737 uint8_t msg_min; 738 uint8_t crc_size; 739 740 boolean_t hard_props_read; 741 742 uint32_t nxge_ncpus; 743 uint16_t intr_timeout; 744 uint16_t intr_threshold; 745 746 int fm_capabilities; /* FMA capabilities */ 747 748 uint32_t nxge_port_rbr_size; 749 uint32_t nxge_port_rbr_spare_size; 750 uint32_t nxge_port_rcr_size; 751 uint32_t nxge_port_rx_cntl_alloc_size; 752 uint32_t nxge_port_tx_ring_size; 753 nxge_mmac_t nxge_mmac_info; 754 #if defined(sun4v) 755 boolean_t niu_hsvc_available; 756 hsvc_info_t niu_hsvc; 757 uint64_t niu_min_ver; 758 #endif 759 boolean_t link_notify; 760 761 kmutex_t poll_lock; 762 kcondvar_t poll_cv; 763 link_mon_enable_t poll_state; 764 #define NXGE_MAGIC 0x3ab434e3 765 uint32_t nxge_magic; 766 767 int soft_lso_enable; 768 /* The following fields are LDOMs-specific additions. */ 769 nxge_environs_t environs; 770 ether_addr_t hio_mac_addr; 771 uint32_t niu_cfg_hdl; 772 kmutex_t group_lock; 773 774 struct nxge_hio_vr *hio_vr; 775 776 nxge_grp_set_t rx_set; 777 nxge_grp_set_t tx_set; 778 boolean_t tdc_is_shared[NXGE_MAX_TDCS]; 779 780 nxge_rx_ring_group_t rx_hio_groups[NXGE_MAX_RDC_GROUPS]; 781 nxge_share_handle_t shares[NXGE_MAX_VRS]; 782 }; 783 784 /* 785 * Driver state flags. 786 */ 787 #define STATE_REGS_MAPPED 0x000000001 /* device registers mapped */ 788 #define STATE_KSTATS_SETUP 0x000000002 /* kstats allocated */ 789 #define STATE_NODE_CREATED 0x000000004 /* device node created */ 790 #define STATE_HW_CONFIG_CREATED 0x000000008 /* hardware properties */ 791 #define STATE_HW_INITIALIZED 0x000000010 /* hardware initialized */ 792 #define STATE_MDIO_LOCK_INIT 0x000000020 /* mdio lock initialized */ 793 #define STATE_MII_LOCK_INIT 0x000000040 /* mii lock initialized */ 794 795 #define STOP_POLL_THRESH 9 796 #define START_POLL_THRESH 2 797 798 typedef struct _nxge_port_kstat_t { 799 /* 800 * Transciever state informations. 801 */ 802 kstat_named_t xcvr_inits; 803 kstat_named_t xcvr_inuse; 804 kstat_named_t xcvr_addr; 805 kstat_named_t xcvr_id; 806 kstat_named_t cap_autoneg; 807 kstat_named_t cap_10gfdx; 808 kstat_named_t cap_10ghdx; 809 kstat_named_t cap_1000fdx; 810 kstat_named_t cap_1000hdx; 811 kstat_named_t cap_100T4; 812 kstat_named_t cap_100fdx; 813 kstat_named_t cap_100hdx; 814 kstat_named_t cap_10fdx; 815 kstat_named_t cap_10hdx; 816 kstat_named_t cap_asmpause; 817 kstat_named_t cap_pause; 818 819 /* 820 * Link partner capabilities. 821 */ 822 kstat_named_t lp_cap_autoneg; 823 kstat_named_t lp_cap_10gfdx; 824 kstat_named_t lp_cap_10ghdx; 825 kstat_named_t lp_cap_1000fdx; 826 kstat_named_t lp_cap_1000hdx; 827 kstat_named_t lp_cap_100T4; 828 kstat_named_t lp_cap_100fdx; 829 kstat_named_t lp_cap_100hdx; 830 kstat_named_t lp_cap_10fdx; 831 kstat_named_t lp_cap_10hdx; 832 kstat_named_t lp_cap_asmpause; 833 kstat_named_t lp_cap_pause; 834 835 /* 836 * Shared link setup. 837 */ 838 kstat_named_t link_T4; 839 kstat_named_t link_speed; 840 kstat_named_t link_duplex; 841 kstat_named_t link_asmpause; 842 kstat_named_t link_pause; 843 kstat_named_t link_up; 844 845 /* 846 * Lets the user know the MTU currently in use by 847 * the physical MAC port. 848 */ 849 kstat_named_t mac_mtu; 850 kstat_named_t lb_mode; 851 kstat_named_t qos_mode; 852 kstat_named_t trunk_mode; 853 854 /* 855 * Misc MAC statistics. 856 */ 857 kstat_named_t ifspeed; 858 kstat_named_t promisc; 859 kstat_named_t rev_id; 860 861 /* 862 * Some statistics added to support bringup, these 863 * should be removed. 864 */ 865 kstat_named_t user_defined; 866 } nxge_port_kstat_t, *p_nxge_port_kstat_t; 867 868 typedef struct _nxge_rdc_kstat { 869 /* 870 * Receive DMA channel statistics. 871 */ 872 kstat_named_t ipackets; 873 kstat_named_t rbytes; 874 kstat_named_t errors; 875 kstat_named_t dcf_err; 876 kstat_named_t rcr_ack_err; 877 878 kstat_named_t dc_fifoflow_err; 879 kstat_named_t rcr_sha_par_err; 880 kstat_named_t rbr_pre_par_err; 881 kstat_named_t wred_drop; 882 kstat_named_t rbr_pre_emty; 883 884 kstat_named_t rcr_shadow_full; 885 kstat_named_t rbr_tmout; 886 kstat_named_t rsp_cnt_err; 887 kstat_named_t byte_en_bus; 888 kstat_named_t rsp_dat_err; 889 890 kstat_named_t pkt_too_long_err; 891 kstat_named_t compl_l2_err; 892 kstat_named_t compl_l4_cksum_err; 893 kstat_named_t compl_zcp_soft_err; 894 kstat_named_t compl_fflp_soft_err; 895 kstat_named_t config_err; 896 897 kstat_named_t rcrincon; 898 kstat_named_t rcrfull; 899 kstat_named_t rbr_empty; 900 kstat_named_t rbrfull; 901 kstat_named_t rbrlogpage; 902 903 kstat_named_t cfiglogpage; 904 kstat_named_t port_drop_pkt; 905 kstat_named_t rcr_to; 906 kstat_named_t rcr_thresh; 907 kstat_named_t rcr_mex; 908 kstat_named_t id_mismatch; 909 kstat_named_t zcp_eop_err; 910 kstat_named_t ipp_eop_err; 911 } nxge_rdc_kstat_t, *p_nxge_rdc_kstat_t; 912 913 typedef struct _nxge_rdc_sys_kstat { 914 /* 915 * Receive DMA system statistics. 916 */ 917 kstat_named_t pre_par; 918 kstat_named_t sha_par; 919 kstat_named_t id_mismatch; 920 kstat_named_t ipp_eop_err; 921 kstat_named_t zcp_eop_err; 922 } nxge_rdc_sys_kstat_t, *p_nxge_rdc_sys_kstat_t; 923 924 typedef struct _nxge_tdc_kstat { 925 /* 926 * Transmit DMA channel statistics. 927 */ 928 kstat_named_t opackets; 929 kstat_named_t obytes; 930 kstat_named_t oerrors; 931 kstat_named_t tx_inits; 932 kstat_named_t tx_no_buf; 933 934 kstat_named_t mbox_err; 935 kstat_named_t pkt_size_err; 936 kstat_named_t tx_ring_oflow; 937 kstat_named_t pref_buf_ecc_err; 938 kstat_named_t nack_pref; 939 kstat_named_t nack_pkt_rd; 940 kstat_named_t conf_part_err; 941 kstat_named_t pkt_prt_err; 942 kstat_named_t reset_fail; 943 /* used to in the common (per port) counter */ 944 945 kstat_named_t tx_starts; 946 kstat_named_t tx_nocanput; 947 kstat_named_t tx_msgdup_fail; 948 kstat_named_t tx_allocb_fail; 949 kstat_named_t tx_no_desc; 950 kstat_named_t tx_dma_bind_fail; 951 kstat_named_t tx_uflo; 952 kstat_named_t tx_hdr_pkts; 953 kstat_named_t tx_ddi_pkts; 954 kstat_named_t tx_dvma_pkts; 955 kstat_named_t tx_max_pend; 956 } nxge_tdc_kstat_t, *p_nxge_tdc_kstat_t; 957 958 typedef struct _nxge_txc_kstat { 959 /* 960 * Transmit port TXC block statistics. 961 */ 962 kstat_named_t pkt_stuffed; 963 kstat_named_t pkt_xmit; 964 kstat_named_t ro_correct_err; 965 kstat_named_t ro_uncorrect_err; 966 kstat_named_t sf_correct_err; 967 kstat_named_t sf_uncorrect_err; 968 kstat_named_t address_failed; 969 kstat_named_t dma_failed; 970 kstat_named_t length_failed; 971 kstat_named_t pkt_assy_dead; 972 kstat_named_t reorder_err; 973 } nxge_txc_kstat_t, *p_nxge_txc_kstat_t; 974 975 typedef struct _nxge_ipp_kstat { 976 /* 977 * Receive port IPP block statistics. 978 */ 979 kstat_named_t eop_miss; 980 kstat_named_t sop_miss; 981 kstat_named_t dfifo_ue; 982 kstat_named_t ecc_err_cnt; 983 kstat_named_t pfifo_perr; 984 kstat_named_t pfifo_over; 985 kstat_named_t pfifo_und; 986 kstat_named_t bad_cs_cnt; 987 kstat_named_t pkt_dis_cnt; 988 } nxge_ipp_kstat_t, *p_nxge_ipp_kstat_t; 989 990 typedef struct _nxge_zcp_kstat { 991 /* 992 * ZCP statistics. 993 */ 994 kstat_named_t errors; 995 kstat_named_t inits; 996 kstat_named_t rrfifo_underrun; 997 kstat_named_t rrfifo_overrun; 998 kstat_named_t rspfifo_uncorr_err; 999 kstat_named_t buffer_overflow; 1000 kstat_named_t stat_tbl_perr; 1001 kstat_named_t dyn_tbl_perr; 1002 kstat_named_t buf_tbl_perr; 1003 kstat_named_t tt_program_err; 1004 kstat_named_t rsp_tt_index_err; 1005 kstat_named_t slv_tt_index_err; 1006 kstat_named_t zcp_tt_index_err; 1007 kstat_named_t access_fail; 1008 kstat_named_t cfifo_ecc; 1009 } nxge_zcp_kstat_t, *p_nxge_zcp_kstat_t; 1010 1011 typedef struct _nxge_mac_kstat { 1012 /* 1013 * Transmit MAC statistics. 1014 */ 1015 kstat_named_t tx_frame_cnt; 1016 kstat_named_t tx_underflow_err; 1017 kstat_named_t tx_overflow_err; 1018 kstat_named_t tx_maxpktsize_err; 1019 kstat_named_t tx_fifo_xfr_err; 1020 kstat_named_t tx_byte_cnt; 1021 1022 /* 1023 * Receive MAC statistics. 1024 */ 1025 kstat_named_t rx_frame_cnt; 1026 kstat_named_t rx_underflow_err; 1027 kstat_named_t rx_overflow_err; 1028 kstat_named_t rx_len_err_cnt; 1029 kstat_named_t rx_crc_err_cnt; 1030 kstat_named_t rx_viol_err_cnt; 1031 kstat_named_t rx_byte_cnt; 1032 kstat_named_t rx_hist1_cnt; 1033 kstat_named_t rx_hist2_cnt; 1034 kstat_named_t rx_hist3_cnt; 1035 kstat_named_t rx_hist4_cnt; 1036 kstat_named_t rx_hist5_cnt; 1037 kstat_named_t rx_hist6_cnt; 1038 kstat_named_t rx_hist7_cnt; 1039 kstat_named_t rx_broadcast_cnt; 1040 kstat_named_t rx_mult_cnt; 1041 kstat_named_t rx_frag_cnt; 1042 kstat_named_t rx_frame_align_err_cnt; 1043 kstat_named_t rx_linkfault_err_cnt; 1044 kstat_named_t rx_local_fault_err_cnt; 1045 kstat_named_t rx_remote_fault_err_cnt; 1046 } nxge_mac_kstat_t, *p_nxge_mac_kstat_t; 1047 1048 typedef struct _nxge_xmac_kstat { 1049 /* 1050 * XMAC statistics. 1051 */ 1052 kstat_named_t tx_frame_cnt; 1053 kstat_named_t tx_underflow_err; 1054 kstat_named_t tx_maxpktsize_err; 1055 kstat_named_t tx_overflow_err; 1056 kstat_named_t tx_fifo_xfr_err; 1057 kstat_named_t tx_byte_cnt; 1058 kstat_named_t rx_frame_cnt; 1059 kstat_named_t rx_underflow_err; 1060 kstat_named_t rx_overflow_err; 1061 kstat_named_t rx_crc_err_cnt; 1062 kstat_named_t rx_len_err_cnt; 1063 kstat_named_t rx_viol_err_cnt; 1064 kstat_named_t rx_byte_cnt; 1065 kstat_named_t rx_hist1_cnt; 1066 kstat_named_t rx_hist2_cnt; 1067 kstat_named_t rx_hist3_cnt; 1068 kstat_named_t rx_hist4_cnt; 1069 kstat_named_t rx_hist5_cnt; 1070 kstat_named_t rx_hist6_cnt; 1071 kstat_named_t rx_hist7_cnt; 1072 kstat_named_t rx_broadcast_cnt; 1073 kstat_named_t rx_mult_cnt; 1074 kstat_named_t rx_frag_cnt; 1075 kstat_named_t rx_frame_align_err_cnt; 1076 kstat_named_t rx_linkfault_err_cnt; 1077 kstat_named_t rx_remote_fault_err_cnt; 1078 kstat_named_t rx_local_fault_err_cnt; 1079 kstat_named_t rx_pause_cnt; 1080 kstat_named_t xpcs_deskew_err_cnt; 1081 kstat_named_t xpcs_ln0_symbol_err_cnt; 1082 kstat_named_t xpcs_ln1_symbol_err_cnt; 1083 kstat_named_t xpcs_ln2_symbol_err_cnt; 1084 kstat_named_t xpcs_ln3_symbol_err_cnt; 1085 } nxge_xmac_kstat_t, *p_nxge_xmac_kstat_t; 1086 1087 typedef struct _nxge_bmac_kstat { 1088 /* 1089 * BMAC statistics. 1090 */ 1091 kstat_named_t tx_frame_cnt; 1092 kstat_named_t tx_underrun_err; 1093 kstat_named_t tx_max_pkt_err; 1094 kstat_named_t tx_byte_cnt; 1095 kstat_named_t rx_frame_cnt; 1096 kstat_named_t rx_byte_cnt; 1097 kstat_named_t rx_overflow_err; 1098 kstat_named_t rx_align_err_cnt; 1099 kstat_named_t rx_crc_err_cnt; 1100 kstat_named_t rx_len_err_cnt; 1101 kstat_named_t rx_viol_err_cnt; 1102 kstat_named_t rx_pause_cnt; 1103 kstat_named_t tx_pause_state; 1104 kstat_named_t tx_nopause_state; 1105 } nxge_bmac_kstat_t, *p_nxge_bmac_kstat_t; 1106 1107 1108 typedef struct _nxge_fflp_kstat { 1109 /* 1110 * FFLP statistics. 1111 */ 1112 1113 kstat_named_t fflp_tcam_perr; 1114 kstat_named_t fflp_tcam_ecc_err; 1115 kstat_named_t fflp_vlan_perr; 1116 kstat_named_t fflp_hasht_lookup_err; 1117 kstat_named_t fflp_hasht_data_err[MAX_PARTITION]; 1118 } nxge_fflp_kstat_t, *p_nxge_fflp_kstat_t; 1119 1120 typedef struct _nxge_mmac_kstat { 1121 kstat_named_t mmac_max_addr_cnt; 1122 kstat_named_t mmac_avail_addr_cnt; 1123 kstat_named_t mmac_addr1; 1124 kstat_named_t mmac_addr2; 1125 kstat_named_t mmac_addr3; 1126 kstat_named_t mmac_addr4; 1127 kstat_named_t mmac_addr5; 1128 kstat_named_t mmac_addr6; 1129 kstat_named_t mmac_addr7; 1130 kstat_named_t mmac_addr8; 1131 kstat_named_t mmac_addr9; 1132 kstat_named_t mmac_addr10; 1133 kstat_named_t mmac_addr11; 1134 kstat_named_t mmac_addr12; 1135 kstat_named_t mmac_addr13; 1136 kstat_named_t mmac_addr14; 1137 kstat_named_t mmac_addr15; 1138 kstat_named_t mmac_addr16; 1139 } nxge_mmac_kstat_t, *p_nxge_mmac_kstat_t; 1140 1141 /* 1142 * Prototype definitions. 1143 */ 1144 nxge_status_t nxge_init(p_nxge_t); 1145 void nxge_uninit(p_nxge_t); 1146 void nxge_get64(p_nxge_t, p_mblk_t); 1147 void nxge_put64(p_nxge_t, p_mblk_t); 1148 void nxge_pio_loop(p_nxge_t, p_mblk_t); 1149 1150 typedef void (*fptrv_t)(); 1151 timeout_id_t nxge_start_timer(p_nxge_t, fptrv_t, int); 1152 void nxge_stop_timer(p_nxge_t, timeout_id_t); 1153 1154 #ifdef __cplusplus 1155 } 1156 #endif 1157 1158 #endif /* _SYS_NXGE_NXGE_H */ 1159