280 }
281 break;
282 }
283 default:
284 return (B_FALSE);
285 }
286 return (B_TRUE);
287 }
288
289 int
290 ixgbe_m_setprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
291 uint_t pr_valsize, const void *pr_val)
292 {
293 ixgbe_t *ixgbe = (ixgbe_t *)arg;
294 struct ixgbe_hw *hw = &ixgbe->hw;
295 int err = 0;
296 uint32_t flow_control;
297 uint32_t cur_mtu, new_mtu;
298 uint32_t rx_size;
299 uint32_t tx_size;
300
301 mutex_enter(&ixgbe->gen_lock);
302 if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
303 mutex_exit(&ixgbe->gen_lock);
304 return (ECANCELED);
305 }
306
307 if (ixgbe->loopback_mode != IXGBE_LB_NONE &&
308 ixgbe_param_locked(pr_num)) {
309 /*
310 * All en_* parameters are locked (read-only)
311 * while the device is in any sort of loopback mode.
312 */
313 mutex_exit(&ixgbe->gen_lock);
314 return (EBUSY);
315 }
316
317 switch (pr_num) {
318 case MAC_PROP_EN_10GFDX_CAP:
319 /* read/write on copper, read-only on serdes */
320 if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
321 err = ENOTSUP;
322 break;
323 } else {
324 ixgbe->param_en_10000fdx_cap = *(uint8_t *)pr_val;
325 ixgbe->param_adv_10000fdx_cap = *(uint8_t *)pr_val;
326 goto setup_link;
327 }
328 case MAC_PROP_EN_1000FDX_CAP:
329 /* read/write on copper, read-only on serdes */
330 if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
331 err = ENOTSUP;
332 break;
333 } else {
334 ixgbe->param_en_1000fdx_cap = *(uint8_t *)pr_val;
335 ixgbe->param_adv_1000fdx_cap = *(uint8_t *)pr_val;
336 goto setup_link;
337 }
338 case MAC_PROP_EN_100FDX_CAP:
339 /* read/write on copper, read-only on serdes */
340 if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
341 err = ENOTSUP;
342 break;
343 } else {
344 ixgbe->param_en_100fdx_cap = *(uint8_t *)pr_val;
345 ixgbe->param_adv_100fdx_cap = *(uint8_t *)pr_val;
346 goto setup_link;
347 }
348 case MAC_PROP_AUTONEG:
349 /* read/write on copper, read-only on serdes */
350 if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
351 err = ENOTSUP;
352 break;
353 } else {
354 ixgbe->param_adv_autoneg_cap = *(uint8_t *)pr_val;
355 goto setup_link;
356 }
357 case MAC_PROP_FLOWCTRL:
358 bcopy(pr_val, &flow_control, sizeof (flow_control));
359
360 switch (flow_control) {
361 default:
362 err = EINVAL;
363 break;
364 case LINK_FLOWCTRL_NONE:
365 hw->fc.requested_mode = ixgbe_fc_none;
366 break;
367 case LINK_FLOWCTRL_RX:
368 hw->fc.requested_mode = ixgbe_fc_rx_pause;
369 break;
370 case LINK_FLOWCTRL_TX:
371 hw->fc.requested_mode = ixgbe_fc_tx_pause;
372 break;
373 case LINK_FLOWCTRL_BI:
374 hw->fc.requested_mode = ixgbe_fc_full;
375 break;
376 }
377 setup_link:
378 if (err == 0) {
379 if (ixgbe_driver_setup_link(ixgbe, B_TRUE) !=
380 IXGBE_SUCCESS)
381 err = EINVAL;
382 }
383 break;
384 case MAC_PROP_ADV_10GFDX_CAP:
385 case MAC_PROP_ADV_1000FDX_CAP:
386 case MAC_PROP_ADV_100FDX_CAP:
387 case MAC_PROP_STATUS:
388 case MAC_PROP_SPEED:
389 case MAC_PROP_DUPLEX:
390 err = ENOTSUP; /* read-only prop. Can't set this. */
391 break;
392 case MAC_PROP_MTU:
393 cur_mtu = ixgbe->default_mtu;
394 bcopy(pr_val, &new_mtu, sizeof (new_mtu));
395 if (new_mtu == cur_mtu) {
396 err = 0;
397 break;
398 }
399
400 if (new_mtu < DEFAULT_MTU || new_mtu > ixgbe->capab->max_mtu) {
401 err = EINVAL;
402 break;
403 }
404
431 case MAC_PROP_PRIVATE:
432 err = ixgbe_set_priv_prop(ixgbe, pr_name, pr_valsize, pr_val);
433 break;
434 default:
435 err = ENOTSUP;
436 break;
437 }
438 mutex_exit(&ixgbe->gen_lock);
439 return (err);
440 }
441
442 int
443 ixgbe_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
444 uint_t pr_valsize, void *pr_val)
445 {
446 ixgbe_t *ixgbe = (ixgbe_t *)arg;
447 struct ixgbe_hw *hw = &ixgbe->hw;
448 int err = 0;
449 uint32_t flow_control;
450 uint64_t tmp = 0;
451
452 switch (pr_num) {
453 case MAC_PROP_DUPLEX:
454 ASSERT(pr_valsize >= sizeof (link_duplex_t));
455 bcopy(&ixgbe->link_duplex, pr_val,
456 sizeof (link_duplex_t));
457 break;
458 case MAC_PROP_SPEED:
459 ASSERT(pr_valsize >= sizeof (uint64_t));
460 tmp = ixgbe->link_speed * 1000000ull;
461 bcopy(&tmp, pr_val, sizeof (tmp));
462 break;
463 case MAC_PROP_AUTONEG:
464 *(uint8_t *)pr_val = ixgbe->param_adv_autoneg_cap;
465 break;
466 case MAC_PROP_FLOWCTRL:
467 ASSERT(pr_valsize >= sizeof (uint32_t));
468
469 switch (hw->fc.requested_mode) {
470 case ixgbe_fc_none:
471 flow_control = LINK_FLOWCTRL_NONE;
472 break;
473 case ixgbe_fc_rx_pause:
474 flow_control = LINK_FLOWCTRL_RX;
475 break;
476 case ixgbe_fc_tx_pause:
477 flow_control = LINK_FLOWCTRL_TX;
478 break;
479 case ixgbe_fc_full:
480 flow_control = LINK_FLOWCTRL_BI;
481 break;
482 }
483 bcopy(&flow_control, pr_val, sizeof (flow_control));
484 break;
485 case MAC_PROP_ADV_10GFDX_CAP:
486 *(uint8_t *)pr_val = ixgbe->param_adv_10000fdx_cap;
487 break;
488 case MAC_PROP_EN_10GFDX_CAP:
489 *(uint8_t *)pr_val = ixgbe->param_en_10000fdx_cap;
490 break;
491 case MAC_PROP_ADV_1000FDX_CAP:
492 *(uint8_t *)pr_val = ixgbe->param_adv_1000fdx_cap;
493 break;
494 case MAC_PROP_EN_1000FDX_CAP:
495 *(uint8_t *)pr_val = ixgbe->param_en_1000fdx_cap;
496 break;
497 case MAC_PROP_ADV_100FDX_CAP:
498 *(uint8_t *)pr_val = ixgbe->param_adv_100fdx_cap;
499 break;
500 case MAC_PROP_EN_100FDX_CAP:
501 *(uint8_t *)pr_val = ixgbe->param_en_100fdx_cap;
502 break;
503 case MAC_PROP_PRIVATE:
504 err = ixgbe_get_priv_prop(ixgbe, pr_name,
505 pr_valsize, pr_val);
506 break;
507 default:
508 err = ENOTSUP;
509 break;
510 }
511 return (err);
512 }
513
514 void
515 ixgbe_m_propinfo(void *arg, const char *pr_name, mac_prop_id_t pr_num,
516 mac_prop_info_handle_t prh)
517 {
518 ixgbe_t *ixgbe = (ixgbe_t *)arg;
519 uint_t perm;
520
521 switch (pr_num) {
522 case MAC_PROP_DUPLEX:
523 case MAC_PROP_SPEED:
524 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
525 break;
526
527 case MAC_PROP_ADV_100FDX_CAP:
528 case MAC_PROP_ADV_1000FDX_CAP:
529 case MAC_PROP_ADV_10GFDX_CAP:
530 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
531 mac_prop_info_set_default_uint8(prh, 1);
532 break;
533
534 case MAC_PROP_AUTONEG:
535 case MAC_PROP_EN_10GFDX_CAP:
536 case MAC_PROP_EN_1000FDX_CAP:
537 case MAC_PROP_EN_100FDX_CAP:
538 perm = (ixgbe->hw.phy.media_type == ixgbe_media_type_copper) ?
539 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
540 mac_prop_info_set_perm(prh, perm);
541 mac_prop_info_set_default_uint8(prh, 1);
542 break;
543
544 case MAC_PROP_FLOWCTRL:
545 mac_prop_info_set_default_link_flowctrl(prh,
546 LINK_FLOWCTRL_NONE);
547 break;
548
549 case MAC_PROP_MTU:
550 mac_prop_info_set_range_uint32(prh,
551 DEFAULT_MTU, ixgbe->capab->max_mtu);
552 break;
553
554 case MAC_PROP_PRIVATE: {
555 char valstr[64];
556 int value;
557
558 bzero(valstr, sizeof (valstr));
559
560 if (strcmp(pr_name, "_adv_pause_cap") == 0 ||
561 strcmp(pr_name, "_adv_asym_pause_cap") == 0) {
578 } if (strcmp(pr_name, "_intr_throttling") == 0) {
579 value = ixgbe->capab->def_intr_throttle;
580 } else {
581 return;
582 }
583
584 (void) snprintf(valstr, sizeof (valstr), "%x", value);
585 }
586 }
587 }
588
589 boolean_t
590 ixgbe_param_locked(mac_prop_id_t pr_num)
591 {
592 /*
593 * All en_* parameters are locked (read-only) while
594 * the device is in any sort of loopback mode ...
595 */
596 switch (pr_num) {
597 case MAC_PROP_EN_10GFDX_CAP:
598 case MAC_PROP_EN_1000FDX_CAP:
599 case MAC_PROP_EN_100FDX_CAP:
600 case MAC_PROP_AUTONEG:
601 case MAC_PROP_FLOWCTRL:
602 return (B_TRUE);
603 }
604 return (B_FALSE);
605 }
606
607 /* ARGSUSED */
608 int
609 ixgbe_set_priv_prop(ixgbe_t *ixgbe, const char *pr_name,
610 uint_t pr_valsize, const void *pr_val)
611 {
612 int err = 0;
613 long result;
614 struct ixgbe_hw *hw = &ixgbe->hw;
615 int i;
616
617 if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
695 err = EINVAL;
696 else {
697 ixgbe->rx_limit_per_intr = (uint32_t)result;
698 }
699 return (err);
700 }
701 if (strcmp(pr_name, "_intr_throttling") == 0) {
702 if (pr_val == NULL) {
703 err = EINVAL;
704 return (err);
705 }
706 (void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
707
708 if (result < ixgbe->capab->min_intr_throttle ||
709 result > ixgbe->capab->max_intr_throttle)
710 err = EINVAL;
711 else {
712 ixgbe->intr_throttling[0] = (uint32_t)result;
713
714 /*
715 * 82599 and X540 require the interrupt throttling
716 * rate is a multiple of 8. This is enforced by the
717 * register definiton.
718 */
719 if (hw->mac.type == ixgbe_mac_82599EB ||
720 hw->mac.type == ixgbe_mac_X540) {
721 ixgbe->intr_throttling[0] =
722 ixgbe->intr_throttling[0] & 0xFF8;
723 }
724
725 for (i = 0; i < MAX_INTR_VECTOR; i++)
726 ixgbe->intr_throttling[i] =
727 ixgbe->intr_throttling[0];
728
729 /* Set interrupt throttling rate */
730 for (i = 0; i < ixgbe->intr_cnt; i++)
731 IXGBE_WRITE_REG(hw, IXGBE_EITR(i),
732 ixgbe->intr_throttling[i]);
733 }
734 return (err);
735 }
736 return (ENOTSUP);
737 }
738
739 int
740 ixgbe_get_priv_prop(ixgbe_t *ixgbe, const char *pr_name,
|
280 }
281 break;
282 }
283 default:
284 return (B_FALSE);
285 }
286 return (B_TRUE);
287 }
288
289 int
290 ixgbe_m_setprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
291 uint_t pr_valsize, const void *pr_val)
292 {
293 ixgbe_t *ixgbe = (ixgbe_t *)arg;
294 struct ixgbe_hw *hw = &ixgbe->hw;
295 int err = 0;
296 uint32_t flow_control;
297 uint32_t cur_mtu, new_mtu;
298 uint32_t rx_size;
299 uint32_t tx_size;
300 ixgbe_link_speed speeds = 0;
301
302 mutex_enter(&ixgbe->gen_lock);
303 if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
304 mutex_exit(&ixgbe->gen_lock);
305 return (ECANCELED);
306 }
307
308 /*
309 * We cannot always rely on the common code maintaining
310 * hw->phy.speeds_supported, therefore we fall back to use the recorded
311 * supported speeds which were obtained during instance init in
312 * ixgbe_init_params().
313 */
314 speeds = hw->phy.speeds_supported;
315 if (speeds == 0)
316 speeds = ixgbe->speeds_supported;
317
318 if (ixgbe->loopback_mode != IXGBE_LB_NONE &&
319 ixgbe_param_locked(pr_num)) {
320 /*
321 * All en_* parameters are locked (read-only)
322 * while the device is in any sort of loopback mode.
323 */
324 mutex_exit(&ixgbe->gen_lock);
325 return (EBUSY);
326 }
327
328 /*
329 * We allow speed changes only on baseT PHYs. MAC_PROP_EN_* are marked
330 * read-only on non-baseT PHYs.
331 */
332 switch (pr_num) {
333 case MAC_PROP_EN_10GFDX_CAP:
334 if (hw->phy.media_type == ixgbe_media_type_copper &&
335 speeds & IXGBE_LINK_SPEED_10GB_FULL) {
336 ixgbe->param_en_10000fdx_cap = *(uint8_t *)pr_val;
337 goto setup_link;
338 } else {
339 err = ENOTSUP;
340 break;
341 }
342 case MAC_PROP_EN_5000FDX_CAP:
343 if (hw->phy.media_type == ixgbe_media_type_copper &&
344 speeds & IXGBE_LINK_SPEED_5GB_FULL) {
345 ixgbe->param_en_5000fdx_cap = *(uint8_t *)pr_val;
346 goto setup_link;
347 } else {
348 err = ENOTSUP;
349 break;
350 }
351 case MAC_PROP_EN_2500FDX_CAP:
352 if (hw->phy.media_type == ixgbe_media_type_copper &&
353 speeds & IXGBE_LINK_SPEED_2_5GB_FULL) {
354 ixgbe->param_en_2500fdx_cap = *(uint8_t *)pr_val;
355 goto setup_link;
356 } else {
357 err = ENOTSUP;
358 break;
359 }
360 case MAC_PROP_EN_1000FDX_CAP:
361 if (hw->phy.media_type == ixgbe_media_type_copper &&
362 speeds & IXGBE_LINK_SPEED_1GB_FULL) {
363 ixgbe->param_en_1000fdx_cap = *(uint8_t *)pr_val;
364 goto setup_link;
365 } else {
366 err = ENOTSUP;
367 break;
368 }
369 case MAC_PROP_EN_100FDX_CAP:
370 if (hw->phy.media_type == ixgbe_media_type_copper &&
371 speeds & IXGBE_LINK_SPEED_100_FULL) {
372 ixgbe->param_en_100fdx_cap = *(uint8_t *)pr_val;
373 goto setup_link;
374 } else {
375 err = ENOTSUP;
376 break;
377 }
378 case MAC_PROP_AUTONEG:
379 if (ixgbe->hw.phy.media_type != ixgbe_media_type_copper) {
380 err = ENOTSUP;
381 break;
382 } else {
383 ixgbe->param_adv_autoneg_cap = *(uint8_t *)pr_val;
384 goto setup_link;
385 }
386 case MAC_PROP_FLOWCTRL:
387 bcopy(pr_val, &flow_control, sizeof (flow_control));
388
389 switch (flow_control) {
390 default:
391 err = EINVAL;
392 break;
393 case LINK_FLOWCTRL_NONE:
394 hw->fc.requested_mode = ixgbe_fc_none;
395 break;
396 case LINK_FLOWCTRL_RX:
397 hw->fc.requested_mode = ixgbe_fc_rx_pause;
398 break;
399 case LINK_FLOWCTRL_TX:
400 hw->fc.requested_mode = ixgbe_fc_tx_pause;
401 break;
402 case LINK_FLOWCTRL_BI:
403 hw->fc.requested_mode = ixgbe_fc_full;
404 break;
405 }
406 setup_link:
407 if (err == 0) {
408 if (ixgbe_driver_setup_link(ixgbe, B_TRUE) !=
409 IXGBE_SUCCESS)
410 err = EINVAL;
411 }
412 break;
413 case MAC_PROP_ADV_10GFDX_CAP:
414 case MAC_PROP_ADV_5000FDX_CAP:
415 case MAC_PROP_ADV_2500FDX_CAP:
416 case MAC_PROP_ADV_1000FDX_CAP:
417 case MAC_PROP_ADV_100FDX_CAP:
418 case MAC_PROP_STATUS:
419 case MAC_PROP_SPEED:
420 case MAC_PROP_DUPLEX:
421 err = ENOTSUP; /* read-only prop. Can't set this. */
422 break;
423 case MAC_PROP_MTU:
424 cur_mtu = ixgbe->default_mtu;
425 bcopy(pr_val, &new_mtu, sizeof (new_mtu));
426 if (new_mtu == cur_mtu) {
427 err = 0;
428 break;
429 }
430
431 if (new_mtu < DEFAULT_MTU || new_mtu > ixgbe->capab->max_mtu) {
432 err = EINVAL;
433 break;
434 }
435
462 case MAC_PROP_PRIVATE:
463 err = ixgbe_set_priv_prop(ixgbe, pr_name, pr_valsize, pr_val);
464 break;
465 default:
466 err = ENOTSUP;
467 break;
468 }
469 mutex_exit(&ixgbe->gen_lock);
470 return (err);
471 }
472
473 int
474 ixgbe_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
475 uint_t pr_valsize, void *pr_val)
476 {
477 ixgbe_t *ixgbe = (ixgbe_t *)arg;
478 struct ixgbe_hw *hw = &ixgbe->hw;
479 int err = 0;
480 uint32_t flow_control;
481 uint64_t tmp = 0;
482 ixgbe_link_speed speeds = 0;
483
484 /*
485 * We cannot always rely on the common code maintaining
486 * hw->phy.speeds_supported, therefore we fall back to use the recorded
487 * supported speeds which were obtained during instance init in
488 * ixgbe_init_params().
489 */
490 speeds = hw->phy.speeds_supported;
491 if (speeds == 0)
492 speeds = ixgbe->speeds_supported;
493
494 switch (pr_num) {
495 case MAC_PROP_DUPLEX:
496 ASSERT(pr_valsize >= sizeof (link_duplex_t));
497 bcopy(&ixgbe->link_duplex, pr_val,
498 sizeof (link_duplex_t));
499 break;
500 case MAC_PROP_SPEED:
501 ASSERT(pr_valsize >= sizeof (uint64_t));
502 tmp = ixgbe->link_speed * 1000000ull;
503 bcopy(&tmp, pr_val, sizeof (tmp));
504 break;
505 case MAC_PROP_AUTONEG:
506 *(uint8_t *)pr_val = ixgbe->param_adv_autoneg_cap;
507 break;
508 case MAC_PROP_FLOWCTRL:
509 ASSERT(pr_valsize >= sizeof (uint32_t));
510
511 switch (hw->fc.requested_mode) {
512 case ixgbe_fc_none:
513 flow_control = LINK_FLOWCTRL_NONE;
514 break;
515 case ixgbe_fc_rx_pause:
516 flow_control = LINK_FLOWCTRL_RX;
517 break;
518 case ixgbe_fc_tx_pause:
519 flow_control = LINK_FLOWCTRL_TX;
520 break;
521 case ixgbe_fc_full:
522 flow_control = LINK_FLOWCTRL_BI;
523 break;
524 }
525 bcopy(&flow_control, pr_val, sizeof (flow_control));
526 break;
527 case MAC_PROP_ADV_10GFDX_CAP:
528 if (speeds & IXGBE_LINK_SPEED_10GB_FULL)
529 *(uint8_t *)pr_val = ixgbe->param_adv_10000fdx_cap;
530 else
531 err = ENOTSUP;
532 break;
533 case MAC_PROP_EN_10GFDX_CAP:
534 if (speeds & IXGBE_LINK_SPEED_10GB_FULL)
535 *(uint8_t *)pr_val = ixgbe->param_en_10000fdx_cap;
536 else
537 err = ENOTSUP;
538 break;
539 case MAC_PROP_ADV_5000FDX_CAP:
540 if (speeds & IXGBE_LINK_SPEED_5GB_FULL)
541 *(uint8_t *)pr_val = ixgbe->param_adv_5000fdx_cap;
542 else
543 err = ENOTSUP;
544 break;
545 case MAC_PROP_EN_5000FDX_CAP:
546 if (speeds & IXGBE_LINK_SPEED_5GB_FULL)
547 *(uint8_t *)pr_val = ixgbe->param_en_5000fdx_cap;
548 else
549 err = ENOTSUP;
550 break;
551 case MAC_PROP_ADV_2500FDX_CAP:
552 if (speeds & IXGBE_LINK_SPEED_2_5GB_FULL)
553 *(uint8_t *)pr_val = ixgbe->param_adv_2500fdx_cap;
554 else
555 err = ENOTSUP;
556 break;
557 case MAC_PROP_EN_2500FDX_CAP:
558 if (speeds & IXGBE_LINK_SPEED_2_5GB_FULL)
559 *(uint8_t *)pr_val = ixgbe->param_en_2500fdx_cap;
560 else
561 err = ENOTSUP;
562 break;
563 case MAC_PROP_ADV_1000FDX_CAP:
564 if (speeds & IXGBE_LINK_SPEED_1GB_FULL)
565 *(uint8_t *)pr_val = ixgbe->param_adv_1000fdx_cap;
566 else
567 err = ENOTSUP;
568 break;
569 case MAC_PROP_EN_1000FDX_CAP:
570 if (speeds & IXGBE_LINK_SPEED_1GB_FULL)
571 *(uint8_t *)pr_val = ixgbe->param_en_1000fdx_cap;
572 else
573 err = ENOTSUP;
574 break;
575 case MAC_PROP_ADV_100FDX_CAP:
576 if (speeds & IXGBE_LINK_SPEED_100_FULL)
577 *(uint8_t *)pr_val = ixgbe->param_adv_100fdx_cap;
578 else
579 err = ENOTSUP;
580 break;
581 case MAC_PROP_EN_100FDX_CAP:
582 if (speeds & IXGBE_LINK_SPEED_100_FULL)
583 *(uint8_t *)pr_val = ixgbe->param_en_100fdx_cap;
584 else
585 err = ENOTSUP;
586 break;
587 case MAC_PROP_PRIVATE:
588 err = ixgbe_get_priv_prop(ixgbe, pr_name,
589 pr_valsize, pr_val);
590 break;
591 default:
592 err = ENOTSUP;
593 break;
594 }
595 return (err);
596 }
597
598 void
599 ixgbe_m_propinfo(void *arg, const char *pr_name, mac_prop_id_t pr_num,
600 mac_prop_info_handle_t prh)
601 {
602 ixgbe_t *ixgbe = (ixgbe_t *)arg;
603 struct ixgbe_hw *hw = &ixgbe->hw;
604 uint_t perm;
605 uint8_t value;
606 ixgbe_link_speed speeds = 0;
607
608 /*
609 * We cannot always rely on the common code maintaining
610 * hw->phy.speeds_supported, therefore we fall back to use the
611 * recorded supported speeds which were obtained during instance init in
612 * ixgbe_init_params().
613 */
614 speeds = hw->phy.speeds_supported;
615 if (speeds == 0)
616 speeds = ixgbe->speeds_supported;
617
618 switch (pr_num) {
619 case MAC_PROP_DUPLEX:
620 case MAC_PROP_SPEED:
621 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
622 break;
623
624 case MAC_PROP_ADV_100FDX_CAP:
625 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
626 value = (speeds & IXGBE_LINK_SPEED_100_FULL) ? 1 : 0;
627 mac_prop_info_set_default_uint8(prh, value);
628 break;
629
630 case MAC_PROP_ADV_1000FDX_CAP:
631 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
632 value = (speeds & IXGBE_LINK_SPEED_1GB_FULL) ? 1 : 0;
633 mac_prop_info_set_default_uint8(prh, value);
634 break;
635
636 case MAC_PROP_ADV_2500FDX_CAP:
637 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
638 value = (speeds & IXGBE_LINK_SPEED_2_5GB_FULL) ? 1 : 0;
639 mac_prop_info_set_default_uint8(prh, value);
640 break;
641
642 case MAC_PROP_ADV_5000FDX_CAP:
643 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
644 value = (speeds & IXGBE_LINK_SPEED_5GB_FULL) ? 1 : 0;
645 mac_prop_info_set_default_uint8(prh, value);
646 break;
647
648 case MAC_PROP_ADV_10GFDX_CAP:
649 mac_prop_info_set_perm(prh, MAC_PROP_PERM_READ);
650 value = (speeds & IXGBE_LINK_SPEED_10GB_FULL) ? 1 : 0;
651 mac_prop_info_set_default_uint8(prh, value);
652 break;
653
654 /*
655 * We allow speed changes only on baseT PHYs. MAC_PROP_EN_* are marked
656 * read-only on non-baseT (SFP) PHYs.
657 */
658 case MAC_PROP_AUTONEG:
659 perm = (hw->phy.media_type == ixgbe_media_type_copper) ?
660 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
661 mac_prop_info_set_perm(prh, perm);
662 mac_prop_info_set_default_uint8(prh, 1);
663 break;
664
665 case MAC_PROP_EN_10GFDX_CAP:
666 if (speeds & IXGBE_LINK_SPEED_10GB_FULL) {
667 perm = (hw->phy.media_type == ixgbe_media_type_copper) ?
668 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
669 mac_prop_info_set_perm(prh, perm);
670 mac_prop_info_set_default_uint8(prh, 1);
671 }
672 break;
673
674 case MAC_PROP_EN_5000FDX_CAP:
675 if (speeds & IXGBE_LINK_SPEED_5GB_FULL) {
676 perm = (hw->phy.media_type == ixgbe_media_type_copper) ?
677 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
678 mac_prop_info_set_perm(prh, perm);
679 mac_prop_info_set_default_uint8(prh, 1);
680 }
681 break;
682
683 case MAC_PROP_EN_2500FDX_CAP:
684 if (speeds & IXGBE_LINK_SPEED_2_5GB_FULL) {
685 perm = (hw->phy.media_type == ixgbe_media_type_copper) ?
686 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
687 mac_prop_info_set_perm(prh, perm);
688 mac_prop_info_set_default_uint8(prh, 1);
689 }
690 break;
691
692 case MAC_PROP_EN_1000FDX_CAP:
693 if (speeds & IXGBE_LINK_SPEED_1GB_FULL) {
694 perm = (hw->phy.media_type == ixgbe_media_type_copper) ?
695 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
696 mac_prop_info_set_perm(prh, perm);
697 mac_prop_info_set_default_uint8(prh, 1);
698 }
699 break;
700
701 case MAC_PROP_EN_100FDX_CAP:
702 if (speeds & IXGBE_LINK_SPEED_100_FULL) {
703 perm = (hw->phy.media_type == ixgbe_media_type_copper) ?
704 MAC_PROP_PERM_RW : MAC_PROP_PERM_READ;
705 mac_prop_info_set_perm(prh, perm);
706 mac_prop_info_set_default_uint8(prh, 1);
707 }
708 break;
709
710 case MAC_PROP_FLOWCTRL:
711 mac_prop_info_set_default_link_flowctrl(prh,
712 LINK_FLOWCTRL_NONE);
713 break;
714
715 case MAC_PROP_MTU:
716 mac_prop_info_set_range_uint32(prh,
717 DEFAULT_MTU, ixgbe->capab->max_mtu);
718 break;
719
720 case MAC_PROP_PRIVATE: {
721 char valstr[64];
722 int value;
723
724 bzero(valstr, sizeof (valstr));
725
726 if (strcmp(pr_name, "_adv_pause_cap") == 0 ||
727 strcmp(pr_name, "_adv_asym_pause_cap") == 0) {
744 } if (strcmp(pr_name, "_intr_throttling") == 0) {
745 value = ixgbe->capab->def_intr_throttle;
746 } else {
747 return;
748 }
749
750 (void) snprintf(valstr, sizeof (valstr), "%x", value);
751 }
752 }
753 }
754
755 boolean_t
756 ixgbe_param_locked(mac_prop_id_t pr_num)
757 {
758 /*
759 * All en_* parameters are locked (read-only) while
760 * the device is in any sort of loopback mode ...
761 */
762 switch (pr_num) {
763 case MAC_PROP_EN_10GFDX_CAP:
764 case MAC_PROP_EN_5000FDX_CAP:
765 case MAC_PROP_EN_2500FDX_CAP:
766 case MAC_PROP_EN_1000FDX_CAP:
767 case MAC_PROP_EN_100FDX_CAP:
768 case MAC_PROP_AUTONEG:
769 case MAC_PROP_FLOWCTRL:
770 return (B_TRUE);
771 }
772 return (B_FALSE);
773 }
774
775 /* ARGSUSED */
776 int
777 ixgbe_set_priv_prop(ixgbe_t *ixgbe, const char *pr_name,
778 uint_t pr_valsize, const void *pr_val)
779 {
780 int err = 0;
781 long result;
782 struct ixgbe_hw *hw = &ixgbe->hw;
783 int i;
784
785 if (strcmp(pr_name, "_tx_copy_thresh") == 0) {
863 err = EINVAL;
864 else {
865 ixgbe->rx_limit_per_intr = (uint32_t)result;
866 }
867 return (err);
868 }
869 if (strcmp(pr_name, "_intr_throttling") == 0) {
870 if (pr_val == NULL) {
871 err = EINVAL;
872 return (err);
873 }
874 (void) ddi_strtol(pr_val, (char **)NULL, 0, &result);
875
876 if (result < ixgbe->capab->min_intr_throttle ||
877 result > ixgbe->capab->max_intr_throttle)
878 err = EINVAL;
879 else {
880 ixgbe->intr_throttling[0] = (uint32_t)result;
881
882 /*
883 * 82599, X540 and X550 require the interrupt throttling
884 * rate is a multiple of 8. This is enforced by the
885 * register definiton.
886 */
887 if (hw->mac.type == ixgbe_mac_82599EB ||
888 hw->mac.type == ixgbe_mac_X540 ||
889 hw->mac.type == ixgbe_mac_X550 ||
890 hw->mac.type == ixgbe_mac_X550EM_x) {
891 ixgbe->intr_throttling[0] =
892 ixgbe->intr_throttling[0] & 0xFF8;
893 }
894
895 for (i = 0; i < MAX_INTR_VECTOR; i++)
896 ixgbe->intr_throttling[i] =
897 ixgbe->intr_throttling[0];
898
899 /* Set interrupt throttling rate */
900 for (i = 0; i < ixgbe->intr_cnt; i++)
901 IXGBE_WRITE_REG(hw, IXGBE_EITR(i),
902 ixgbe->intr_throttling[i]);
903 }
904 return (err);
905 }
906 return (ENOTSUP);
907 }
908
909 int
910 ixgbe_get_priv_prop(ixgbe_t *ixgbe, const char *pr_name,
|