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.
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.
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]
23 * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Copyright 2017, Joyent, Inc.
29 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
30 * Copyright (c) 2013 Saso Kiselkov. All rights reserved.
31 * Copyright (c) 2013 OSN Online Service Nuernberg GmbH. All rights reserved.
32 * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
37 static char ixgbe_ident
[] = "Intel 10Gb Ethernet";
40 * Local function protoypes
42 static int ixgbe_register_mac(ixgbe_t
*);
43 static int ixgbe_identify_hardware(ixgbe_t
*);
44 static int ixgbe_regs_map(ixgbe_t
*);
45 static void ixgbe_init_properties(ixgbe_t
*);
46 static int ixgbe_init_driver_settings(ixgbe_t
*);
47 static void ixgbe_init_locks(ixgbe_t
*);
48 static void ixgbe_destroy_locks(ixgbe_t
*);
49 static int ixgbe_init(ixgbe_t
*);
50 static int ixgbe_chip_start(ixgbe_t
*);
51 static void ixgbe_chip_stop(ixgbe_t
*);
52 static int ixgbe_reset(ixgbe_t
*);
53 static void ixgbe_tx_clean(ixgbe_t
*);
54 static bool ixgbe_tx_drain(ixgbe_t
*);
55 static bool ixgbe_rx_drain(ixgbe_t
*);
56 static int ixgbe_alloc_rings(ixgbe_t
*);
57 static void ixgbe_free_rings(ixgbe_t
*);
58 static int ixgbe_alloc_rx_data(ixgbe_t
*);
59 static void ixgbe_free_rx_data(ixgbe_t
*);
60 static void ixgbe_setup_rings(ixgbe_t
*);
61 static void ixgbe_setup_rx(ixgbe_t
*);
62 static void ixgbe_setup_tx(ixgbe_t
*);
63 static void ixgbe_setup_rx_ring(ixgbe_rx_ring_t
*);
64 static void ixgbe_setup_tx_ring(ixgbe_tx_ring_t
*);
65 static void ixgbe_setup_rss(ixgbe_t
*);
66 static void ixgbe_setup_vmdq(ixgbe_t
*);
67 static void ixgbe_setup_vmdq_rss(ixgbe_t
*);
68 static void ixgbe_setup_rss_table(ixgbe_t
*);
69 static void ixgbe_init_unicst(ixgbe_t
*);
70 static int ixgbe_unicst_find(ixgbe_t
*, const uint8_t *);
71 static void ixgbe_setup_multicst(ixgbe_t
*);
72 static void ixgbe_get_hw_state(ixgbe_t
*);
73 static void ixgbe_setup_vmdq_rss_conf(ixgbe_t
*ixgbe
);
74 static void ixgbe_get_conf(ixgbe_t
*);
75 static void ixgbe_init_params(ixgbe_t
*);
76 static int ixgbe_get_prop(ixgbe_t
*, char *, int, int, int);
77 static void ixgbe_driver_link_check(ixgbe_t
*);
78 static void ixgbe_sfp_check(void *);
79 static void ixgbe_overtemp_check(void *);
80 static void ixgbe_phy_check(void *);
81 static void ixgbe_link_timer(void *);
82 static void ixgbe_local_timer(void *);
83 static void ixgbe_arm_watchdog_timer(ixgbe_t
*);
84 static void ixgbe_restart_watchdog_timer(ixgbe_t
*);
85 static void ixgbe_disable_adapter_interrupts(ixgbe_t
*);
86 static void ixgbe_enable_adapter_interrupts(ixgbe_t
*);
87 static bool is_valid_mac_addr(uint8_t *);
88 static bool ixgbe_stall_check(ixgbe_t
*);
89 static bool ixgbe_set_loopback_mode(ixgbe_t
*, uint32_t);
90 static void ixgbe_set_internal_mac_loopback(ixgbe_t
*);
91 static bool ixgbe_find_mac_address(ixgbe_t
*);
92 static int ixgbe_alloc_intrs(ixgbe_t
*);
93 static int ixgbe_alloc_intr_handles(ixgbe_t
*, int);
94 static int ixgbe_add_intr_handlers(ixgbe_t
*);
95 static void ixgbe_map_rxring_to_vector(ixgbe_t
*, int, int);
96 static void ixgbe_map_txring_to_vector(ixgbe_t
*, int, int);
97 static void ixgbe_setup_ivar(ixgbe_t
*, uint16_t, uint8_t, int8_t);
98 static void ixgbe_enable_ivar(ixgbe_t
*, uint16_t, int8_t);
99 static void ixgbe_disable_ivar(ixgbe_t
*, uint16_t, int8_t);
100 static uint32_t ixgbe_get_hw_rx_index(ixgbe_t
*ixgbe
, uint32_t sw_rx_index
);
101 static int ixgbe_map_intrs_to_vectors(ixgbe_t
*);
102 static void ixgbe_setup_adapter_vector(ixgbe_t
*);
103 static void ixgbe_rem_intr_handlers(ixgbe_t
*);
104 static void ixgbe_rem_intrs(ixgbe_t
*);
105 static int ixgbe_enable_intrs(ixgbe_t
*);
106 static int ixgbe_disable_intrs(ixgbe_t
*);
107 static uint_t
ixgbe_intr_legacy(void *, void *);
108 static uint_t
ixgbe_intr_msi(void *, void *);
109 static uint_t
ixgbe_intr_msix(void *, void *);
110 static void ixgbe_intr_rx_work(ixgbe_rx_ring_t
*);
111 static void ixgbe_intr_tx_work(ixgbe_tx_ring_t
*);
112 static void ixgbe_intr_other_work(ixgbe_t
*, uint32_t);
113 static void ixgbe_get_driver_control(struct ixgbe_hw
*);
114 static int ixgbe_addmac(void *, const uint8_t *);
115 static int ixgbe_remmac(void *, const uint8_t *);
116 static void ixgbe_release_driver_control(struct ixgbe_hw
*);
118 static int ixgbe_attach(dev_info_t
*, ddi_attach_cmd_t
);
119 static int ixgbe_detach(dev_info_t
*, ddi_detach_cmd_t
);
120 static int ixgbe_resume(dev_info_t
*);
121 static int ixgbe_suspend(dev_info_t
*);
122 static int ixgbe_quiesce(dev_info_t
*);
123 static void ixgbe_unconfigure(dev_info_t
*, ixgbe_t
*);
124 static uint8_t *ixgbe_mc_table_itr(struct ixgbe_hw
*, uint8_t **, uint32_t *);
125 static int ixgbe_cbfunc(dev_info_t
*, ddi_cb_action_t
, void *, void *, void *);
126 static int ixgbe_intr_cb_register(ixgbe_t
*);
127 static int ixgbe_intr_adjust(ixgbe_t
*, ddi_cb_action_t
, int);
129 static int ixgbe_fm_error_cb(dev_info_t
*dip
, ddi_fm_error_t
*err
,
130 const void *impl_data
);
131 static void ixgbe_fm_init(ixgbe_t
*);
132 static void ixgbe_fm_fini(ixgbe_t
*);
134 char *ixgbe_priv_props
[] = {
136 "_tx_recycle_thresh",
137 "_tx_overload_thresh",
138 "_tx_resched_thresh",
140 "_rx_limit_per_intr",
143 "_adv_asym_pause_cap",
147 #define IXGBE_MAX_PRIV_PROPS \
148 (sizeof (ixgbe_priv_props) / sizeof (mac_priv_prop_t))
150 static struct cb_ops ixgbe_cb_ops
= {
151 nulldev
, /* cb_open */
152 nulldev
, /* cb_close */
153 nodev
, /* cb_strategy */
154 nodev
, /* cb_print */
157 nodev
, /* cb_write */
158 nodev
, /* cb_ioctl */
159 nodev
, /* cb_devmap */
161 nodev
, /* cb_segmap */
162 nochpoll
, /* cb_chpoll */
163 ddi_prop_op
, /* cb_prop_op */
164 NULL
, /* cb_stream */
165 D_MP
| D_HOTPLUG
, /* cb_flag */
167 nodev
, /* cb_aread */
168 nodev
/* cb_awrite */
171 static struct dev_ops ixgbe_dev_ops
= {
172 DEVO_REV
, /* devo_rev */
174 NULL
, /* devo_getinfo */
175 nulldev
, /* devo_identify */
176 nulldev
, /* devo_probe */
177 ixgbe_attach
, /* devo_attach */
178 ixgbe_detach
, /* devo_detach */
179 nodev
, /* devo_reset */
180 &ixgbe_cb_ops
, /* devo_cb_ops */
181 NULL
, /* devo_bus_ops */
182 ddi_power
, /* devo_power */
183 ixgbe_quiesce
, /* devo_quiesce */
186 static struct modldrv ixgbe_modldrv
= {
187 &mod_driverops
, /* Type of module. This one is a driver */
188 ixgbe_ident
, /* Discription string */
189 &ixgbe_dev_ops
/* driver ops */
192 static struct modlinkage ixgbe_modlinkage
= {
193 MODREV_1
, &ixgbe_modldrv
, NULL
197 * Access attributes for register mapping
199 ddi_device_acc_attr_t ixgbe_regs_acc_attr
= {
201 DDI_STRUCTURE_LE_ACC
,
209 static lb_property_t lb_normal
= {
210 normal
, "normal", IXGBE_LB_NONE
213 static lb_property_t lb_mac
= {
214 internal
, "MAC", IXGBE_LB_INTERNAL_MAC
217 static lb_property_t lb_external
= {
218 external
, "External", IXGBE_LB_EXTERNAL
221 #define IXGBE_M_CALLBACK_FLAGS \
222 (MC_IOCTL | MC_GETCAPAB | MC_SETPROP | MC_GETPROP | MC_PROPINFO)
224 static mac_callbacks_t ixgbe_m_callbacks
= {
225 IXGBE_M_CALLBACK_FLAGS
,
244 * Initialize capabilities of each supported adapter type
246 static adapter_info_t ixgbe_82598eb_cap
= {
247 64, /* maximum number of rx queues */
248 1, /* minimum number of rx queues */
249 64, /* default number of rx queues */
250 16, /* maximum number of rx groups */
251 1, /* minimum number of rx groups */
252 1, /* default number of rx groups */
253 32, /* maximum number of tx queues */
254 1, /* minimum number of tx queues */
255 8, /* default number of tx queues */
256 16366, /* maximum MTU size */
257 0xFFFF, /* maximum interrupt throttle rate */
258 0, /* minimum interrupt throttle rate */
259 200, /* default interrupt throttle rate */
260 18, /* maximum total msix vectors */
261 16, /* maximum number of ring vectors */
262 2, /* maximum number of other vectors */
263 IXGBE_EICR_LSC
, /* "other" interrupt types handled */
264 0, /* "other" interrupt types enable mask */
265 (IXGBE_FLAG_DCA_CAPABLE
/* capability flags */
266 | IXGBE_FLAG_RSS_CAPABLE
267 | IXGBE_FLAG_VMDQ_CAPABLE
)
270 static adapter_info_t ixgbe_82599eb_cap
= {
271 128, /* maximum number of rx queues */
272 1, /* minimum number of rx queues */
273 128, /* default number of rx queues */
274 64, /* maximum number of rx groups */
275 1, /* minimum number of rx groups */
276 1, /* default number of rx groups */
277 128, /* maximum number of tx queues */
278 1, /* minimum number of tx queues */
279 8, /* default number of tx queues */
280 15500, /* maximum MTU size */
281 0xFF8, /* maximum interrupt throttle rate */
282 0, /* minimum interrupt throttle rate */
283 200, /* default interrupt throttle rate */
284 64, /* maximum total msix vectors */
285 16, /* maximum number of ring vectors */
286 2, /* maximum number of other vectors */
288 | IXGBE_EICR_GPI_SDP1
289 | IXGBE_EICR_GPI_SDP2
), /* "other" interrupt types handled */
292 | IXGBE_SDP2_GPIEN
), /* "other" interrupt types enable mask */
294 (IXGBE_FLAG_DCA_CAPABLE
295 | IXGBE_FLAG_RSS_CAPABLE
296 | IXGBE_FLAG_VMDQ_CAPABLE
297 | IXGBE_FLAG_RSC_CAPABLE
298 | IXGBE_FLAG_SFP_PLUG_CAPABLE
) /* capability flags */
301 static adapter_info_t ixgbe_X540_cap
= {
302 128, /* maximum number of rx queues */
303 1, /* minimum number of rx queues */
304 128, /* default number of rx queues */
305 64, /* maximum number of rx groups */
306 1, /* minimum number of rx groups */
307 1, /* default number of rx groups */
308 128, /* maximum number of tx queues */
309 1, /* minimum number of tx queues */
310 8, /* default number of tx queues */
311 15500, /* maximum MTU size */
312 0xFF8, /* maximum interrupt throttle rate */
313 0, /* minimum interrupt throttle rate */
314 200, /* default interrupt throttle rate */
315 64, /* maximum total msix vectors */
316 16, /* maximum number of ring vectors */
317 2, /* maximum number of other vectors */
319 | IXGBE_EICR_GPI_SDP1_X540
320 | IXGBE_EICR_GPI_SDP2_X540
), /* "other" interrupt types handled */
322 (IXGBE_SDP1_GPIEN_X540
323 | IXGBE_SDP2_GPIEN_X540
), /* "other" interrupt types enable mask */
325 (IXGBE_FLAG_DCA_CAPABLE
326 | IXGBE_FLAG_RSS_CAPABLE
327 | IXGBE_FLAG_VMDQ_CAPABLE
328 | IXGBE_FLAG_RSC_CAPABLE
) /* capability flags */
331 static adapter_info_t ixgbe_X550_cap
= {
332 128, /* maximum number of rx queues */
333 1, /* minimum number of rx queues */
334 128, /* default number of rx queues */
335 64, /* maximum number of rx groups */
336 1, /* minimum number of rx groups */
337 1, /* default number of rx groups */
338 128, /* maximum number of tx queues */
339 1, /* minimum number of tx queues */
340 8, /* default number of tx queues */
341 15500, /* maximum MTU size */
342 0xFF8, /* maximum interrupt throttle rate */
343 0, /* minimum interrupt throttle rate */
344 0x200, /* default interrupt throttle rate */
345 64, /* maximum total msix vectors */
346 16, /* maximum number of ring vectors */
347 2, /* maximum number of other vectors */
348 IXGBE_EICR_LSC
, /* "other" interrupt types handled */
349 0, /* "other" interrupt types enable mask */
350 (IXGBE_FLAG_RSS_CAPABLE
351 | IXGBE_FLAG_VMDQ_CAPABLE
352 | IXGBE_FLAG_RSC_CAPABLE
) /* capability flags */
356 * Module Initialization Functions.
364 mac_init_ops(&ixgbe_dev_ops
, MODULE_NAME
);
366 status
= mod_install(&ixgbe_modlinkage
);
368 if (status
!= DDI_SUCCESS
) {
369 mac_fini_ops(&ixgbe_dev_ops
);
380 status
= mod_remove(&ixgbe_modlinkage
);
382 if (status
== DDI_SUCCESS
) {
383 mac_fini_ops(&ixgbe_dev_ops
);
390 _info(struct modinfo
*modinfop
)
394 status
= mod_info(&ixgbe_modlinkage
, modinfop
);
400 * ixgbe_attach - Driver attach.
402 * This function is the device specific initialization entry
403 * point. This entry point is required and must be written.
404 * The DDI_ATTACH command must be provided in the attach entry
405 * point. When attach() is called with cmd set to DDI_ATTACH,
406 * all normal kernel services (such as kmem_alloc(9F)) are
407 * available for use by the driver.
409 * The attach() function will be called once for each instance
410 * of the device on the system with cmd set to DDI_ATTACH.
411 * Until attach() succeeds, the only driver entry points which
412 * may be called are open(9E) and getinfo(9E).
415 ixgbe_attach(dev_info_t
*devinfo
, ddi_attach_cmd_t cmd
)
418 struct ixgbe_osdep
*osdep
;
424 * Check the command and perform corresponding operations
428 return (DDI_FAILURE
);
431 return (ixgbe_resume(devinfo
));
437 /* Get the device instance */
438 instance
= ddi_get_instance(devinfo
);
440 /* Allocate memory for the instance data structure */
441 ixgbe
= kmem_zalloc(sizeof (ixgbe_t
), KM_SLEEP
);
443 ixgbe
->dip
= devinfo
;
444 ixgbe
->instance
= instance
;
447 osdep
= &ixgbe
->osdep
;
449 osdep
->ixgbe
= ixgbe
;
451 /* Attach the instance pointer to the dev_info data structure */
452 ddi_set_driver_private(devinfo
, ixgbe
);
455 * Initialize for FMA support
457 ixgbe
->fm_capabilities
= ixgbe_get_prop(ixgbe
, PROP_FM_CAPABLE
,
458 0, 0x0f, DDI_FM_EREPORT_CAPABLE
| DDI_FM_ACCCHK_CAPABLE
|
459 DDI_FM_DMACHK_CAPABLE
| DDI_FM_ERRCB_CAPABLE
);
460 ixgbe_fm_init(ixgbe
);
461 ixgbe
->attach_progress
|= ATTACH_PROGRESS_FM_INIT
;
464 * Map PCI config space registers
466 if (pci_config_setup(devinfo
, &osdep
->cfg_handle
) != DDI_SUCCESS
) {
467 ixgbe_error(ixgbe
, "Failed to map PCI configurations");
470 ixgbe
->attach_progress
|= ATTACH_PROGRESS_PCI_CONFIG
;
473 * Identify the chipset family
475 if (ixgbe_identify_hardware(ixgbe
) != IXGBE_SUCCESS
) {
476 ixgbe_error(ixgbe
, "Failed to identify hardware");
481 * Map device registers
483 if (ixgbe_regs_map(ixgbe
) != IXGBE_SUCCESS
) {
484 ixgbe_error(ixgbe
, "Failed to map device registers");
487 ixgbe
->attach_progress
|= ATTACH_PROGRESS_REGS_MAP
;
490 * Initialize driver parameters
492 ixgbe_init_properties(ixgbe
);
493 ixgbe
->attach_progress
|= ATTACH_PROGRESS_PROPS
;
496 * Register interrupt callback
498 if (ixgbe_intr_cb_register(ixgbe
) != IXGBE_SUCCESS
) {
499 ixgbe_error(ixgbe
, "Failed to register interrupt callback");
504 * Allocate interrupts
506 if (ixgbe_alloc_intrs(ixgbe
) != IXGBE_SUCCESS
) {
507 ixgbe_error(ixgbe
, "Failed to allocate interrupts");
510 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ALLOC_INTR
;
513 * Allocate rx/tx rings based on the ring numbers.
514 * The actual numbers of rx/tx rings are decided by the number of
515 * allocated interrupt vectors, so we should allocate the rings after
516 * interrupts are allocated.
518 if (ixgbe_alloc_rings(ixgbe
) != IXGBE_SUCCESS
) {
519 ixgbe_error(ixgbe
, "Failed to allocate rx and tx rings");
522 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ALLOC_RINGS
;
525 * Map rings to interrupt vectors
527 if (ixgbe_map_intrs_to_vectors(ixgbe
) != IXGBE_SUCCESS
) {
528 ixgbe_error(ixgbe
, "Failed to map interrupts to vectors");
533 * Add interrupt handlers
535 if (ixgbe_add_intr_handlers(ixgbe
) != IXGBE_SUCCESS
) {
536 ixgbe_error(ixgbe
, "Failed to add interrupt handlers");
539 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ADD_INTR
;
542 * Create a taskq for sfp-change
544 (void) sprintf(taskqname
, "ixgbe%d_sfp_taskq", instance
);
545 if ((ixgbe
->sfp_taskq
= ddi_taskq_create(devinfo
, taskqname
,
546 1, TASKQ_DEFAULTPRI
, 0)) == NULL
) {
547 ixgbe_error(ixgbe
, "sfp_taskq create failed");
550 ixgbe
->attach_progress
|= ATTACH_PROGRESS_SFP_TASKQ
;
553 * Create a taskq for over-temp
555 (void) sprintf(taskqname
, "ixgbe%d_overtemp_taskq", instance
);
556 if ((ixgbe
->overtemp_taskq
= ddi_taskq_create(devinfo
, taskqname
,
557 1, TASKQ_DEFAULTPRI
, 0)) == NULL
) {
558 ixgbe_error(ixgbe
, "overtemp_taskq create failed");
561 ixgbe
->attach_progress
|= ATTACH_PROGRESS_OVERTEMP_TASKQ
;
564 * Create a taskq for processing external PHY interrupts
566 (void) sprintf(taskqname
, "ixgbe%d_phy_taskq", instance
);
567 if ((ixgbe
->phy_taskq
= ddi_taskq_create(devinfo
, taskqname
,
568 1, TASKQ_DEFAULTPRI
, 0)) == NULL
) {
569 ixgbe_error(ixgbe
, "phy_taskq create failed");
572 ixgbe
->attach_progress
|= ATTACH_PROGRESS_PHY_TASKQ
;
575 * Initialize driver parameters
577 if (ixgbe_init_driver_settings(ixgbe
) != IXGBE_SUCCESS
) {
578 ixgbe_error(ixgbe
, "Failed to initialize driver settings");
583 * Initialize mutexes for this device.
584 * Do this before enabling the interrupt handler and
585 * register the softint to avoid the condition where
586 * interrupt handler can try using uninitialized mutex.
588 ixgbe_init_locks(ixgbe
);
589 ixgbe
->attach_progress
|= ATTACH_PROGRESS_LOCKS
;
592 * Initialize chipset hardware
594 if (ixgbe_init(ixgbe
) != IXGBE_SUCCESS
) {
595 ixgbe_error(ixgbe
, "Failed to initialize adapter");
598 ixgbe
->link_check_complete
= B_FALSE
;
599 ixgbe
->link_check_hrtime
= gethrtime() +
600 (IXGBE_LINK_UP_TIME
* 100000000ULL);
601 ixgbe
->attach_progress
|= ATTACH_PROGRESS_INIT
;
603 if (ixgbe_check_acc_handle(ixgbe
->osdep
.cfg_handle
) != DDI_FM_OK
) {
604 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
609 * Initialize adapter capabilities
611 ixgbe_init_params(ixgbe
);
614 * Initialize statistics
616 if (ixgbe_init_stats(ixgbe
) != IXGBE_SUCCESS
) {
617 ixgbe_error(ixgbe
, "Failed to initialize statistics");
620 ixgbe
->attach_progress
|= ATTACH_PROGRESS_STATS
;
623 * Register the driver to the MAC
625 if (ixgbe_register_mac(ixgbe
) != IXGBE_SUCCESS
) {
626 ixgbe_error(ixgbe
, "Failed to register MAC");
629 mac_link_update(ixgbe
->mac_hdl
, LINK_STATE_UNKNOWN
);
630 ixgbe
->attach_progress
|= ATTACH_PROGRESS_MAC
;
632 ixgbe
->periodic_id
= ddi_periodic_add(ixgbe_link_timer
, ixgbe
,
633 IXGBE_CYCLIC_PERIOD
, DDI_IPL_0
);
634 if (ixgbe
->periodic_id
== 0) {
635 ixgbe_error(ixgbe
, "Failed to add the link check timer");
638 ixgbe
->attach_progress
|= ATTACH_PROGRESS_LINK_TIMER
;
641 * Now that mutex locks are initialized, and the chip is also
642 * initialized, enable interrupts.
644 if (ixgbe_enable_intrs(ixgbe
) != IXGBE_SUCCESS
) {
645 ixgbe_error(ixgbe
, "Failed to enable DDI interrupts");
648 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ENABLE_INTR
;
650 ixgbe_log(ixgbe
, "%s", ixgbe_ident
);
651 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_INITIALIZED
);
653 return (DDI_SUCCESS
);
656 ixgbe_unconfigure(devinfo
, ixgbe
);
657 return (DDI_FAILURE
);
661 * ixgbe_detach - Driver detach.
663 * The detach() function is the complement of the attach routine.
664 * If cmd is set to DDI_DETACH, detach() is used to remove the
665 * state associated with a given instance of a device node
666 * prior to the removal of that instance from the system.
668 * The detach() function will be called once for each instance
669 * of the device for which there has been a successful attach()
670 * once there are no longer any opens on the device.
672 * Interrupts routine are disabled, All memory allocated by this
676 ixgbe_detach(dev_info_t
*devinfo
, ddi_detach_cmd_t cmd
)
681 * Check detach command
685 return (DDI_FAILURE
);
688 return (ixgbe_suspend(devinfo
));
695 * Get the pointer to the driver private data structure
697 ixgbe
= (ixgbe_t
*)ddi_get_driver_private(devinfo
);
699 return (DDI_FAILURE
);
702 * If the device is still running, it needs to be stopped first.
703 * This check is necessary because under some specific circumstances,
704 * the detach routine can be called without stopping the interface
707 if (ixgbe
->ixgbe_state
& IXGBE_STARTED
) {
708 atomic_and_32(&ixgbe
->ixgbe_state
, ~IXGBE_STARTED
);
709 mutex_enter(&ixgbe
->gen_lock
);
710 ixgbe_stop(ixgbe
, B_TRUE
);
711 mutex_exit(&ixgbe
->gen_lock
);
712 /* Disable and stop the watchdog timer */
713 ixgbe_disable_watchdog_timer(ixgbe
);
717 * Check if there are still rx buffers held by the upper layer.
718 * If so, fail the detach.
720 if (!ixgbe_rx_drain(ixgbe
))
721 return (DDI_FAILURE
);
724 * Do the remaining unconfigure routines
726 ixgbe_unconfigure(devinfo
, ixgbe
);
728 return (DDI_SUCCESS
);
732 * quiesce(9E) entry point.
734 * This function is called when the system is single-threaded at high
735 * PIL with preemption disabled. Therefore, this function must not be
738 * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
739 * DDI_FAILURE indicates an error condition and should almost never happen.
742 ixgbe_quiesce(dev_info_t
*devinfo
)
747 ixgbe
= (ixgbe_t
*)ddi_get_driver_private(devinfo
);
750 return (DDI_FAILURE
);
755 * Disable the adapter interrupts
757 ixgbe_disable_adapter_interrupts(ixgbe
);
760 * Tell firmware driver is no longer in control
762 ixgbe_release_driver_control(hw
);
767 (void) ixgbe_reset_hw(hw
);
772 (void) ixgbe_reset_phy(hw
);
774 return (DDI_SUCCESS
);
778 ixgbe_unconfigure(dev_info_t
*devinfo
, ixgbe_t
*ixgbe
)
783 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_ENABLE_INTR
) {
784 (void) ixgbe_disable_intrs(ixgbe
);
788 * remove the link check timer
790 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_LINK_TIMER
) {
791 if (ixgbe
->periodic_id
!= NULL
) {
792 ddi_periodic_delete(ixgbe
->periodic_id
);
793 ixgbe
->periodic_id
= NULL
;
800 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_MAC
) {
801 (void) mac_unregister(ixgbe
->mac_hdl
);
807 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_STATS
) {
808 kstat_delete((kstat_t
*)ixgbe
->ixgbe_ks
);
812 * Remove interrupt handlers
814 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_ADD_INTR
) {
815 ixgbe_rem_intr_handlers(ixgbe
);
819 * Remove taskq for sfp-status-change
821 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_SFP_TASKQ
) {
822 ddi_taskq_destroy(ixgbe
->sfp_taskq
);
826 * Remove taskq for over-temp
828 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_OVERTEMP_TASKQ
) {
829 ddi_taskq_destroy(ixgbe
->overtemp_taskq
);
833 * Remove taskq for external PHYs
835 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_PHY_TASKQ
) {
836 ddi_taskq_destroy(ixgbe
->phy_taskq
);
842 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_ALLOC_INTR
) {
843 ixgbe_rem_intrs(ixgbe
);
847 * Unregister interrupt callback handler
849 (void) ddi_cb_unregister(ixgbe
->cb_hdl
);
852 * Remove driver properties
854 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_PROPS
) {
855 (void) ddi_prop_remove_all(devinfo
);
861 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_INIT
) {
862 mutex_enter(&ixgbe
->gen_lock
);
863 ixgbe_chip_stop(ixgbe
);
864 mutex_exit(&ixgbe
->gen_lock
);
868 * Free register handle
870 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_REGS_MAP
) {
871 if (ixgbe
->osdep
.reg_handle
!= NULL
)
872 ddi_regs_map_free(&ixgbe
->osdep
.reg_handle
);
876 * Free PCI config handle
878 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_PCI_CONFIG
) {
879 if (ixgbe
->osdep
.cfg_handle
!= NULL
)
880 pci_config_teardown(&ixgbe
->osdep
.cfg_handle
);
886 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_LOCKS
) {
887 ixgbe_destroy_locks(ixgbe
);
891 * Free the rx/tx rings
893 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_ALLOC_RINGS
) {
894 ixgbe_free_rings(ixgbe
);
898 * Unregister FMA capabilities
900 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_FM_INIT
) {
901 ixgbe_fm_fini(ixgbe
);
905 * Free the driver data structure
907 kmem_free(ixgbe
, sizeof (ixgbe_t
));
909 ddi_set_driver_private(devinfo
, NULL
);
913 * ixgbe_register_mac - Register the driver and its function pointers with
917 ixgbe_register_mac(ixgbe_t
*ixgbe
)
919 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
923 if ((mac
= mac_alloc(MAC_VERSION
)) == NULL
)
924 return (IXGBE_FAILURE
);
926 mac
->m_type_ident
= MAC_PLUGIN_IDENT_ETHER
;
927 mac
->m_driver
= ixgbe
;
928 mac
->m_dip
= ixgbe
->dip
;
929 mac
->m_src_addr
= hw
->mac
.addr
;
930 mac
->m_callbacks
= &ixgbe_m_callbacks
;
932 mac
->m_max_sdu
= ixgbe
->default_mtu
;
933 mac
->m_margin
= VLAN_TAGSZ
;
934 mac
->m_priv_props
= ixgbe_priv_props
;
935 mac
->m_v12n
= MAC_VIRT_LEVEL1
;
937 status
= mac_register(mac
, &ixgbe
->mac_hdl
);
941 return ((status
== 0) ? IXGBE_SUCCESS
: IXGBE_FAILURE
);
945 * ixgbe_identify_hardware - Identify the type of the chipset.
948 ixgbe_identify_hardware(ixgbe_t
*ixgbe
)
950 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
951 struct ixgbe_osdep
*osdep
= &ixgbe
->osdep
;
957 pci_config_get16(osdep
->cfg_handle
, PCI_CONF_VENID
);
959 pci_config_get16(osdep
->cfg_handle
, PCI_CONF_DEVID
);
961 pci_config_get8(osdep
->cfg_handle
, PCI_CONF_REVID
);
962 hw
->subsystem_device_id
=
963 pci_config_get16(osdep
->cfg_handle
, PCI_CONF_SUBSYSID
);
964 hw
->subsystem_vendor_id
=
965 pci_config_get16(osdep
->cfg_handle
, PCI_CONF_SUBVENID
);
968 * Set the mac type of the adapter based on the device id
970 if (ixgbe_set_mac_type(hw
) != IXGBE_SUCCESS
) {
971 return (IXGBE_FAILURE
);
975 * Install adapter capabilities
977 switch (hw
->mac
.type
) {
978 case ixgbe_mac_82598EB
:
979 IXGBE_DEBUGLOG_0(ixgbe
, "identify 82598 adapter\n");
980 ixgbe
->capab
= &ixgbe_82598eb_cap
;
982 if (ixgbe_get_media_type(hw
) == ixgbe_media_type_copper
) {
983 ixgbe
->capab
->flags
|= IXGBE_FLAG_FAN_FAIL_CAPABLE
;
984 ixgbe
->capab
->other_intr
|= IXGBE_EICR_GPI_SDP1
;
985 ixgbe
->capab
->other_gpie
|= IXGBE_SDP1_GPIEN
;
989 case ixgbe_mac_82599EB
:
990 IXGBE_DEBUGLOG_0(ixgbe
, "identify 82599 adapter\n");
991 ixgbe
->capab
= &ixgbe_82599eb_cap
;
993 if (hw
->device_id
== IXGBE_DEV_ID_82599_T3_LOM
) {
994 ixgbe
->capab
->flags
|= IXGBE_FLAG_TEMP_SENSOR_CAPABLE
;
995 ixgbe
->capab
->other_intr
|= IXGBE_EICR_GPI_SDP0
;
996 ixgbe
->capab
->other_gpie
|= IXGBE_SDP0_GPIEN
;
1000 case ixgbe_mac_X540
:
1001 IXGBE_DEBUGLOG_0(ixgbe
, "identify X540 adapter\n");
1002 ixgbe
->capab
= &ixgbe_X540_cap
;
1004 * For now, X540 is all set in its capab structure.
1005 * As other X540 variants show up, things can change here.
1009 case ixgbe_mac_X550
:
1010 case ixgbe_mac_X550EM_x
:
1011 IXGBE_DEBUGLOG_0(ixgbe
, "identify X550 adapter\n");
1012 ixgbe
->capab
= &ixgbe_X550_cap
;
1014 if (hw
->device_id
== IXGBE_DEV_ID_X550EM_X_SFP
)
1015 ixgbe
->capab
->flags
|= IXGBE_FLAG_SFP_PLUG_CAPABLE
;
1018 * Link detection on X552 SFP+ and X552/X557-AT
1020 if (hw
->device_id
== IXGBE_DEV_ID_X550EM_X_SFP
||
1021 hw
->device_id
== IXGBE_DEV_ID_X550EM_X_10G_T
) {
1022 ixgbe
->capab
->other_intr
|=
1023 IXGBE_EIMS_GPI_SDP0_BY_MAC(hw
);
1024 ixgbe
->capab
->other_gpie
|= IXGBE_SDP0_GPIEN_X540
;
1029 IXGBE_DEBUGLOG_1(ixgbe
,
1030 "adapter not supported in ixgbe_identify_hardware(): %d\n",
1032 return (IXGBE_FAILURE
);
1035 return (IXGBE_SUCCESS
);
1039 * ixgbe_regs_map - Map the device registers.
1043 ixgbe_regs_map(ixgbe_t
*ixgbe
)
1045 dev_info_t
*devinfo
= ixgbe
->dip
;
1046 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
1047 struct ixgbe_osdep
*osdep
= &ixgbe
->osdep
;
1051 * First get the size of device registers to be mapped.
1053 if (ddi_dev_regsize(devinfo
, IXGBE_ADAPTER_REGSET
, &mem_size
)
1055 return (IXGBE_FAILURE
);
1059 * Call ddi_regs_map_setup() to map registers
1061 if ((ddi_regs_map_setup(devinfo
, IXGBE_ADAPTER_REGSET
,
1062 (caddr_t
*)&hw
->hw_addr
, 0,
1063 mem_size
, &ixgbe_regs_acc_attr
,
1064 &osdep
->reg_handle
)) != DDI_SUCCESS
) {
1065 return (IXGBE_FAILURE
);
1068 return (IXGBE_SUCCESS
);
1072 * ixgbe_init_properties - Initialize driver properties.
1075 ixgbe_init_properties(ixgbe_t
*ixgbe
)
1078 * Get conf file properties, including link settings
1079 * jumbo frames, ring number, descriptor number, etc.
1081 ixgbe_get_conf(ixgbe
);
1085 * ixgbe_init_driver_settings - Initialize driver settings.
1087 * The settings include hardware function pointers, bus information,
1088 * rx/tx rings settings, link state, and any other parameters that
1089 * need to be setup during driver initialization.
1092 ixgbe_init_driver_settings(ixgbe_t
*ixgbe
)
1094 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
1095 dev_info_t
*devinfo
= ixgbe
->dip
;
1096 ixgbe_rx_ring_t
*rx_ring
;
1097 ixgbe_rx_group_t
*rx_group
;
1098 ixgbe_tx_ring_t
*tx_ring
;
1101 uint32_t ring_per_group
;
1105 * Initialize chipset specific hardware function pointers
1107 if (ixgbe_init_shared_code(hw
) != IXGBE_SUCCESS
) {
1108 return (IXGBE_FAILURE
);
1112 * Get the system page size
1114 ixgbe
->sys_page_size
= ddi_ptob(devinfo
, (ulong_t
)1);
1117 * Set rx buffer size
1119 * The IP header alignment room is counted in the calculation.
1120 * The rx buffer size is in unit of 1K that is required by the
1123 rx_size
= ixgbe
->max_frame_size
+ IPHDR_ALIGN_ROOM
;
1124 ixgbe
->rx_buf_size
= ((rx_size
>> 10) +
1125 ((rx_size
& (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
1128 * Set tx buffer size
1130 tx_size
= ixgbe
->max_frame_size
;
1131 ixgbe
->tx_buf_size
= ((tx_size
>> 10) +
1132 ((tx_size
& (((uint32_t)1 << 10) - 1)) > 0 ? 1 : 0)) << 10;
1135 * Initialize rx/tx rings/groups parameters
1137 ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
1138 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
1139 rx_ring
= &ixgbe
->rx_rings
[i
];
1141 rx_ring
->ixgbe
= ixgbe
;
1142 rx_ring
->group_index
= i
/ ring_per_group
;
1143 rx_ring
->hw_index
= ixgbe_get_hw_rx_index(ixgbe
, i
);
1146 for (i
= 0; i
< ixgbe
->num_rx_groups
; i
++) {
1147 rx_group
= &ixgbe
->rx_groups
[i
];
1148 rx_group
->index
= i
;
1149 rx_group
->ixgbe
= ixgbe
;
1152 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
1153 tx_ring
= &ixgbe
->tx_rings
[i
];
1155 tx_ring
->ixgbe
= ixgbe
;
1156 if (ixgbe
->tx_head_wb_enable
)
1157 tx_ring
->tx_recycle
= ixgbe_tx_recycle_head_wb
;
1159 tx_ring
->tx_recycle
= ixgbe_tx_recycle_legacy
;
1161 tx_ring
->ring_size
= ixgbe
->tx_ring_size
;
1162 tx_ring
->free_list_size
= ixgbe
->tx_ring_size
+
1163 (ixgbe
->tx_ring_size
>> 1);
1167 * Initialize values of interrupt throttling rate
1169 for (i
= 1; i
< MAX_INTR_VECTOR
; i
++)
1170 ixgbe
->intr_throttling
[i
] = ixgbe
->intr_throttling
[0];
1173 * The initial link state should be "unknown"
1175 ixgbe
->link_state
= LINK_STATE_UNKNOWN
;
1177 return (IXGBE_SUCCESS
);
1181 * ixgbe_init_locks - Initialize locks.
1184 ixgbe_init_locks(ixgbe_t
*ixgbe
)
1186 ixgbe_rx_ring_t
*rx_ring
;
1187 ixgbe_tx_ring_t
*tx_ring
;
1190 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
1191 rx_ring
= &ixgbe
->rx_rings
[i
];
1192 mutex_init(&rx_ring
->rx_lock
, NULL
,
1193 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1196 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
1197 tx_ring
= &ixgbe
->tx_rings
[i
];
1198 mutex_init(&tx_ring
->tx_lock
, NULL
,
1199 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1200 mutex_init(&tx_ring
->recycle_lock
, NULL
,
1201 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1202 mutex_init(&tx_ring
->tcb_head_lock
, NULL
,
1203 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1204 mutex_init(&tx_ring
->tcb_tail_lock
, NULL
,
1205 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1208 mutex_init(&ixgbe
->gen_lock
, NULL
,
1209 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1211 mutex_init(&ixgbe
->watchdog_lock
, NULL
,
1212 MUTEX_DRIVER
, DDI_INTR_PRI(ixgbe
->intr_pri
));
1216 * ixgbe_destroy_locks - Destroy locks.
1219 ixgbe_destroy_locks(ixgbe_t
*ixgbe
)
1221 ixgbe_rx_ring_t
*rx_ring
;
1222 ixgbe_tx_ring_t
*tx_ring
;
1225 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
1226 rx_ring
= &ixgbe
->rx_rings
[i
];
1227 mutex_destroy(&rx_ring
->rx_lock
);
1230 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
1231 tx_ring
= &ixgbe
->tx_rings
[i
];
1232 mutex_destroy(&tx_ring
->tx_lock
);
1233 mutex_destroy(&tx_ring
->recycle_lock
);
1234 mutex_destroy(&tx_ring
->tcb_head_lock
);
1235 mutex_destroy(&tx_ring
->tcb_tail_lock
);
1238 mutex_destroy(&ixgbe
->gen_lock
);
1239 mutex_destroy(&ixgbe
->watchdog_lock
);
1243 ixgbe_resume(dev_info_t
*devinfo
)
1248 ixgbe
= (ixgbe_t
*)ddi_get_driver_private(devinfo
);
1250 return (DDI_FAILURE
);
1252 mutex_enter(&ixgbe
->gen_lock
);
1254 if (ixgbe
->ixgbe_state
& IXGBE_STARTED
) {
1255 if (ixgbe_start(ixgbe
, B_FALSE
) != IXGBE_SUCCESS
) {
1256 mutex_exit(&ixgbe
->gen_lock
);
1257 return (DDI_FAILURE
);
1261 * Enable and start the watchdog timer
1263 ixgbe_enable_watchdog_timer(ixgbe
);
1266 atomic_and_32(&ixgbe
->ixgbe_state
, ~IXGBE_SUSPENDED
);
1268 if (ixgbe
->ixgbe_state
& IXGBE_STARTED
) {
1269 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
1270 mac_tx_ring_update(ixgbe
->mac_hdl
,
1271 ixgbe
->tx_rings
[i
].ring_handle
);
1275 mutex_exit(&ixgbe
->gen_lock
);
1277 return (DDI_SUCCESS
);
1281 ixgbe_suspend(dev_info_t
*devinfo
)
1285 ixgbe
= (ixgbe_t
*)ddi_get_driver_private(devinfo
);
1287 return (DDI_FAILURE
);
1289 mutex_enter(&ixgbe
->gen_lock
);
1291 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_SUSPENDED
);
1292 if (!(ixgbe
->ixgbe_state
& IXGBE_STARTED
)) {
1293 mutex_exit(&ixgbe
->gen_lock
);
1294 return (DDI_SUCCESS
);
1296 ixgbe_stop(ixgbe
, B_FALSE
);
1298 mutex_exit(&ixgbe
->gen_lock
);
1301 * Disable and stop the watchdog timer
1303 ixgbe_disable_watchdog_timer(ixgbe
);
1305 return (DDI_SUCCESS
);
1309 * ixgbe_init - Initialize the device.
1312 ixgbe_init(ixgbe_t
*ixgbe
)
1314 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
1315 u8 pbanum
[IXGBE_PBANUM_LENGTH
];
1318 mutex_enter(&ixgbe
->gen_lock
);
1321 * Configure/Initialize hardware
1323 rv
= ixgbe_init_hw(hw
);
1324 if (rv
!= IXGBE_SUCCESS
) {
1328 * The first three errors are not prohibitive to us progressing
1329 * further, and are maily advisory in nature. In the case of a
1330 * SFP module not being present or not deemed supported by the
1331 * common code, we adivse the operator of this fact but carry on
1332 * instead of failing hard, as SFPs can be inserted or replaced
1333 * while the driver is running. In the case of a unknown error,
1334 * we fail-hard, logging the reason and emitting a FMA event.
1336 case IXGBE_ERR_EEPROM_VERSION
:
1338 "This Intel 10Gb Ethernet device is pre-release and"
1339 " contains outdated firmware. Please contact your"
1340 " hardware vendor for a replacement.");
1342 case IXGBE_ERR_SFP_NOT_PRESENT
:
1344 "No SFP+ module detected on this interface. Please "
1345 "install a supported SFP+ module for this "
1346 "interface to become operational.");
1348 case IXGBE_ERR_SFP_NOT_SUPPORTED
:
1350 "Unsupported SFP+ module detected. Please replace "
1351 "it with a supported SFP+ module per Intel "
1352 "documentation, or bypass this check with "
1353 "allow_unsupported_sfp=1 in ixgbe.conf.");
1357 "Failed to initialize hardware. ixgbe_init_hw "
1359 ixgbe_fm_ereport(ixgbe
, DDI_FM_DEVICE_INVAL_STATE
);
1365 * Need to init eeprom before validating the checksum.
1367 if (ixgbe_init_eeprom_params(hw
) < 0) {
1369 "Unable to intitialize the eeprom interface.");
1370 ixgbe_fm_ereport(ixgbe
, DDI_FM_DEVICE_INVAL_STATE
);
1377 if (ixgbe_validate_eeprom_checksum(hw
, NULL
) < 0) {
1379 * Some PCI-E parts fail the first check due to
1380 * the link being in sleep state. Call it again,
1381 * if it fails a second time it's a real issue.
1383 if (ixgbe_validate_eeprom_checksum(hw
, NULL
) < 0) {
1385 "Invalid NVM checksum. Please contact "
1386 "the vendor to update the NVM.");
1387 ixgbe_fm_ereport(ixgbe
, DDI_FM_DEVICE_INVAL_STATE
);
1393 * Setup default flow control thresholds - enable/disable
1394 * & flow control type is controlled by ixgbe.conf
1396 hw
->fc
.high_water
[0] = DEFAULT_FCRTH
;
1397 hw
->fc
.low_water
[0] = DEFAULT_FCRTL
;
1398 hw
->fc
.pause_time
= DEFAULT_FCPAUSE
;
1399 hw
->fc
.send_xon
= B_TRUE
;
1402 * Initialize flow control
1404 (void) ixgbe_start_hw(hw
);
1407 * Initialize link settings
1409 (void) ixgbe_driver_setup_link(ixgbe
, B_FALSE
);
1412 * Initialize the chipset hardware
1414 if (ixgbe_chip_start(ixgbe
) != IXGBE_SUCCESS
) {
1415 ixgbe_fm_ereport(ixgbe
, DDI_FM_DEVICE_INVAL_STATE
);
1420 * Read identifying information and place in devinfo.
1423 (void) ixgbe_read_pba_string(hw
, pbanum
, sizeof (pbanum
));
1424 if (*pbanum
!= '\0') {
1425 (void) ddi_prop_update_string(DDI_DEV_T_NONE
, ixgbe
->dip
,
1426 "printed-board-assembly", (char *)pbanum
);
1429 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
1433 mutex_exit(&ixgbe
->gen_lock
);
1434 return (IXGBE_SUCCESS
);
1440 (void) ixgbe_reset_phy(hw
);
1442 mutex_exit(&ixgbe
->gen_lock
);
1443 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
1444 return (IXGBE_FAILURE
);
1448 * ixgbe_chip_start - Initialize and start the chipset hardware.
1451 ixgbe_chip_start(ixgbe_t
*ixgbe
)
1453 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
1456 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
1459 * Get the mac address
1460 * This function should handle SPARC case correctly.
1462 if (!ixgbe_find_mac_address(ixgbe
)) {
1463 ixgbe_error(ixgbe
, "Failed to get the mac address");
1464 return (IXGBE_FAILURE
);
1468 * Validate the mac address
1470 (void) ixgbe_init_rx_addrs(hw
);
1471 if (!is_valid_mac_addr(hw
->mac
.addr
)) {
1472 ixgbe_error(ixgbe
, "Invalid mac address");
1473 return (IXGBE_FAILURE
);
1477 * Re-enable relaxed ordering for performance. It is disabled
1478 * by default in the hardware init.
1480 if (ixgbe
->relax_order_enable
== B_TRUE
)
1481 ixgbe_enable_relaxed_ordering(hw
);
1484 * Setup adapter interrupt vectors
1486 ixgbe_setup_adapter_vector(ixgbe
);
1489 * Initialize unicast addresses.
1491 ixgbe_init_unicst(ixgbe
);
1494 * Setup and initialize the mctable structures.
1496 ixgbe_setup_multicst(ixgbe
);
1499 * Set interrupt throttling rate
1501 for (i
= 0; i
< ixgbe
->intr_cnt
; i
++) {
1502 IXGBE_WRITE_REG(hw
, IXGBE_EITR(i
), ixgbe
->intr_throttling
[i
]);
1506 * Disable Wake-on-LAN
1508 IXGBE_WRITE_REG(hw
, IXGBE_WUC
, 0);
1511 * Some adapters offer Energy Efficient Ethernet (EEE) support.
1512 * Due to issues with EEE in e1000g/igb, we disable this by default
1513 * as a precautionary measure.
1515 * Currently, the only known adapter which supports EEE in the ixgbe
1516 * line is 8086,15AB (IXGBE_DEV_ID_X550EM_X_KR), and only after the
1517 * first revision of it, as well as any X550 with MAC type 6 (non-EM)
1519 (void) ixgbe_setup_eee(hw
, B_FALSE
);
1522 * Turn on any present SFP Tx laser
1524 ixgbe_enable_tx_laser(hw
);
1529 (void) ixgbe_set_phy_power(hw
, B_TRUE
);
1532 * Save the state of the PHY
1534 ixgbe_get_hw_state(ixgbe
);
1537 * Make sure driver has control
1539 ixgbe_get_driver_control(hw
);
1541 return (IXGBE_SUCCESS
);
1545 * ixgbe_chip_stop - Stop the chipset hardware
1548 ixgbe_chip_stop(ixgbe_t
*ixgbe
)
1550 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
1553 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
1556 * Stop interupt generation and disable Tx unit
1558 hw
->adapter_stopped
= B_FALSE
;
1559 (void) ixgbe_stop_adapter(hw
);
1564 (void) ixgbe_reset_hw(hw
);
1569 (void) ixgbe_reset_phy(hw
);
1572 * Enter LPLU (Low Power, Link Up) mode, if available. Avoid resetting
1573 * the PHY while doing so. Else, just power down the PHY.
1575 if (hw
->phy
.ops
.enter_lplu
!= NULL
) {
1576 hw
->phy
.reset_disable
= B_TRUE
;
1577 rv
= hw
->phy
.ops
.enter_lplu(hw
);
1578 if (rv
!= IXGBE_SUCCESS
)
1579 ixgbe_error(ixgbe
, "Error while entering LPLU: %d", rv
);
1580 hw
->phy
.reset_disable
= B_FALSE
;
1582 (void) ixgbe_set_phy_power(hw
, B_FALSE
);
1586 * Turn off any present SFP Tx laser
1587 * Expected for health and safety reasons
1589 ixgbe_disable_tx_laser(hw
);
1592 * Tell firmware driver is no longer in control
1594 ixgbe_release_driver_control(hw
);
1599 * ixgbe_reset - Reset the chipset and re-start the driver.
1601 * It involves stopping and re-starting the chipset,
1602 * and re-configuring the rx/tx rings.
1605 ixgbe_reset(ixgbe_t
*ixgbe
)
1610 * Disable and stop the watchdog timer
1612 ixgbe_disable_watchdog_timer(ixgbe
);
1614 mutex_enter(&ixgbe
->gen_lock
);
1616 ASSERT(ixgbe
->ixgbe_state
& IXGBE_STARTED
);
1617 atomic_and_32(&ixgbe
->ixgbe_state
, ~IXGBE_STARTED
);
1619 ixgbe_stop(ixgbe
, B_FALSE
);
1621 if (ixgbe_start(ixgbe
, B_FALSE
) != IXGBE_SUCCESS
) {
1622 mutex_exit(&ixgbe
->gen_lock
);
1623 return (IXGBE_FAILURE
);
1627 * After resetting, need to recheck the link status.
1629 ixgbe
->link_check_complete
= B_FALSE
;
1630 ixgbe
->link_check_hrtime
= gethrtime() +
1631 (IXGBE_LINK_UP_TIME
* 100000000ULL);
1633 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_STARTED
);
1635 if (!(ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
)) {
1636 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
1637 mac_tx_ring_update(ixgbe
->mac_hdl
,
1638 ixgbe
->tx_rings
[i
].ring_handle
);
1642 mutex_exit(&ixgbe
->gen_lock
);
1645 * Enable and start the watchdog timer
1647 ixgbe_enable_watchdog_timer(ixgbe
);
1649 return (IXGBE_SUCCESS
);
1653 * ixgbe_tx_clean - Clean the pending transmit packets and DMA resources.
1656 ixgbe_tx_clean(ixgbe_t
*ixgbe
)
1658 ixgbe_tx_ring_t
*tx_ring
;
1659 tx_control_block_t
*tcb
;
1660 link_list_t pending_list
;
1664 LINK_LIST_INIT(&pending_list
);
1666 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
1667 tx_ring
= &ixgbe
->tx_rings
[i
];
1669 mutex_enter(&tx_ring
->recycle_lock
);
1672 * Clean the pending tx data - the pending packets in the
1673 * work_list that have no chances to be transmitted again.
1675 * We must ensure the chipset is stopped or the link is down
1676 * before cleaning the transmit packets.
1679 for (j
= 0; j
< tx_ring
->ring_size
; j
++) {
1680 tcb
= tx_ring
->work_list
[j
];
1682 desc_num
+= tcb
->desc_num
;
1684 tx_ring
->work_list
[j
] = NULL
;
1686 ixgbe_free_tcb(tcb
);
1688 LIST_PUSH_TAIL(&pending_list
, &tcb
->link
);
1693 atomic_add_32(&tx_ring
->tbd_free
, desc_num
);
1694 ASSERT(tx_ring
->tbd_free
== tx_ring
->ring_size
);
1697 * Reset the head and tail pointers of the tbd ring;
1698 * Reset the writeback head if it's enable.
1700 tx_ring
->tbd_head
= 0;
1701 tx_ring
->tbd_tail
= 0;
1702 if (ixgbe
->tx_head_wb_enable
)
1703 *tx_ring
->tbd_head_wb
= 0;
1705 IXGBE_WRITE_REG(&ixgbe
->hw
,
1706 IXGBE_TDH(tx_ring
->index
), 0);
1707 IXGBE_WRITE_REG(&ixgbe
->hw
,
1708 IXGBE_TDT(tx_ring
->index
), 0);
1711 mutex_exit(&tx_ring
->recycle_lock
);
1714 * Add the tx control blocks in the pending list to
1717 ixgbe_put_free_list(tx_ring
, &pending_list
);
1722 * ixgbe_tx_drain - Drain the tx rings to allow pending packets to be
1726 ixgbe_tx_drain(ixgbe_t
*ixgbe
)
1728 ixgbe_tx_ring_t
*tx_ring
;
1733 * Wait for a specific time to allow pending tx packets
1734 * to be transmitted.
1736 * Check the counter tbd_free to see if transmission is done.
1737 * No lock protection is needed here.
1739 * Return B_TRUE if all pending packets have been transmitted;
1740 * Otherwise return B_FALSE;
1742 for (i
= 0; i
< TX_DRAIN_TIME
; i
++) {
1745 for (j
= 0; j
< ixgbe
->num_tx_rings
; j
++) {
1746 tx_ring
= &ixgbe
->tx_rings
[j
];
1748 (tx_ring
->tbd_free
== tx_ring
->ring_size
);
1761 * ixgbe_rx_drain - Wait for all rx buffers to be released by upper layer.
1764 ixgbe_rx_drain(ixgbe_t
*ixgbe
)
1770 * Polling the rx free list to check if those rx buffers held by
1771 * the upper layer are released.
1773 * Check the counter rcb_free to see if all pending buffers are
1774 * released. No lock protection is needed here.
1776 * Return B_TRUE if all pending buffers have been released;
1777 * Otherwise return B_FALSE;
1779 for (i
= 0; i
< RX_DRAIN_TIME
; i
++) {
1780 done
= (ixgbe
->rcb_pending
== 0);
1792 * ixgbe_start - Start the driver/chipset.
1795 ixgbe_start(ixgbe_t
*ixgbe
, bool alloc_buffer
)
1797 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
1800 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
1803 if (ixgbe_alloc_rx_data(ixgbe
) != IXGBE_SUCCESS
) {
1805 "Failed to allocate software receive rings");
1806 return (IXGBE_FAILURE
);
1809 /* Allocate buffers for all the rx/tx rings */
1810 if (ixgbe_alloc_dma(ixgbe
) != IXGBE_SUCCESS
) {
1811 ixgbe_error(ixgbe
, "Failed to allocate DMA resource");
1812 return (IXGBE_FAILURE
);
1815 ixgbe
->tx_ring_init
= B_TRUE
;
1817 ixgbe
->tx_ring_init
= B_FALSE
;
1820 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++)
1821 mutex_enter(&ixgbe
->rx_rings
[i
].rx_lock
);
1822 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++)
1823 mutex_enter(&ixgbe
->tx_rings
[i
].tx_lock
);
1826 * Start the chipset hardware
1828 if (ixgbe_chip_start(ixgbe
) != IXGBE_SUCCESS
) {
1829 ixgbe_fm_ereport(ixgbe
, DDI_FM_DEVICE_INVAL_STATE
);
1834 * Configure link now for X550
1836 * X550 possesses a LPLU (Low-Power Link Up) mode which keeps the
1837 * resting state of the adapter at a 1Gb FDX speed. Prior to the X550,
1838 * the resting state of the link would be the maximum speed that
1839 * autonegotiation will allow (usually 10Gb, infrastructure allowing)
1840 * so we never bothered with explicitly setting the link to 10Gb as it
1841 * would already be at that state on driver attach. With X550, we must
1842 * trigger a re-negotiation of the link in order to switch from a LPLU
1843 * 1Gb link to 10Gb (cable and link partner permitting.)
1845 if (hw
->mac
.type
== ixgbe_mac_X550
||
1846 hw
->mac
.type
== ixgbe_mac_X550EM_x
) {
1847 (void) ixgbe_driver_setup_link(ixgbe
, B_TRUE
);
1848 ixgbe_get_hw_state(ixgbe
);
1851 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
1856 * Setup the rx/tx rings
1858 ixgbe_setup_rings(ixgbe
);
1861 * ixgbe_start() will be called when resetting, however if reset
1862 * happens, we need to clear the ERROR, STALL and OVERTEMP flags
1863 * before enabling the interrupts.
1865 atomic_and_32(&ixgbe
->ixgbe_state
, ~(IXGBE_ERROR
1866 | IXGBE_STALL
| IXGBE_OVERTEMP
));
1869 * Enable adapter interrupts
1870 * The interrupts must be enabled after the driver state is START
1872 ixgbe_enable_adapter_interrupts(ixgbe
);
1874 for (i
= ixgbe
->num_tx_rings
- 1; i
>= 0; i
--)
1875 mutex_exit(&ixgbe
->tx_rings
[i
].tx_lock
);
1876 for (i
= ixgbe
->num_rx_rings
- 1; i
>= 0; i
--)
1877 mutex_exit(&ixgbe
->rx_rings
[i
].rx_lock
);
1879 return (IXGBE_SUCCESS
);
1882 for (i
= ixgbe
->num_tx_rings
- 1; i
>= 0; i
--)
1883 mutex_exit(&ixgbe
->tx_rings
[i
].tx_lock
);
1884 for (i
= ixgbe
->num_rx_rings
- 1; i
>= 0; i
--)
1885 mutex_exit(&ixgbe
->rx_rings
[i
].rx_lock
);
1887 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
1889 return (IXGBE_FAILURE
);
1893 * ixgbe_stop - Stop the driver/chipset.
1896 ixgbe_stop(ixgbe_t
*ixgbe
, bool free_buffer
)
1900 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
1903 * Disable the adapter interrupts
1905 ixgbe_disable_adapter_interrupts(ixgbe
);
1908 * Drain the pending tx packets
1910 (void) ixgbe_tx_drain(ixgbe
);
1912 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++)
1913 mutex_enter(&ixgbe
->rx_rings
[i
].rx_lock
);
1914 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++)
1915 mutex_enter(&ixgbe
->tx_rings
[i
].tx_lock
);
1918 * Stop the chipset hardware
1920 ixgbe_chip_stop(ixgbe
);
1922 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
1923 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
1927 * Clean the pending tx data/resources
1929 ixgbe_tx_clean(ixgbe
);
1931 for (i
= ixgbe
->num_tx_rings
- 1; i
>= 0; i
--)
1932 mutex_exit(&ixgbe
->tx_rings
[i
].tx_lock
);
1933 for (i
= ixgbe
->num_rx_rings
- 1; i
>= 0; i
--)
1934 mutex_exit(&ixgbe
->rx_rings
[i
].rx_lock
);
1936 if (ixgbe
->link_state
== LINK_STATE_UP
) {
1937 ixgbe
->link_state
= LINK_STATE_UNKNOWN
;
1938 mac_link_update(ixgbe
->mac_hdl
, ixgbe
->link_state
);
1943 * Release the DMA/memory resources of rx/tx rings
1945 ixgbe_free_dma(ixgbe
);
1946 ixgbe_free_rx_data(ixgbe
);
1951 * ixgbe_cbfunc - Driver interface for generic DDI callbacks
1955 ixgbe_cbfunc(dev_info_t
*dip
, ddi_cb_action_t cbaction
, void *cbarg
,
1956 void *arg1
, void *arg2
)
1958 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg1
;
1963 case DDI_CB_INTR_ADD
:
1964 case DDI_CB_INTR_REMOVE
:
1965 count
= (int)(uintptr_t)cbarg
;
1966 ASSERT(ixgbe
->intr_type
== DDI_INTR_TYPE_MSIX
);
1967 DTRACE_PROBE2(ixgbe__irm__callback
, int, count
,
1968 int, ixgbe
->intr_cnt
);
1969 if (ixgbe_intr_adjust(ixgbe
, cbaction
, count
) !=
1972 "IRM CB: Failed to adjust interrupts");
1977 IXGBE_DEBUGLOG_1(ixgbe
, "DDI CB: action 0x%x NOT supported",
1979 return (DDI_ENOTSUP
);
1981 return (DDI_SUCCESS
);
1983 return (DDI_FAILURE
);
1987 * ixgbe_intr_adjust - Adjust interrupt to respond to IRM request.
1990 ixgbe_intr_adjust(ixgbe_t
*ixgbe
, ddi_cb_action_t cbaction
, int count
)
1995 return (DDI_SUCCESS
);
1997 if ((cbaction
== DDI_CB_INTR_ADD
&&
1998 ixgbe
->intr_cnt
+ count
> ixgbe
->intr_cnt_max
) ||
1999 (cbaction
== DDI_CB_INTR_REMOVE
&&
2000 ixgbe
->intr_cnt
- count
< ixgbe
->intr_cnt_min
))
2001 return (DDI_FAILURE
);
2003 if (!(ixgbe
->ixgbe_state
& IXGBE_STARTED
)) {
2004 return (DDI_FAILURE
);
2007 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++)
2008 mac_ring_intr_set(ixgbe
->rx_rings
[i
].ring_handle
, NULL
);
2009 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++)
2010 mac_ring_intr_set(ixgbe
->tx_rings
[i
].ring_handle
, NULL
);
2012 mutex_enter(&ixgbe
->gen_lock
);
2013 ixgbe
->ixgbe_state
&= ~IXGBE_STARTED
;
2014 ixgbe
->ixgbe_state
|= IXGBE_INTR_ADJUST
;
2015 ixgbe
->ixgbe_state
|= IXGBE_SUSPENDED
;
2016 mac_link_update(ixgbe
->mac_hdl
, LINK_STATE_UNKNOWN
);
2018 ixgbe_stop(ixgbe
, B_FALSE
);
2020 * Disable interrupts
2022 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_ENABLE_INTR
) {
2023 rc
= ixgbe_disable_intrs(ixgbe
);
2024 ASSERT(rc
== IXGBE_SUCCESS
);
2026 ixgbe
->attach_progress
&= ~ATTACH_PROGRESS_ENABLE_INTR
;
2029 * Remove interrupt handlers
2031 if (ixgbe
->attach_progress
& ATTACH_PROGRESS_ADD_INTR
) {
2032 ixgbe_rem_intr_handlers(ixgbe
);
2034 ixgbe
->attach_progress
&= ~ATTACH_PROGRESS_ADD_INTR
;
2039 bzero(&ixgbe
->vect_map
, sizeof (ixgbe
->vect_map
));
2041 case DDI_CB_INTR_ADD
:
2042 rc
= ddi_intr_alloc(ixgbe
->dip
, ixgbe
->htable
,
2043 DDI_INTR_TYPE_MSIX
, ixgbe
->intr_cnt
, count
, &actual
,
2044 DDI_INTR_ALLOC_NORMAL
);
2045 if (rc
!= DDI_SUCCESS
|| actual
!= count
) {
2046 ixgbe_log(ixgbe
, "Adjust interrupts failed."
2047 "return: %d, irm cb size: %d, actual: %d",
2049 goto intr_adjust_fail
;
2051 ixgbe
->intr_cnt
+= count
;
2054 case DDI_CB_INTR_REMOVE
:
2055 for (i
= ixgbe
->intr_cnt
- count
;
2056 i
< ixgbe
->intr_cnt
; i
++) {
2057 rc
= ddi_intr_free(ixgbe
->htable
[i
]);
2058 ixgbe
->htable
[i
] = NULL
;
2059 if (rc
!= DDI_SUCCESS
) {
2060 ixgbe_log(ixgbe
, "Adjust interrupts failed."
2061 "return: %d, irm cb size: %d, actual: %d",
2063 goto intr_adjust_fail
;
2066 ixgbe
->intr_cnt
-= count
;
2071 * Get priority for first vector, assume remaining are all the same
2073 rc
= ddi_intr_get_pri(ixgbe
->htable
[0], &ixgbe
->intr_pri
);
2074 if (rc
!= DDI_SUCCESS
) {
2076 "Get interrupt priority failed: %d", rc
);
2077 goto intr_adjust_fail
;
2079 rc
= ddi_intr_get_cap(ixgbe
->htable
[0], &ixgbe
->intr_cap
);
2080 if (rc
!= DDI_SUCCESS
) {
2081 ixgbe_log(ixgbe
, "Get interrupt cap failed: %d", rc
);
2082 goto intr_adjust_fail
;
2084 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ALLOC_INTR
;
2087 * Map rings to interrupt vectors
2089 if (ixgbe_map_intrs_to_vectors(ixgbe
) != IXGBE_SUCCESS
) {
2091 "IRM CB: Failed to map interrupts to vectors");
2092 goto intr_adjust_fail
;
2096 * Add interrupt handlers
2098 if (ixgbe_add_intr_handlers(ixgbe
) != IXGBE_SUCCESS
) {
2099 ixgbe_error(ixgbe
, "IRM CB: Failed to add interrupt handlers");
2100 goto intr_adjust_fail
;
2102 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ADD_INTR
;
2105 * Now that mutex locks are initialized, and the chip is also
2106 * initialized, enable interrupts.
2108 if (ixgbe_enable_intrs(ixgbe
) != IXGBE_SUCCESS
) {
2109 ixgbe_error(ixgbe
, "IRM CB: Failed to enable DDI interrupts");
2110 goto intr_adjust_fail
;
2112 ixgbe
->attach_progress
|= ATTACH_PROGRESS_ENABLE_INTR
;
2113 if (ixgbe_start(ixgbe
, B_FALSE
) != IXGBE_SUCCESS
) {
2114 ixgbe_error(ixgbe
, "IRM CB: Failed to start");
2115 goto intr_adjust_fail
;
2117 ixgbe
->ixgbe_state
&= ~IXGBE_INTR_ADJUST
;
2118 ixgbe
->ixgbe_state
&= ~IXGBE_SUSPENDED
;
2119 ixgbe
->ixgbe_state
|= IXGBE_STARTED
;
2120 mutex_exit(&ixgbe
->gen_lock
);
2122 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
2123 mac_ring_intr_set(ixgbe
->rx_rings
[i
].ring_handle
,
2124 ixgbe
->htable
[ixgbe
->rx_rings
[i
].intr_vector
]);
2126 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
2127 mac_ring_intr_set(ixgbe
->tx_rings
[i
].ring_handle
,
2128 ixgbe
->htable
[ixgbe
->tx_rings
[i
].intr_vector
]);
2131 /* Wakeup all Tx rings */
2132 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
2133 mac_tx_ring_update(ixgbe
->mac_hdl
,
2134 ixgbe
->tx_rings
[i
].ring_handle
);
2137 IXGBE_DEBUGLOG_3(ixgbe
,
2138 "IRM CB: interrupts new value: 0x%x(0x%x:0x%x).",
2139 ixgbe
->intr_cnt
, ixgbe
->intr_cnt_min
, ixgbe
->intr_cnt_max
);
2140 return (DDI_SUCCESS
);
2143 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
2144 mutex_exit(&ixgbe
->gen_lock
);
2145 return (DDI_FAILURE
);
2149 * ixgbe_intr_cb_register - Register interrupt callback function.
2152 ixgbe_intr_cb_register(ixgbe_t
*ixgbe
)
2154 if (ddi_cb_register(ixgbe
->dip
, DDI_CB_FLAG_INTR
, ixgbe_cbfunc
,
2155 ixgbe
, NULL
, &ixgbe
->cb_hdl
) != DDI_SUCCESS
) {
2156 return (IXGBE_FAILURE
);
2158 IXGBE_DEBUGLOG_0(ixgbe
, "Interrupt callback function registered.");
2159 return (IXGBE_SUCCESS
);
2163 * ixgbe_alloc_rings - Allocate memory space for rx/tx rings.
2166 ixgbe_alloc_rings(ixgbe_t
*ixgbe
)
2169 * Allocate memory space for rx rings
2171 ixgbe
->rx_rings
= kmem_zalloc(
2172 sizeof (ixgbe_rx_ring_t
) * ixgbe
->num_rx_rings
,
2175 if (ixgbe
->rx_rings
== NULL
) {
2176 return (IXGBE_FAILURE
);
2180 * Allocate memory space for tx rings
2182 ixgbe
->tx_rings
= kmem_zalloc(
2183 sizeof (ixgbe_tx_ring_t
) * ixgbe
->num_tx_rings
,
2186 if (ixgbe
->tx_rings
== NULL
) {
2187 kmem_free(ixgbe
->rx_rings
,
2188 sizeof (ixgbe_rx_ring_t
) * ixgbe
->num_rx_rings
);
2189 ixgbe
->rx_rings
= NULL
;
2190 return (IXGBE_FAILURE
);
2194 * Allocate memory space for rx ring groups
2196 ixgbe
->rx_groups
= kmem_zalloc(
2197 sizeof (ixgbe_rx_group_t
) * ixgbe
->num_rx_groups
,
2200 if (ixgbe
->rx_groups
== NULL
) {
2201 kmem_free(ixgbe
->rx_rings
,
2202 sizeof (ixgbe_rx_ring_t
) * ixgbe
->num_rx_rings
);
2203 kmem_free(ixgbe
->tx_rings
,
2204 sizeof (ixgbe_tx_ring_t
) * ixgbe
->num_tx_rings
);
2205 ixgbe
->rx_rings
= NULL
;
2206 ixgbe
->tx_rings
= NULL
;
2207 return (IXGBE_FAILURE
);
2210 return (IXGBE_SUCCESS
);
2214 * ixgbe_free_rings - Free the memory space of rx/tx rings.
2217 ixgbe_free_rings(ixgbe_t
*ixgbe
)
2219 if (ixgbe
->rx_rings
!= NULL
) {
2220 kmem_free(ixgbe
->rx_rings
,
2221 sizeof (ixgbe_rx_ring_t
) * ixgbe
->num_rx_rings
);
2222 ixgbe
->rx_rings
= NULL
;
2225 if (ixgbe
->tx_rings
!= NULL
) {
2226 kmem_free(ixgbe
->tx_rings
,
2227 sizeof (ixgbe_tx_ring_t
) * ixgbe
->num_tx_rings
);
2228 ixgbe
->tx_rings
= NULL
;
2231 if (ixgbe
->rx_groups
!= NULL
) {
2232 kmem_free(ixgbe
->rx_groups
,
2233 sizeof (ixgbe_rx_group_t
) * ixgbe
->num_rx_groups
);
2234 ixgbe
->rx_groups
= NULL
;
2239 ixgbe_alloc_rx_data(ixgbe_t
*ixgbe
)
2241 ixgbe_rx_ring_t
*rx_ring
;
2244 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
2245 rx_ring
= &ixgbe
->rx_rings
[i
];
2246 if (ixgbe_alloc_rx_ring_data(rx_ring
) != IXGBE_SUCCESS
)
2247 goto alloc_rx_rings_failure
;
2249 return (IXGBE_SUCCESS
);
2251 alloc_rx_rings_failure
:
2252 ixgbe_free_rx_data(ixgbe
);
2253 return (IXGBE_FAILURE
);
2257 ixgbe_free_rx_data(ixgbe_t
*ixgbe
)
2259 ixgbe_rx_ring_t
*rx_ring
;
2260 ixgbe_rx_data_t
*rx_data
;
2263 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
2264 rx_ring
= &ixgbe
->rx_rings
[i
];
2266 mutex_enter(&ixgbe
->rx_pending_lock
);
2267 rx_data
= rx_ring
->rx_data
;
2269 if (rx_data
!= NULL
) {
2270 rx_data
->flag
|= IXGBE_RX_STOPPED
;
2272 if (rx_data
->rcb_pending
== 0) {
2273 ixgbe_free_rx_ring_data(rx_data
);
2274 rx_ring
->rx_data
= NULL
;
2278 mutex_exit(&ixgbe
->rx_pending_lock
);
2283 * ixgbe_setup_rings - Setup rx/tx rings.
2286 ixgbe_setup_rings(ixgbe_t
*ixgbe
)
2289 * Setup the rx/tx rings, including the following:
2291 * 1. Setup the descriptor ring and the control block buffers;
2292 * 2. Initialize necessary registers for receive/transmit;
2293 * 3. Initialize software pointers/parameters for receive/transmit;
2295 ixgbe_setup_rx(ixgbe
);
2297 ixgbe_setup_tx(ixgbe
);
2301 ixgbe_setup_rx_ring(ixgbe_rx_ring_t
*rx_ring
)
2303 ixgbe_t
*ixgbe
= rx_ring
->ixgbe
;
2304 ixgbe_rx_data_t
*rx_data
= rx_ring
->rx_data
;
2305 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2306 rx_control_block_t
*rcb
;
2307 union ixgbe_adv_rx_desc
*rbd
;
2314 ASSERT(mutex_owned(&rx_ring
->rx_lock
));
2315 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
2317 for (i
= 0; i
< ixgbe
->rx_ring_size
; i
++) {
2318 rcb
= rx_data
->work_list
[i
];
2319 rbd
= &rx_data
->rbd_ring
[i
];
2321 rbd
->read
.pkt_addr
= rcb
->rx_buf
.dma_address
;
2322 rbd
->read
.hdr_addr
= (uintptr_t)NULL
;
2326 * Initialize the length register
2328 size
= rx_data
->ring_size
* sizeof (union ixgbe_adv_rx_desc
);
2329 IXGBE_WRITE_REG(hw
, IXGBE_RDLEN(rx_ring
->hw_index
), size
);
2332 * Initialize the base address registers
2334 buf_low
= (uint32_t)rx_data
->rbd_area
.dma_address
;
2335 buf_high
= (uint32_t)(rx_data
->rbd_area
.dma_address
>> 32);
2336 IXGBE_WRITE_REG(hw
, IXGBE_RDBAH(rx_ring
->hw_index
), buf_high
);
2337 IXGBE_WRITE_REG(hw
, IXGBE_RDBAL(rx_ring
->hw_index
), buf_low
);
2340 * Setup head & tail pointers
2342 IXGBE_WRITE_REG(hw
, IXGBE_RDT(rx_ring
->hw_index
),
2343 rx_data
->ring_size
- 1);
2344 IXGBE_WRITE_REG(hw
, IXGBE_RDH(rx_ring
->hw_index
), 0);
2346 rx_data
->rbd_next
= 0;
2347 rx_data
->lro_first
= 0;
2350 * Setup the Receive Descriptor Control Register (RXDCTL)
2351 * PTHRESH=32 descriptors (half the internal cache)
2352 * HTHRESH=0 descriptors (to minimize latency on fetch)
2353 * WTHRESH defaults to 1 (writeback each descriptor)
2355 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RXDCTL(rx_ring
->hw_index
));
2356 reg_val
|= IXGBE_RXDCTL_ENABLE
; /* enable queue */
2358 /* Not a valid value for 82599, X540 or X550 */
2359 if (hw
->mac
.type
== ixgbe_mac_82598EB
) {
2360 reg_val
|= 0x0020; /* pthresh */
2362 IXGBE_WRITE_REG(hw
, IXGBE_RXDCTL(rx_ring
->hw_index
), reg_val
);
2364 if (hw
->mac
.type
== ixgbe_mac_82599EB
||
2365 hw
->mac
.type
== ixgbe_mac_X540
||
2366 hw
->mac
.type
== ixgbe_mac_X550
||
2367 hw
->mac
.type
== ixgbe_mac_X550EM_x
) {
2368 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RDRXCTL
);
2369 reg_val
|= (IXGBE_RDRXCTL_CRCSTRIP
| IXGBE_RDRXCTL_AGGDIS
);
2370 IXGBE_WRITE_REG(hw
, IXGBE_RDRXCTL
, reg_val
);
2374 * Setup the Split and Replication Receive Control Register.
2375 * Set the rx buffer size and the advanced descriptor type.
2377 reg_val
= (ixgbe
->rx_buf_size
>> IXGBE_SRRCTL_BSIZEPKT_SHIFT
) |
2378 IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF
;
2379 reg_val
|= IXGBE_SRRCTL_DROP_EN
;
2380 IXGBE_WRITE_REG(hw
, IXGBE_SRRCTL(rx_ring
->hw_index
), reg_val
);
2384 ixgbe_setup_rx(ixgbe_t
*ixgbe
)
2386 ixgbe_rx_ring_t
*rx_ring
;
2387 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2389 uint32_t ring_mapping
;
2391 uint32_t psrtype_rss_bit
;
2394 * Ensure that Rx is disabled while setting up
2395 * the Rx unit and Rx descriptor ring(s)
2397 ixgbe_disable_rx(hw
);
2399 /* PSRTYPE must be configured for 82599 */
2400 if (ixgbe
->classify_mode
!= IXGBE_CLASSIFY_VMDQ
&&
2401 ixgbe
->classify_mode
!= IXGBE_CLASSIFY_VMDQ_RSS
) {
2402 reg_val
= IXGBE_PSRTYPE_TCPHDR
| IXGBE_PSRTYPE_UDPHDR
|
2403 IXGBE_PSRTYPE_IPV4HDR
| IXGBE_PSRTYPE_IPV6HDR
;
2404 reg_val
|= IXGBE_PSRTYPE_L2HDR
;
2405 reg_val
|= 0x80000000;
2406 IXGBE_WRITE_REG(hw
, IXGBE_PSRTYPE(0), reg_val
);
2408 if (ixgbe
->num_rx_groups
> 32) {
2409 psrtype_rss_bit
= 0x20000000;
2411 psrtype_rss_bit
= 0x40000000;
2413 for (i
= 0; i
< ixgbe
->capab
->max_rx_grp_num
; i
++) {
2414 reg_val
= IXGBE_PSRTYPE_TCPHDR
| IXGBE_PSRTYPE_UDPHDR
|
2415 IXGBE_PSRTYPE_IPV4HDR
| IXGBE_PSRTYPE_IPV6HDR
;
2416 reg_val
|= IXGBE_PSRTYPE_L2HDR
;
2417 reg_val
|= psrtype_rss_bit
;
2418 IXGBE_WRITE_REG(hw
, IXGBE_PSRTYPE(i
), reg_val
);
2423 * Set filter control in FCTRL to determine types of packets are passed
2425 * - Pass broadcast packets.
2426 * - Do not pass flow control pause frames (82598-specific)
2428 reg_val
= IXGBE_READ_REG(hw
, IXGBE_FCTRL
);
2429 reg_val
|= IXGBE_FCTRL_BAM
; /* Broadcast Accept Mode */
2430 if (hw
->mac
.type
== ixgbe_mac_82598EB
) {
2431 reg_val
|= IXGBE_FCTRL_DPF
; /* Discard Pause Frames */
2433 IXGBE_WRITE_REG(hw
, IXGBE_FCTRL
, reg_val
);
2436 * Hardware checksum settings
2438 if (ixgbe
->rx_hcksum_enable
) {
2439 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RXCSUM
);
2440 reg_val
|= IXGBE_RXCSUM_IPPCSE
; /* IP checksum */
2441 IXGBE_WRITE_REG(hw
, IXGBE_RXCSUM
, reg_val
);
2445 * Setup VMDq and RSS for multiple receive queues
2447 switch (ixgbe
->classify_mode
) {
2448 case IXGBE_CLASSIFY_RSS
:
2450 * One group, only RSS is needed when more than
2453 ixgbe_setup_rss(ixgbe
);
2456 case IXGBE_CLASSIFY_VMDQ
:
2458 * Multiple groups, each group has one ring,
2459 * only VMDq is needed.
2461 ixgbe_setup_vmdq(ixgbe
);
2464 case IXGBE_CLASSIFY_VMDQ_RSS
:
2466 * Multiple groups and multiple rings, both
2467 * VMDq and RSS are needed.
2469 ixgbe_setup_vmdq_rss(ixgbe
);
2477 * Enable the receive unit. This must be done after filter
2478 * control is set in FCTRL. On 82598, we disable the descriptor monitor.
2479 * 82598 is the only adapter which defines this RXCTRL option.
2481 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RXCTRL
);
2482 if (hw
->mac
.type
== ixgbe_mac_82598EB
)
2483 reg_val
|= IXGBE_RXCTRL_DMBYPS
; /* descriptor monitor bypass */
2484 reg_val
|= IXGBE_RXCTRL_RXEN
;
2485 (void) ixgbe_enable_rx_dma(hw
, reg_val
);
2488 * ixgbe_setup_rx_ring must be called after configuring RXCTRL
2490 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
2491 rx_ring
= &ixgbe
->rx_rings
[i
];
2492 ixgbe_setup_rx_ring(rx_ring
);
2496 * Setup the per-ring statistics mapping.
2499 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
2500 index
= ixgbe
->rx_rings
[i
].hw_index
;
2501 ring_mapping
= IXGBE_READ_REG(hw
, IXGBE_RQSMR(index
>> 2));
2502 ring_mapping
|= (i
& 0xF) << (8 * (index
& 0x3));
2503 IXGBE_WRITE_REG(hw
, IXGBE_RQSMR(index
>> 2), ring_mapping
);
2507 * The Max Frame Size in MHADD/MAXFRS will be internally increased
2508 * by four bytes if the packet has a VLAN field, so includes MTU,
2509 * ethernet header and frame check sequence.
2510 * Register is MAXFRS in 82599.
2512 reg_val
= IXGBE_READ_REG(hw
, IXGBE_MHADD
);
2513 reg_val
&= ~IXGBE_MHADD_MFS_MASK
;
2514 reg_val
|= (ixgbe
->default_mtu
+ sizeof (struct ether_header
)
2515 + ETHERFCSL
) << IXGBE_MHADD_MFS_SHIFT
;
2516 IXGBE_WRITE_REG(hw
, IXGBE_MHADD
, reg_val
);
2519 * Setup Jumbo Frame enable bit
2521 reg_val
= IXGBE_READ_REG(hw
, IXGBE_HLREG0
);
2522 if (ixgbe
->default_mtu
> ETHERMTU
)
2523 reg_val
|= IXGBE_HLREG0_JUMBOEN
;
2525 reg_val
&= ~IXGBE_HLREG0_JUMBOEN
;
2526 IXGBE_WRITE_REG(hw
, IXGBE_HLREG0
, reg_val
);
2529 * Setup RSC for multiple receive queues.
2531 if (ixgbe
->lro_enable
) {
2532 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
2534 * Make sure rx_buf_size * MAXDESC not greater
2536 * Intel recommends 4 for MAXDESC field value.
2538 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RSCCTL(i
));
2539 reg_val
|= IXGBE_RSCCTL_RSCEN
;
2540 if (ixgbe
->rx_buf_size
== IXGBE_PKG_BUF_16k
)
2541 reg_val
|= IXGBE_RSCCTL_MAXDESC_1
;
2543 reg_val
|= IXGBE_RSCCTL_MAXDESC_4
;
2544 IXGBE_WRITE_REG(hw
, IXGBE_RSCCTL(i
), reg_val
);
2547 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RSCDBU
);
2548 reg_val
|= IXGBE_RSCDBU_RSCACKDIS
;
2549 IXGBE_WRITE_REG(hw
, IXGBE_RSCDBU
, reg_val
);
2551 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RDRXCTL
);
2552 reg_val
|= IXGBE_RDRXCTL_RSCACKC
;
2553 reg_val
|= IXGBE_RDRXCTL_FCOE_WRFIX
;
2554 reg_val
&= ~IXGBE_RDRXCTL_RSCFRSTSIZE
;
2556 IXGBE_WRITE_REG(hw
, IXGBE_RDRXCTL
, reg_val
);
2561 ixgbe_setup_tx_ring(ixgbe_tx_ring_t
*tx_ring
)
2563 ixgbe_t
*ixgbe
= tx_ring
->ixgbe
;
2564 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2570 ASSERT(mutex_owned(&tx_ring
->tx_lock
));
2571 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
2574 * Initialize the length register
2576 size
= tx_ring
->ring_size
* sizeof (union ixgbe_adv_tx_desc
);
2577 IXGBE_WRITE_REG(hw
, IXGBE_TDLEN(tx_ring
->index
), size
);
2580 * Initialize the base address registers
2582 buf_low
= (uint32_t)tx_ring
->tbd_area
.dma_address
;
2583 buf_high
= (uint32_t)(tx_ring
->tbd_area
.dma_address
>> 32);
2584 IXGBE_WRITE_REG(hw
, IXGBE_TDBAL(tx_ring
->index
), buf_low
);
2585 IXGBE_WRITE_REG(hw
, IXGBE_TDBAH(tx_ring
->index
), buf_high
);
2588 * Setup head & tail pointers
2590 IXGBE_WRITE_REG(hw
, IXGBE_TDH(tx_ring
->index
), 0);
2591 IXGBE_WRITE_REG(hw
, IXGBE_TDT(tx_ring
->index
), 0);
2594 * Setup head write-back
2596 if (ixgbe
->tx_head_wb_enable
) {
2598 * The memory of the head write-back is allocated using
2599 * the extra tbd beyond the tail of the tbd ring.
2601 tx_ring
->tbd_head_wb
= (uint32_t *)
2602 ((uintptr_t)tx_ring
->tbd_area
.address
+ size
);
2603 *tx_ring
->tbd_head_wb
= 0;
2605 buf_low
= (uint32_t)
2606 (tx_ring
->tbd_area
.dma_address
+ size
);
2607 buf_high
= (uint32_t)
2608 ((tx_ring
->tbd_area
.dma_address
+ size
) >> 32);
2610 /* Set the head write-back enable bit */
2611 buf_low
|= IXGBE_TDWBAL_HEAD_WB_ENABLE
;
2613 IXGBE_WRITE_REG(hw
, IXGBE_TDWBAL(tx_ring
->index
), buf_low
);
2614 IXGBE_WRITE_REG(hw
, IXGBE_TDWBAH(tx_ring
->index
), buf_high
);
2617 * Turn off relaxed ordering for head write back or it will
2618 * cause problems with the tx recycling
2621 reg_val
= (hw
->mac
.type
== ixgbe_mac_82598EB
) ?
2622 IXGBE_READ_REG(hw
, IXGBE_DCA_TXCTRL(tx_ring
->index
)) :
2623 IXGBE_READ_REG(hw
, IXGBE_DCA_TXCTRL_82599(tx_ring
->index
));
2624 reg_val
&= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN
;
2625 if (hw
->mac
.type
== ixgbe_mac_82598EB
) {
2627 IXGBE_DCA_TXCTRL(tx_ring
->index
), reg_val
);
2630 IXGBE_DCA_TXCTRL_82599(tx_ring
->index
), reg_val
);
2633 tx_ring
->tbd_head_wb
= NULL
;
2636 tx_ring
->tbd_head
= 0;
2637 tx_ring
->tbd_tail
= 0;
2638 tx_ring
->tbd_free
= tx_ring
->ring_size
;
2640 if (ixgbe
->tx_ring_init
== B_TRUE
) {
2641 tx_ring
->tcb_head
= 0;
2642 tx_ring
->tcb_tail
= 0;
2643 tx_ring
->tcb_free
= tx_ring
->free_list_size
;
2647 * Initialize the s/w context structure
2649 bzero(&tx_ring
->tx_context
, sizeof (ixgbe_tx_context_t
));
2653 ixgbe_setup_tx(ixgbe_t
*ixgbe
)
2655 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2656 ixgbe_tx_ring_t
*tx_ring
;
2658 uint32_t ring_mapping
;
2661 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
2662 tx_ring
= &ixgbe
->tx_rings
[i
];
2663 ixgbe_setup_tx_ring(tx_ring
);
2667 * Setup the per-ring statistics mapping.
2670 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
2671 ring_mapping
|= (i
& 0xF) << (8 * (i
& 0x3));
2672 if ((i
& 0x3) == 0x3) {
2673 switch (hw
->mac
.type
) {
2674 case ixgbe_mac_82598EB
:
2675 IXGBE_WRITE_REG(hw
, IXGBE_TQSMR(i
>> 2),
2679 case ixgbe_mac_82599EB
:
2680 case ixgbe_mac_X540
:
2681 case ixgbe_mac_X550
:
2682 case ixgbe_mac_X550EM_x
:
2683 IXGBE_WRITE_REG(hw
, IXGBE_TQSM(i
>> 2),
2695 switch (hw
->mac
.type
) {
2696 case ixgbe_mac_82598EB
:
2697 IXGBE_WRITE_REG(hw
, IXGBE_TQSMR(i
>> 2), ring_mapping
);
2700 case ixgbe_mac_82599EB
:
2701 case ixgbe_mac_X540
:
2702 case ixgbe_mac_X550
:
2703 case ixgbe_mac_X550EM_x
:
2704 IXGBE_WRITE_REG(hw
, IXGBE_TQSM(i
>> 2), ring_mapping
);
2713 * Enable CRC appending and TX padding (for short tx frames)
2715 reg_val
= IXGBE_READ_REG(hw
, IXGBE_HLREG0
);
2716 reg_val
|= IXGBE_HLREG0_TXCRCEN
| IXGBE_HLREG0_TXPADEN
;
2717 IXGBE_WRITE_REG(hw
, IXGBE_HLREG0
, reg_val
);
2720 * enable DMA for 82599, X540 and X550 parts
2722 if (hw
->mac
.type
== ixgbe_mac_82599EB
||
2723 hw
->mac
.type
== ixgbe_mac_X540
||
2724 hw
->mac
.type
== ixgbe_mac_X550
||
2725 hw
->mac
.type
== ixgbe_mac_X550EM_x
) {
2726 /* DMATXCTL.TE must be set after all Tx config is complete */
2727 reg_val
= IXGBE_READ_REG(hw
, IXGBE_DMATXCTL
);
2728 reg_val
|= IXGBE_DMATXCTL_TE
;
2729 IXGBE_WRITE_REG(hw
, IXGBE_DMATXCTL
, reg_val
);
2731 /* Disable arbiter to set MTQC */
2732 reg_val
= IXGBE_READ_REG(hw
, IXGBE_RTTDCS
);
2733 reg_val
|= IXGBE_RTTDCS_ARBDIS
;
2734 IXGBE_WRITE_REG(hw
, IXGBE_RTTDCS
, reg_val
);
2735 IXGBE_WRITE_REG(hw
, IXGBE_MTQC
, IXGBE_MTQC_64Q_1PB
);
2736 reg_val
&= ~IXGBE_RTTDCS_ARBDIS
;
2737 IXGBE_WRITE_REG(hw
, IXGBE_RTTDCS
, reg_val
);
2741 * Enabling tx queues ..
2742 * For 82599 must be done after DMATXCTL.TE is set
2744 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
2745 tx_ring
= &ixgbe
->tx_rings
[i
];
2746 reg_val
= IXGBE_READ_REG(hw
, IXGBE_TXDCTL(tx_ring
->index
));
2747 reg_val
|= IXGBE_TXDCTL_ENABLE
;
2748 IXGBE_WRITE_REG(hw
, IXGBE_TXDCTL(tx_ring
->index
), reg_val
);
2753 * ixgbe_setup_rss - Setup receive-side scaling feature.
2756 ixgbe_setup_rss(ixgbe_t
*ixgbe
)
2758 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2762 * Initialize RETA/ERETA table
2764 ixgbe_setup_rss_table(ixgbe
);
2767 * Enable RSS & perform hash on these packet types
2769 mrqc
= IXGBE_MRQC_RSSEN
|
2770 IXGBE_MRQC_RSS_FIELD_IPV4
|
2771 IXGBE_MRQC_RSS_FIELD_IPV4_TCP
|
2772 IXGBE_MRQC_RSS_FIELD_IPV4_UDP
|
2773 IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP
|
2774 IXGBE_MRQC_RSS_FIELD_IPV6_EX
|
2775 IXGBE_MRQC_RSS_FIELD_IPV6
|
2776 IXGBE_MRQC_RSS_FIELD_IPV6_TCP
|
2777 IXGBE_MRQC_RSS_FIELD_IPV6_UDP
|
2778 IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP
;
2779 IXGBE_WRITE_REG(hw
, IXGBE_MRQC
, mrqc
);
2783 * ixgbe_setup_vmdq - Setup MAC classification feature
2786 ixgbe_setup_vmdq(ixgbe_t
*ixgbe
)
2788 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2789 uint32_t vmdctl
, i
, vtctl
;
2792 * Setup the VMDq Control register, enable VMDq based on
2793 * packet destination MAC address:
2795 switch (hw
->mac
.type
) {
2796 case ixgbe_mac_82598EB
:
2799 * VMDq Filter = 0; MAC filtering
2800 * Default VMDq output index = 0;
2802 vmdctl
= IXGBE_VMD_CTL_VMDQ_EN
;
2803 IXGBE_WRITE_REG(hw
, IXGBE_VMD_CTL
, vmdctl
);
2806 case ixgbe_mac_82599EB
:
2807 case ixgbe_mac_X540
:
2808 case ixgbe_mac_X550
:
2809 case ixgbe_mac_X550EM_x
:
2813 vmdctl
= IXGBE_MRQC_VMDQEN
;
2814 IXGBE_WRITE_REG(hw
, IXGBE_MRQC
, vmdctl
);
2816 for (i
= 0; i
< hw
->mac
.num_rar_entries
; i
++) {
2817 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_LO(i
), 0);
2818 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_HI(i
), 0);
2822 * Enable Virtualization and Replication.
2824 vtctl
= IXGBE_VT_CTL_VT_ENABLE
| IXGBE_VT_CTL_REPLEN
;
2825 IXGBE_WRITE_REG(hw
, IXGBE_VT_CTL
, vtctl
);
2828 * Enable receiving packets to all VFs
2830 IXGBE_WRITE_REG(hw
, IXGBE_VFRE(0), IXGBE_VFRE_ENABLE_ALL
);
2831 IXGBE_WRITE_REG(hw
, IXGBE_VFRE(1), IXGBE_VFRE_ENABLE_ALL
);
2840 * ixgbe_setup_vmdq_rss - Setup both vmdq feature and rss feature.
2843 ixgbe_setup_vmdq_rss(ixgbe_t
*ixgbe
)
2845 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2847 uint32_t vtctl
, vmdctl
;
2850 * Initialize RETA/ERETA table
2852 ixgbe_setup_rss_table(ixgbe
);
2855 * Enable and setup RSS and VMDq
2857 switch (hw
->mac
.type
) {
2858 case ixgbe_mac_82598EB
:
2860 * Enable RSS & Setup RSS Hash functions
2862 mrqc
= IXGBE_MRQC_RSSEN
|
2863 IXGBE_MRQC_RSS_FIELD_IPV4
|
2864 IXGBE_MRQC_RSS_FIELD_IPV4_TCP
|
2865 IXGBE_MRQC_RSS_FIELD_IPV4_UDP
|
2866 IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP
|
2867 IXGBE_MRQC_RSS_FIELD_IPV6_EX
|
2868 IXGBE_MRQC_RSS_FIELD_IPV6
|
2869 IXGBE_MRQC_RSS_FIELD_IPV6_TCP
|
2870 IXGBE_MRQC_RSS_FIELD_IPV6_UDP
|
2871 IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP
;
2872 IXGBE_WRITE_REG(hw
, IXGBE_MRQC
, mrqc
);
2875 * Enable and Setup VMDq
2876 * VMDq Filter = 0; MAC filtering
2877 * Default VMDq output index = 0;
2879 vmdctl
= IXGBE_VMD_CTL_VMDQ_EN
;
2880 IXGBE_WRITE_REG(hw
, IXGBE_VMD_CTL
, vmdctl
);
2883 case ixgbe_mac_82599EB
:
2884 case ixgbe_mac_X540
:
2885 case ixgbe_mac_X550
:
2886 case ixgbe_mac_X550EM_x
:
2888 * Enable RSS & Setup RSS Hash functions
2890 mrqc
= IXGBE_MRQC_RSS_FIELD_IPV4
|
2891 IXGBE_MRQC_RSS_FIELD_IPV4_TCP
|
2892 IXGBE_MRQC_RSS_FIELD_IPV4_UDP
|
2893 IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP
|
2894 IXGBE_MRQC_RSS_FIELD_IPV6_EX
|
2895 IXGBE_MRQC_RSS_FIELD_IPV6
|
2896 IXGBE_MRQC_RSS_FIELD_IPV6_TCP
|
2897 IXGBE_MRQC_RSS_FIELD_IPV6_UDP
|
2898 IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP
;
2903 if (ixgbe
->num_rx_groups
> 32) {
2904 mrqc
= mrqc
| IXGBE_MRQC_VMDQRSS64EN
;
2906 mrqc
= mrqc
| IXGBE_MRQC_VMDQRSS32EN
;
2909 IXGBE_WRITE_REG(hw
, IXGBE_MRQC
, mrqc
);
2911 for (i
= 0; i
< hw
->mac
.num_rar_entries
; i
++) {
2912 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_LO(i
), 0);
2913 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_HI(i
), 0);
2922 if (hw
->mac
.type
== ixgbe_mac_82599EB
||
2923 hw
->mac
.type
== ixgbe_mac_X540
||
2924 hw
->mac
.type
== ixgbe_mac_X550
||
2925 hw
->mac
.type
== ixgbe_mac_X550EM_x
) {
2927 * Enable Virtualization and Replication.
2929 vtctl
= IXGBE_VT_CTL_VT_ENABLE
| IXGBE_VT_CTL_REPLEN
;
2930 IXGBE_WRITE_REG(hw
, IXGBE_VT_CTL
, vtctl
);
2933 * Enable receiving packets to all VFs
2935 IXGBE_WRITE_REG(hw
, IXGBE_VFRE(0), IXGBE_VFRE_ENABLE_ALL
);
2936 IXGBE_WRITE_REG(hw
, IXGBE_VFRE(1), IXGBE_VFRE_ENABLE_ALL
);
2941 * ixgbe_setup_rss_table - Setup RSS table
2944 ixgbe_setup_rss_table(ixgbe_t
*ixgbe
)
2946 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
2950 uint32_t ring_per_group
;
2952 uint32_t table_size
;
2953 uint32_t index_mult
;
2957 * Set multiplier for RETA setup and table size based on MAC type.
2958 * RETA table sizes vary by model:
2960 * 82598, 82599, X540: 128 table entries.
2961 * X550: 512 table entries.
2965 switch (ixgbe
->hw
.mac
.type
) {
2966 case ixgbe_mac_82598EB
:
2969 case ixgbe_mac_X550
:
2970 case ixgbe_mac_X550EM_x
:
2978 * Fill out RSS redirection table. The configuation of the indices is
2979 * hardware-dependent.
2981 * 82598: 8 bits wide containing two 4 bit RSS indices
2982 * 82599, X540: 8 bits wide containing one 4 bit RSS index
2983 * X550: 8 bits wide containing one 6 bit RSS index
2986 ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
2988 for (i
= 0, j
= 0; i
< table_size
; i
++, j
++) {
2989 if (j
== ring_per_group
) j
= 0;
2992 * The low 8 bits are for hash value (n+0);
2993 * The next 8 bits are for hash value (n+1), etc.
2995 ring
= (j
* index_mult
);
2997 reta
= reta
| (((uint32_t)ring
) << 24);
3001 * The first 128 table entries are programmed into the
3002 * RETA register, with any beyond that (eg; on X550)
3006 IXGBE_WRITE_REG(hw
, IXGBE_RETA(i
>> 2), reta
);
3008 IXGBE_WRITE_REG(hw
, IXGBE_ERETA((i
>> 2) - 32),
3015 * Fill out hash function seeds with a random constant
3017 for (i
= 0; i
< 10; i
++) {
3018 (void) random_get_pseudo_bytes((uint8_t *)&random
,
3020 IXGBE_WRITE_REG(hw
, IXGBE_RSSRK(i
), random
);
3024 * Disable Packet Checksum to enable RSS for multiple receive queues.
3025 * It is an adapter hardware limitation that Packet Checksum is
3026 * mutually exclusive with RSS.
3028 rxcsum
= IXGBE_READ_REG(hw
, IXGBE_RXCSUM
);
3029 rxcsum
|= IXGBE_RXCSUM_PCSD
;
3030 rxcsum
&= ~IXGBE_RXCSUM_IPPCSE
;
3031 IXGBE_WRITE_REG(hw
, IXGBE_RXCSUM
, rxcsum
);
3035 * ixgbe_init_unicst - Initialize the unicast addresses.
3038 ixgbe_init_unicst(ixgbe_t
*ixgbe
)
3040 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3044 * Here we should consider two situations:
3046 * 1. Chipset is initialized at the first time,
3047 * Clear all the multiple unicast addresses.
3049 * 2. Chipset is reset
3050 * Recover the multiple unicast addresses from the
3051 * software data structure to the RAR registers.
3053 if (!ixgbe
->unicst_init
) {
3055 * Initialize the multiple unicast addresses
3057 ixgbe
->unicst_total
= hw
->mac
.num_rar_entries
;
3058 ixgbe
->unicst_avail
= ixgbe
->unicst_total
;
3059 for (slot
= 0; slot
< ixgbe
->unicst_total
; slot
++) {
3060 mac_addr
= ixgbe
->unicst_addr
[slot
].mac
.addr
;
3061 bzero(mac_addr
, ETHERADDRL
);
3062 (void) ixgbe_set_rar(hw
, slot
, mac_addr
, 0, 0);
3063 ixgbe
->unicst_addr
[slot
].mac
.set
= 0;
3065 ixgbe
->unicst_init
= B_TRUE
;
3067 /* Re-configure the RAR registers */
3068 for (slot
= 0; slot
< ixgbe
->unicst_total
; slot
++) {
3069 mac_addr
= ixgbe
->unicst_addr
[slot
].mac
.addr
;
3070 if (ixgbe
->unicst_addr
[slot
].mac
.set
== 1) {
3071 (void) ixgbe_set_rar(hw
, slot
, mac_addr
,
3072 ixgbe
->unicst_addr
[slot
].mac
.group_index
,
3075 bzero(mac_addr
, ETHERADDRL
);
3076 (void) ixgbe_set_rar(hw
, slot
, mac_addr
,
3084 * ixgbe_unicst_find - Find the slot for the specified unicast address
3087 ixgbe_unicst_find(ixgbe_t
*ixgbe
, const uint8_t *mac_addr
)
3091 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
3093 for (slot
= 0; slot
< ixgbe
->unicst_total
; slot
++) {
3094 if (bcmp(ixgbe
->unicst_addr
[slot
].mac
.addr
,
3095 mac_addr
, ETHERADDRL
) == 0)
3103 * ixgbe_multicst_add - Add a multicst address.
3106 ixgbe_multicst_add(ixgbe_t
*ixgbe
, const uint8_t *multiaddr
)
3108 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
3110 if ((multiaddr
[0] & 01) == 0) {
3114 if (ixgbe
->mcast_count
>= MAX_NUM_MULTICAST_ADDRESSES
) {
3119 &ixgbe
->mcast_table
[ixgbe
->mcast_count
], ETHERADDRL
);
3120 ixgbe
->mcast_count
++;
3123 * Update the multicast table in the hardware
3125 ixgbe_setup_multicst(ixgbe
);
3127 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
3128 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
3136 * ixgbe_multicst_remove - Remove a multicst address.
3139 ixgbe_multicst_remove(ixgbe_t
*ixgbe
, const uint8_t *multiaddr
)
3143 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
3145 for (i
= 0; i
< ixgbe
->mcast_count
; i
++) {
3146 if (bcmp(multiaddr
, &ixgbe
->mcast_table
[i
],
3148 for (i
++; i
< ixgbe
->mcast_count
; i
++) {
3149 ixgbe
->mcast_table
[i
- 1] =
3150 ixgbe
->mcast_table
[i
];
3152 ixgbe
->mcast_count
--;
3158 * Update the multicast table in the hardware
3160 ixgbe_setup_multicst(ixgbe
);
3162 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
3163 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
3171 * ixgbe_setup_multicast - Setup multicast data structures.
3173 * This routine initializes all of the multicast related structures
3174 * and save them in the hardware registers.
3177 ixgbe_setup_multicst(ixgbe_t
*ixgbe
)
3179 uint8_t *mc_addr_list
;
3180 uint32_t mc_addr_count
;
3181 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3183 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
3185 ASSERT(ixgbe
->mcast_count
<= MAX_NUM_MULTICAST_ADDRESSES
);
3187 mc_addr_list
= (uint8_t *)ixgbe
->mcast_table
;
3188 mc_addr_count
= ixgbe
->mcast_count
;
3191 * Update the multicast addresses to the MTA registers
3193 (void) ixgbe_update_mc_addr_list(hw
, mc_addr_list
, mc_addr_count
,
3194 ixgbe_mc_table_itr
, TRUE
);
3198 * ixgbe_setup_vmdq_rss_conf - Configure vmdq and rss (number and mode).
3200 * Configure the rx classification mode (vmdq & rss) and vmdq & rss numbers.
3201 * Different chipsets may have different allowed configuration of vmdq and rss.
3204 ixgbe_setup_vmdq_rss_conf(ixgbe_t
*ixgbe
)
3206 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3207 uint32_t ring_per_group
;
3209 switch (hw
->mac
.type
) {
3210 case ixgbe_mac_82598EB
:
3212 * 82598 supports the following combination:
3213 * vmdq no. x rss no.
3216 * However 8 rss queue per pool (vmdq) is sufficient for
3219 ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
3220 if (ixgbe
->num_rx_groups
> 4) {
3221 ixgbe
->num_rx_rings
= ixgbe
->num_rx_groups
;
3223 ixgbe
->num_rx_rings
= ixgbe
->num_rx_groups
*
3224 min(8, ring_per_group
);
3229 case ixgbe_mac_82599EB
:
3230 case ixgbe_mac_X540
:
3231 case ixgbe_mac_X550
:
3232 case ixgbe_mac_X550EM_x
:
3234 * 82599 supports the following combination:
3235 * vmdq no. x rss no.
3239 * However 8 rss queue per pool (vmdq) is sufficient for
3242 * For now, treat X540 and X550 like the 82599.
3244 ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
3245 if (ixgbe
->num_rx_groups
== 1) {
3246 ixgbe
->num_rx_rings
= min(8, ring_per_group
);
3247 } else if (ixgbe
->num_rx_groups
<= 32) {
3248 ixgbe
->num_rx_rings
= ixgbe
->num_rx_groups
*
3249 min(4, ring_per_group
);
3250 } else if (ixgbe
->num_rx_groups
<= 64) {
3251 ixgbe
->num_rx_rings
= ixgbe
->num_rx_groups
*
3252 min(2, ring_per_group
);
3260 ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
3262 if (ixgbe
->num_rx_groups
== 1 && ring_per_group
== 1) {
3263 ixgbe
->classify_mode
= IXGBE_CLASSIFY_NONE
;
3264 } else if (ixgbe
->num_rx_groups
!= 1 && ring_per_group
== 1) {
3265 ixgbe
->classify_mode
= IXGBE_CLASSIFY_VMDQ
;
3266 } else if (ixgbe
->num_rx_groups
!= 1 && ring_per_group
!= 1) {
3267 ixgbe
->classify_mode
= IXGBE_CLASSIFY_VMDQ_RSS
;
3269 ixgbe
->classify_mode
= IXGBE_CLASSIFY_RSS
;
3272 IXGBE_DEBUGLOG_2(ixgbe
, "rx group number:%d, rx ring number:%d",
3273 ixgbe
->num_rx_groups
, ixgbe
->num_rx_rings
);
3277 * ixgbe_get_conf - Get driver configurations set in driver.conf.
3279 * This routine gets user-configured values out of the configuration
3282 * For each configurable value, there is a minimum, a maximum, and a
3284 * If user does not configure a value, use the default.
3285 * If user configures below the minimum, use the minumum.
3286 * If user configures above the maximum, use the maxumum.
3289 ixgbe_get_conf(ixgbe_t
*ixgbe
)
3291 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3292 uint32_t flow_control
;
3295 * ixgbe driver supports the following user configurations:
3297 * Jumbo frame configuration:
3300 * Ethernet flow control configuration:
3303 * Multiple rings configurations:
3309 * Call ixgbe_get_prop() to get the value for a specific
3310 * configuration parameter.
3314 * Jumbo frame configuration - max_frame_size controls host buffer
3315 * allocation, so includes MTU, ethernet header, vlan tag and
3316 * frame check sequence.
3318 ixgbe
->default_mtu
= ixgbe_get_prop(ixgbe
, PROP_DEFAULT_MTU
,
3319 MIN_MTU
, ixgbe
->capab
->max_mtu
, DEFAULT_MTU
);
3321 ixgbe
->max_frame_size
= ixgbe
->default_mtu
+
3322 sizeof (struct ether_vlan_header
) + ETHERFCSL
;
3325 * Ethernet flow control configuration
3327 flow_control
= ixgbe_get_prop(ixgbe
, PROP_FLOW_CONTROL
,
3328 ixgbe_fc_none
, 3, ixgbe_fc_none
);
3329 if (flow_control
== 3)
3330 flow_control
= ixgbe_fc_default
;
3333 * fc.requested mode is what the user requests. After autoneg,
3334 * fc.current_mode will be the flow_control mode that was negotiated.
3336 hw
->fc
.requested_mode
= flow_control
;
3339 * Multiple rings configurations
3341 ixgbe
->num_tx_rings
= ixgbe_get_prop(ixgbe
, PROP_TX_QUEUE_NUM
,
3342 ixgbe
->capab
->min_tx_que_num
,
3343 ixgbe
->capab
->max_tx_que_num
,
3344 ixgbe
->capab
->def_tx_que_num
);
3345 ixgbe
->tx_ring_size
= ixgbe_get_prop(ixgbe
, PROP_TX_RING_SIZE
,
3346 MIN_TX_RING_SIZE
, MAX_TX_RING_SIZE
, DEFAULT_TX_RING_SIZE
);
3348 ixgbe
->num_rx_rings
= ixgbe_get_prop(ixgbe
, PROP_RX_QUEUE_NUM
,
3349 ixgbe
->capab
->min_rx_que_num
,
3350 ixgbe
->capab
->max_rx_que_num
,
3351 ixgbe
->capab
->def_rx_que_num
);
3352 ixgbe
->rx_ring_size
= ixgbe_get_prop(ixgbe
, PROP_RX_RING_SIZE
,
3353 MIN_RX_RING_SIZE
, MAX_RX_RING_SIZE
, DEFAULT_RX_RING_SIZE
);
3356 * Multiple groups configuration
3358 ixgbe
->num_rx_groups
= ixgbe_get_prop(ixgbe
, PROP_RX_GROUP_NUM
,
3359 ixgbe
->capab
->min_rx_grp_num
, ixgbe
->capab
->max_rx_grp_num
,
3360 ixgbe
->capab
->def_rx_grp_num
);
3362 ixgbe
->mr_enable
= ixgbe_get_prop(ixgbe
, PROP_MR_ENABLE
,
3363 0, 1, DEFAULT_MR_ENABLE
);
3365 if (ixgbe
->mr_enable
== B_FALSE
) {
3366 ixgbe
->num_tx_rings
= 1;
3367 ixgbe
->num_rx_rings
= 1;
3368 ixgbe
->num_rx_groups
= 1;
3369 ixgbe
->classify_mode
= IXGBE_CLASSIFY_NONE
;
3371 ixgbe
->num_rx_rings
= ixgbe
->num_rx_groups
*
3372 max(ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
, 1);
3374 * The combination of num_rx_rings and num_rx_groups
3375 * may be not supported by h/w. We need to adjust
3376 * them to appropriate values.
3378 ixgbe_setup_vmdq_rss_conf(ixgbe
);
3382 * Tunable used to force an interrupt type. The only use is
3383 * for testing of the lesser interrupt types.
3384 * 0 = don't force interrupt type
3385 * 1 = force interrupt type MSI-X
3386 * 2 = force interrupt type MSI
3387 * 3 = force interrupt type Legacy
3389 ixgbe
->intr_force
= ixgbe_get_prop(ixgbe
, PROP_INTR_FORCE
,
3390 IXGBE_INTR_NONE
, IXGBE_INTR_LEGACY
, IXGBE_INTR_NONE
);
3392 ixgbe
->tx_hcksum_enable
= ixgbe_get_prop(ixgbe
, PROP_TX_HCKSUM_ENABLE
,
3393 0, 1, DEFAULT_TX_HCKSUM_ENABLE
);
3394 ixgbe
->rx_hcksum_enable
= ixgbe_get_prop(ixgbe
, PROP_RX_HCKSUM_ENABLE
,
3395 0, 1, DEFAULT_RX_HCKSUM_ENABLE
);
3396 ixgbe
->lso_enable
= ixgbe_get_prop(ixgbe
, PROP_LSO_ENABLE
,
3397 0, 1, DEFAULT_LSO_ENABLE
);
3398 ixgbe
->lro_enable
= ixgbe_get_prop(ixgbe
, PROP_LRO_ENABLE
,
3399 0, 1, DEFAULT_LRO_ENABLE
);
3400 ixgbe
->tx_head_wb_enable
= ixgbe_get_prop(ixgbe
, PROP_TX_HEAD_WB_ENABLE
,
3401 0, 1, DEFAULT_TX_HEAD_WB_ENABLE
);
3402 ixgbe
->relax_order_enable
= ixgbe_get_prop(ixgbe
,
3403 PROP_RELAX_ORDER_ENABLE
, 0, 1, DEFAULT_RELAX_ORDER_ENABLE
);
3405 /* Head Write Back not recommended for 82599, X540 and X550 */
3406 if (hw
->mac
.type
== ixgbe_mac_82599EB
||
3407 hw
->mac
.type
== ixgbe_mac_X540
||
3408 hw
->mac
.type
== ixgbe_mac_X550
||
3409 hw
->mac
.type
== ixgbe_mac_X550EM_x
) {
3410 ixgbe
->tx_head_wb_enable
= B_FALSE
;
3414 * ixgbe LSO needs the tx h/w checksum support.
3415 * LSO will be disabled if tx h/w checksum is not
3418 if (ixgbe
->tx_hcksum_enable
== B_FALSE
) {
3419 ixgbe
->lso_enable
= B_FALSE
;
3423 * ixgbe LRO needs the rx h/w checksum support.
3424 * LRO will be disabled if rx h/w checksum is not
3427 if (ixgbe
->rx_hcksum_enable
== B_FALSE
) {
3428 ixgbe
->lro_enable
= B_FALSE
;
3432 * ixgbe LRO only supported by 82599, X540 and X550
3434 if (hw
->mac
.type
== ixgbe_mac_82598EB
) {
3435 ixgbe
->lro_enable
= B_FALSE
;
3437 ixgbe
->tx_copy_thresh
= ixgbe_get_prop(ixgbe
, PROP_TX_COPY_THRESHOLD
,
3438 MIN_TX_COPY_THRESHOLD
, MAX_TX_COPY_THRESHOLD
,
3439 DEFAULT_TX_COPY_THRESHOLD
);
3440 ixgbe
->tx_recycle_thresh
= ixgbe_get_prop(ixgbe
,
3441 PROP_TX_RECYCLE_THRESHOLD
, MIN_TX_RECYCLE_THRESHOLD
,
3442 MAX_TX_RECYCLE_THRESHOLD
, DEFAULT_TX_RECYCLE_THRESHOLD
);
3443 ixgbe
->tx_overload_thresh
= ixgbe_get_prop(ixgbe
,
3444 PROP_TX_OVERLOAD_THRESHOLD
, MIN_TX_OVERLOAD_THRESHOLD
,
3445 MAX_TX_OVERLOAD_THRESHOLD
, DEFAULT_TX_OVERLOAD_THRESHOLD
);
3446 ixgbe
->tx_resched_thresh
= ixgbe_get_prop(ixgbe
,
3447 PROP_TX_RESCHED_THRESHOLD
, MIN_TX_RESCHED_THRESHOLD
,
3448 MAX_TX_RESCHED_THRESHOLD
, DEFAULT_TX_RESCHED_THRESHOLD
);
3450 ixgbe
->rx_copy_thresh
= ixgbe_get_prop(ixgbe
, PROP_RX_COPY_THRESHOLD
,
3451 MIN_RX_COPY_THRESHOLD
, MAX_RX_COPY_THRESHOLD
,
3452 DEFAULT_RX_COPY_THRESHOLD
);
3453 ixgbe
->rx_limit_per_intr
= ixgbe_get_prop(ixgbe
, PROP_RX_LIMIT_PER_INTR
,
3454 MIN_RX_LIMIT_PER_INTR
, MAX_RX_LIMIT_PER_INTR
,
3455 DEFAULT_RX_LIMIT_PER_INTR
);
3457 ixgbe
->intr_throttling
[0] = ixgbe_get_prop(ixgbe
, PROP_INTR_THROTTLING
,
3458 ixgbe
->capab
->min_intr_throttle
,
3459 ixgbe
->capab
->max_intr_throttle
,
3460 ixgbe
->capab
->def_intr_throttle
);
3462 * 82599, X540 and X550 require the interrupt throttling rate is
3463 * a multiple of 8. This is enforced by the register definiton.
3465 if (hw
->mac
.type
== ixgbe_mac_82599EB
||
3466 hw
->mac
.type
== ixgbe_mac_X540
||
3467 hw
->mac
.type
== ixgbe_mac_X550
||
3468 hw
->mac
.type
== ixgbe_mac_X550EM_x
)
3469 ixgbe
->intr_throttling
[0] = ixgbe
->intr_throttling
[0] & 0xFF8;
3471 hw
->allow_unsupported_sfp
= ixgbe_get_prop(ixgbe
,
3472 PROP_ALLOW_UNSUPPORTED_SFP
, 0, 1, DEFAULT_ALLOW_UNSUPPORTED_SFP
);
3476 ixgbe_init_params(ixgbe_t
*ixgbe
)
3478 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3479 ixgbe_link_speed speeds_supported
= 0;
3483 * Get a list of speeds the adapter supports. If the hw struct hasn't
3484 * been populated with this information yet, retrieve it from the
3485 * adapter and save it to our own variable.
3487 * On certain adapters, such as ones which use SFPs, the contents of
3488 * hw->phy.speeds_supported (and hw->phy.autoneg_advertised) are not
3489 * updated, so we must rely on calling ixgbe_get_link_capabilities()
3490 * in order to ascertain the speeds which we are capable of supporting,
3491 * and in the case of SFP-equipped adapters, which speed we are
3492 * advertising. If ixgbe_get_link_capabilities() fails for some reason,
3493 * we'll go with a default list of speeds as a last resort.
3495 speeds_supported
= hw
->phy
.speeds_supported
;
3497 if (speeds_supported
== 0) {
3498 if (ixgbe_get_link_capabilities(hw
, &speeds_supported
,
3499 &negotiate
) != IXGBE_SUCCESS
) {
3500 if (hw
->mac
.type
== ixgbe_mac_82598EB
) {
3502 IXGBE_LINK_SPEED_82598_AUTONEG
;
3505 IXGBE_LINK_SPEED_82599_AUTONEG
;
3509 ixgbe
->speeds_supported
= speeds_supported
;
3512 * By default, all supported speeds are enabled and advertised.
3514 if (speeds_supported
& IXGBE_LINK_SPEED_10GB_FULL
) {
3515 ixgbe
->param_en_10000fdx_cap
= 1;
3516 ixgbe
->param_adv_10000fdx_cap
= 1;
3518 ixgbe
->param_en_10000fdx_cap
= 0;
3519 ixgbe
->param_adv_10000fdx_cap
= 0;
3522 if (speeds_supported
& IXGBE_LINK_SPEED_5GB_FULL
) {
3523 ixgbe
->param_en_5000fdx_cap
= 1;
3524 ixgbe
->param_adv_5000fdx_cap
= 1;
3526 ixgbe
->param_en_5000fdx_cap
= 0;
3527 ixgbe
->param_adv_5000fdx_cap
= 0;
3530 if (speeds_supported
& IXGBE_LINK_SPEED_2_5GB_FULL
) {
3531 ixgbe
->param_en_2500fdx_cap
= 1;
3532 ixgbe
->param_adv_2500fdx_cap
= 1;
3534 ixgbe
->param_en_2500fdx_cap
= 0;
3535 ixgbe
->param_adv_2500fdx_cap
= 0;
3538 if (speeds_supported
& IXGBE_LINK_SPEED_1GB_FULL
) {
3539 ixgbe
->param_en_1000fdx_cap
= 1;
3540 ixgbe
->param_adv_1000fdx_cap
= 1;
3542 ixgbe
->param_en_1000fdx_cap
= 0;
3543 ixgbe
->param_adv_1000fdx_cap
= 0;
3546 if (speeds_supported
& IXGBE_LINK_SPEED_100_FULL
) {
3547 ixgbe
->param_en_100fdx_cap
= 1;
3548 ixgbe
->param_adv_100fdx_cap
= 1;
3550 ixgbe
->param_en_100fdx_cap
= 0;
3551 ixgbe
->param_adv_100fdx_cap
= 0;
3554 ixgbe
->param_pause_cap
= 1;
3555 ixgbe
->param_asym_pause_cap
= 1;
3556 ixgbe
->param_rem_fault
= 0;
3558 ixgbe
->param_adv_autoneg_cap
= 1;
3559 ixgbe
->param_adv_pause_cap
= 1;
3560 ixgbe
->param_adv_asym_pause_cap
= 1;
3561 ixgbe
->param_adv_rem_fault
= 0;
3563 ixgbe
->param_lp_10000fdx_cap
= 0;
3564 ixgbe
->param_lp_5000fdx_cap
= 0;
3565 ixgbe
->param_lp_2500fdx_cap
= 0;
3566 ixgbe
->param_lp_1000fdx_cap
= 0;
3567 ixgbe
->param_lp_100fdx_cap
= 0;
3568 ixgbe
->param_lp_autoneg_cap
= 0;
3569 ixgbe
->param_lp_pause_cap
= 0;
3570 ixgbe
->param_lp_asym_pause_cap
= 0;
3571 ixgbe
->param_lp_rem_fault
= 0;
3575 * ixgbe_get_prop - Get a property value out of the configuration file
3578 * Caller provides the name of the property, a default value, a minimum
3579 * value, and a maximum value.
3581 * Return configured value of the property, with default, minimum and
3582 * maximum properly applied.
3585 ixgbe_get_prop(ixgbe_t
*ixgbe
,
3586 char *propname
, /* name of the property */
3587 int minval
, /* minimum acceptable value */
3588 int maxval
, /* maximim acceptable value */
3589 int defval
) /* default value */
3594 * Call ddi_prop_get_int() to read the conf settings
3596 value
= ddi_prop_get_int(DDI_DEV_T_ANY
, ixgbe
->dip
,
3597 DDI_PROP_DONTPASS
, propname
, defval
);
3608 * ixgbe_driver_setup_link - Using the link properties to setup the link.
3611 ixgbe_driver_setup_link(ixgbe_t
*ixgbe
, bool setup_hw
)
3613 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3614 ixgbe_link_speed advertised
= 0;
3617 * Assemble a list of enabled speeds to auto-negotiate with.
3619 if (ixgbe
->param_en_10000fdx_cap
== 1)
3620 advertised
|= IXGBE_LINK_SPEED_10GB_FULL
;
3622 if (ixgbe
->param_en_5000fdx_cap
== 1)
3623 advertised
|= IXGBE_LINK_SPEED_5GB_FULL
;
3625 if (ixgbe
->param_en_2500fdx_cap
== 1)
3626 advertised
|= IXGBE_LINK_SPEED_2_5GB_FULL
;
3628 if (ixgbe
->param_en_1000fdx_cap
== 1)
3629 advertised
|= IXGBE_LINK_SPEED_1GB_FULL
;
3631 if (ixgbe
->param_en_100fdx_cap
== 1)
3632 advertised
|= IXGBE_LINK_SPEED_100_FULL
;
3635 * As a last resort, autoneg with a default list of speeds.
3637 if (ixgbe
->param_adv_autoneg_cap
== 1 && advertised
== 0) {
3638 ixgbe_notice(ixgbe
, "Invalid link settings. Setting link "
3639 "to autonegotiate with full capabilities.");
3641 if (hw
->mac
.type
== ixgbe_mac_82598EB
)
3642 advertised
= IXGBE_LINK_SPEED_82598_AUTONEG
;
3644 advertised
= IXGBE_LINK_SPEED_82599_AUTONEG
;
3648 if (ixgbe_setup_link(&ixgbe
->hw
, advertised
,
3649 ixgbe
->param_adv_autoneg_cap
) != IXGBE_SUCCESS
) {
3650 ixgbe_notice(ixgbe
, "Setup link failed on this "
3652 return (IXGBE_FAILURE
);
3656 return (IXGBE_SUCCESS
);
3660 * ixgbe_driver_link_check - Link status processing.
3662 * This function can be called in both kernel context and interrupt context
3665 ixgbe_driver_link_check(ixgbe_t
*ixgbe
)
3667 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3668 ixgbe_link_speed speed
= IXGBE_LINK_SPEED_UNKNOWN
;
3669 bool link_up
= B_FALSE
;
3670 bool link_changed
= B_FALSE
;
3672 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
3674 (void) ixgbe_check_link(hw
, &speed
, &link_up
, B_FALSE
);
3676 ixgbe
->link_check_complete
= B_TRUE
;
3678 /* Link is up, enable flow control settings */
3679 (void) ixgbe_fc_enable(hw
);
3682 * The Link is up, check whether it was marked as down earlier
3684 if (ixgbe
->link_state
!= LINK_STATE_UP
) {
3686 case IXGBE_LINK_SPEED_10GB_FULL
:
3687 ixgbe
->link_speed
= SPEED_10GB
;
3689 case IXGBE_LINK_SPEED_5GB_FULL
:
3690 ixgbe
->link_speed
= SPEED_5GB
;
3692 case IXGBE_LINK_SPEED_2_5GB_FULL
:
3693 ixgbe
->link_speed
= SPEED_2_5GB
;
3695 case IXGBE_LINK_SPEED_1GB_FULL
:
3696 ixgbe
->link_speed
= SPEED_1GB
;
3698 case IXGBE_LINK_SPEED_100_FULL
:
3699 ixgbe
->link_speed
= SPEED_100
;
3701 ixgbe
->link_duplex
= LINK_DUPLEX_FULL
;
3702 ixgbe
->link_state
= LINK_STATE_UP
;
3703 link_changed
= B_TRUE
;
3706 if (ixgbe
->link_check_complete
== B_TRUE
||
3707 (ixgbe
->link_check_complete
== B_FALSE
&&
3708 gethrtime() >= ixgbe
->link_check_hrtime
)) {
3710 * The link is really down
3712 ixgbe
->link_check_complete
= B_TRUE
;
3714 if (ixgbe
->link_state
!= LINK_STATE_DOWN
) {
3715 ixgbe
->link_speed
= 0;
3716 ixgbe
->link_duplex
= LINK_DUPLEX_UNKNOWN
;
3717 ixgbe
->link_state
= LINK_STATE_DOWN
;
3718 link_changed
= B_TRUE
;
3724 * If we are in an interrupt context, need to re-enable the
3725 * interrupt, which was automasked
3727 if (servicing_interrupt() != 0) {
3728 ixgbe
->eims
|= IXGBE_EICR_LSC
;
3729 IXGBE_WRITE_REG(hw
, IXGBE_EIMS
, ixgbe
->eims
);
3733 mac_link_update(ixgbe
->mac_hdl
, ixgbe
->link_state
);
3738 * ixgbe_sfp_check - sfp module processing done in taskq only for 82599.
3741 ixgbe_sfp_check(void *arg
)
3743 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
3744 uint32_t eicr
= ixgbe
->eicr
;
3745 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3747 mutex_enter(&ixgbe
->gen_lock
);
3748 if (eicr
& IXGBE_EICR_GPI_SDP1_BY_MAC(hw
)) {
3749 /* clear the interrupt */
3750 IXGBE_WRITE_REG(hw
, IXGBE_EICR
, IXGBE_EICR_GPI_SDP1_BY_MAC(hw
));
3752 /* if link up, do multispeed fiber setup */
3753 (void) ixgbe_setup_link(hw
, IXGBE_LINK_SPEED_82599_AUTONEG
,
3755 ixgbe_driver_link_check(ixgbe
);
3756 ixgbe_get_hw_state(ixgbe
);
3757 } else if (eicr
& IXGBE_EICR_GPI_SDP2_BY_MAC(hw
)) {
3758 /* clear the interrupt */
3759 IXGBE_WRITE_REG(hw
, IXGBE_EICR
, IXGBE_EICR_GPI_SDP2_BY_MAC(hw
));
3761 /* if link up, do sfp module setup */
3762 (void) hw
->mac
.ops
.setup_sfp(hw
);
3764 /* do multispeed fiber setup */
3765 (void) ixgbe_setup_link(hw
, IXGBE_LINK_SPEED_82599_AUTONEG
,
3767 ixgbe_driver_link_check(ixgbe
);
3768 ixgbe_get_hw_state(ixgbe
);
3770 mutex_exit(&ixgbe
->gen_lock
);
3773 * We need to fully re-check the link later.
3775 ixgbe
->link_check_complete
= B_FALSE
;
3776 ixgbe
->link_check_hrtime
= gethrtime() +
3777 (IXGBE_LINK_UP_TIME
* 100000000ULL);
3781 * ixgbe_overtemp_check - overtemp module processing done in taskq
3783 * This routine will only be called on adapters with temperature sensor.
3784 * The indication of over-temperature can be either SDP0 interrupt or the link
3785 * status change interrupt.
3788 ixgbe_overtemp_check(void *arg
)
3790 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
3791 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3792 uint32_t eicr
= ixgbe
->eicr
;
3793 ixgbe_link_speed speed
;
3796 mutex_enter(&ixgbe
->gen_lock
);
3798 /* make sure we know current state of link */
3799 (void) ixgbe_check_link(hw
, &speed
, &link_up
, B_FALSE
);
3801 /* check over-temp condition */
3802 if (((eicr
& IXGBE_EICR_GPI_SDP0_BY_MAC(hw
)) && (!link_up
)) ||
3803 (eicr
& IXGBE_EICR_LSC
)) {
3804 if (hw
->phy
.ops
.check_overtemp(hw
) == IXGBE_ERR_OVERTEMP
) {
3805 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_OVERTEMP
);
3808 * Disable the adapter interrupts
3810 ixgbe_disable_adapter_interrupts(ixgbe
);
3813 * Disable Rx/Tx units
3815 (void) ixgbe_stop_adapter(hw
);
3817 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
3819 "Problem: Network adapter has been stopped "
3820 "because it has overheated");
3822 "Action: Restart the computer. "
3823 "If the problem persists, power off the system "
3824 "and replace the adapter");
3828 /* write to clear the interrupt */
3829 IXGBE_WRITE_REG(hw
, IXGBE_EICR
, eicr
);
3831 mutex_exit(&ixgbe
->gen_lock
);
3835 * ixgbe_phy_check - taskq to process interrupts from an external PHY
3837 * This routine will only be called on adapters with external PHYs
3838 * (such as X550) that may be trying to raise our attention to some event.
3839 * Currently, this is limited to claiming PHY overtemperature and link status
3840 * change (LSC) events, however this may expand to include other things in
3844 ixgbe_phy_check(void *arg
)
3846 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
3847 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
3850 mutex_enter(&ixgbe
->gen_lock
);
3853 * X550 baseT PHY overtemp and LSC events are handled here.
3855 * If an overtemp event occurs, it will be reflected in the
3856 * return value of phy.ops.handle_lasi() and the common code will
3857 * automatically power off the baseT PHY. This is our cue to trigger
3860 * If a link status change event occurs, phy.ops.handle_lasi() will
3861 * automatically initiate a link setup between the integrated KR PHY
3862 * and the external X557 PHY to ensure that the link speed between
3863 * them matches the link speed of the baseT link.
3865 rv
= ixgbe_handle_lasi(hw
);
3867 if (rv
== IXGBE_ERR_OVERTEMP
) {
3868 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_OVERTEMP
);
3871 * Disable the adapter interrupts
3873 ixgbe_disable_adapter_interrupts(ixgbe
);
3876 * Disable Rx/Tx units
3878 (void) ixgbe_stop_adapter(hw
);
3880 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
3882 "Problem: Network adapter has been stopped due to a "
3883 "overtemperature event being detected.");
3885 "Action: Shut down or restart the computer. If the issue "
3886 "persists, please take action in accordance with the "
3887 "recommendations from your system vendor.");
3890 mutex_exit(&ixgbe
->gen_lock
);
3894 * ixgbe_link_timer - timer for link status detection
3897 ixgbe_link_timer(void *arg
)
3899 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
3901 mutex_enter(&ixgbe
->gen_lock
);
3902 ixgbe_driver_link_check(ixgbe
);
3903 mutex_exit(&ixgbe
->gen_lock
);
3907 * ixgbe_local_timer - Driver watchdog function.
3909 * This function will handle the transmit stall check and other routines.
3912 ixgbe_local_timer(void *arg
)
3914 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
3916 if (ixgbe
->ixgbe_state
& IXGBE_OVERTEMP
)
3919 if (ixgbe
->ixgbe_state
& IXGBE_ERROR
) {
3920 ixgbe
->reset_count
++;
3921 if (ixgbe_reset(ixgbe
) == IXGBE_SUCCESS
)
3922 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_RESTORED
);
3926 if (ixgbe_stall_check(ixgbe
)) {
3927 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_STALL
);
3928 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
3930 ixgbe
->reset_count
++;
3931 if (ixgbe_reset(ixgbe
) == IXGBE_SUCCESS
)
3932 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_RESTORED
);
3936 ixgbe_restart_watchdog_timer(ixgbe
);
3940 * ixgbe_stall_check - Check for transmit stall.
3942 * This function checks if the adapter is stalled (in transmit).
3944 * It is called each time the watchdog timeout is invoked.
3945 * If the transmit descriptor reclaim continuously fails,
3946 * the watchdog value will increment by 1. If the watchdog
3947 * value exceeds the threshold, the ixgbe is assumed to
3948 * have stalled and need to be reset.
3951 ixgbe_stall_check(ixgbe_t
*ixgbe
)
3953 ixgbe_tx_ring_t
*tx_ring
;
3957 if (ixgbe
->link_state
!= LINK_STATE_UP
)
3961 * If any tx ring is stalled, we'll reset the chipset
3964 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
3965 tx_ring
= &ixgbe
->tx_rings
[i
];
3966 if (tx_ring
->tbd_free
<= ixgbe
->tx_recycle_thresh
) {
3967 tx_ring
->tx_recycle(tx_ring
);
3970 if (tx_ring
->recycle_fail
> 0)
3971 tx_ring
->stall_watchdog
++;
3973 tx_ring
->stall_watchdog
= 0;
3975 if (tx_ring
->stall_watchdog
>= STALL_WATCHDOG_TIMEOUT
) {
3982 tx_ring
->stall_watchdog
= 0;
3983 tx_ring
->recycle_fail
= 0;
3991 * is_valid_mac_addr - Check if the mac address is valid.
3994 is_valid_mac_addr(uint8_t *mac_addr
)
3996 const uint8_t addr_test1
[6] = { 0, 0, 0, 0, 0, 0 };
3997 const uint8_t addr_test2
[6] =
3998 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
4000 if (!(bcmp(addr_test1
, mac_addr
, ETHERADDRL
)) ||
4001 !(bcmp(addr_test2
, mac_addr
, ETHERADDRL
)))
4008 ixgbe_find_mac_address(ixgbe_t
*ixgbe
)
4010 _NOTE(ARGUNUSED(ixgbe
));
4015 #pragma inline(ixgbe_arm_watchdog_timer)
4017 ixgbe_arm_watchdog_timer(ixgbe_t
*ixgbe
)
4020 * Fire a watchdog timer
4022 ixgbe
->watchdog_tid
=
4023 timeout(ixgbe_local_timer
,
4024 (void *)ixgbe
, 1 * drv_usectohz(1000000));
4029 * ixgbe_enable_watchdog_timer - Enable and start the driver watchdog timer.
4032 ixgbe_enable_watchdog_timer(ixgbe_t
*ixgbe
)
4034 mutex_enter(&ixgbe
->watchdog_lock
);
4036 if (!ixgbe
->watchdog_enable
) {
4037 ixgbe
->watchdog_enable
= B_TRUE
;
4038 ixgbe
->watchdog_start
= B_TRUE
;
4039 ixgbe_arm_watchdog_timer(ixgbe
);
4042 mutex_exit(&ixgbe
->watchdog_lock
);
4046 * ixgbe_disable_watchdog_timer - Disable and stop the driver watchdog timer.
4049 ixgbe_disable_watchdog_timer(ixgbe_t
*ixgbe
)
4053 mutex_enter(&ixgbe
->watchdog_lock
);
4055 ixgbe
->watchdog_enable
= B_FALSE
;
4056 ixgbe
->watchdog_start
= B_FALSE
;
4057 tid
= ixgbe
->watchdog_tid
;
4058 ixgbe
->watchdog_tid
= 0;
4060 mutex_exit(&ixgbe
->watchdog_lock
);
4063 (void) untimeout(tid
);
4067 * ixgbe_start_watchdog_timer - Start the driver watchdog timer.
4070 ixgbe_start_watchdog_timer(ixgbe_t
*ixgbe
)
4072 mutex_enter(&ixgbe
->watchdog_lock
);
4074 if (ixgbe
->watchdog_enable
) {
4075 if (!ixgbe
->watchdog_start
) {
4076 ixgbe
->watchdog_start
= B_TRUE
;
4077 ixgbe_arm_watchdog_timer(ixgbe
);
4081 mutex_exit(&ixgbe
->watchdog_lock
);
4085 * ixgbe_restart_watchdog_timer - Restart the driver watchdog timer.
4088 ixgbe_restart_watchdog_timer(ixgbe_t
*ixgbe
)
4090 mutex_enter(&ixgbe
->watchdog_lock
);
4092 if (ixgbe
->watchdog_start
)
4093 ixgbe_arm_watchdog_timer(ixgbe
);
4095 mutex_exit(&ixgbe
->watchdog_lock
);
4099 * ixgbe_stop_watchdog_timer - Stop the driver watchdog timer.
4102 ixgbe_stop_watchdog_timer(ixgbe_t
*ixgbe
)
4106 mutex_enter(&ixgbe
->watchdog_lock
);
4108 ixgbe
->watchdog_start
= B_FALSE
;
4109 tid
= ixgbe
->watchdog_tid
;
4110 ixgbe
->watchdog_tid
= 0;
4112 mutex_exit(&ixgbe
->watchdog_lock
);
4115 (void) untimeout(tid
);
4119 * ixgbe_disable_adapter_interrupts - Disable all adapter interrupts.
4122 ixgbe_disable_adapter_interrupts(ixgbe_t
*ixgbe
)
4124 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
4127 * mask all interrupts off
4129 IXGBE_WRITE_REG(hw
, IXGBE_EIMC
, 0xffffffff);
4132 * for MSI-X, also disable autoclear
4134 if (ixgbe
->intr_type
== DDI_INTR_TYPE_MSIX
) {
4135 IXGBE_WRITE_REG(hw
, IXGBE_EIAC
, 0x0);
4138 IXGBE_WRITE_FLUSH(hw
);
4142 * ixgbe_enable_adapter_interrupts - Enable all hardware interrupts.
4145 ixgbe_enable_adapter_interrupts(ixgbe_t
*ixgbe
)
4147 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
4148 uint32_t eiac
, eiam
;
4149 uint32_t gpie
= IXGBE_READ_REG(hw
, IXGBE_GPIE
);
4151 /* interrupt types to enable */
4152 ixgbe
->eims
= IXGBE_EIMS_ENABLE_MASK
; /* shared code default */
4153 ixgbe
->eims
&= ~IXGBE_EIMS_TCP_TIMER
; /* minus tcp timer */
4154 ixgbe
->eims
|= ixgbe
->capab
->other_intr
; /* "other" interrupt types */
4156 /* enable automask on "other" causes that this adapter can generate */
4157 eiam
= ixgbe
->capab
->other_intr
;
4162 if (ixgbe
->intr_type
== DDI_INTR_TYPE_MSIX
) {
4163 /* enable autoclear but not on bits 29:20 */
4164 eiac
= (ixgbe
->eims
& ~IXGBE_OTHER_INTR
);
4166 /* general purpose interrupt enable */
4167 gpie
|= (IXGBE_GPIE_MSIX_MODE
4168 | IXGBE_GPIE_PBA_SUPPORT
4170 | IXGBE_GPIE_EIAME
);
4176 /* disable autoclear, leave gpie at default */
4180 * General purpose interrupt enable.
4181 * For 82599, X540 and X550, extended interrupt
4182 * automask enable only in MSI or MSI-X mode
4184 if ((hw
->mac
.type
== ixgbe_mac_82598EB
) ||
4185 (ixgbe
->intr_type
== DDI_INTR_TYPE_MSI
)) {
4186 gpie
|= IXGBE_GPIE_EIAME
;
4190 /* Enable specific "other" interrupt types */
4191 switch (hw
->mac
.type
) {
4192 case ixgbe_mac_82598EB
:
4193 gpie
|= ixgbe
->capab
->other_gpie
;
4196 case ixgbe_mac_82599EB
:
4197 case ixgbe_mac_X540
:
4198 case ixgbe_mac_X550
:
4199 case ixgbe_mac_X550EM_x
:
4200 gpie
|= ixgbe
->capab
->other_gpie
;
4202 /* Enable RSC Delay 8us when LRO enabled */
4203 if (ixgbe
->lro_enable
) {
4204 gpie
|= (1 << IXGBE_GPIE_RSC_DELAY_SHIFT
);
4212 /* write to interrupt control registers */
4213 IXGBE_WRITE_REG(hw
, IXGBE_EIMS
, ixgbe
->eims
);
4214 IXGBE_WRITE_REG(hw
, IXGBE_EIAC
, eiac
);
4215 IXGBE_WRITE_REG(hw
, IXGBE_EIAM
, eiam
);
4216 IXGBE_WRITE_REG(hw
, IXGBE_GPIE
, gpie
);
4217 IXGBE_WRITE_FLUSH(hw
);
4221 * ixgbe_loopback_ioctl - Loopback support.
4224 ixgbe_loopback_ioctl(ixgbe_t
*ixgbe
, struct iocblk
*iocp
, mblk_t
*mp
)
4227 lb_property_t
*lbpp
;
4232 if (mp
->b_cont
== NULL
)
4235 switch (iocp
->ioc_cmd
) {
4239 case LB_GET_INFO_SIZE
:
4240 size
= sizeof (lb_info_sz_t
);
4241 if (iocp
->ioc_count
!= size
)
4244 value
= sizeof (lb_normal
);
4245 value
+= sizeof (lb_mac
);
4246 value
+= sizeof (lb_external
);
4248 lbsp
= (lb_info_sz_t
*)(uintptr_t)mp
->b_cont
->b_rptr
;
4253 value
= sizeof (lb_normal
);
4254 value
+= sizeof (lb_mac
);
4255 value
+= sizeof (lb_external
);
4258 if (iocp
->ioc_count
!= size
)
4262 lbpp
= (lb_property_t
*)(uintptr_t)mp
->b_cont
->b_rptr
;
4264 lbpp
[value
++] = lb_normal
;
4265 lbpp
[value
++] = lb_mac
;
4266 lbpp
[value
++] = lb_external
;
4270 size
= sizeof (uint32_t);
4271 if (iocp
->ioc_count
!= size
)
4274 lbmp
= (uint32_t *)(uintptr_t)mp
->b_cont
->b_rptr
;
4275 *lbmp
= ixgbe
->loopback_mode
;
4280 if (iocp
->ioc_count
!= sizeof (uint32_t))
4283 lbmp
= (uint32_t *)(uintptr_t)mp
->b_cont
->b_rptr
;
4284 if (!ixgbe_set_loopback_mode(ixgbe
, *lbmp
))
4289 iocp
->ioc_count
= size
;
4290 iocp
->ioc_error
= 0;
4292 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
4293 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
4301 * ixgbe_set_loopback_mode - Setup loopback based on the loopback mode.
4304 ixgbe_set_loopback_mode(ixgbe_t
*ixgbe
, uint32_t mode
)
4306 if (mode
== ixgbe
->loopback_mode
)
4309 ixgbe
->loopback_mode
= mode
;
4311 if (mode
== IXGBE_LB_NONE
) {
4315 (void) ixgbe_reset(ixgbe
);
4319 mutex_enter(&ixgbe
->gen_lock
);
4323 mutex_exit(&ixgbe
->gen_lock
);
4326 case IXGBE_LB_EXTERNAL
:
4329 case IXGBE_LB_INTERNAL_MAC
:
4330 ixgbe_set_internal_mac_loopback(ixgbe
);
4334 mutex_exit(&ixgbe
->gen_lock
);
4340 * ixgbe_set_internal_mac_loopback - Set the internal MAC loopback mode.
4343 ixgbe_set_internal_mac_loopback(ixgbe_t
*ixgbe
)
4345 struct ixgbe_hw
*hw
;
4352 * Setup MAC loopback
4354 reg
= IXGBE_READ_REG(&ixgbe
->hw
, IXGBE_HLREG0
);
4355 reg
|= IXGBE_HLREG0_LPBK
;
4356 IXGBE_WRITE_REG(&ixgbe
->hw
, IXGBE_HLREG0
, reg
);
4358 reg
= IXGBE_READ_REG(&ixgbe
->hw
, IXGBE_AUTOC
);
4359 reg
&= ~IXGBE_AUTOC_LMS_MASK
;
4360 IXGBE_WRITE_REG(&ixgbe
->hw
, IXGBE_AUTOC
, reg
);
4363 * Disable Atlas Tx lanes to keep packets in loopback and not on wire
4365 switch (hw
->mac
.type
) {
4366 case ixgbe_mac_82598EB
:
4367 (void) ixgbe_read_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_LPBK
,
4369 atlas
|= IXGBE_ATLAS_PDN_TX_REG_EN
;
4370 (void) ixgbe_write_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_LPBK
,
4373 (void) ixgbe_read_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_10G
,
4375 atlas
|= IXGBE_ATLAS_PDN_TX_10G_QL_ALL
;
4376 (void) ixgbe_write_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_10G
,
4379 (void) ixgbe_read_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_1G
,
4381 atlas
|= IXGBE_ATLAS_PDN_TX_1G_QL_ALL
;
4382 (void) ixgbe_write_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_1G
,
4385 (void) ixgbe_read_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_AN
,
4387 atlas
|= IXGBE_ATLAS_PDN_TX_AN_QL_ALL
;
4388 (void) ixgbe_write_analog_reg8(&ixgbe
->hw
, IXGBE_ATLAS_PDN_AN
,
4392 case ixgbe_mac_82599EB
:
4393 case ixgbe_mac_X540
:
4394 case ixgbe_mac_X550
:
4395 case ixgbe_mac_X550EM_x
:
4396 reg
= IXGBE_READ_REG(&ixgbe
->hw
, IXGBE_AUTOC
);
4397 reg
|= (IXGBE_AUTOC_FLU
|
4398 IXGBE_AUTOC_10G_KX4
);
4399 IXGBE_WRITE_REG(&ixgbe
->hw
, IXGBE_AUTOC
, reg
);
4401 (void) ixgbe_setup_link(&ixgbe
->hw
, IXGBE_LINK_SPEED_10GB_FULL
,
4410 #pragma inline(ixgbe_intr_rx_work)
4412 * ixgbe_intr_rx_work - RX processing of ISR.
4415 ixgbe_intr_rx_work(ixgbe_rx_ring_t
*rx_ring
)
4419 mutex_enter(&rx_ring
->rx_lock
);
4421 mp
= ixgbe_ring_rx(rx_ring
, IXGBE_POLL_NULL
);
4422 mutex_exit(&rx_ring
->rx_lock
);
4425 mac_rx_ring(rx_ring
->ixgbe
->mac_hdl
, rx_ring
->ring_handle
, mp
,
4426 rx_ring
->ring_gen_num
);
4429 #pragma inline(ixgbe_intr_tx_work)
4431 * ixgbe_intr_tx_work - TX processing of ISR.
4434 ixgbe_intr_tx_work(ixgbe_tx_ring_t
*tx_ring
)
4436 ixgbe_t
*ixgbe
= tx_ring
->ixgbe
;
4439 * Recycle the tx descriptors
4441 tx_ring
->tx_recycle(tx_ring
);
4444 * Schedule the re-transmit
4446 if (tx_ring
->reschedule
&&
4447 (tx_ring
->tbd_free
>= ixgbe
->tx_resched_thresh
)) {
4448 tx_ring
->reschedule
= B_FALSE
;
4449 mac_tx_ring_update(tx_ring
->ixgbe
->mac_hdl
,
4450 tx_ring
->ring_handle
);
4451 tx_ring
->stat_reschedule
++;
4455 #pragma inline(ixgbe_intr_other_work)
4457 * ixgbe_intr_other_work - Process interrupt types other than tx/rx
4460 ixgbe_intr_other_work(ixgbe_t
*ixgbe
, uint32_t eicr
)
4462 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
4464 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
4467 * handle link status change
4469 if (eicr
& IXGBE_EICR_LSC
) {
4470 ixgbe_driver_link_check(ixgbe
);
4471 ixgbe_get_hw_state(ixgbe
);
4475 * check for fan failure on adapters with fans
4477 if ((ixgbe
->capab
->flags
& IXGBE_FLAG_FAN_FAIL_CAPABLE
) &&
4478 (eicr
& IXGBE_EICR_GPI_SDP1
)) {
4479 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_OVERTEMP
);
4482 * Disable the adapter interrupts
4484 ixgbe_disable_adapter_interrupts(ixgbe
);
4487 * Disable Rx/Tx units
4489 (void) ixgbe_stop_adapter(&ixgbe
->hw
);
4491 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_LOST
);
4493 "Problem: Network adapter has been stopped "
4494 "because the fan has stopped.\n");
4496 "Action: Replace the adapter.\n");
4498 /* re-enable the interrupt, which was automasked */
4499 ixgbe
->eims
|= IXGBE_EICR_GPI_SDP1
;
4503 * Do SFP check for adapters with hot-plug capability
4505 if ((ixgbe
->capab
->flags
& IXGBE_FLAG_SFP_PLUG_CAPABLE
) &&
4506 ((eicr
& IXGBE_EICR_GPI_SDP1_BY_MAC(hw
)) ||
4507 (eicr
& IXGBE_EICR_GPI_SDP2_BY_MAC(hw
)))) {
4509 if ((ddi_taskq_dispatch(ixgbe
->sfp_taskq
,
4510 ixgbe_sfp_check
, (void *)ixgbe
,
4511 DDI_NOSLEEP
)) != DDI_SUCCESS
) {
4512 ixgbe_log(ixgbe
, "No memory available to dispatch "
4513 "taskq for SFP check");
4518 * Do over-temperature check for adapters with temp sensor
4520 if ((ixgbe
->capab
->flags
& IXGBE_FLAG_TEMP_SENSOR_CAPABLE
) &&
4521 ((eicr
& IXGBE_EICR_GPI_SDP0_BY_MAC(hw
)) ||
4522 (eicr
& IXGBE_EICR_LSC
))) {
4524 if ((ddi_taskq_dispatch(ixgbe
->overtemp_taskq
,
4525 ixgbe_overtemp_check
, (void *)ixgbe
,
4526 DDI_NOSLEEP
)) != DDI_SUCCESS
) {
4527 ixgbe_log(ixgbe
, "No memory available to dispatch "
4528 "taskq for overtemp check");
4533 * Process an external PHY interrupt
4535 if (hw
->device_id
== IXGBE_DEV_ID_X550EM_X_10G_T
&&
4536 (eicr
& IXGBE_EICR_GPI_SDP0_X540
)) {
4538 if ((ddi_taskq_dispatch(ixgbe
->phy_taskq
,
4539 ixgbe_phy_check
, (void *)ixgbe
,
4540 DDI_NOSLEEP
)) != DDI_SUCCESS
) {
4541 ixgbe_log(ixgbe
, "No memory available to dispatch "
4542 "taskq for PHY check");
4548 * ixgbe_intr_legacy - Interrupt handler for legacy interrupts.
4551 ixgbe_intr_legacy(void *arg1
, void *arg2
)
4553 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg1
;
4554 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
4555 ixgbe_tx_ring_t
*tx_ring
;
4556 ixgbe_rx_ring_t
*rx_ring
;
4562 _NOTE(ARGUNUSED(arg2
));
4564 mutex_enter(&ixgbe
->gen_lock
);
4565 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
4566 mutex_exit(&ixgbe
->gen_lock
);
4567 return (DDI_INTR_UNCLAIMED
);
4571 tx_reschedule
= B_FALSE
;
4574 * Any bit set in eicr: claim this interrupt
4576 eicr
= IXGBE_READ_REG(hw
, IXGBE_EICR
);
4578 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
4579 mutex_exit(&ixgbe
->gen_lock
);
4580 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
4581 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_ERROR
);
4582 return (DDI_INTR_CLAIMED
);
4587 * For legacy interrupt, we have only one interrupt,
4588 * so we have only one rx ring and one tx ring enabled.
4590 ASSERT(ixgbe
->num_rx_rings
== 1);
4591 ASSERT(ixgbe
->num_tx_rings
== 1);
4594 * For legacy interrupt, rx rings[0] will use RTxQ[0].
4597 ixgbe
->eimc
|= IXGBE_EICR_RTX_QUEUE
;
4598 IXGBE_WRITE_REG(hw
, IXGBE_EIMC
, ixgbe
->eimc
);
4599 ixgbe
->eims
|= IXGBE_EICR_RTX_QUEUE
;
4601 * Clean the rx descriptors
4603 rx_ring
= &ixgbe
->rx_rings
[0];
4604 mp
= ixgbe_ring_rx(rx_ring
, IXGBE_POLL_NULL
);
4608 * For legacy interrupt, tx rings[0] will use RTxQ[1].
4612 * Recycle the tx descriptors
4614 tx_ring
= &ixgbe
->tx_rings
[0];
4615 tx_ring
->tx_recycle(tx_ring
);
4618 * Schedule the re-transmit
4620 tx_reschedule
= (tx_ring
->reschedule
&&
4621 (tx_ring
->tbd_free
>= ixgbe
->tx_resched_thresh
));
4624 /* any interrupt type other than tx/rx */
4625 if (eicr
& ixgbe
->capab
->other_intr
) {
4626 switch (hw
->mac
.type
) {
4627 case ixgbe_mac_82598EB
:
4628 ixgbe
->eims
&= ~(eicr
& IXGBE_OTHER_INTR
);
4631 case ixgbe_mac_82599EB
:
4632 case ixgbe_mac_X540
:
4633 case ixgbe_mac_X550
:
4634 case ixgbe_mac_X550EM_x
:
4635 ixgbe
->eimc
= IXGBE_82599_OTHER_INTR
;
4636 IXGBE_WRITE_REG(hw
, IXGBE_EIMC
, ixgbe
->eimc
);
4642 ixgbe_intr_other_work(ixgbe
, eicr
);
4643 ixgbe
->eims
&= ~(eicr
& IXGBE_OTHER_INTR
);
4646 mutex_exit(&ixgbe
->gen_lock
);
4648 result
= DDI_INTR_CLAIMED
;
4650 mutex_exit(&ixgbe
->gen_lock
);
4653 * No interrupt cause bits set: don't claim this interrupt.
4655 result
= DDI_INTR_UNCLAIMED
;
4658 /* re-enable the interrupts which were automasked */
4659 IXGBE_WRITE_REG(hw
, IXGBE_EIMS
, ixgbe
->eims
);
4662 * Do the following work outside of the gen_lock
4665 mac_rx_ring(rx_ring
->ixgbe
->mac_hdl
, rx_ring
->ring_handle
, mp
,
4666 rx_ring
->ring_gen_num
);
4669 if (tx_reschedule
) {
4670 tx_ring
->reschedule
= B_FALSE
;
4671 mac_tx_ring_update(ixgbe
->mac_hdl
, tx_ring
->ring_handle
);
4672 tx_ring
->stat_reschedule
++;
4679 * ixgbe_intr_msi - Interrupt handler for MSI.
4682 ixgbe_intr_msi(void *arg1
, void *arg2
)
4684 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg1
;
4685 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
4688 _NOTE(ARGUNUSED(arg2
));
4690 eicr
= IXGBE_READ_REG(hw
, IXGBE_EICR
);
4692 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
4693 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
4694 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_ERROR
);
4695 return (DDI_INTR_CLAIMED
);
4699 * For MSI interrupt, we have only one vector,
4700 * so we have only one rx ring and one tx ring enabled.
4702 ASSERT(ixgbe
->num_rx_rings
== 1);
4703 ASSERT(ixgbe
->num_tx_rings
== 1);
4706 * For MSI interrupt, rx rings[0] will use RTxQ[0].
4709 ixgbe_intr_rx_work(&ixgbe
->rx_rings
[0]);
4713 * For MSI interrupt, tx rings[0] will use RTxQ[1].
4716 ixgbe_intr_tx_work(&ixgbe
->tx_rings
[0]);
4719 /* any interrupt type other than tx/rx */
4720 if (eicr
& ixgbe
->capab
->other_intr
) {
4721 mutex_enter(&ixgbe
->gen_lock
);
4722 switch (hw
->mac
.type
) {
4723 case ixgbe_mac_82598EB
:
4724 ixgbe
->eims
&= ~(eicr
& IXGBE_OTHER_INTR
);
4727 case ixgbe_mac_82599EB
:
4728 case ixgbe_mac_X540
:
4729 case ixgbe_mac_X550
:
4730 case ixgbe_mac_X550EM_x
:
4731 ixgbe
->eimc
= IXGBE_82599_OTHER_INTR
;
4732 IXGBE_WRITE_REG(hw
, IXGBE_EIMC
, ixgbe
->eimc
);
4738 ixgbe_intr_other_work(ixgbe
, eicr
);
4739 ixgbe
->eims
&= ~(eicr
& IXGBE_OTHER_INTR
);
4740 mutex_exit(&ixgbe
->gen_lock
);
4743 /* re-enable the interrupts which were automasked */
4744 IXGBE_WRITE_REG(hw
, IXGBE_EIMS
, ixgbe
->eims
);
4746 return (DDI_INTR_CLAIMED
);
4750 * ixgbe_intr_msix - Interrupt handler for MSI-X.
4753 ixgbe_intr_msix(void *arg1
, void *arg2
)
4755 ixgbe_intr_vector_t
*vect
= (ixgbe_intr_vector_t
*)arg1
;
4756 ixgbe_t
*ixgbe
= vect
->ixgbe
;
4757 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
4761 _NOTE(ARGUNUSED(arg2
));
4764 * Clean each rx ring that has its bit set in the map
4766 r_idx
= bt_getlowbit(vect
->rx_map
, 0, (ixgbe
->num_rx_rings
- 1));
4767 while (r_idx
>= 0) {
4768 ixgbe_intr_rx_work(&ixgbe
->rx_rings
[r_idx
]);
4769 r_idx
= bt_getlowbit(vect
->rx_map
, (r_idx
+ 1),
4770 (ixgbe
->num_rx_rings
- 1));
4774 * Clean each tx ring that has its bit set in the map
4776 r_idx
= bt_getlowbit(vect
->tx_map
, 0, (ixgbe
->num_tx_rings
- 1));
4777 while (r_idx
>= 0) {
4778 ixgbe_intr_tx_work(&ixgbe
->tx_rings
[r_idx
]);
4779 r_idx
= bt_getlowbit(vect
->tx_map
, (r_idx
+ 1),
4780 (ixgbe
->num_tx_rings
- 1));
4785 * Clean other interrupt (link change) that has its bit set in the map
4787 if (BT_TEST(vect
->other_map
, 0) == 1) {
4788 eicr
= IXGBE_READ_REG(hw
, IXGBE_EICR
);
4790 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) !=
4792 ddi_fm_service_impact(ixgbe
->dip
,
4793 DDI_SERVICE_DEGRADED
);
4794 atomic_or_32(&ixgbe
->ixgbe_state
, IXGBE_ERROR
);
4795 return (DDI_INTR_CLAIMED
);
4799 * Check "other" cause bits: any interrupt type other than tx/rx
4801 if (eicr
& ixgbe
->capab
->other_intr
) {
4802 mutex_enter(&ixgbe
->gen_lock
);
4803 switch (hw
->mac
.type
) {
4804 case ixgbe_mac_82598EB
:
4805 ixgbe
->eims
&= ~(eicr
& IXGBE_OTHER_INTR
);
4806 ixgbe_intr_other_work(ixgbe
, eicr
);
4809 case ixgbe_mac_82599EB
:
4810 case ixgbe_mac_X540
:
4811 case ixgbe_mac_X550
:
4812 case ixgbe_mac_X550EM_x
:
4813 ixgbe
->eims
|= IXGBE_EICR_RTX_QUEUE
;
4814 ixgbe_intr_other_work(ixgbe
, eicr
);
4820 mutex_exit(&ixgbe
->gen_lock
);
4823 /* re-enable the interrupts which were automasked */
4824 IXGBE_WRITE_REG(hw
, IXGBE_EIMS
, ixgbe
->eims
);
4827 return (DDI_INTR_CLAIMED
);
4831 * ixgbe_alloc_intrs - Allocate interrupts for the driver.
4833 * Normal sequence is to try MSI-X; if not sucessful, try MSI;
4834 * if not successful, try Legacy.
4835 * ixgbe->intr_force can be used to force sequence to start with
4836 * any of the 3 types.
4837 * If MSI-X is not used, number of tx/rx rings is forced to 1.
4840 ixgbe_alloc_intrs(ixgbe_t
*ixgbe
)
4842 dev_info_t
*devinfo
;
4846 devinfo
= ixgbe
->dip
;
4849 * Get supported interrupt types
4851 rc
= ddi_intr_get_supported_types(devinfo
, &intr_types
);
4853 if (rc
!= DDI_SUCCESS
) {
4855 "Get supported interrupt types failed: %d", rc
);
4856 return (IXGBE_FAILURE
);
4858 IXGBE_DEBUGLOG_1(ixgbe
, "Supported interrupt types: %x", intr_types
);
4860 ixgbe
->intr_type
= 0;
4863 * Install MSI-X interrupts
4865 if ((intr_types
& DDI_INTR_TYPE_MSIX
) &&
4866 (ixgbe
->intr_force
<= IXGBE_INTR_MSIX
)) {
4867 rc
= ixgbe_alloc_intr_handles(ixgbe
, DDI_INTR_TYPE_MSIX
);
4868 if (rc
== IXGBE_SUCCESS
)
4869 return (IXGBE_SUCCESS
);
4872 "Allocate MSI-X failed, trying MSI interrupts...");
4876 * MSI-X not used, force rings and groups to 1
4878 ixgbe
->num_rx_rings
= 1;
4879 ixgbe
->num_rx_groups
= 1;
4880 ixgbe
->num_tx_rings
= 1;
4881 ixgbe
->classify_mode
= IXGBE_CLASSIFY_NONE
;
4883 "MSI-X not used, force rings and groups number to 1");
4886 * Install MSI interrupts
4888 if ((intr_types
& DDI_INTR_TYPE_MSI
) &&
4889 (ixgbe
->intr_force
<= IXGBE_INTR_MSI
)) {
4890 rc
= ixgbe_alloc_intr_handles(ixgbe
, DDI_INTR_TYPE_MSI
);
4891 if (rc
== IXGBE_SUCCESS
)
4892 return (IXGBE_SUCCESS
);
4895 "Allocate MSI failed, trying Legacy interrupts...");
4899 * Install legacy interrupts
4901 if (intr_types
& DDI_INTR_TYPE_FIXED
) {
4903 * Disallow legacy interrupts for X550. X550 has a silicon
4904 * bug which prevents Shared Legacy interrupts from working.
4905 * For details, please reference:
4907 * Intel Ethernet Controller X550 Specification Update rev. 2.1
4908 * May 2016, erratum 22: PCIe Interrupt Status Bit
4910 if (ixgbe
->hw
.mac
.type
== ixgbe_mac_X550
||
4911 ixgbe
->hw
.mac
.type
== ixgbe_mac_X550EM_x
||
4912 ixgbe
->hw
.mac
.type
== ixgbe_mac_X550_vf
||
4913 ixgbe
->hw
.mac
.type
== ixgbe_mac_X550EM_x_vf
) {
4915 "Legacy interrupts are not supported on this "
4916 "adapter. Please use MSI or MSI-X instead.");
4917 return (IXGBE_FAILURE
);
4919 rc
= ixgbe_alloc_intr_handles(ixgbe
, DDI_INTR_TYPE_FIXED
);
4920 if (rc
== IXGBE_SUCCESS
)
4921 return (IXGBE_SUCCESS
);
4924 "Allocate Legacy interrupts failed");
4928 * If none of the 3 types succeeded, return failure
4930 return (IXGBE_FAILURE
);
4934 * ixgbe_alloc_intr_handles - Allocate interrupt handles.
4936 * For legacy and MSI, only 1 handle is needed. For MSI-X,
4937 * if fewer than 2 handles are available, return failure.
4938 * Upon success, this maps the vectors to rx and tx rings for
4942 ixgbe_alloc_intr_handles(ixgbe_t
*ixgbe
, int intr_type
)
4944 dev_info_t
*devinfo
;
4945 int request
, count
, actual
;
4948 uint32_t ring_per_group
;
4950 devinfo
= ixgbe
->dip
;
4952 switch (intr_type
) {
4953 case DDI_INTR_TYPE_FIXED
:
4954 request
= 1; /* Request 1 legacy interrupt handle */
4956 IXGBE_DEBUGLOG_0(ixgbe
, "interrupt type: legacy");
4959 case DDI_INTR_TYPE_MSI
:
4960 request
= 1; /* Request 1 MSI interrupt handle */
4962 IXGBE_DEBUGLOG_0(ixgbe
, "interrupt type: MSI");
4965 case DDI_INTR_TYPE_MSIX
:
4967 * Best number of vectors for the adapter is
4968 * (# rx rings + # tx rings), however we will
4969 * limit the request number.
4971 request
= min(16, ixgbe
->num_rx_rings
+ ixgbe
->num_tx_rings
);
4972 if (request
> ixgbe
->capab
->max_ring_vect
)
4973 request
= ixgbe
->capab
->max_ring_vect
;
4975 IXGBE_DEBUGLOG_0(ixgbe
, "interrupt type: MSI-X");
4980 "invalid call to ixgbe_alloc_intr_handles(): %d\n",
4982 return (IXGBE_FAILURE
);
4984 IXGBE_DEBUGLOG_2(ixgbe
, "interrupt handles requested: %d minimum: %d",
4988 * Get number of supported interrupts
4990 rc
= ddi_intr_get_nintrs(devinfo
, intr_type
, &count
);
4991 if ((rc
!= DDI_SUCCESS
) || (count
< minimum
)) {
4993 "Get interrupt number failed. Return: %d, count: %d",
4995 return (IXGBE_FAILURE
);
4997 IXGBE_DEBUGLOG_1(ixgbe
, "interrupts supported: %d", count
);
5000 ixgbe
->intr_cnt
= 0;
5001 ixgbe
->intr_cnt_max
= 0;
5002 ixgbe
->intr_cnt_min
= 0;
5005 * Allocate an array of interrupt handles
5007 ixgbe
->intr_size
= request
* sizeof (ddi_intr_handle_t
);
5008 ixgbe
->htable
= kmem_alloc(ixgbe
->intr_size
, KM_SLEEP
);
5010 rc
= ddi_intr_alloc(devinfo
, ixgbe
->htable
, intr_type
, 0,
5011 request
, &actual
, DDI_INTR_ALLOC_NORMAL
);
5012 if (rc
!= DDI_SUCCESS
) {
5013 ixgbe_log(ixgbe
, "Allocate interrupts failed. "
5014 "return: %d, request: %d, actual: %d",
5015 rc
, request
, actual
);
5016 goto alloc_handle_fail
;
5018 IXGBE_DEBUGLOG_1(ixgbe
, "interrupts actually allocated: %d", actual
);
5021 * upper/lower limit of interrupts
5023 ixgbe
->intr_cnt
= actual
;
5024 ixgbe
->intr_cnt_max
= request
;
5025 ixgbe
->intr_cnt_min
= minimum
;
5028 * rss number per group should not exceed the rx interrupt number,
5029 * else need to adjust rx ring number.
5031 ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
5032 ASSERT((ixgbe
->num_rx_rings
% ixgbe
->num_rx_groups
) == 0);
5033 if (actual
< ring_per_group
) {
5034 ixgbe
->num_rx_rings
= ixgbe
->num_rx_groups
* actual
;
5035 ixgbe_setup_vmdq_rss_conf(ixgbe
);
5039 * Now we know the actual number of vectors. Here we map the vector
5040 * to other, rx rings and tx ring.
5042 if (actual
< minimum
) {
5043 ixgbe_log(ixgbe
, "Insufficient interrupt handles available: %d",
5045 goto alloc_handle_fail
;
5049 * Get priority for first vector, assume remaining are all the same
5051 rc
= ddi_intr_get_pri(ixgbe
->htable
[0], &ixgbe
->intr_pri
);
5052 if (rc
!= DDI_SUCCESS
) {
5054 "Get interrupt priority failed: %d", rc
);
5055 goto alloc_handle_fail
;
5058 rc
= ddi_intr_get_cap(ixgbe
->htable
[0], &ixgbe
->intr_cap
);
5059 if (rc
!= DDI_SUCCESS
) {
5061 "Get interrupt cap failed: %d", rc
);
5062 goto alloc_handle_fail
;
5065 ixgbe
->intr_type
= intr_type
;
5067 return (IXGBE_SUCCESS
);
5070 ixgbe_rem_intrs(ixgbe
);
5072 return (IXGBE_FAILURE
);
5076 * ixgbe_add_intr_handlers - Add interrupt handlers based on the interrupt type.
5078 * Before adding the interrupt handlers, the interrupt vectors have
5079 * been allocated, and the rx/tx rings have also been allocated.
5082 ixgbe_add_intr_handlers(ixgbe_t
*ixgbe
)
5087 switch (ixgbe
->intr_type
) {
5088 case DDI_INTR_TYPE_MSIX
:
5090 * Add interrupt handler for all vectors
5092 for (vector
= 0; vector
< ixgbe
->intr_cnt
; vector
++) {
5094 * install pointer to vect_map[vector]
5096 rc
= ddi_intr_add_handler(ixgbe
->htable
[vector
],
5097 (ddi_intr_handler_t
*)ixgbe_intr_msix
,
5098 (void *)&ixgbe
->vect_map
[vector
], NULL
);
5100 if (rc
!= DDI_SUCCESS
) {
5102 "Add interrupt handler failed. "
5103 "return: %d, vector: %d", rc
, vector
);
5104 for (vector
--; vector
>= 0; vector
--) {
5105 (void) ddi_intr_remove_handler(
5106 ixgbe
->htable
[vector
]);
5108 return (IXGBE_FAILURE
);
5114 case DDI_INTR_TYPE_MSI
:
5116 * Add interrupt handlers for the only vector
5118 rc
= ddi_intr_add_handler(ixgbe
->htable
[vector
],
5119 (ddi_intr_handler_t
*)ixgbe_intr_msi
,
5120 (void *)ixgbe
, NULL
);
5122 if (rc
!= DDI_SUCCESS
) {
5124 "Add MSI interrupt handler failed: %d", rc
);
5125 return (IXGBE_FAILURE
);
5130 case DDI_INTR_TYPE_FIXED
:
5132 * Add interrupt handlers for the only vector
5134 rc
= ddi_intr_add_handler(ixgbe
->htable
[vector
],
5135 (ddi_intr_handler_t
*)ixgbe_intr_legacy
,
5136 (void *)ixgbe
, NULL
);
5138 if (rc
!= DDI_SUCCESS
) {
5140 "Add legacy interrupt handler failed: %d", rc
);
5141 return (IXGBE_FAILURE
);
5147 return (IXGBE_FAILURE
);
5150 return (IXGBE_SUCCESS
);
5153 #pragma inline(ixgbe_map_rxring_to_vector)
5155 * ixgbe_map_rxring_to_vector - Map given rx ring to given interrupt vector.
5158 ixgbe_map_rxring_to_vector(ixgbe_t
*ixgbe
, int r_idx
, int v_idx
)
5163 BT_SET(ixgbe
->vect_map
[v_idx
].rx_map
, r_idx
);
5168 ixgbe
->vect_map
[v_idx
].rxr_cnt
++;
5171 * Remember bit position
5173 ixgbe
->rx_rings
[r_idx
].intr_vector
= v_idx
;
5174 ixgbe
->rx_rings
[r_idx
].vect_bit
= 1 << v_idx
;
5177 #pragma inline(ixgbe_map_txring_to_vector)
5179 * ixgbe_map_txring_to_vector - Map given tx ring to given interrupt vector.
5182 ixgbe_map_txring_to_vector(ixgbe_t
*ixgbe
, int t_idx
, int v_idx
)
5187 BT_SET(ixgbe
->vect_map
[v_idx
].tx_map
, t_idx
);
5192 ixgbe
->vect_map
[v_idx
].txr_cnt
++;
5195 * Remember bit position
5197 ixgbe
->tx_rings
[t_idx
].intr_vector
= v_idx
;
5198 ixgbe
->tx_rings
[t_idx
].vect_bit
= 1 << v_idx
;
5202 * ixgbe_setup_ivar - Set the given entry in the given interrupt vector
5203 * allocation register (IVAR).
5210 ixgbe_setup_ivar(ixgbe_t
*ixgbe
, uint16_t intr_alloc_entry
, uint8_t msix_vector
,
5213 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
5216 switch (hw
->mac
.type
) {
5217 case ixgbe_mac_82598EB
:
5218 msix_vector
|= IXGBE_IVAR_ALLOC_VAL
;
5222 index
= (((cause
* 64) + intr_alloc_entry
) >> 2) & 0x1F;
5223 ivar
= IXGBE_READ_REG(hw
, IXGBE_IVAR(index
));
5224 ivar
&= ~(0xFF << (8 * (intr_alloc_entry
& 0x3)));
5225 ivar
|= (msix_vector
<< (8 * (intr_alloc_entry
& 0x3)));
5226 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(index
), ivar
);
5229 case ixgbe_mac_82599EB
:
5230 case ixgbe_mac_X540
:
5231 case ixgbe_mac_X550
:
5232 case ixgbe_mac_X550EM_x
:
5235 msix_vector
|= IXGBE_IVAR_ALLOC_VAL
;
5236 index
= (intr_alloc_entry
& 1) * 8;
5237 ivar
= IXGBE_READ_REG(hw
, IXGBE_IVAR_MISC
);
5238 ivar
&= ~(0xFF << index
);
5239 ivar
|= (msix_vector
<< index
);
5240 IXGBE_WRITE_REG(hw
, IXGBE_IVAR_MISC
, ivar
);
5242 /* tx or rx causes */
5243 msix_vector
|= IXGBE_IVAR_ALLOC_VAL
;
5244 index
= ((16 * (intr_alloc_entry
& 1)) + (8 * cause
));
5245 ivar
= IXGBE_READ_REG(hw
,
5246 IXGBE_IVAR(intr_alloc_entry
>> 1));
5247 ivar
&= ~(0xFF << index
);
5248 ivar
|= (msix_vector
<< index
);
5249 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(intr_alloc_entry
>> 1),
5260 * ixgbe_enable_ivar - Enable the given entry by setting the VAL bit of
5261 * given interrupt vector allocation register (IVAR).
5268 ixgbe_enable_ivar(ixgbe_t
*ixgbe
, uint16_t intr_alloc_entry
, int8_t cause
)
5270 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
5273 switch (hw
->mac
.type
) {
5274 case ixgbe_mac_82598EB
:
5278 index
= (((cause
* 64) + intr_alloc_entry
) >> 2) & 0x1F;
5279 ivar
= IXGBE_READ_REG(hw
, IXGBE_IVAR(index
));
5280 ivar
|= (IXGBE_IVAR_ALLOC_VAL
<< (8 *
5281 (intr_alloc_entry
& 0x3)));
5282 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(index
), ivar
);
5285 case ixgbe_mac_82599EB
:
5286 case ixgbe_mac_X540
:
5287 case ixgbe_mac_X550
:
5288 case ixgbe_mac_X550EM_x
:
5291 index
= (intr_alloc_entry
& 1) * 8;
5292 ivar
= IXGBE_READ_REG(hw
, IXGBE_IVAR_MISC
);
5293 ivar
|= (IXGBE_IVAR_ALLOC_VAL
<< index
);
5294 IXGBE_WRITE_REG(hw
, IXGBE_IVAR_MISC
, ivar
);
5296 /* tx or rx causes */
5297 index
= ((16 * (intr_alloc_entry
& 1)) + (8 * cause
));
5298 ivar
= IXGBE_READ_REG(hw
,
5299 IXGBE_IVAR(intr_alloc_entry
>> 1));
5300 ivar
|= (IXGBE_IVAR_ALLOC_VAL
<< index
);
5301 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(intr_alloc_entry
>> 1),
5312 * ixgbe_disable_ivar - Disble the given entry by clearing the VAL bit of
5313 * given interrupt vector allocation register (IVAR).
5320 ixgbe_disable_ivar(ixgbe_t
*ixgbe
, uint16_t intr_alloc_entry
, int8_t cause
)
5322 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
5325 switch (hw
->mac
.type
) {
5326 case ixgbe_mac_82598EB
:
5330 index
= (((cause
* 64) + intr_alloc_entry
) >> 2) & 0x1F;
5331 ivar
= IXGBE_READ_REG(hw
, IXGBE_IVAR(index
));
5332 ivar
&= ~(IXGBE_IVAR_ALLOC_VAL
<< (8 *
5333 (intr_alloc_entry
& 0x3)));
5334 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(index
), ivar
);
5337 case ixgbe_mac_82599EB
:
5338 case ixgbe_mac_X540
:
5339 case ixgbe_mac_X550
:
5340 case ixgbe_mac_X550EM_x
:
5343 index
= (intr_alloc_entry
& 1) * 8;
5344 ivar
= IXGBE_READ_REG(hw
, IXGBE_IVAR_MISC
);
5345 ivar
&= ~(IXGBE_IVAR_ALLOC_VAL
<< index
);
5346 IXGBE_WRITE_REG(hw
, IXGBE_IVAR_MISC
, ivar
);
5348 /* tx or rx causes */
5349 index
= ((16 * (intr_alloc_entry
& 1)) + (8 * cause
));
5350 ivar
= IXGBE_READ_REG(hw
,
5351 IXGBE_IVAR(intr_alloc_entry
>> 1));
5352 ivar
&= ~(IXGBE_IVAR_ALLOC_VAL
<< index
);
5353 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(intr_alloc_entry
>> 1),
5364 * Convert the rx ring index driver maintained to the rx ring index
5368 ixgbe_get_hw_rx_index(ixgbe_t
*ixgbe
, uint32_t sw_rx_index
)
5371 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
5372 uint32_t rx_ring_per_group
, hw_rx_index
;
5374 if (ixgbe
->classify_mode
== IXGBE_CLASSIFY_RSS
||
5375 ixgbe
->classify_mode
== IXGBE_CLASSIFY_NONE
) {
5376 return (sw_rx_index
);
5377 } else if (ixgbe
->classify_mode
== IXGBE_CLASSIFY_VMDQ
) {
5378 switch (hw
->mac
.type
) {
5379 case ixgbe_mac_82598EB
:
5380 return (sw_rx_index
);
5382 case ixgbe_mac_82599EB
:
5383 case ixgbe_mac_X540
:
5384 case ixgbe_mac_X550
:
5385 case ixgbe_mac_X550EM_x
:
5386 return (sw_rx_index
* 2);
5391 } else if (ixgbe
->classify_mode
== IXGBE_CLASSIFY_VMDQ_RSS
) {
5392 rx_ring_per_group
= ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
;
5394 switch (hw
->mac
.type
) {
5395 case ixgbe_mac_82598EB
:
5396 hw_rx_index
= (sw_rx_index
/ rx_ring_per_group
) *
5397 16 + (sw_rx_index
% rx_ring_per_group
);
5398 return (hw_rx_index
);
5400 case ixgbe_mac_82599EB
:
5401 case ixgbe_mac_X540
:
5402 case ixgbe_mac_X550
:
5403 case ixgbe_mac_X550EM_x
:
5404 if (ixgbe
->num_rx_groups
> 32) {
5405 hw_rx_index
= (sw_rx_index
/
5406 rx_ring_per_group
) * 2 +
5407 (sw_rx_index
% rx_ring_per_group
);
5409 hw_rx_index
= (sw_rx_index
/
5410 rx_ring_per_group
) * 4 +
5411 (sw_rx_index
% rx_ring_per_group
);
5413 return (hw_rx_index
);
5421 * Should never reach. Just to make compiler happy.
5423 return (sw_rx_index
);
5427 * ixgbe_map_intrs_to_vectors - Map different interrupts to MSI-X vectors.
5429 * For MSI-X, here will map rx interrupt, tx interrupt and other interrupt
5430 * to vector[0 - (intr_cnt -1)].
5433 ixgbe_map_intrs_to_vectors(ixgbe_t
*ixgbe
)
5437 /* initialize vector map */
5438 bzero(&ixgbe
->vect_map
, sizeof (ixgbe
->vect_map
));
5439 for (i
= 0; i
< ixgbe
->intr_cnt
; i
++) {
5440 ixgbe
->vect_map
[i
].ixgbe
= ixgbe
;
5444 * non-MSI-X case is very simple: rx rings[0] on RTxQ[0],
5445 * tx rings[0] on RTxQ[1].
5447 if (ixgbe
->intr_type
!= DDI_INTR_TYPE_MSIX
) {
5448 ixgbe_map_rxring_to_vector(ixgbe
, 0, 0);
5449 ixgbe_map_txring_to_vector(ixgbe
, 0, 1);
5450 return (IXGBE_SUCCESS
);
5454 * Interrupts/vectors mapping for MSI-X
5458 * Map other interrupt to vector 0,
5459 * Set bit in map and count the bits set.
5461 BT_SET(ixgbe
->vect_map
[vector
].other_map
, 0);
5462 ixgbe
->vect_map
[vector
].other_cnt
++;
5465 * Map rx ring interrupts to vectors
5467 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
5468 ixgbe_map_rxring_to_vector(ixgbe
, i
, vector
);
5469 vector
= (vector
+1) % ixgbe
->intr_cnt
;
5473 * Map tx ring interrupts to vectors
5475 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
5476 ixgbe_map_txring_to_vector(ixgbe
, i
, vector
);
5477 vector
= (vector
+1) % ixgbe
->intr_cnt
;
5480 return (IXGBE_SUCCESS
);
5484 * ixgbe_setup_adapter_vector - Setup the adapter interrupt vector(s).
5486 * This relies on ring/vector mapping already set up in the
5487 * vect_map[] structures
5490 ixgbe_setup_adapter_vector(ixgbe_t
*ixgbe
)
5492 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
5493 ixgbe_intr_vector_t
*vect
; /* vector bitmap */
5494 int r_idx
; /* ring index */
5495 int v_idx
; /* vector index */
5499 * Clear any previous entries
5501 switch (hw
->mac
.type
) {
5502 case ixgbe_mac_82598EB
:
5503 for (v_idx
= 0; v_idx
< 25; v_idx
++)
5504 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(v_idx
), 0);
5507 case ixgbe_mac_82599EB
:
5508 case ixgbe_mac_X540
:
5509 case ixgbe_mac_X550
:
5510 case ixgbe_mac_X550EM_x
:
5511 for (v_idx
= 0; v_idx
< 64; v_idx
++)
5512 IXGBE_WRITE_REG(hw
, IXGBE_IVAR(v_idx
), 0);
5513 IXGBE_WRITE_REG(hw
, IXGBE_IVAR_MISC
, 0);
5521 * For non MSI-X interrupt, rx rings[0] will use RTxQ[0], and
5522 * tx rings[0] will use RTxQ[1].
5524 if (ixgbe
->intr_type
!= DDI_INTR_TYPE_MSIX
) {
5525 ixgbe_setup_ivar(ixgbe
, 0, 0, 0);
5526 ixgbe_setup_ivar(ixgbe
, 0, 1, 1);
5531 * For MSI-X interrupt, "Other" is always on vector[0].
5533 ixgbe_setup_ivar(ixgbe
, IXGBE_IVAR_OTHER_CAUSES_INDEX
, 0, -1);
5536 * For each interrupt vector, populate the IVAR table
5538 for (v_idx
= 0; v_idx
< ixgbe
->intr_cnt
; v_idx
++) {
5539 vect
= &ixgbe
->vect_map
[v_idx
];
5542 * For each rx ring bit set
5544 r_idx
= bt_getlowbit(vect
->rx_map
, 0,
5545 (ixgbe
->num_rx_rings
- 1));
5547 while (r_idx
>= 0) {
5548 hw_index
= ixgbe
->rx_rings
[r_idx
].hw_index
;
5549 ixgbe_setup_ivar(ixgbe
, hw_index
, v_idx
, 0);
5550 r_idx
= bt_getlowbit(vect
->rx_map
, (r_idx
+ 1),
5551 (ixgbe
->num_rx_rings
- 1));
5555 * For each tx ring bit set
5557 r_idx
= bt_getlowbit(vect
->tx_map
, 0,
5558 (ixgbe
->num_tx_rings
- 1));
5560 while (r_idx
>= 0) {
5561 ixgbe_setup_ivar(ixgbe
, r_idx
, v_idx
, 1);
5562 r_idx
= bt_getlowbit(vect
->tx_map
, (r_idx
+ 1),
5563 (ixgbe
->num_tx_rings
- 1));
5569 * ixgbe_rem_intr_handlers - Remove the interrupt handlers.
5572 ixgbe_rem_intr_handlers(ixgbe_t
*ixgbe
)
5577 for (i
= 0; i
< ixgbe
->intr_cnt
; i
++) {
5578 rc
= ddi_intr_remove_handler(ixgbe
->htable
[i
]);
5579 if (rc
!= DDI_SUCCESS
) {
5580 IXGBE_DEBUGLOG_1(ixgbe
,
5581 "Remove intr handler failed: %d", rc
);
5587 * ixgbe_rem_intrs - Remove the allocated interrupts.
5590 ixgbe_rem_intrs(ixgbe_t
*ixgbe
)
5595 for (i
= 0; i
< ixgbe
->intr_cnt
; i
++) {
5596 rc
= ddi_intr_free(ixgbe
->htable
[i
]);
5597 if (rc
!= DDI_SUCCESS
) {
5598 IXGBE_DEBUGLOG_1(ixgbe
,
5599 "Free intr failed: %d", rc
);
5603 kmem_free(ixgbe
->htable
, ixgbe
->intr_size
);
5604 ixgbe
->htable
= NULL
;
5608 * ixgbe_enable_intrs - Enable all the ddi interrupts.
5611 ixgbe_enable_intrs(ixgbe_t
*ixgbe
)
5619 if (ixgbe
->intr_cap
& DDI_INTR_FLAG_BLOCK
) {
5621 * Call ddi_intr_block_enable() for MSI
5623 rc
= ddi_intr_block_enable(ixgbe
->htable
, ixgbe
->intr_cnt
);
5624 if (rc
!= DDI_SUCCESS
) {
5626 "Enable block intr failed: %d", rc
);
5627 return (IXGBE_FAILURE
);
5631 * Call ddi_intr_enable() for Legacy/MSI non block enable
5633 for (i
= 0; i
< ixgbe
->intr_cnt
; i
++) {
5634 rc
= ddi_intr_enable(ixgbe
->htable
[i
]);
5635 if (rc
!= DDI_SUCCESS
) {
5637 "Enable intr failed: %d", rc
);
5638 return (IXGBE_FAILURE
);
5643 return (IXGBE_SUCCESS
);
5647 * ixgbe_disable_intrs - Disable all the interrupts.
5650 ixgbe_disable_intrs(ixgbe_t
*ixgbe
)
5656 * Disable all interrupts
5658 if (ixgbe
->intr_cap
& DDI_INTR_FLAG_BLOCK
) {
5659 rc
= ddi_intr_block_disable(ixgbe
->htable
, ixgbe
->intr_cnt
);
5660 if (rc
!= DDI_SUCCESS
) {
5662 "Disable block intr failed: %d", rc
);
5663 return (IXGBE_FAILURE
);
5666 for (i
= 0; i
< ixgbe
->intr_cnt
; i
++) {
5667 rc
= ddi_intr_disable(ixgbe
->htable
[i
]);
5668 if (rc
!= DDI_SUCCESS
) {
5670 "Disable intr failed: %d", rc
);
5671 return (IXGBE_FAILURE
);
5676 return (IXGBE_SUCCESS
);
5680 * ixgbe_get_hw_state - Get and save parameters related to adapter hardware.
5683 ixgbe_get_hw_state(ixgbe_t
*ixgbe
)
5685 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
5686 ixgbe_link_speed speed
= 0;
5687 bool link_up
= B_FALSE
;
5688 uint32_t pcs1g_anlp
= 0;
5690 ASSERT(mutex_owned(&ixgbe
->gen_lock
));
5691 ixgbe
->param_lp_1000fdx_cap
= 0;
5692 ixgbe
->param_lp_100fdx_cap
= 0;
5694 /* check for link, don't wait */
5695 (void) ixgbe_check_link(hw
, &speed
, &link_up
, B_FALSE
);
5698 * Update the observed Link Partner's capabilities. Not all adapters
5699 * can provide full information on the LP's capable speeds, so we
5700 * provide what we can.
5703 pcs1g_anlp
= IXGBE_READ_REG(hw
, IXGBE_PCS1GANLP
);
5705 ixgbe
->param_lp_1000fdx_cap
=
5706 (pcs1g_anlp
& IXGBE_PCS1GANLP_LPFD
) ? 1 : 0;
5707 ixgbe
->param_lp_100fdx_cap
=
5708 (pcs1g_anlp
& IXGBE_PCS1GANLP_LPFD
) ? 1 : 0;
5712 * Update GLD's notion of the adapter's currently advertised speeds.
5713 * Since the common code doesn't always record the current autonegotiate
5714 * settings in the phy struct for all parts (specifically, adapters with
5715 * SFPs) we first test to see if it is 0, and if so, we fall back to
5716 * using the adapter's speed capabilities which we saved during instance
5717 * init in ixgbe_init_params().
5719 * Adapters with SFPs will always be shown as advertising all of their
5720 * supported speeds, and adapters with baseT PHYs (where the phy struct
5721 * is maintained by the common code) will always have a factual view of
5722 * their currently-advertised speeds. In the case of SFPs, this is
5723 * acceptable as we default to advertising all speeds that the adapter
5724 * claims to support, and those properties are immutable; unlike on
5725 * baseT (copper) PHYs, where speeds can be enabled or disabled at will.
5727 speed
= hw
->phy
.autoneg_advertised
;
5729 speed
= ixgbe
->speeds_supported
;
5731 ixgbe
->param_adv_10000fdx_cap
=
5732 (speed
& IXGBE_LINK_SPEED_10GB_FULL
) ? 1 : 0;
5733 ixgbe
->param_adv_5000fdx_cap
=
5734 (speed
& IXGBE_LINK_SPEED_5GB_FULL
) ? 1 : 0;
5735 ixgbe
->param_adv_2500fdx_cap
=
5736 (speed
& IXGBE_LINK_SPEED_2_5GB_FULL
) ? 1 : 0;
5737 ixgbe
->param_adv_1000fdx_cap
=
5738 (speed
& IXGBE_LINK_SPEED_1GB_FULL
) ? 1 : 0;
5739 ixgbe
->param_adv_100fdx_cap
=
5740 (speed
& IXGBE_LINK_SPEED_100_FULL
) ? 1 : 0;
5744 * ixgbe_get_driver_control - Notify that driver is in control of device.
5747 ixgbe_get_driver_control(struct ixgbe_hw
*hw
)
5752 * Notify firmware that driver is in control of device
5754 ctrl_ext
= IXGBE_READ_REG(hw
, IXGBE_CTRL_EXT
);
5755 ctrl_ext
|= IXGBE_CTRL_EXT_DRV_LOAD
;
5756 IXGBE_WRITE_REG(hw
, IXGBE_CTRL_EXT
, ctrl_ext
);
5760 * ixgbe_release_driver_control - Notify that driver is no longer in control
5764 ixgbe_release_driver_control(struct ixgbe_hw
*hw
)
5769 * Notify firmware that driver is no longer in control of device
5771 ctrl_ext
= IXGBE_READ_REG(hw
, IXGBE_CTRL_EXT
);
5772 ctrl_ext
&= ~IXGBE_CTRL_EXT_DRV_LOAD
;
5773 IXGBE_WRITE_REG(hw
, IXGBE_CTRL_EXT
, ctrl_ext
);
5777 * ixgbe_atomic_reserve - Atomic decrease operation.
5780 ixgbe_atomic_reserve(uint32_t *count_p
, uint32_t n
)
5792 newval
= oldval
- n
;
5793 } while (atomic_cas_32(count_p
, oldval
, newval
) != oldval
);
5799 * ixgbe_mc_table_itr - Traverse the entries in the multicast table.
5802 ixgbe_mc_table_itr(struct ixgbe_hw
*hw
, uint8_t **upd_ptr
, uint32_t *vmdq
)
5804 uint8_t *addr
= *upd_ptr
;
5807 _NOTE(ARGUNUSED(hw
));
5808 _NOTE(ARGUNUSED(vmdq
));
5810 new_ptr
= addr
+ IXGBE_ETH_LENGTH_OF_ADDRESS
;
5819 ixgbe_check_acc_handle(ddi_acc_handle_t handle
)
5823 ddi_fm_acc_err_get(handle
, &de
, DDI_FME_VERSION
);
5824 ddi_fm_acc_err_clear(handle
, DDI_FME_VERSION
);
5825 return (de
.fme_status
);
5829 ixgbe_check_dma_handle(ddi_dma_handle_t handle
)
5833 ddi_fm_dma_err_get(handle
, &de
, DDI_FME_VERSION
);
5834 return (de
.fme_status
);
5838 * ixgbe_fm_error_cb - The IO fault service error handling callback function.
5841 ixgbe_fm_error_cb(dev_info_t
*dip
, ddi_fm_error_t
*err
, const void *impl_data
)
5843 _NOTE(ARGUNUSED(impl_data
));
5845 * as the driver can always deal with an error in any dma or
5846 * access handle, we can just return the fme_status value.
5848 pci_ereport_post(dip
, err
, NULL
);
5849 return (err
->fme_status
);
5853 ixgbe_fm_init(ixgbe_t
*ixgbe
)
5855 ddi_iblock_cookie_t iblk
;
5859 * Only register with IO Fault Services if we have some capability
5861 if (ixgbe
->fm_capabilities
& DDI_FM_ACCCHK_CAPABLE
) {
5862 ixgbe_regs_acc_attr
.devacc_attr_access
= DDI_FLAGERR_ACC
;
5864 ixgbe_regs_acc_attr
.devacc_attr_access
= DDI_DEFAULT_ACC
;
5867 if (ixgbe
->fm_capabilities
& DDI_FM_DMACHK_CAPABLE
) {
5873 ixgbe_set_fma_flags(fma_dma_flag
);
5875 if (ixgbe
->fm_capabilities
) {
5878 * Register capabilities with IO Fault Services
5880 ddi_fm_init(ixgbe
->dip
, &ixgbe
->fm_capabilities
, &iblk
);
5883 * Initialize pci ereport capabilities if ereport capable
5885 if (DDI_FM_EREPORT_CAP(ixgbe
->fm_capabilities
) ||
5886 DDI_FM_ERRCB_CAP(ixgbe
->fm_capabilities
))
5887 pci_ereport_setup(ixgbe
->dip
);
5890 * Register error callback if error callback capable
5892 if (DDI_FM_ERRCB_CAP(ixgbe
->fm_capabilities
))
5893 ddi_fm_handler_register(ixgbe
->dip
,
5894 ixgbe_fm_error_cb
, (void*) ixgbe
);
5899 ixgbe_fm_fini(ixgbe_t
*ixgbe
)
5902 * Only unregister FMA capabilities if they are registered
5904 if (ixgbe
->fm_capabilities
) {
5907 * Release any resources allocated by pci_ereport_setup()
5909 if (DDI_FM_EREPORT_CAP(ixgbe
->fm_capabilities
) ||
5910 DDI_FM_ERRCB_CAP(ixgbe
->fm_capabilities
))
5911 pci_ereport_teardown(ixgbe
->dip
);
5914 * Un-register error callback if error callback capable
5916 if (DDI_FM_ERRCB_CAP(ixgbe
->fm_capabilities
))
5917 ddi_fm_handler_unregister(ixgbe
->dip
);
5920 * Unregister from IO Fault Service
5922 ddi_fm_fini(ixgbe
->dip
);
5927 ixgbe_fm_ereport(ixgbe_t
*ixgbe
, char *detail
)
5930 char buf
[FM_MAX_CLASS
];
5932 (void) snprintf(buf
, FM_MAX_CLASS
, "%s.%s", DDI_FM_DEVICE
, detail
);
5933 ena
= fm_ena_generate(0, FM_ENA_FMT1
);
5934 if (DDI_FM_EREPORT_CAP(ixgbe
->fm_capabilities
)) {
5935 ddi_fm_ereport_post(ixgbe
->dip
, buf
, ena
, DDI_NOSLEEP
,
5936 FM_VERSION
, DATA_TYPE_UINT8
, FM_EREPORT_VERS0
, NULL
);
5941 ixgbe_ring_start(mac_ring_driver_t rh
, uint64_t mr_gen_num
)
5943 ixgbe_rx_ring_t
*rx_ring
= (ixgbe_rx_ring_t
*)rh
;
5945 mutex_enter(&rx_ring
->rx_lock
);
5946 rx_ring
->ring_gen_num
= mr_gen_num
;
5947 mutex_exit(&rx_ring
->rx_lock
);
5952 * Get the global ring index by a ring index within a group.
5955 ixgbe_get_rx_ring_index(ixgbe_t
*ixgbe
, int gindex
, int rindex
)
5957 ixgbe_rx_ring_t
*rx_ring
;
5960 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
5961 rx_ring
= &ixgbe
->rx_rings
[i
];
5962 if (rx_ring
->group_index
== gindex
)
5972 * Callback funtion for MAC layer to register all rings.
5976 ixgbe_fill_ring(void *arg
, mac_ring_type_t rtype
, const int group_index
,
5977 const int ring_index
, mac_ring_info_t
*infop
, mac_ring_handle_t rh
)
5979 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
5980 mac_intr_t
*mintr
= &infop
->mri_intr
;
5983 case MAC_RING_TYPE_RX
: {
5985 * 'index' is the ring index within the group.
5986 * Need to get the global ring index by searching in groups.
5988 int global_ring_index
= ixgbe_get_rx_ring_index(
5989 ixgbe
, group_index
, ring_index
);
5991 ASSERT(global_ring_index
>= 0);
5993 ixgbe_rx_ring_t
*rx_ring
= &ixgbe
->rx_rings
[global_ring_index
];
5994 rx_ring
->ring_handle
= rh
;
5996 infop
->mri_driver
= (mac_ring_driver_t
)rx_ring
;
5997 infop
->mri_start
= ixgbe_ring_start
;
5998 infop
->mri_stop
= NULL
;
5999 infop
->mri_poll
= ixgbe_ring_rx_poll
;
6000 infop
->mri_stat
= ixgbe_rx_ring_stat
;
6002 mintr
->mi_handle
= (mac_intr_handle_t
)rx_ring
;
6003 mintr
->mi_enable
= ixgbe_rx_ring_intr_enable
;
6004 mintr
->mi_disable
= ixgbe_rx_ring_intr_disable
;
6005 if (ixgbe
->intr_type
&
6006 (DDI_INTR_TYPE_MSIX
| DDI_INTR_TYPE_MSI
)) {
6007 mintr
->mi_ddi_handle
=
6008 ixgbe
->htable
[rx_ring
->intr_vector
];
6013 case MAC_RING_TYPE_TX
: {
6014 ASSERT(group_index
== -1);
6015 ASSERT(ring_index
< ixgbe
->num_tx_rings
);
6017 ixgbe_tx_ring_t
*tx_ring
= &ixgbe
->tx_rings
[ring_index
];
6018 tx_ring
->ring_handle
= rh
;
6020 infop
->mri_driver
= (mac_ring_driver_t
)tx_ring
;
6021 infop
->mri_start
= NULL
;
6022 infop
->mri_stop
= NULL
;
6023 infop
->mri_tx
= ixgbe_ring_tx
;
6024 infop
->mri_stat
= ixgbe_tx_ring_stat
;
6025 if (ixgbe
->intr_type
&
6026 (DDI_INTR_TYPE_MSIX
| DDI_INTR_TYPE_MSI
)) {
6027 mintr
->mi_ddi_handle
=
6028 ixgbe
->htable
[tx_ring
->intr_vector
];
6038 * Callback funtion for MAC layer to register all groups.
6041 ixgbe_fill_group(void *arg
, mac_ring_type_t rtype
, const int index
,
6042 mac_group_info_t
*infop
, mac_group_handle_t gh
)
6044 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
6047 case MAC_RING_TYPE_RX
: {
6048 ixgbe_rx_group_t
*rx_group
;
6050 rx_group
= &ixgbe
->rx_groups
[index
];
6051 rx_group
->group_handle
= gh
;
6053 infop
->mgi_driver
= (mac_group_driver_t
)rx_group
;
6054 infop
->mgi_start
= NULL
;
6055 infop
->mgi_stop
= NULL
;
6056 infop
->mgi_addmac
= ixgbe_addmac
;
6057 infop
->mgi_remmac
= ixgbe_remmac
;
6058 infop
->mgi_count
= (ixgbe
->num_rx_rings
/ ixgbe
->num_rx_groups
);
6062 case MAC_RING_TYPE_TX
:
6070 * Enable interrupt on the specificed rx ring.
6073 ixgbe_rx_ring_intr_enable(mac_intr_handle_t intrh
)
6075 ixgbe_rx_ring_t
*rx_ring
= (ixgbe_rx_ring_t
*)intrh
;
6076 ixgbe_t
*ixgbe
= rx_ring
->ixgbe
;
6077 int r_idx
= rx_ring
->index
;
6078 int hw_r_idx
= rx_ring
->hw_index
;
6079 int v_idx
= rx_ring
->intr_vector
;
6081 mutex_enter(&ixgbe
->gen_lock
);
6082 if (ixgbe
->ixgbe_state
& IXGBE_INTR_ADJUST
) {
6083 mutex_exit(&ixgbe
->gen_lock
);
6086 * Interrupts are being adjusted. ixgbe_intr_adjust()
6087 * will eventually re-enable the interrupt when it's
6088 * done with the adjustment.
6094 * To enable interrupt by setting the VAL bit of given interrupt
6095 * vector allocation register (IVAR).
6097 ixgbe_enable_ivar(ixgbe
, hw_r_idx
, 0);
6099 BT_SET(ixgbe
->vect_map
[v_idx
].rx_map
, r_idx
);
6102 * Trigger a Rx interrupt on this ring
6104 IXGBE_WRITE_REG(&ixgbe
->hw
, IXGBE_EICS
, (1 << v_idx
));
6105 IXGBE_WRITE_FLUSH(&ixgbe
->hw
);
6107 mutex_exit(&ixgbe
->gen_lock
);
6113 * Disable interrupt on the specificed rx ring.
6116 ixgbe_rx_ring_intr_disable(mac_intr_handle_t intrh
)
6118 ixgbe_rx_ring_t
*rx_ring
= (ixgbe_rx_ring_t
*)intrh
;
6119 ixgbe_t
*ixgbe
= rx_ring
->ixgbe
;
6120 int r_idx
= rx_ring
->index
;
6121 int hw_r_idx
= rx_ring
->hw_index
;
6122 int v_idx
= rx_ring
->intr_vector
;
6124 mutex_enter(&ixgbe
->gen_lock
);
6125 if (ixgbe
->ixgbe_state
& IXGBE_INTR_ADJUST
) {
6126 mutex_exit(&ixgbe
->gen_lock
);
6129 * In the rare case where an interrupt is being
6130 * disabled while interrupts are being adjusted,
6131 * we don't fail the operation. No interrupts will
6132 * be generated while they are adjusted, and
6133 * ixgbe_intr_adjust() will cause the interrupts
6134 * to be re-enabled once it completes. Note that
6135 * in this case, packets may be delivered to the
6136 * stack via interrupts before xgbe_rx_ring_intr_enable()
6137 * is called again. This is acceptable since interrupt
6138 * adjustment is infrequent, and the stack will be
6139 * able to handle these packets.
6145 * To disable interrupt by clearing the VAL bit of given interrupt
6146 * vector allocation register (IVAR).
6148 ixgbe_disable_ivar(ixgbe
, hw_r_idx
, 0);
6150 BT_CLEAR(ixgbe
->vect_map
[v_idx
].rx_map
, r_idx
);
6152 mutex_exit(&ixgbe
->gen_lock
);
6158 * Add a mac address.
6161 ixgbe_addmac(void *arg
, const uint8_t *mac_addr
)
6163 ixgbe_rx_group_t
*rx_group
= (ixgbe_rx_group_t
*)arg
;
6164 ixgbe_t
*ixgbe
= rx_group
->ixgbe
;
6165 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
6168 mutex_enter(&ixgbe
->gen_lock
);
6170 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
6171 mutex_exit(&ixgbe
->gen_lock
);
6175 if (ixgbe
->unicst_avail
== 0) {
6176 /* no slots available */
6177 mutex_exit(&ixgbe
->gen_lock
);
6182 * The first ixgbe->num_rx_groups slots are reserved for each respective
6183 * group. The rest slots are shared by all groups. While adding a
6184 * MAC address, reserved slots are firstly checked then the shared
6185 * slots are searched.
6188 if (ixgbe
->unicst_addr
[rx_group
->index
].mac
.set
== 1) {
6189 for (i
= ixgbe
->num_rx_groups
; i
< ixgbe
->unicst_total
; i
++) {
6190 if (ixgbe
->unicst_addr
[i
].mac
.set
== 0) {
6196 slot
= rx_group
->index
;
6200 /* no slots available */
6201 mutex_exit(&ixgbe
->gen_lock
);
6205 bcopy(mac_addr
, ixgbe
->unicst_addr
[slot
].mac
.addr
, ETHERADDRL
);
6206 (void) ixgbe_set_rar(hw
, slot
, ixgbe
->unicst_addr
[slot
].mac
.addr
,
6207 rx_group
->index
, IXGBE_RAH_AV
);
6208 ixgbe
->unicst_addr
[slot
].mac
.set
= 1;
6209 ixgbe
->unicst_addr
[slot
].mac
.group_index
= rx_group
->index
;
6210 ixgbe
->unicst_avail
--;
6212 mutex_exit(&ixgbe
->gen_lock
);
6218 * Remove a mac address.
6221 ixgbe_remmac(void *arg
, const uint8_t *mac_addr
)
6223 ixgbe_rx_group_t
*rx_group
= (ixgbe_rx_group_t
*)arg
;
6224 ixgbe_t
*ixgbe
= rx_group
->ixgbe
;
6225 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
6228 mutex_enter(&ixgbe
->gen_lock
);
6230 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
6231 mutex_exit(&ixgbe
->gen_lock
);
6235 slot
= ixgbe_unicst_find(ixgbe
, mac_addr
);
6237 mutex_exit(&ixgbe
->gen_lock
);
6241 if (ixgbe
->unicst_addr
[slot
].mac
.set
== 0) {
6242 mutex_exit(&ixgbe
->gen_lock
);
6246 bzero(ixgbe
->unicst_addr
[slot
].mac
.addr
, ETHERADDRL
);
6247 (void) ixgbe_clear_rar(hw
, slot
);
6248 ixgbe
->unicst_addr
[slot
].mac
.set
= 0;
6249 ixgbe
->unicst_avail
++;
6251 mutex_exit(&ixgbe
->gen_lock
);